mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-30 00:00:15 +01:00
move more helper functions to the architecture dependent directory
This commit is contained in:
parent
3a383b21e3
commit
a3ea183edc
3 changed files with 39 additions and 25 deletions
|
@ -77,6 +77,13 @@ static inline int jump_to_user_code(size_t ep, size_t stack)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** @brief Architecture dependent initialize routine
|
||||
*/
|
||||
static inline void arch_init_task(task_t* task)
|
||||
{
|
||||
set_tss((size_t) task->stack + KERNEL_STACK_SIZE - 0x10, (size_t) task->ist_addr + KERNEL_STACK_SIZE - 0x10);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -82,8 +82,9 @@ extern void isr29(void);
|
|||
extern void isr30(void);
|
||||
extern void isr31(void);
|
||||
|
||||
static void fault_handler(struct state *s);
|
||||
extern void fpu_handler(struct state *s);
|
||||
static void arch_fault_handler(struct state *s);
|
||||
static void arch_fpu_handler(struct state *s);
|
||||
extern void fpu_handler(void);
|
||||
|
||||
/*
|
||||
* This is a very repetitive function... it's not hard, it's
|
||||
|
@ -174,11 +175,11 @@ void isrs_install(void)
|
|||
|
||||
// install the default handler
|
||||
for(i=0; i<32; i++)
|
||||
irq_install_handler(i, fault_handler);
|
||||
irq_install_handler(i, arch_fault_handler);
|
||||
|
||||
// set hanlder for fpu exceptions
|
||||
irq_uninstall_handler(7);
|
||||
irq_install_handler(7, fpu_handler);
|
||||
irq_install_handler(7, arch_fpu_handler);
|
||||
}
|
||||
|
||||
/** @brief Exception messages
|
||||
|
@ -198,6 +199,16 @@ static const char *exception_messages[] = {
|
|||
"Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved",
|
||||
"Reserved", "Reserved" };
|
||||
|
||||
/* interrupt handler to save / restore the FPU context */
|
||||
static void arch_fpu_handler(struct state *s)
|
||||
{
|
||||
(void) s;
|
||||
|
||||
clts(); // clear the TS flag of cr0
|
||||
|
||||
fpu_handler();
|
||||
}
|
||||
|
||||
/*
|
||||
* All of our Exception handling Interrupt Service Routines will
|
||||
* point to this function. This will tell us what exception has
|
||||
|
@ -206,7 +217,7 @@ static const char *exception_messages[] = {
|
|||
* serviced as a 'locking' mechanism to prevent an IRQ from
|
||||
* happening and messing up kernel data structures
|
||||
*/
|
||||
static void fault_handler(struct state *s)
|
||||
static void arch_fault_handler(struct state *s)
|
||||
{
|
||||
|
||||
if (s->int_no < 32)
|
||||
|
|
|
@ -195,15 +195,11 @@ static void readyqueues_remove(uint32_t core_id, task_t* task)
|
|||
}
|
||||
|
||||
|
||||
/* interrupt handler to save / restore the FPU context */
|
||||
void fpu_handler(struct state *s)
|
||||
void fpu_handler(void)
|
||||
{
|
||||
(void) s;
|
||||
|
||||
task_t* task = per_core(current_task);
|
||||
uint32_t core_id = CORE_ID;
|
||||
|
||||
clts(); // clear the TS flag of cr0
|
||||
task->flags |= TASK_FPU_USED;
|
||||
|
||||
if (!(task->flags & TASK_FPU_INIT)) {
|
||||
|
@ -284,7 +280,7 @@ int multitasking_init(void)
|
|||
task_table[0].ist_addr = (char*)&boot_ist;
|
||||
set_per_core(kernel_stack, task_table[0].stack + KERNEL_STACK_SIZE - 0x10);
|
||||
set_per_core(current_task, task_table+0);
|
||||
set_tss((size_t) task_table[0].stack + KERNEL_STACK_SIZE - 0x10, (size_t) task_table[0].ist_addr + KERNEL_STACK_SIZE - 0x10);
|
||||
arch_init_task(task_table+0);
|
||||
|
||||
readyqueues[core_id].idle = task_table+0;
|
||||
|
||||
|
@ -312,7 +308,7 @@ int set_idle_task(void)
|
|||
task_table[i].heap = NULL;
|
||||
readyqueues[core_id].idle = task_table+i;
|
||||
set_per_core(current_task, readyqueues[core_id].idle);
|
||||
set_tss((size_t) task_table[i].stack + KERNEL_STACK_SIZE - 0x10, (size_t) task_table[i].ist_addr + KERNEL_STACK_SIZE - 0x10);
|
||||
arch_init_task(task_table+i);
|
||||
ret = 0;
|
||||
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue