1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

create a seperate stack for interrupts

This commit is contained in:
Stefan Lankes 2015-08-28 07:55:49 +02:00
parent 6c707f6595
commit 987ea13265
2 changed files with 11 additions and 10 deletions

View file

@ -36,9 +36,10 @@
#include <asm/page.h>
gdt_ptr_t gp;
tss_t task_state_segments[MAX_CORES] __attribute__ ((aligned (PAGE_SIZE)));
// currently, our kernel has full access to the ioports
static gdt_entry_t gdt[GDT_ENTRIES] = {[0 ... GDT_ENTRIES-1] = {0, 0, 0, 0, 0, 0}};
static uint8_t irq_stacks[MAX_CORES][KERNEL_STACK_SIZE] __attribute__ ((aligned (PAGE_SIZE)));
static tss_t task_state_segments[MAX_CORES] __attribute__ ((aligned (PAGE_SIZE)));
/*
* This is defined in entry.asm. We use this to properly reload
@ -136,7 +137,7 @@ void gdt_install(void)
* Create TSS for each core (we use these segments for task switching)
*/
for(i=0; i<MAX_CORES; i++) {
task_state_segments[i].rsp0 = (size_t) &boot_stack + i * KERNEL_STACK_SIZE - 0x10;
task_state_segments[i].rsp0 = (size_t) irq_stacks[i] + KERNEL_STACK_SIZE - 0x10;
gdt_set_gate(num+i*2, (unsigned long) (task_state_segments+i), sizeof(tss_t)-1,
GDT_FLAG_PRESENT | GDT_FLAG_TSS | GDT_FLAG_RING0, 0);
}

View file

@ -36,11 +36,9 @@
#include <hermit/vma.h>
#include <asm/elf.h>
#include <asm/page.h>
#include <asm/tss.h>
#define START_ADDRESS 0x40200000
extern tss_t task_state_segments[MAX_CORES];
extern uint64_t base;
static inline void enter_user_task(size_t ep, size_t stack)
@ -108,17 +106,13 @@ static int thread_entry(void* arg, size_t ep)
size_t* get_current_stack(void)
{
uint32_t core_id = CORE_ID;
task_t* curr_task = per_core(current_task);
size_t stptr = ((size_t) curr_task->stack + KERNEL_STACK_SIZE - 0x10) & ~0xF;
size_t cr3;
set_per_core(kernel_stack, stptr);
task_state_segments[core_id].rsp0 = stptr;
cr3 = read_cr3();
// do we change the address space?
if (cr3 != curr_task->page_map)
if (read_cr3() != curr_task->page_map)
write_cr3(curr_task->page_map); // use new page table
return curr_task->last_stack_pointer;
@ -488,10 +482,16 @@ static int user_entry(void* arg)
return -EINVAL;
ret = load_task((load_args_t*) arg);
if (ret)
kprintf("Load task failed: %d\n", ret);
kfree(arg);
return ret;
sys_exit(ret);
while(1) {
HALT;
}
}
/** @brief Luxus-edition of create_user_task functions. Just call with an exe name