Fixed interrupts using wrong stack
Tasks were running in kernel mode, so the tss stack was not being used. Unfortunatley, I had to set kmalloc to user r/w so switchTask can save and load registers.
This commit is contained in:
parent
5618dd6834
commit
0c50e1eb8c
@ -103,7 +103,7 @@ void* new_address_space() {
|
|||||||
uint32_t entry_virt=(uint32_t)&(kern_page_tables[i*1024]);
|
uint32_t entry_virt=(uint32_t)&(kern_page_tables[i*1024]);
|
||||||
smap[i+768]=(entry_virt-0xC0000000)|0x7;
|
smap[i+768]=(entry_virt-0xC0000000)|0x7;
|
||||||
}
|
}
|
||||||
smap[1021]=(((uint32_t)kmalloc_page_tables)-0xC0000000)|0x3;
|
smap[1021]=(((uint32_t)kmalloc_page_tables)-0xC0000000)|0x7;
|
||||||
for (uint32_t i=0;i<2;i++) {
|
for (uint32_t i=0;i<2;i++) {
|
||||||
uint32_t entry_virt=(uint32_t)&(smap_page_tables[i*1024]);
|
uint32_t entry_virt=(uint32_t)&(smap_page_tables[i*1024]);
|
||||||
smap[i+1022]=(entry_virt-0xC0000000)|0x3;
|
smap[i+1022]=(entry_virt-0xC0000000)|0x3;
|
||||||
@ -128,7 +128,7 @@ void paging_init() {
|
|||||||
kern_page_tables[i]=(i<<12)|0x7;
|
kern_page_tables[i]=(i<<12)|0x7;
|
||||||
}
|
}
|
||||||
for (uint32_t i=0;i<1024;i++) {
|
for (uint32_t i=0;i<1024;i++) {
|
||||||
kmalloc_page_tables[i]=(uint32_t)pmem_alloc(1)|0x3;
|
kmalloc_page_tables[i]=(uint32_t)pmem_alloc(1)|0x7;
|
||||||
}
|
}
|
||||||
smap_page_tables[0]=(((uint32_t)&(page_directory))-0xC0000000)|0x3;
|
smap_page_tables[0]=(((uint32_t)&(page_directory))-0xC0000000)|0x3;
|
||||||
for (uint32_t i=1;i<2048;i++) {
|
for (uint32_t i=1;i<2048;i++) {
|
||||||
@ -138,7 +138,7 @@ void paging_init() {
|
|||||||
uint32_t entry_virt=(uint32_t)&(kern_page_tables[i*1024]);
|
uint32_t entry_virt=(uint32_t)&(kern_page_tables[i*1024]);
|
||||||
page_directory[i+768]=(entry_virt-0xC0000000)|0x7;
|
page_directory[i+768]=(entry_virt-0xC0000000)|0x7;
|
||||||
}
|
}
|
||||||
page_directory[1021]=(((uint32_t)kmalloc_page_tables)-0xC0000000)|0x3;
|
page_directory[1021]=(((uint32_t)kmalloc_page_tables)-0xC0000000)|0x7;
|
||||||
for (uint32_t i=0;i<2;i++) {
|
for (uint32_t i=0;i<2;i++) {
|
||||||
uint32_t entry_virt=(uint32_t)&(smap_page_tables[i*1024]);
|
uint32_t entry_virt=(uint32_t)&(smap_page_tables[i*1024]);
|
||||||
page_directory[i+1022]=(entry_virt-0xC0000000)|0x3;
|
page_directory[i+1022]=(entry_virt-0xC0000000)|0x3;
|
||||||
|
@ -74,7 +74,7 @@ char isPrivleged(uint32_t pid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Task* tasking_createTask(void* eip) {
|
Task* tasking_createTask(void* eip) {
|
||||||
return createTaskKmode(eip,1);
|
return createTaskKmode(eip,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_msg(uint32_t pid,void* msg) {
|
void send_msg(uint32_t pid,void* msg) {
|
||||||
@ -124,6 +124,11 @@ void tasking_yield() {
|
|||||||
Task* oldCurr=currentTask;
|
Task* oldCurr=currentTask;
|
||||||
currentTask=task;
|
currentTask=task;
|
||||||
load_address_space(task->regs.cr3);
|
load_address_space(task->regs.cr3);
|
||||||
|
if (task->priv) {
|
||||||
|
allow_all_ports();
|
||||||
|
} else {
|
||||||
|
block_all_ports();
|
||||||
|
}
|
||||||
if (!task->kmode) {
|
if (!task->kmode) {
|
||||||
asm volatile(" \
|
asm volatile(" \
|
||||||
cli; \
|
cli; \
|
||||||
@ -143,10 +148,5 @@ void tasking_yield() {
|
|||||||
1: \
|
1: \
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
if (task->priv) {
|
|
||||||
allow_all_ports();
|
|
||||||
} else {
|
|
||||||
block_all_ports();
|
|
||||||
}
|
|
||||||
switchTask(&oldCurr->regs, ¤tTask->regs);
|
switchTask(&oldCurr->regs, ¤tTask->regs);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user