mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 23:23:13 +00:00
2009-05-03 Joel Sherrill <joel.sherrill@oarcorp.com>
* libchip/rtc/ds1375.c, libchip/rtc/mc146818a.c: Fix warnings. Reformat as needed.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2009-05-03 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
|
* libchip/rtc/ds1375.c, libchip/rtc/mc146818a.c: Fix warnings. Reformat
|
||||||
|
as needed.
|
||||||
|
|
||||||
2009-04-29 Chris Johns <chrisj@rtems.org>
|
2009-04-29 Chris Johns <chrisj@rtems.org>
|
||||||
|
|
||||||
* libchip/ide/ata.c: Remove a detection test that fails in qemu.
|
* libchip/ide/ata.c: Remove a detection test that fails in qemu.
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
STATIC uint8_t ds1375_bcd2bin(uint8_t x)
|
STATIC uint8_t ds1375_bcd2bin(uint8_t x)
|
||||||
{
|
{
|
||||||
uint8_t h = x & 0xf0;
|
uint8_t h = x & 0xf0;
|
||||||
|
|
||||||
/* 8*hi + 2*hi + lo */
|
/* 8*hi + 2*hi + lo */
|
||||||
return ( h >> 1 ) + ( h >> 3 ) + ( x & 0xf );
|
return ( h >> 1 ) + ( h >> 3 ) + ( x & 0xf );
|
||||||
@@ -90,7 +90,7 @@ uint8_t h = x & 0xf0;
|
|||||||
|
|
||||||
STATIC uint8_t ds1375_bin2bcd(uint8_t x)
|
STATIC uint8_t ds1375_bin2bcd(uint8_t x)
|
||||||
{
|
{
|
||||||
uint8_t h = x/10;
|
uint8_t h = x/10;
|
||||||
|
|
||||||
return ( h << 4 ) + ( x - ( ( h << 3 ) + ( h << 1 ) ) );
|
return ( h << 4 ) + ( x - ( ( h << 3 ) + ( h << 1 ) ) );
|
||||||
}
|
}
|
||||||
@@ -103,8 +103,6 @@ uint8_t h = x/10;
|
|||||||
* starting at the seconds (for the 1375 both,
|
* starting at the seconds (for the 1375 both,
|
||||||
* _REG and _OFF happen to be identical).
|
* _REG and _OFF happen to be identical).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define DS1375_SEC_REG 0x0
|
#define DS1375_SEC_REG 0x0
|
||||||
#define DS1375_SEC_OFF (DS1375_SEC_REG-DS1375_SEC_REG)
|
#define DS1375_SEC_OFF (DS1375_SEC_REG-DS1375_SEC_REG)
|
||||||
/* Extract seconds and convert to binary */
|
/* Extract seconds and convert to binary */
|
||||||
@@ -165,18 +163,26 @@ uint8_t h = x/10;
|
|||||||
|
|
||||||
/* Access Primitives */
|
/* Access Primitives */
|
||||||
|
|
||||||
STATIC int
|
STATIC int rd_bytes(
|
||||||
rd_bytes( int fd, uint32_t off, uint8_t *buf, int len )
|
int fd,
|
||||||
|
uint32_t off,
|
||||||
|
uint8_t *buf,
|
||||||
|
int len
|
||||||
|
)
|
||||||
{
|
{
|
||||||
uint8_t ptr = off;
|
uint8_t ptr = off;
|
||||||
|
|
||||||
return 1 == write( fd, &ptr, 1 ) && len == read( fd, buf, len ) ? 0 : -1;
|
return 1 == write( fd, &ptr, 1 ) && len == read( fd, buf, len ) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int
|
STATIC int wr_bytes(
|
||||||
wr_bytes( int fd, uint32_t off, uint8_t *buf, int len )
|
int fd,
|
||||||
|
uint32_t off,
|
||||||
|
uint8_t *buf,
|
||||||
|
int len
|
||||||
|
)
|
||||||
{
|
{
|
||||||
uint8_t d[ len + 1 ];
|
uint8_t d[ len + 1 ];
|
||||||
|
|
||||||
/* Must not break up writing of the register pointer and
|
/* Must not break up writing of the register pointer and
|
||||||
* the data to-be-written into multiple write() calls
|
* the data to-be-written into multiple write() calls
|
||||||
@@ -193,19 +199,21 @@ uint8_t d[ len + 1 ];
|
|||||||
|
|
||||||
/* Helpers */
|
/* Helpers */
|
||||||
|
|
||||||
static int
|
static int getfd(
|
||||||
getfd( int minor )
|
int minor
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return open( (const char *)RTC_Table[minor].ulCtrlPort1, O_RDWR );
|
return open( (const char *)RTC_Table[minor].ulCtrlPort1, O_RDWR );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Driver Access Functions */
|
/* Driver Access Functions */
|
||||||
|
|
||||||
STATIC void
|
STATIC void ds1375_initialize(
|
||||||
ds1375_initialize( int minor )
|
int minor
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
uint8_t cr;
|
uint8_t cr;
|
||||||
|
|
||||||
if ( ( fd = getfd( minor ) ) >= 0 ) {
|
if ( ( fd = getfd( minor ) ) >= 0 ) {
|
||||||
if ( 0 == rd_bytes( fd, DS1375_CR_REG, &cr, 1 ) ) {
|
if ( 0 == rd_bytes( fd, DS1375_CR_REG, &cr, 1 ) ) {
|
||||||
@@ -220,12 +228,14 @@ uint8_t cr;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int
|
STATIC int ds1375_get_time(
|
||||||
ds1375_get_time( int minor, rtems_time_of_day *time )
|
int minor,
|
||||||
|
rtems_time_of_day *time
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int rval = -1;
|
int rval = -1;
|
||||||
int fd;
|
int fd;
|
||||||
uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
|
uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
|
||||||
|
|
||||||
if ( time && ( ( fd = getfd( minor ) ) >= 0 ) ) {
|
if ( time && ( ( fd = getfd( minor ) ) >= 0 ) ) {
|
||||||
if ( 0 == rd_bytes( fd, DS1375_SEC_REG, buf, sizeof(buf) ) ) {
|
if ( 0 == rd_bytes( fd, DS1375_SEC_REG, buf, sizeof(buf) ) ) {
|
||||||
@@ -252,15 +262,18 @@ uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int
|
STATIC int ds1375_set_time(
|
||||||
ds1375_set_time( int minor, rtems_time_of_day *time )
|
int minor,
|
||||||
|
const rtems_time_of_day *time
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int rval = -1;
|
int rval = -1;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
time_t secs;
|
time_t secs;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
|
uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
|
||||||
uint8_t cr = 0xff;
|
uint8_t cr = 0xff;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The clock hardware maintains the day-of-week as a separate counter
|
* The clock hardware maintains the day-of-week as a separate counter
|
||||||
* so we must compute it ourselves (rtems_time_of_day doesn't come
|
* so we must compute it ourselves (rtems_time_of_day doesn't come
|
||||||
@@ -412,10 +425,11 @@ uint8_t v = value;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool rtc_ds1375_device_probe(
|
||||||
rtc_ds1375_device_probe( int minor )
|
int minor
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if ( ( fd = getfd( minor ) ) < 0 ) {
|
if ( ( fd = getfd( minor ) ) < 0 ) {
|
||||||
STDIOSAFE( "ds1375_probe (open): %s\n", strerror( errno ) );
|
STDIOSAFE( "ds1375_probe (open): %s\n", strerror( errno ) );
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ int mc146818a_get_time(
|
|||||||
*/
|
*/
|
||||||
int mc146818a_set_time(
|
int mc146818a_set_time(
|
||||||
int minor,
|
int minor,
|
||||||
rtems_time_of_day *time
|
const rtems_time_of_day *time
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
uint32_t mc146818a;
|
uint32_t mc146818a;
|
||||||
|
|||||||
Reference in New Issue
Block a user