X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/7c7b5f05d39b7739d990f71256a2267ec67a6913..f6ab9c9ababa2cf6e5c723b83ffb9362094054e8:/lunaix-os/hal/timer/hwtimer.c diff --git a/lunaix-os/hal/timer/hwtimer.c b/lunaix-os/hal/timer/hwtimer.c index bd6477a..3a79ca1 100644 --- a/lunaix-os/hal/timer/hwtimer.c +++ b/lunaix-os/hal/timer/hwtimer.c @@ -1,18 +1,9 @@ #include #include -struct hwtimer_context* current_timer; +#include -void -hwtimer_init(u32_t hertz, void* tick_callback) -{ - struct hwtimer_context* hwt_ctx = hwtimer_choose(); - - hwt_ctx->init(hwt_ctx, hertz, tick_callback); - hwt_ctx->running_freq = hertz; - - current_timer = hwt_ctx; -} +struct hwtimer* current_timer; ticks_t hwtimer_base_frequency() @@ -37,4 +28,34 @@ hwtimer_to_ticks(u32_t value, int unit) ticks_t freq_ms = current_timer->running_freq / 1000; return freq_ms * value; +} + +static int +__hwtimer_ioctl(struct device* dev, u32_t req, va_list args) +{ + struct hwtimer* hwt = (struct hwtimer*)dev->underlay; + switch (req) { + case TIMERIO_GETINFO: + // TODO + break; + + default: + break; + } + return 0; +} + +void +hwtimer_init(u32_t hertz, void* tick_callback) +{ + struct hwtimer* hwt_ctx = hwtimer_choose(); + + hwt_ctx->init(hwt_ctx, hertz, tick_callback); + hwt_ctx->running_freq = hertz; + + current_timer = hwt_ctx; + + struct device* timerdev = device_addsys(NULL, hwt_ctx, hwt_ctx->name); + + timerdev->ops.exec_cmd = __hwtimer_ioctl; } \ No newline at end of file