]> wirehaze git hosting - BOS.git/blobdiff - kernel/int/idt.asm

wirehaze git hosting

Now bootable
[BOS.git] / kernel / int / idt.asm
index cafbc63fc5dd368645431a0a1f513147232b1ea1..5b4a8d8a3942b843e50b44ad86fe1aa990fcd343 100644 (file)
 ;----------------------------------------------------------;\r
-; BOS kernel               Christoffer Bubach, 2003-2005. ;\r
+; BOS kernel                Christoffer Bubach, 2003-2005. ;\r
 ;----------------------------------------------------------;\r
-;                                                         ;\r
-;      set/modify IDT entries                             ;\r
-;                                                         ;\r
+;                                                          ;\r
+;    set/modify IDT entries                                ;\r
+;                                                          ;\r
 ;----------------------------------------------------------;\r
 \r
 \r
 \r
 ;--------------------------------------------------;\r
-;     set up IDT                                  ;\r
-; in:  edi = pointer to "unhandled int"-function.  ;\r
+;     set up IDT                                   ;\r
+; in:  esi = pointer to "unhandled int"-function.  ;\r
 ;--------------------------------------------------;\r
 init_idt:\r
-         push    eax\r
-         push    ecx\r
+        push   eax\r
+        push   ecx\r
 \r
-         mov     ecx, 0\r
-     .loop:                                          ; loop\r
-         mov     eax, edi                            ; and\r
-         mov     [(0x6c00+ecx)], ax                  ; set whole IDT\r
-         add     ecx, 2                              ; to one ISR\r
+        xor    ecx, ecx\r
+    .l1:\r
+        mov    eax, esi                               ; loop full IDT and\r
+        mov    [(0x6c00+ecx)], ax                     ; set to one ISR\r
+        add    ecx, 2\r
 \r
-         mov     dword [(0x6c00+ecx)], 0x8E000008    ; 0x6c00 is where\r
-         add     ecx, 4                              ; we put the IDT\r
+        mov    dword [(0x6c00+ecx)], 0x8E000008       ; 0x6c00 is where\r
+        add    ecx, 4                                 ; we put the IDT\r
 \r
-         mov     eax, edi\r
-         shr     eax, 16\r
-         mov     [(0x6c00+ecx)], ax\r
-         add     ecx, 2\r
+        mov    eax, esi\r
+        shr    eax, 16\r
+        mov    [(0x6c00+ecx)], ax\r
+        add    ecx, 2\r
 \r
-         cmp     ecx, 0x800                          ; 256 ints\r
-         jb      .loop                               ; * 8 bytes each\r
+        cmp    ecx, 0x800                             ; 256 ints\r
+        jb     .l1                                    ; * 8 bytes each\r
 \r
-         pop     ecx\r
-         pop     eax\r
-         ret\r
+        pop    ecx\r
+        pop    eax\r
+        ret\r
 \r
 \r
 \r
 ;--------------------------------------;\r
-;  modify IDT, set any int            ;\r
-;     in: cl  = int number            ;\r
-;        edi = int function pointer   ;\r
+;  modify IDT, set any int             ;\r
+;     in: cl  = int number             ;\r
+;      edi = int function pointer      ;\r
 ;--------------------------------------;\r
 set_int:\r
-         push    eax\r
-         push    ecx\r
+               push   eax\r
+               push   ecx\r
 \r
-         mov     al, 8                               ; 8 bytes for each int\r
-         mul     cl                                  ; cl * al = ax\r
-         movzx   ecx, ax                             ; ecx = offset in IDT (1/2 for dword list)\r
-         ;;mov   [(idt_list+ecx/2)], edi             ; add new int to idt entry list\r
-         mov     dword [(idt_list+ecx)], edi         ; add new int to idt entry list\r
+               mov    al, 8                                  ; 8 bytes for each int\r
+               mul    cl                                     ; cl * al = ax\r
+               movzx  ecx, ax                                ; ecx = IDT offset\r
+               shr    ecx, 1                                 ; 1/2 for dword list\r
+               mov    dword [(idt_list+ecx)], edi            ; add to dword int list\r
+               movzx  ecx, ax                                ; ecx = IDT offset\r
 \r
-         mov     eax, edi\r
-         mov     [(0x6c00+ecx)], ax\r
-         add     ecx, 2\r
+               mov    eax, edi\r
+               mov    [(0x6c00+ecx)], ax\r
+               add    ecx, 2\r
 \r
-         mov     dword [(0x6c00+ecx)], 0x8E000008\r
-         add     ecx, 4\r
+               mov    dword [(0x6c00+ecx)], 0x8E000008\r
+               add    ecx, 4\r
 \r
-         mov     eax, edi\r
-         shr     eax, 16\r
-         mov     [(0x6c00+ecx)], ax\r
+               mov    eax, edi\r
+               shr    eax, 16\r
+               mov    [(0x6c00+ecx)], ax\r
 \r
-         pop     ecx\r
-         pop     eax\r
-         ret\r
+               pop    ecx\r
+               pop    eax\r
+               ret\r
 \r
 \r
 \r
 ;------------------------------------------------;\r
-;   get int address                             ;\r
-;      in:  cl = int number                     ;\r
-;      out: esi = address or 0 if none present  ;\r
+;   get int address                              ;\r
+;      in:  cl    = int number                   ;\r
+;      out: esi = address or 0 if none present   ;\r
 ;------------------------------------------------;\r
 get_int:\r
-         push    eax\r
+               push   eax\r
 \r
-         mov     eax, 4                              ; 4 bytes for each address\r
-         mul     cl                                  ; cl * al = ax\r
-         mov     esi, idt_list\r
-         add     esi, eax\r
+               mov    eax, 4                                 ; 4 bytes for each address\r
+               mul    cl                                     ; cl * al = ax\r
+               mov    esi, idt_list\r
+               add    esi, eax\r
 \r
-         pop     eax\r
-         ret\r
+               pop    eax\r
+               ret\r
 \r
 \r
 \r
 \r
 ;----------------------------------------;\r
-;   sets ints from list                 ;\r
-;      in:  esi = pointer to int list   ;\r
+;   sets ints from list                  ;\r
+;      in:  esi = pointer to int list    ;\r
 ;----------------------------------------;\r
 set_idt_list:\r
-         push    eax\r
-         push    edi\r
+               push   eax\r
+               push   edi\r
 \r
-         mov     ecx, 0\r
-     .loop:\r
-         lodsd\r
-         or      eax, eax\r
-         jz      .next\r
-         mov     edi, eax\r
-         call    set_int\r
-     .next:\r
-         inc     ecx\r
-         cmp     ecx, 0x100\r
-         jb      .loop\r
+               xor    ecx, ecx\r
+       .l1:\r
+               lodsd\r
+               or     eax, eax\r
+               jz     .next\r
+               mov    edi, eax\r
+               call   set_int\r
+       .next:\r
+               inc    ecx\r
+               cmp    ecx, 0x100\r
+               jb     .l1\r
 \r
-         pop     edi\r
-         pop     eax\r
-         ret\r
+               pop    edi\r
+               pop    eax\r
+               ret\r
 \r
 \r
 \r
 ;------------------------------;\r
 ;   list of idt entries.       ;\r
-;          0 = not handled    ;\r
+;        0 = not handled       ;\r
 ;------------------------------;\r
-idt_list:           dd   isr00\r
-                    dd   isr01\r
-                    dd   isr02\r
-                    dd   isr03\r
-                    dd   isr04\r
-                    dd   isr05\r
-                    dd   isr06\r
-                    dd   isr07\r
-                    dd   isr08\r
-                    dd   isr09\r
-                    dd   isr0A\r
-                    dd   isr0B\r
-                    dd   isr0C\r
-                    dd   isr0D\r
-                    dd   isr0E\r
-                    dd   0\r
-                    dd   isr10\r
-                    dd   isr11\r
-                    dd   isr12\r
-                    dd   isr13\r
-           times 12 dd   0                           ; 12 unused ints\r
-                    dd   isr20\r
-                    dd   isr21\r
-           times 16 dd   0                           ; 16 unused ints\r
-                    dd   isr32                       ; First free and BOS system interrupt.\r
-          times 205 dd   0                           ; 205 unused ints
\ No newline at end of file
+idt_list:   dd   isr00\r
+            dd   isr01\r
+            dd   isr02\r
+            dd   isr03\r
+            dd   isr04\r
+            dd   isr05\r
+            dd   isr06\r
+            dd   isr07\r
+            dd   isr08\r
+            dd   isr09\r
+            dd   isr0A\r
+            dd   isr0B\r
+            dd   isr0C\r
+            dd   isr0D\r
+            dd   isr0E\r
+            dd   0\r
+            dd   isr10\r
+            dd   isr11\r
+            dd   isr12\r
+            dd   isr13\r
+   times 12 dd   0                                    ; 12 unused ints\r
+            dd   isr20\r
+            dd   isr21\r
+   times 16 dd   0                                    ; 16 unused ints\r
+            dd   isr32                                ; First free and BOS system interrupt.\r
+  times 205 dd   0                                    ; 205 unused ints
\ No newline at end of file