feat: fstat now handle symbolic link
[lunaix-os.git] / lunaix-os / hal / rtc / mc146818a.c
index 1a507653192df1d5a5d40cdba38a89b3a6718955..dce0a5179ad8386212d9552d1f417259c50a5a2e 100644 (file)
@@ -145,8 +145,7 @@ mc146818_check_support(struct hwrtc* rtc)
 static void
 __rtc_tick(const isr_param* param)
 {
-    struct mc146818* state =
-      (struct mc146818*)isrm_get_payload(param->execp->vector);
+    struct mc146818* state = (struct mc146818*)isrm_get_payload(param);
 
     state->tick_counts++;
 
@@ -183,8 +182,8 @@ rtc_getcnt(struct hwrtc* rtc)
     return state->tick_counts;
 }
 
-static void
-rtc_init()
+static int
+rtc_init(struct device_def* devdef)
 {
     u8_t reg = rtc_read_reg(RTC_REG_A);
     reg = (reg & ~0x7f) | RTC_FREQUENCY_1024HZ | RTC_DIVIDER_33KHZ;
@@ -196,7 +195,7 @@ rtc_init()
     // Make sure the rtc timer is disabled by default
     rtc_disable_timer();
 
-    struct hwrtc* rtc = hwrtc_alloc_new("mc146818");
+    struct hwrtc* rtc = hwrtc_alloc_new(devdef, "mc146818");
     struct mc146818* state = valloc(sizeof(struct mc146818));
 
     state->rtc_context = rtc;
@@ -212,5 +211,13 @@ rtc_init()
     rtc->cls_mask = rtc_cls_mask;
     rtc->get_counts = rtc_getcnt;
     rtc->chfreq = rtc_chfreq;
+
+    return 0;
 }
-EXPORT_RTC_DEVICE(mc146818, rtc_init);
\ No newline at end of file
+
+static struct device_def devrtc_mc146818 = {
+    .name = "MC146818 RTC",
+    .class = DEVCLASS(DEVIF_SOC, DEVFN_TIME, DEV_RTC, 1),
+    .init = rtc_init
+};
+EXPORT_DEVICE(mc146818, &devrtc_mc146818, load_earlystage);
\ No newline at end of file