Feat: kernel thread done
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <logger.h>
|
||||
#include <utils.h>
|
||||
#include <kmalloc.h>
|
||||
#include <thread.h>
|
||||
|
||||
#define CORE0_TIMER_IRQ_CTRL ((volatile uint32_t *)0x40000040)
|
||||
|
||||
@@ -92,6 +93,21 @@ void add_timer_task(task_t task)
|
||||
_check_enable_timer();
|
||||
}
|
||||
|
||||
void sleep(uint64_t ms)
|
||||
{
|
||||
uint64_t cntpct_el0, cntfrq_el0;
|
||||
R_SYSREG(cntpct_el0, cntpct_el0);
|
||||
R_SYSREG(cntfrq_el0, cntfrq_el0);
|
||||
|
||||
uint64_t wake = cntpct_el0 + cntfrq_el0 * ms / 1000000;
|
||||
for (;;) {
|
||||
R_SYSREG(cntpct_el0, cntpct_el0);
|
||||
if (cntpct_el0 >= wake)
|
||||
break;
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
interrupt_callback_func_t func;
|
||||
uint64_t param;
|
||||
|
||||
Reference in New Issue
Block a user