X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86_64%2Fdesctab.asm;h=816d14e5c68385e1abc00b635a0ed7f07d26480a;hb=18b264927674c480481466c40368554fb72f560f;hp=039fe95ed5497afa456f3b3416c5979eec6fa64b;hpb=d8b11d2074b48f17f999d44c75b1f76fdffd970b;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86_64/desctab.asm b/Kernel/arch/x86_64/desctab.asm index 039fe95e..816d14e5 100644 --- a/Kernel/arch/x86_64/desctab.asm +++ b/Kernel/arch/x86_64/desctab.asm @@ -3,6 +3,8 @@ ; [BITS 64] +[extern Log] + %define NUM_IRQ_CALLBACKS 4 MM_LOCALAPIC equ 0xFFFFFD0000000000 @@ -78,7 +80,7 @@ Desctab_Init: %endrep ; Install IRQs - SETIDT 0xF0, Irq0 + SETIDT 0xF0, SchedulerIRQ SETIDT 0xF1, Irq1 SETIDT 0xF2, Irq2 SETIDT 0xF3, Irq3 @@ -171,11 +173,31 @@ IRQ_AddHandler: ; Assign the IRQ Callback .assign: + ; A little bit of debug + push rdi + push rsi + push rax + sub rsp, 8 + mov rcx, rdi ; IRQ Number + mov rdx, rsi ; Callback + mov rsi, rax ; Pointer + mov rdi, csIRQ_Assigned + call Log + add rsp, 8 + pop rax + pop rsi + pop rdi + mov [rax], rsi xor rax, rax .ret: ret + +[section .rodata] +csIRQ_Assigned: + db "IRQ %p := %p (IRQ %i)",0 +[section .text] %macro ISR_NOERRNO 1 Isr%1: @@ -299,20 +321,43 @@ IrqCommon: [extern Proc_Scheduler] [global SchedulerIRQ] SchedulerIRQ: - ; TODO: Find Current CPU PUSH_GPR ;PUSH_FPU ;PUSH_XMM - xor rsi, rsi - mov rdi, MM_LOCALAPIC+0x20 - mov esi, [rdi] + ; Save Thread Pointer + mov rax, dr0 + push rax + + ; Get the CPU Number + mov rdi, dr1 + ; Call the Scheduler call Proc_Scheduler + ; Restore Thread Pointer + pop rax + mov dr0, rax + + ; Send EOI (To either the APIC or the PIC) + %if USE_MP + test ebx, ebx + jnz .sendEOI + %endif + ; PIC + mov al, 0x20 + out 0x20, al ; ACK IRQ + %if USE_MP + jmp .ret + ; APIC +.sendEOI: + mov eax, DWORD [gpMP_LocalAPIC] + mov DWORD [eax+0x0B0], 0 + %endif +.ret: + ;POP_XMM ;POP_FPU POP_GPR - add rsp, 8*2 iretq [section .data]