Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset d8a4e79 in mainline


Ignore:
Timestamp:
2012-04-04T20:22:20Z (10 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master
Children:
2a4c22d
Parents:
f87ea202
Message:

rtc: Add an option to the default handler to get the status of the clock's battery

Location:
uspace
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/time/cmos-rtc/cmos-regs.h

    rf87ea202 rd8a4e79  
    4040#define RTC_MASK_BCD    0x04
    4141
     42#define RTC_STATUS_D    0x0D
     43#define RTC_BATTERY_OK  0x80
     44
    4245#define RTC_UPDATE      0x0A
    4346#define RTC_MASK_UPDATE 0x08
  • uspace/drv/time/cmos-rtc/cmos-rtc.c

    rf87ea202 rd8a4e79  
    4646#include <device/hw_res.h>
    4747#include <devman.h>
     48#include <ipc/clock_ctl.h>
    4849
    4950#include "cmos-regs.h"
     
    8283static int  rtc_register_read(rtc_t *rtc, int reg);
    8384static int  bcd2dec(int bcd);
     85static void rtc_default_handler(ddf_fun_t *fun,
     86    ipc_callid_t callid, ipc_call_t *call);
    8487
    8588
     
    114117
    115118        rtc_dev_ops.interfaces[CLOCK_DEV_IFACE] = &rtc_clock_dev_ops;
    116         rtc_dev_ops.default_handler = NULL; /* XXX */
     119        rtc_dev_ops.default_handler = &rtc_default_handler;
    117120}
    118121
     
    387390}
    388391
     392/** Default handler for client requests not handled
     393 *  by the standard interface
     394 */
     395static void
     396rtc_default_handler(ddf_fun_t *fun, ipc_callid_t callid, ipc_call_t *call)
     397{
     398        sysarg_t method = IPC_GET_IMETHOD(*call);
     399        rtc_t *rtc = RTC_FROM_FNODE(fun);
     400        bool batt_ok;
     401
     402        switch (method) {
     403        case CLOCK_GET_BATTERY_STATUS:
     404                batt_ok = !(rtc_register_read(rtc, RTC_STATUS_D) &
     405                    RTC_BATTERY_OK);
     406                async_answer_1(callid, EOK, batt_ok);
     407                break;
     408        default:
     409                async_answer_0(callid, ENOTSUP);
     410        }
     411}
     412
    389413/** Open the device
    390414 *
Note: See TracChangeset for help on using the changeset viewer.