Skip to content
Snippets Groups Projects
timer.c 647 B
Newer Older
jie's avatar
jie committed
#include <am.h>
#include <x86.h>
#include <amdev.h>

#include <klib.h>

jie's avatar
jie committed
size_t timer_read(uintptr_t reg, void *buf, size_t size) {
Recolic Keghart's avatar
Recolic Keghart committed
  const size_t rtc_port_id = 0x48;

jie's avatar
jie committed
  switch (reg) {
    case _DEVREG_TIMER_UPTIME: {
      _UptimeReg *uptime = (_UptimeReg *)buf;
      uptime->hi = 0;
      uptime->lo = inl(rtc_port_id);
jie's avatar
jie committed
      return sizeof(_UptimeReg);
    }
    case _DEVREG_TIMER_DATE: {
      _RTCReg *rtc = (_RTCReg *)buf;
      rtc->second = 0;
      rtc->minute = 0;
      rtc->hour   = 0;
      rtc->day    = 0;
      rtc->month  = 0;
      rtc->year   = 2018;
      return sizeof(_RTCReg);
    }
  }
  return 0;
}

void timer_init() {
}