forked from Imagelibrary/rtems
2009-05-27 Sebastian Huber <sebastian.huber@embedded-brains.de>
* tod.h, tod.c: Update for new RTC driver interface.
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/rtc.h>
|
||||
#include <rtems/libio.h>
|
||||
|
||||
#include <libchip/rtc.h>
|
||||
|
||||
/*
|
||||
@@ -34,8 +37,8 @@ rtems_device_driver rtc_initialize(
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
rtems_device_minor_number minor;
|
||||
rtems_status_code status;
|
||||
rtems_device_minor_number minor;
|
||||
rtems_status_code status;
|
||||
|
||||
for (minor=0; minor < RTC_Count ; minor++) {
|
||||
/*
|
||||
@@ -65,7 +68,7 @@ rtems_device_driver rtc_initialize(
|
||||
* Register and initialize the primary RTC's
|
||||
*/
|
||||
|
||||
status = rtems_io_register_name( "/dev/rtc", major, RTC_Minor );
|
||||
status = rtems_io_register_name( RTC_DEVICE_NAME, major, RTC_Minor );
|
||||
if (status != RTEMS_SUCCESSFUL) {
|
||||
rtems_fatal_error_occurred(status);
|
||||
}
|
||||
@@ -104,6 +107,101 @@ rtems_device_driver rtc_initialize(
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver rtc_read(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
int rv = 0;
|
||||
rtems_libio_rw_args_t *rw = arg;
|
||||
rtems_time_of_day *tod = (rtems_time_of_day *) rw->buffer;
|
||||
|
||||
rw->offset = 0;
|
||||
rw->bytes_moved = 0;
|
||||
|
||||
if (!RTC_Present) {
|
||||
return RTEMS_NOT_CONFIGURED;
|
||||
}
|
||||
|
||||
if (rw->count != sizeof( rtems_time_of_day)) {
|
||||
return RTEMS_INVALID_SIZE;
|
||||
}
|
||||
|
||||
rv = RTC_Table [RTC_Minor].pDeviceFns->deviceGetTime(
|
||||
RTC_Minor,
|
||||
tod
|
||||
);
|
||||
if (rv != 0) {
|
||||
return RTEMS_IO_ERROR;
|
||||
}
|
||||
|
||||
rw->bytes_moved = rw->count;
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver rtc_write(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
int rv = 0;
|
||||
rtems_libio_rw_args_t *rw = arg;
|
||||
const rtems_time_of_day *tod = (const rtems_time_of_day *) rw->buffer;
|
||||
|
||||
rw->offset = 0;
|
||||
rw->bytes_moved = 0;
|
||||
|
||||
if (!RTC_Present) {
|
||||
return RTEMS_NOT_CONFIGURED;
|
||||
}
|
||||
|
||||
if (rw->count != sizeof( rtems_time_of_day)) {
|
||||
return RTEMS_INVALID_SIZE;
|
||||
}
|
||||
|
||||
rv = RTC_Table [RTC_Minor].pDeviceFns->deviceSetTime(
|
||||
RTC_Minor,
|
||||
tod
|
||||
);
|
||||
if (rv != 0) {
|
||||
return RTEMS_IO_ERROR;
|
||||
}
|
||||
|
||||
rw->bytes_moved = rw->count;
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver rtc_open(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver rtc_close(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver rtc_control(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
return RTEMS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* This routine copies the time from the real time clock to RTEMS
|
||||
@@ -186,7 +284,7 @@ void getRealTime(
|
||||
* Return values: NONE
|
||||
*/
|
||||
int setRealTime(
|
||||
rtems_time_of_day *tod
|
||||
const rtems_time_of_day *tod
|
||||
)
|
||||
{
|
||||
if (!RTC_Present)
|
||||
|
||||
Reference in New Issue
Block a user