diff --git a/include/asm.h b/include/asm.h index cd02ef1..b514eb1 100644 --- a/include/asm.h +++ b/include/asm.h @@ -7,6 +7,9 @@ # define _ASM /******************************************************************************/ + +# define int20 asm("int $0x14") + # define halt() asm("hlt"::) # define sti() asm("sti"::) diff --git a/lib/handlers_asm.S b/lib/handlers_asm.S index a297e57..a8b2aaf 100644 --- a/lib/handlers_asm.S +++ b/lib/handlers_asm.S @@ -16,6 +16,7 @@ jmp exception_suite .endm .macro semidumpcpu +cli pushl %ds pushl %es pushl %fs @@ -88,6 +89,16 @@ pushl $0x00 semidumpcpu call sysenter_handler +.global wrapper_interruption20 +wrapper_interruption20: +pushl %ss +pushl %esp +pushf +pushl %cs +pushl $0x14 +semidumpcpu +call interruption_handler + .global wrapper_interruption wrapper_interruption: pushl %ss diff --git a/lib/keyboard.c b/lib/keyboard.c index 19460a0..c6f5f0c 100644 --- a/lib/keyboard.c +++ b/lib/keyboard.c @@ -247,8 +247,7 @@ unsigned convert(u32 keypressed) else if (key == SCAN_F9) { - regs dump; - show_cpu(&dump); + int20; } else if (key == SCAN_F10) @@ -363,6 +362,7 @@ unsigned convert(u32 keypressed) __attribute__((interrupt)) void keyboard_handler(exception_stack_noerror *caller) { + cli(); u8 scancode, ascii; while ((inb(0x64) & 1) == 0); scancode = inb(0x60); @@ -375,6 +375,7 @@ __attribute__((interrupt)) void keyboard_handler(exception_stack_noerror *caller bufferascii[ptrascii] = ascii; } irqendmaster(); + sti(); } /******************************************************************************/ diff --git a/lib/mouse.c b/lib/mouse.c index fac73ca..85532dc 100644 --- a/lib/mouse.c +++ b/lib/mouse.c @@ -66,6 +66,7 @@ void outmsecmd(u8 command) __attribute__((interrupt)) void mouse_handler(exception_stack_noerror *caller) { + cli(); u8 mbyte = inb(0x60); s8 changex, changey; @@ -142,6 +143,7 @@ __attribute__((interrupt)) void mouse_handler(exception_stack_noerror *caller) endofint: irqendmaster(); irqendslave(); + sti(); } /*******************************************************************************/ diff --git a/lib/process.c b/lib/process.c index 8c4a324..b33ce75 100644 --- a/lib/process.c +++ b/lib/process.c @@ -76,8 +76,10 @@ END */ void processexit(void) { + cli(); deleteprocess(getcurrentpid()); switchtask(maketid(1,1)); + sti(); } /*******************************************************************************/ @@ -257,6 +259,7 @@ process* findcurrentprocess(void) void switchtask(tid_t tid) { + cli(); tid_t previous = current; task *atask = findtask(tid); if (atask==NULL) return; @@ -346,6 +349,7 @@ task* findcurrenttask(void) void deletetask(tid_t tid) { + cli(); stoptask(tid); process* aprocess=findprocess(tid.pid); if (aprocess==NULL) return; @@ -353,6 +357,7 @@ void deletetask(tid_t tid) if (atask==NULL) return; TAILQ_REMOVE(&aprocess->task_head, atask, tailq); vfree(atask); + sti(); } /*******************************************************************************/ @@ -360,6 +365,7 @@ void deletetask(tid_t tid) void runtask(tid_t tid) { + cli(); task *atask=findtask(tid); if (atask==NULL) return; if (atask->status == TASK_STATUS_READY) @@ -367,6 +373,7 @@ void runtask(tid_t tid) atask->status = TASK_STATUS_RUN; switchtask(tid); } + sti(); } /*******************************************************************************/ @@ -374,6 +381,7 @@ void runtask(tid_t tid) tid_t createtask(pid_t pid,u8 *entry, bool kerneltask) { + cli(); tid_t tid; tid.pid=pid; process* aprocess=findprocess(pid); @@ -429,6 +437,7 @@ tid_t createtask(pid_t pid,u8 *entry, bool kerneltask) new->dump.edi = 0; new->status = TASK_STATUS_READY; return new->tid; + sti(); } /*******************************************************************************/ @@ -436,9 +445,11 @@ tid_t createtask(pid_t pid,u8 *entry, bool kerneltask) void stoptask(tid_t tid) { + cli(); task *atask=findtask(tid); if (atask==NULL) return; atask->status=TASK_STATUS_STOP; + sti(); } /*******************************************************************************/ @@ -446,6 +457,7 @@ void stoptask(tid_t tid) pid_t createprocess(u8 *src, bool kerneltask) { + cli(); tid_t previous = current; current.pid = getfreepid(); current.number = 0; @@ -467,6 +479,7 @@ pid_t createprocess(u8 *src, bool kerneltask) cr3=old->pdd->addr->paddr; setCR3(cr3); new->status=PROCESS_STATUS_READY; + sti(); return new->pid; } @@ -475,6 +488,7 @@ pid_t createprocess(u8 *src, bool kerneltask) void deleteprocess(pid_t pid) { + cli(); stopprocess(pid); process* aprocess=findprocess(pid); if (aprocess==NULL) return; @@ -482,7 +496,7 @@ void deleteprocess(pid_t pid) TAILQ_FOREACH(next, &aprocess->task_head, tailq) deletetask(next->tid); aprocess->status = PROCESS_STATUS_FREE; - + sti(); } /*******************************************************************************/ @@ -490,6 +504,7 @@ void deleteprocess(pid_t pid) void runprocess(pid_t pid) { + cli(); process* aprocess=findprocess(pid); if (aprocess==NULL) return; if (aprocess->status == PROCESS_STATUS_READY) @@ -501,6 +516,7 @@ void runprocess(pid_t pid) atask->status=TASK_STATUS_RUN; switchtask(tid); } + sti(); } /*******************************************************************************/ diff --git a/lib/shell.c b/lib/shell.c index 9e234a4..91bfafc 100644 --- a/lib/shell.c +++ b/lib/shell.c @@ -449,8 +449,7 @@ int showinfo() int showregs() { - regs dump; - show_cpu(&dump); + int20; return 0; } diff --git a/programs/test2.c b/programs/test2.c index 84b085e..a974baf 100644 --- a/programs/test2.c +++ b/programs/test2.c @@ -10,7 +10,7 @@ void main(void) { while (true) { - if (getticks()%10==0) + if (getticks()%100000==0) print("[TEST]\r\n"); } exit(1); diff --git a/system/system.c b/system/system.c index 060f23c..4bcd96a 100644 --- a/system/system.c +++ b/system/system.c @@ -26,6 +26,7 @@ static u8 errormsg[] = static u8 key = 0; extern wrapper_timer; +extern wrapper_interruption20; void ok() { @@ -77,6 +78,8 @@ int main(u32 magic, u32 addr) print("\033[37m\033[0m -Initilisation des interruptions"); initidt(); initpic(); + setidt((u32) &wrapper_interruption20, SEL_KERNEL_CODE, + ENTRY_PRESENT | ENTRY_RING3 | TRAPGATE, 20); sti(); ok();