diff --git a/drivers/ddk/core.S b/drivers/ddk/core.S index 373c7e01b1..039fb6acac 100644 --- a/drivers/ddk/core.S +++ b/drivers/ddk/core.S @@ -10,6 +10,7 @@ .global _AttachIntHandler + .global _CancelTimerHS .global _CreateEvent .global _CreateObject .global _CreateRingBuffer @@ -64,7 +65,7 @@ .global _SetScreen .global _SysMsgBoardStr - .global _TimerHs + .global _TimerHS .global _UserAlloc .global _UserFree @@ -79,6 +80,7 @@ .def _AttachIntHandler; .scl 2; .type 32; .endef + .def _CancelTimerHS; .scl 2; .type 32; .endef .def _CreateEvent; .scl 2; .type 32; .endef .def _CreateObject; .scl 2; .type 32; .endef .def _CreateRingBuffer; .scl 2; .type 32; .endef @@ -133,7 +135,7 @@ .def _SetKeyboardData; .scl 2; .type 32; .endef .def _SysMsgBoardStr; .scl 2; .type 32; .endef - .def _TimerHs; .scl 2; .type 32; .endef + .def _TimerHS; .scl 2; .type 32; .endef .def _UserAlloc; .scl 2; .type 32; .endef .def _UserFree; .scl 2; .type 32; .endef @@ -148,6 +150,7 @@ _AllocPages: _AttachIntHandler: +_CancelTimerHS: _CreateEvent: _CreateObject: _CreateRingBuffer: @@ -202,7 +205,7 @@ _SetKeyboardData: _SetScreen: _SysMsgBoardStr: -_TimerHs: +_TimerHS: _UserAlloc: _UserFree: @@ -220,16 +223,15 @@ _WaitEventTimeout: .ascii " -export:AttachIntHandler" # stdcall + .ascii " -export:CancelTimerHS" # stfcall .ascii " -export:CreateEvent" # .ascii " -export:CreateObject" # .ascii " -export:CreateRingBuffer" # stdcall .ascii " -export:CreateThread" # .ascii " -export:Delay" # stdcall - .ascii " -export:DestroyEvent" .ascii " -export:DestroyObject" - .ascii " -export:DiskAdd" # stdcall .ascii " -export:DiskMediaChanged" # stdcall @@ -237,7 +239,6 @@ _WaitEventTimeout: .ascii " -export:FreePage" # .ascii " -export:GetCpuFreq" # - .ascii " -export:GetDisplay" # stdcall .ascii " -export:GetEvent" # .ascii " -export:GetPid" # @@ -276,7 +277,7 @@ _WaitEventTimeout: .ascii " -export:SetScreen" # stdcall .ascii " -export:SysMsgBoardStr" # stdcall - .ascii " -export:TimerHs" # stdcall + .ascii " -export:TimerHS" # stdcall .ascii " -export:UserAlloc" # stdcall .ascii " -export:UserFree" # stdcall diff --git a/drivers/ddk/linux/workqueue.c b/drivers/ddk/linux/workqueue.c index c2e46bd4fd..98a8ffa63d 100644 --- a/drivers/ddk/linux/workqueue.c +++ b/drivers/ddk/linux/workqueue.c @@ -94,7 +94,7 @@ int queue_delayed_work(struct workqueue_struct *wq, // dbgprintf("%s %p queue: %p\n", __FUNCTION__, &dwork->work, wq); work->data = wq; - TimerHs(delay,0, delayed_work_timer_fn, dwork); + TimerHS(delay,0, delayed_work_timer_fn, dwork); return 1; } @@ -104,3 +104,20 @@ bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay) return queue_delayed_work(system_wq, dwork, delay); } +int mod_timer(struct timer_list *timer, unsigned long expires) +{ + int ret = 0; + expires - GetTimerTicks(); + + if(timer->handle) + { + CancelTimerHS(timer->handle); + timer->handle = 0; + ret = 1; + }; + + timer->handle = TimerHS(expires, 0, timer->function, timer->data); + + return ret; +} + diff --git a/drivers/include/linux/kernel.h b/drivers/include/linux/kernel.h index 308e1202ec..897150b24d 100644 --- a/drivers/include/linux/kernel.h +++ b/drivers/include/linux/kernel.h @@ -273,10 +273,17 @@ struct timer_list { void (*function)(unsigned long); unsigned long data; - -// struct tvec_base *base; + u32 handle; }; +#define setup_timer(_timer, _fn, _data) \ + do { \ + (_timer)->function = (_fn); \ + (_timer)->data = (_data); \ + (_timer)->handle = 0; \ + } while (0) + + struct timespec { long tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ diff --git a/drivers/include/linux/workqueue.h b/drivers/include/linux/workqueue.h index 3c578eade4..70c9dbc4cc 100644 --- a/drivers/include/linux/workqueue.h +++ b/drivers/include/linux/workqueue.h @@ -61,6 +61,7 @@ struct workqueue_struct *alloc_workqueue_key(const char *fmt, #define alloc_ordered_workqueue(fmt, flags, args...) \ alloc_workqueue(fmt, WQ_UNBOUND | (flags), 1, ##args) +bool queue_work(struct workqueue_struct *wq, struct work_struct *work); int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay); @@ -80,6 +81,10 @@ bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay); (_work)->work.func = _func; \ } while (0) +static inline bool schedule_work(struct work_struct *work) +{ + return queue_work(system_wq, work); +} #endif /* _LINUX_WORKQUEUE_H */ diff --git a/drivers/include/syscall.h b/drivers/include/syscall.h index 89897972dc..6d0535d083 100644 --- a/drivers/include/syscall.h +++ b/drivers/include/syscall.h @@ -55,8 +55,10 @@ void FASTCALL MutexUnlock(struct mutex*)__asm__("MutexUnlock"); addr_t IMPORT GetStackBase(void)__asm__("GetStackBase"); u32_t IMPORT GetPid(void)__asm__("GetPid"); -u32 STDCALL TimerHs(u32 delay, u32 interval, - void *fn, void *data)asm("TimerHs"); +u32 STDCALL TimerHS(u32 delay, u32 interval, + void *fn, void *data)asm("TimerHS"); + +void STDCALL CancelTimerHS(u32 handle)asm("CancelTimerHS"); u64 IMPORT GetCpuFreq()__asm__("GetCpuFreq");