]> wirehaze git hosting - BOS.git/commitdiff

wirehaze git hosting

More cleaning. Now runs error-free. IMG added to repo.
authorChristoffer Bubach <christoffer@ridestore.com>
Sun, 11 Jan 2015 21:14:51 +0000 (22:14 +0100)
committerChristoffer Bubach <christoffer@ridestore.com>
Sun, 11 Jan 2015 21:14:51 +0000 (22:14 +0100)
bos.img [new file with mode: 0755]
doc/bochsrc-osx.txt
kernel/fdc/fdc.asm
kernel/init/bios.asm
kernel/init/cmos.asm
kernel/init/init32b.asm
kernel/init/pic.asm
kernel/init/timer.asm
kernel/int/idt.asm
kernel/kernel.sys

diff --git a/bos.img b/bos.img
new file mode 100755 (executable)
index 0000000..113e9fe
Binary files /dev/null and b/bos.img differ
index 32aeabe5f9d4efa29b7baf880c6b2d357c94ae97..9ea686c055f8323d834fbb4e00e63e5464863b74 100644 (file)
@@ -7,7 +7,7 @@
 #display_library: term
 romimage: file=/usr/local/Cellar/bochs/2.6.2/share/bochs/BIOS-bochs-latest
 megs: 32
 #display_library: term
 romimage: file=/usr/local/Cellar/bochs/2.6.2/share/bochs/BIOS-bochs-latest
 megs: 32
-vgaromimage: file=/usr/local/Cellar/bochs/2.6.2/share/bochs/VGABIOS-elpin-2.40
+vgaromimage: file=/usr/local/Cellar/bochs/2.6.2/share/bochs/VGABIOS-lgpl-latest
 floppya: 1_44=../bos.img, status=inserted
 boot: a
 floppy_bootsig_check: disabled=0
 floppya: 1_44=../bos.img, status=inserted
 boot: a
 floppy_bootsig_check: disabled=0
index 5048e4304de43647e54d8037f44c964b0c57f85a..ac3cf0089561a7ee2e89e433e9536608b79549eb 100755 (executable)
@@ -77,21 +77,21 @@ fdc_init:
 ;                                                      ;\r
 ;------------------------------------------------------;\r
 floppy_irq:\r
 ;                                                      ;\r
 ;------------------------------------------------------;\r
 floppy_irq:\r
-               push   ds\r
-               push   eax\r
-               push   ebx\r
+        push   ds\r
+        push   eax\r
+        push   ebx\r
 \r
 \r
-               mov    ax, 0x10\r
-               mov    ds, ax\r
+        mov    ax, 0x10\r
+        mov    ds, ax\r
 \r
 \r
-               mov    [fdd_int_done], 1\r
-               mov    al, 0x20\r
-               out    0x20, al\r
+        mov    [fdd_int_done], 1\r
+        mov    al, 0x20\r
+        out    0x20, al\r
 \r
 \r
-               pop    ebx\r
-               pop    eax\r
-               pop    ds\r
-               iret\r
+        pop    ebx\r
+        pop    eax\r
+        pop    ds\r
+        iret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -128,18 +128,18 @@ wait_int:
 ;                           out:  nothing              ;\r
 ;------------------------------------------------------;\r
 fdd_off:\r
 ;                           out:  nothing              ;\r
 ;------------------------------------------------------;\r
 fdd_off:\r
-               cmp    [fdd_motor_on], 0\r
-               je     .end\r
-               push   eax\r
-               push   edx\r
-\r
-               mov    dx, 0x3F2\r
-               mov    al, 0x0c                               ; motor off\r
-               out    dx, al\r
-               mov    [fdd_motor_on], 0\r
-\r
-               pop    edx\r
-               pop    eax\r
+        cmp    [fdd_motor_on], 0\r
+        je     .end\r
+        push   eax\r
+        push   edx\r
+\r
+        mov    dx, 0x3F2\r
+        mov    al, 0x0c                               ; motor off\r
+        out    dx, al\r
+        mov    [fdd_motor_on], 0\r
+\r
+        pop    edx\r
+        pop    eax\r
     .end:\r
          ret\r
 \r
     .end:\r
          ret\r
 \r
@@ -150,21 +150,21 @@ fdd_off:
 ;                           out: nothing               ;\r
 ;------------------------------------------------------;\r
 fdd_on:\r
 ;                           out: nothing               ;\r
 ;------------------------------------------------------;\r
 fdd_on:\r
-               cmp    [fdd_motor_on], 1\r
-               je     .end\r
-               push   eax\r
-               push   edx\r
+        cmp    [fdd_motor_on], 1\r
+        je     .end\r
+        push   eax\r
+        push   edx\r
 \r
 \r
-               mov    dx, 0x3F2                              ; motor 0 on..\r
-               mov    al, 0x1C\r
-               out    dx, al\r
+        mov    dx, 0x3F2                              ; motor 0 on..\r
+        mov    al, 0x1C\r
+        out    dx, al\r
 \r
 \r
-               mov    ecx, 20                                ; 1/5 of a sec. to speed up\r
-               call   delay                                  ; in timer.inc\r
-               mov    [fdd_motor_on], 1\r
+        mov    ecx, 20                                ; 1/5 of a sec. to speed up\r
+        call   delay                                  ; in timer.inc\r
+        mov    [fdd_motor_on], 1\r
 \r
 \r
-               pop    edx\r
-               pop    eax\r
+        pop    edx\r
+        pop    eax\r
     .end:\r
         ret\r
 \r
     .end:\r
         ret\r
 \r
@@ -176,34 +176,34 @@ fdd_on:
 ;                                in:  al  = data byte  ;\r
 ;------------------------------------------------------;\r
 fdc_sendbyte:\r
 ;                                in:  al  = data byte  ;\r
 ;------------------------------------------------------;\r
 fdc_sendbyte:\r
-               push   edx\r
-               push   ecx\r
-               push   eax\r
+        push   edx\r
+        push   ecx\r
+        push   eax\r
 \r
 \r
-               mov    ecx, 50                             ; 50 = 0.5 seconds.\r
-               call   active_delay                        ; timer.inc\r
+        mov    ecx, 50                             ; 50 = 0.5 seconds.\r
+        call   active_delay                        ; timer.inc\r
     .l1:\r
     .l1:\r
-               cmp    dword [ecx], 0                      ; timeup?\r
-               je     .error\r
-               mov    dx, 0x3f4                           ; check status reg\r
-               in     al, dx\r
-               and    al, 0xC0\r
-               cmp    al, 0x80                            ; ok to write?\r
-               jnz    .l1\r
-\r
-               pop    eax\r
-               pop    ecx\r
-               mov    dx, 0x3F5                           ; send byte\r
-               out    dx, al\r
-               pop    edx\r
-               clc\r
-               ret\r
+        cmp    dword [ecx], 0                      ; timeup?\r
+        je     .error\r
+        mov    dx, 0x3f4                           ; check status reg\r
+        in     al, dx\r
+        and    al, 0xC0\r
+        cmp    al, 0x80                            ; ok to write?\r
+        jnz    .l1\r
+\r
+        pop    eax\r
+        pop    ecx\r
+        mov    dx, 0x3F5                           ; send byte\r
+        out    dx, al\r
+        pop    edx\r
+        clc\r
+        ret\r
     .error:\r
     .error:\r
-               pop    eax\r
-               pop    ecx\r
-               pop    edx\r
-               stc\r
-               ret\r
+        pop    eax\r
+        pop    ecx\r
+        pop    edx\r
+        stc\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -213,34 +213,34 @@ fdc_sendbyte:
 ;                             out: al  = data byte     ;\r
 ;------------------------------------------------------;\r
 fdc_getbyte:\r
 ;                             out: al  = data byte     ;\r
 ;------------------------------------------------------;\r
 fdc_getbyte:\r
-               push   edx\r
-               push   ecx\r
-               push   eax\r
+        push   edx\r
+        push   ecx\r
+        push   eax\r
 \r
 \r
-               mov    ecx, 50                                ; 50 = 0.5 seconds.\r
-               call   active_delay                           ; timer.inc\r
+        mov    ecx, 50                                ; 50 = 0.5 seconds.\r
+        call   active_delay                           ; timer.inc\r
     .l1:\r
     .l1:\r
-               cmp    dword [ecx], 0                         ; timeup?\r
-               je     .error\r
-               mov    dx, 0x3f4                              ; check status reg\r
-               in     al, dx\r
-               and    al, 0xD0\r
-               cmp    al, 0xD0                               ; ok to read?\r
-               jnz    .l1\r
-\r
-               pop    eax\r
-               pop    ecx\r
-               mov    dx, 0x3F5                              ; get the byte\r
-               in     al, dx\r
-               pop    edx\r
-               clc\r
-               ret\r
+        cmp    dword [ecx], 0                         ; timeup?\r
+        je     .error\r
+        mov    dx, 0x3f4                              ; check status reg\r
+        in     al, dx\r
+        and    al, 0xD0\r
+        cmp    al, 0xD0                               ; ok to read?\r
+        jnz    .l1\r
+\r
+        pop    eax\r
+        pop    ecx\r
+        mov    dx, 0x3F5                              ; get the byte\r
+        in     al, dx\r
+        pop    edx\r
+        clc\r
+        ret\r
     .error:\r
     .error:\r
-               pop    eax\r
-               pop    ecx\r
-               pop    edx\r
-               stc\r
-               ret\r
+        pop    eax\r
+        pop    ecx\r
+        pop    edx\r
+        stc\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -249,20 +249,20 @@ fdc_getbyte:
 ;                                                      ;\r
 ;------------------------------------------------------;\r
 sensei:\r
 ;                                                      ;\r
 ;------------------------------------------------------;\r
 sensei:\r
-               push   eax\r
-\r
-               mov    al, 0x08                            ; fdc command\r
-               call   fdc_sendbyte\r
-               call   fdc_getbyte\r
-               mov    ah, al                              ; save ST0 in ah\r
-               call   fdc_getbyte                         ; read PCN\r
-               clc\r
-               test   ah, 0x80                            ; test for error:\r
-               jz     .end                                ; "invalid command"\r
-               stc\r
+        push   eax\r
+\r
+        mov    al, 0x08                               ; fdc command\r
+        call   fdc_sendbyte\r
+        call   fdc_getbyte\r
+        mov    ah, al                                 ; save ST0 in ah\r
+        call   fdc_getbyte                            ; read PCN\r
+        clc\r
+        test   ah, 0x80                               ; test for error:\r
+        jz     .end                                   ; "invalid command"\r
+        stc\r
     .end:\r
     .end:\r
-               pop    eax\r
-               ret\r
+        pop    eax\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -271,57 +271,57 @@ sensei:
 ;                                                      ;\r
 ;------------------------------------------------------;\r
 fdd_reset:\r
 ;                                                      ;\r
 ;------------------------------------------------------;\r
 fdd_reset:\r
-               push   eax\r
-               push   ecx\r
-               push   edx\r
+        push   eax\r
+        push   ecx\r
+        push   edx\r
 \r
 \r
-               mov    byte [fdd_motor_on], 0\r
+        mov    byte [fdd_motor_on], 0\r
 \r
 \r
-               mov    dx, 0x3f2\r
-               mov    al, 8                                  ; off with all motors,\r
-               out    dx, al                                 ; dma,irq etc..\r
+        mov    dx, 0x3f2\r
+        mov    al, 8                                  ; off with all motors,\r
+        out    dx, al                                 ; dma,irq etc..\r
 \r
 \r
-               mov    ecx, 5\r
-               call   delay                                  ; in timer.inc\r
+        mov    ecx, 5\r
+        call   delay                                  ; in timer.inc\r
 \r
 \r
-               mov    dx, 0x3f7\r
-               mov    al, 0\r
-               out    dx, al                                 ; work at 500 kbit/s\r
+        mov    dx, 0x3f7\r
+        mov    al, 0\r
+        out    dx, al                                 ; work at 500 kbit/s\r
 \r
 \r
-               mov    dx, 0x3f2\r
-               mov    al, 0x0c\r
-               out    dx, al                                 ; reenable interrupts\r
+        mov    dx, 0x3f2\r
+        mov    al, 0x0c\r
+        out    dx, al                                 ; reenable interrupts\r
 \r
 \r
-               mov    [fdd_int_done], 0\r
-               call   wait_int                               ; wait for floppy int.\r
-               jc     .error                                 ; timeout?\r
+        mov    [fdd_int_done], 0\r
+        call   wait_int                               ; wait for floppy int.\r
+        jc     .error                                 ; timeout?\r
 \r
 \r
-               mov    cx, 0x04\r
+        mov    cx, 0x04\r
     .status:                                          ; 4 dummy-reads.\r
     .status:                                          ; 4 dummy-reads.\r
-               call   sensei\r
-               loop   .status\r
-\r
-               mov    al, 0x03                               ; specify command\r
-               call   fdc_sendbyte\r
-               mov    al, 0xDF                               ; SRT, HUT\r
-               call   fdc_sendbyte\r
-               mov    al, 0x02                               ; HLT, ND\r
-               call   fdc_sendbyte\r
-\r
-               mov    al, 1\r
-               call   fdd_recal_seek\r
-               jc     .error\r
-               call   fdd_off\r
-               clc\r
-               jmp    .end\r
+        call   sensei\r
+        loop   .status\r
+\r
+        mov    al, 0x03                               ; specify command\r
+        call   fdc_sendbyte\r
+        mov    al, 0xDF                               ; SRT, HUT\r
+        call   fdc_sendbyte\r
+        mov    al, 0x02                               ; HLT, ND\r
+        call   fdc_sendbyte\r
+\r
+        mov    al, 1\r
+        call   fdd_recal_seek\r
+        jc     .error\r
+        call   fdd_off\r
+        clc\r
+        jmp    .end\r
     .error:\r
     .error:\r
-               call   fdd_off\r
-               stc\r
+        call   fdd_off\r
+        stc\r
     .end:\r
     .end:\r
-               pop    edx\r
-               pop    ecx\r
-               pop    eax\r
-               ret\r
+        pop    edx\r
+        pop    ecx\r
+        pop    eax\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -335,38 +335,38 @@ fdd_reset:
 ;                                                      ;\r
 ;------------------------------------------------------;\r
 fdd_recal_seek:\r
 ;                                                      ;\r
 ;------------------------------------------------------;\r
 fdd_recal_seek:\r
-               push   eax\r
-\r
-               call   fdd_on                                 ; turn motor on\r
-               cmp    al, 0\r
-               jne    .recalibrate\r
-               clc\r
-               cmp    bl, [result_C]                         ; are we there yet? :D\r
-               je     .ok\r
-               mov    al, 0x0F                               ; seek command\r
-               call   fdc_sendbyte\r
-               mov    al, bh                                 ; ((head*4)|drive)\r
-               call   fdc_sendbyte\r
-               mov    al, bl                                 ; track\r
-               call   fdc_sendbyte\r
-               mov    [result_C], bl                         ; now on..?\r
-               jmp    .get_int\r
+        push   eax\r
+\r
+        call   fdd_on                                 ; turn motor on\r
+        cmp    al, 0\r
+        jne    .recalibrate\r
+        clc\r
+        cmp    bl, [result_C]                         ; are we there yet? :D\r
+        je     .ok\r
+        mov    al, 0x0F                               ; seek command\r
+        call   fdc_sendbyte\r
+        mov    al, bh                                 ; ((head*4)|drive)\r
+        call   fdc_sendbyte\r
+        mov    al, bl                                 ; track\r
+        call   fdc_sendbyte\r
+        mov    [result_C], bl                         ; now on..?\r
+        jmp    .get_int\r
     .recalibrate:\r
     .recalibrate:\r
-               mov    al, 0x07                               ; recalibrate command\r
-               call   fdc_sendbyte\r
-               mov    al, 0                                  ; drive number\r
-               call   fdc_sendbyte\r
-               mov    [result_C], 0                          ; now on track 0\r
+        mov    al, 0x07                               ; recalibrate command\r
+        call   fdc_sendbyte\r
+        mov    al, 0                                  ; drive number\r
+        call   fdc_sendbyte\r
+        mov    [result_C], 0                          ; now on track 0\r
     .get_int:\r
     .get_int:\r
-               mov    [fdd_int_done], 0\r
-               call   wait_int\r
-               jc     .error\r
+        mov    [fdd_int_done], 0\r
+        call   wait_int\r
+        jc     .error\r
 \r
 \r
-               call   sensei                                 ; sense interrupt status\r
-               jc     .error\r
+        call   sensei                                 ; sense interrupt status\r
+        jc     .error\r
      .ok:\r
      .ok:\r
-               clc\r
-               jmp    .end\r
+        clc\r
+        jmp    .end\r
     .error:\r
         stc\r
     .end:\r
     .error:\r
         stc\r
     .end:\r
@@ -387,136 +387,136 @@ fdd_recal_seek:
 ;           cf  = 0 if ok, 1 if error                  ;\r
 ;------------------------------------------------------;\r
 fdd_read_write:\r
 ;           cf  = 0 if ok, 1 if error                  ;\r
 ;------------------------------------------------------;\r
 fdd_read_write:\r
-               pushad\r
-\r
-               and    dh, 1                                  ; head 0 or 1?\r
-               mov    [fdd_head], dh                         ; store it.\r
-               shl    dh, 2\r
-               or     dh, 0                                  ; drive 0, fd0\r
-               mov    [fdd_drivehead], dh                    ; dh = ((head*4)|drive)\r
-               mov    [fdd_errorcode], 0x04                  ; basic error code\r
-               cmp    ch, 0x51                               ; check for allowed\r
-               jae    .error                                 ; track number.\r
-               mov    [fdd_track], ch\r
-               cmp    cl, 0x13                               ; check for allowed\r
-               jae    .error                                 ; sector number.\r
-               mov    [fdd_sector], cl\r
-\r
-               cmp    [fdd_error], 1\r
-               jne    .no_previous_error\r
-               mov    al, 1\r
-               call   fdd_recal_seek\r
+        pushad\r
+\r
+        and    dh, 1                                  ; head 0 or 1?\r
+        mov    [fdd_head], dh                         ; store it.\r
+        shl    dh, 2\r
+        or     dh, 0                                  ; drive 0, fd0\r
+        mov    [fdd_drivehead], dh                    ; dh = ((head*4)|drive)\r
+        mov    [fdd_errorcode], 0x04                  ; basic error code\r
+        cmp    ch, 0x51                               ; check for allowed\r
+        jae    .error                                 ; track number.\r
+        mov    [fdd_track], ch\r
+        cmp    cl, 0x13                               ; check for allowed\r
+        jae    .error                                 ; sector number.\r
+        mov    [fdd_sector], cl\r
+\r
+        cmp    [fdd_error], 1\r
+        jne    .no_previous_error\r
+        mov    al, 1\r
+        call   fdd_recal_seek\r
     .no_previous_error:\r
     .no_previous_error:\r
-               call   fdd_on\r
+        call   fdd_on\r
 \r
 \r
-               mov    dx, 0x3F7\r
-               mov    al, 0                                  ; 500Kb/sec mode\r
-               out    dx, al\r
-               mov    [fdd_errorcode], 0x80                  ; error code\r
+        mov    dx, 0x3F7\r
+        mov    al, 0                                  ; 500Kb/sec mode\r
+        out    dx, al\r
+        mov    [fdd_errorcode], 0x80                  ; error code\r
 \r
 \r
-               xor    ecx, ecx\r
-               mov    cx, 3                                  ; try seek 3 times\r
+        xor    ecx, ecx\r
+        mov    cx, 3                                  ; try seek 3 times\r
     .l2:\r
     .l2:\r
-               mov    al, 0\r
-               push   ebx\r
-               mov    bl, [fdd_track]\r
-               mov    bh, [fdd_drivehead]                    ; ((head*4)|drive)\r
-               call   fdd_recal_seek\r
-               pop    ebx\r
-               jnc    .l3                                    ; ok, continue.\r
-               loop   .l2\r
-               jmp    .error                                 ; timeout.\r
+        mov    al, 0\r
+        push   ebx\r
+        mov    bl, [fdd_track]\r
+        mov    bh, [fdd_drivehead]                    ; ((head*4)|drive)\r
+        call   fdd_recal_seek\r
+        pop    ebx\r
+        jnc    .l3                                    ; ok, continue.\r
+        loop   .l2\r
+        jmp    .error                                 ; timeout.\r
     .l3:\r
     .l3:\r
-               push   ebx\r
-               cmp    bl, 0\r
-               je     .read_fdd\r
+        push   ebx\r
+        cmp    bl, 0\r
+        je     .read_fdd\r
 \r
     .write_fdd:\r
 \r
     .write_fdd:\r
-               push   edi\r
-               mov    esi, edi\r
-               mov    edi, 0x80000                           ; copy the stuff we will\r
-               mov    ecx, 128                               ; write to the DMA buffer\r
-               rep    movsd                                  ; 128*4=512\r
-               pop    edi\r
-\r
-               mov    bl, 2                                  ; channel 2\r
-               mov    esi, 512                               ; bytes to write\r
-               mov    ecx, 0x80000                           ; page & offset\r
-               mov    bh, 1                                  ; write floppy, read DMA\r
-               call   dma_transfer\r
-\r
-               mov    al, 0xC5                               ; write sector command\r
-               call   fdc_sendbyte\r
-               jmp    .cont\r
+        push   edi\r
+        mov    esi, edi\r
+        mov    edi, 0x80000                           ; copy the stuff we will\r
+        mov    ecx, 128                               ; write to the DMA buffer\r
+        rep    movsd                                  ; 128*4=512\r
+        pop    edi\r
+\r
+        mov    bl, 2                                  ; channel 2\r
+        mov    esi, 512                               ; bytes to write\r
+        mov    ecx, 0x80000                           ; page & offset\r
+        mov    bh, 1                                  ; write floppy, read DMA\r
+        call   dma_transfer\r
+\r
+        mov    al, 0xC5                               ; write sector command\r
+        call   fdc_sendbyte\r
+        jmp    .cont\r
 \r
     .read_fdd:\r
 \r
     .read_fdd:\r
-               mov    bl, 2                                  ; channel 2\r
-               mov    esi, 512                               ; bytes to read\r
-               mov    ecx, 0x80000                           ; page & offset\r
-               mov    bh, 0                                  ; read floppy, write DMA\r
-               call   dma_transfer\r
+        mov    bl, 2                                  ; channel 2\r
+        mov    esi, 512                               ; bytes to read\r
+        mov    ecx, 0x80000                           ; page & offset\r
+        mov    bh, 0                                  ; read floppy, write DMA\r
+        call   dma_transfer\r
 \r
 \r
-               mov    al, 0xE6                               ; read sector command\r
-               call   fdc_sendbyte\r
+        mov    al, 0xE6                               ; read sector command\r
+        call   fdc_sendbyte\r
 \r
     .cont:\r
 \r
     .cont:\r
-               pop    ebx\r
-               mov    al, [fdd_drivehead]                    ; ((head*4)|drive)\r
-               call   fdc_sendbyte\r
-               mov    al, [fdd_track]                        ; track/cylinder\r
-               call   fdc_sendbyte\r
-\r
-               mov    al, [fdd_head]                         ; head/side 0 or 1\r
-               call   fdc_sendbyte\r
-               mov    al, [fdd_sector]                       ; sector number\r
-               call   fdc_sendbyte\r
-               mov    al, 0x02                               ; sector size, 512 bytes\r
-               call   fdc_sendbyte\r
-\r
-               mov    al, 0x12                               ; sectors to a track\r
-               call   fdc_sendbyte\r
-               mov    al, 0x1B                               ; gap length\r
-               call   fdc_sendbyte\r
-               mov    al, 0xFF                               ; data length\r
-               call   fdc_sendbyte\r
-\r
-               mov    [fdd_int_done], 0\r
-               call   wait_int\r
-               jc     .error\r
-\r
-               call   fdc_getbyte\r
-               mov    [result_ST0], al                       ; ST0\r
-               call   fdc_getbyte\r
-               mov    [result_ST1], al                       ; ST1\r
-               call   fdc_getbyte\r
-               mov    [result_ST2], al                       ; ST2\r
-               call   fdc_getbyte\r
-               mov    [result_C], al                         ; cylinder\r
-               call   fdc_getbyte\r
-               mov    [result_H], al                         ; head\r
-               call   fdc_getbyte\r
-               mov    [result_R], al                         ; sector number.\r
-               call   fdc_getbyte\r
-               mov    [result_N], al                         ; sector size\r
-\r
-               test   [result_ST0], 0xc0                     ; test if sr0 is 0xC0\r
-               jnz    .error\r
-               cmp    bl, 1                                  ; did we write the disk?\r
-               je     .ok\r
-\r
-               mov    ecx, 512                               ; sector size in bytes\r
-               mov    esi, 0x80000                           ; copy to dest. in edi\r
-               rep    movsb\r
+        pop    ebx\r
+        mov    al, [fdd_drivehead]                    ; ((head*4)|drive)\r
+        call   fdc_sendbyte\r
+        mov    al, [fdd_track]                        ; track/cylinder\r
+        call   fdc_sendbyte\r
+\r
+        mov    al, [fdd_head]                         ; head/side 0 or 1\r
+        call   fdc_sendbyte\r
+        mov    al, [fdd_sector]                       ; sector number\r
+        call   fdc_sendbyte\r
+        mov    al, 0x02                               ; sector size, 512 bytes\r
+        call   fdc_sendbyte\r
+\r
+        mov    al, 0x12                               ; sectors to a track\r
+        call   fdc_sendbyte\r
+        mov    al, 0x1B                               ; gap length\r
+        call   fdc_sendbyte\r
+        mov    al, 0xFF                               ; data length\r
+        call   fdc_sendbyte\r
+\r
+        mov    [fdd_int_done], 0\r
+        call   wait_int\r
+        jc     .error\r
+\r
+        call   fdc_getbyte\r
+        mov    [result_ST0], al                       ; ST0\r
+        call   fdc_getbyte\r
+        mov    [result_ST1], al                       ; ST1\r
+        call   fdc_getbyte\r
+        mov    [result_ST2], al                       ; ST2\r
+        call   fdc_getbyte\r
+        mov    [result_C], al                         ; cylinder\r
+        call   fdc_getbyte\r
+        mov    [result_H], al                         ; head\r
+        call   fdc_getbyte\r
+        mov    [result_R], al                         ; sector number.\r
+        call   fdc_getbyte\r
+        mov    [result_N], al                         ; sector size\r
+\r
+        test   [result_ST0], 0xc0                     ; test if sr0 is 0xC0\r
+        jnz    .error\r
+        cmp    bl, 1                                  ; did we write the disk?\r
+        je     .ok\r
+\r
+        mov    ecx, 512                               ; sector size in bytes\r
+        mov    esi, 0x80000                           ; copy to dest. in edi\r
+        rep    movsb\r
     .ok:\r
     .ok:\r
-               mov    [fdd_errorcode], 0                     ; no error.. :D\r
-               mov    [fdd_error], 0                         ; no recal. next time\r
-               clc\r
-               jmp    .end\r
+        mov    [fdd_errorcode], 0                     ; no error.. :D\r
+        mov    [fdd_error], 0                         ; no recal. next time\r
+        clc\r
+        jmp    .end\r
     .error:\r
     .error:\r
-               mov    [fdd_error], 1                         ; recalibrate next time\r
-               stc\r
+        mov    [fdd_error], 1                         ; recalibrate next time\r
+        stc\r
     .end:\r
     .end:\r
-               call   fdd_off                                ; floppy motor off\r
-               popad\r
-               mov    al, [fdd_errorcode]                    ; error status\r
-               ret
\ No newline at end of file
+        call   fdd_off                                ; floppy motor off\r
+        popad\r
+        mov    al, [fdd_errorcode]                    ; error status\r
+        ret
\ No newline at end of file
index ed5716d9a04144a6699f04384afb9d315fee5019..8ecad9fea01995d2ed90aa6209b1c6342663b22b 100755 (executable)
 \r
 \r
 rmode_int:\r
 \r
 \r
 rmode_int:\r
-         pushad\r
-         push    eax\r
-         shr     eax, 16                             ; move high bits to ax\r
-         mov     word [realmode_ax], ax              ; save new ax value\r
-         pop     eax                                 ; restore\r
-\r
-         push    ebx\r
-         shr     ebx, 16                             ; move high bits to bx\r
-         mov     byte [int_number], bl               ; save int number to call\r
-         pop     ebx\r
-\r
-         mov     byte [realmode_error], 0            ; all variables is in the\r
-         mov     word [realmode_bx], bx              ; realmode/variables.inc file\r
-         mov     word [realmode_cx], cx\r
-         mov     word [realmode_dx], dx\r
-         call    disable_irqs\r
-         jmp     pword 0x18:do_16pmode       ; must substract 0x10000 from\r
-                                                     ; data addresses becasue of\r
-                                                     ; fasm strict "org" behavior\r
+        pushad\r
+        push   eax\r
+        shr    eax, 16                                ; move high bits to ax\r
+        mov    word [realmode_ax], ax                 ; save new ax value\r
+        pop    eax                                    ; restore\r
+\r
+        push   ebx\r
+        shr    ebx, 16                                ; move high bits to bx\r
+        mov    byte [int_number], bl                  ; save int number to call\r
+        pop    ebx\r
+\r
+        mov    byte [realmode_error], 0               ; all variables is in the\r
+        mov    word [realmode_bx], bx                 ; realmode/variables.inc file\r
+        mov    word [realmode_cx], cx\r
+        mov    word [realmode_dx], dx\r
+        call   disable_irqs\r
+        jmp    pword 0x18:do_16pmode                  ; begin our dark journey into 16bit-land\r
+\r
 use16\r
 do_16pmode:\r
 use16\r
 do_16pmode:\r
-         mov     ax, 0x20\r
-         mov     ds, ax\r
-         mov     es, ax\r
-         mov     fs, ax\r
-         mov     gs, ax\r
-         mov     ss, ax\r
+        mov    ax, 0x20\r
+        mov    ds, ax\r
+        mov    es, ax\r
+        mov    fs, ax\r
+        mov    gs, ax\r
+        mov    ss, ax\r
 \r
 \r
-         cli\r
-         mov     eax, cr0\r
-         and     al, 0xFE\r
-         mov     cr0, eax\r
+        cli\r
+        mov    eax, cr0\r
+        and    al, 0xFE\r
+        mov    cr0, eax\r
 \r
 \r
-         jmp     0x1000:(do_realm)\r
+        jmp    0x0000:(do_realm)                      ; this should be triple checked!\r
 \r
 do_realm:\r
 \r
 do_realm:\r
-         mov     ax, cs\r
-         mov     ds, ax\r
+        mov    ax, cs\r
+        mov    ds, ax\r
 \r
 \r
-         xor     ax, ax\r
-         mov     es, ax\r
-         mov     fs, ax\r
-         mov     gs, ax\r
-         mov     ss, ax\r
+        xor    ax, ax\r
+        mov    es, ax\r
+        mov    fs, ax\r
+        mov    gs, ax\r
+        mov    ss, ax\r
 \r
 \r
-         lidt    [ridtr]                     ; realmode/variables.inc\r
-         sti\r
+        lidt   [ridtr]                                ; realmode/variables.inc\r
+        sti\r
 \r
 \r
-         mov     ax, word [realmode_ax]\r
-         mov     bx, word [realmode_bx]\r
-         mov     cx, word [realmode_cx]\r
-         mov     dx, word [realmode_dx]\r
+        mov    ax, word [realmode_ax]\r
+        mov    bx, word [realmode_bx]\r
+        mov    cx, word [realmode_cx]\r
+        mov    dx, word [realmode_dx]\r
 \r
 \r
-         push    ax                                  ; this is some cool shit.. ;)\r
-         mov     al, [int_number]            ; interrupt to preform\r
-         mov     [$+5], al                   ; move it to right pos.\r
-         pop     ax\r
-         db      0xCD                                ; opcode for int.\r
-         db      0x00                                ; move int_number here\r
+        push   ax                                     ; this is some cool shit.. ;)\r
+        mov    al, [int_number]                       ; interrupt to preform\r
+        mov    [$+5], al                              ; move it to right pos.\r
+        pop    ax\r
+        db     0xCD                                   ; opcode for int.\r
+        db     0x00                                   ; move int_number here\r
 \r
 \r
-         jnc     .no_error\r
-         mov     byte [realmode_error], 1\r
+        jnc    .no_error\r
+        mov    byte [realmode_error], 1\r
 \r
 \r
-     .no_error:\r
-         mov     word [realmode_ax], ax\r
-         mov     word [realmode_bx], bx\r
-         mov     word [realmode_cx], cx\r
-         mov     word [realmode_dx], dx\r
+    .no_error:\r
+        mov    word [realmode_ax], ax\r
+        mov    word [realmode_bx], bx\r
+        mov    word [realmode_cx], cx\r
+        mov    word [realmode_dx], dx\r
 \r
 \r
-         cli\r
+        cli\r
 \r
 \r
-         lgdt    [gdtr]\r
-         lidt    [idtr]\r
-         mov     eax, cr0\r
-         or      al, 1\r
-         mov     cr0, eax\r
+        lgdt   [gdtr]\r
+        lidt   [idtr]\r
+        mov    eax, cr0\r
+        or     al, 1\r
+        mov    cr0, eax\r
 \r
 \r
-         jmp     pword 0x08:gobackto_pm\r
+        jmp    pword 0x08:gobackto_pm\r
 \r
 \r
 use32\r
 gobackto_pm:\r
 \r
 \r
 use32\r
 gobackto_pm:\r
-         mov     ax, 0x10                            ; refresh all segment registers\r
-         mov     ds, ax\r
-         mov     es, ax\r
-         mov     fs, ax\r
-         mov     gs, ax\r
-         mov     ss, ax\r
-         call    enable_irqs\r
-         sti\r
-         popad\r
-         clc                                         ; clear carry.\r
-         cmp     [realmode_error], 1                 ; if error, then\r
-         jne     .end\r
-         stc                                         ; set carry.\r
-     .end:\r
-         ret
\ No newline at end of file
+        mov    ax, 0x10                               ; refresh all segment registers\r
+        mov    ds, ax\r
+        mov    es, ax\r
+        mov    fs, ax\r
+        mov    gs, ax\r
+        mov    ss, ax\r
+        call   enable_irqs\r
+        sti\r
+        popad\r
+        clc                                           ; clear carry.\r
+        cmp    [realmode_error], 1                    ; if error, then\r
+        jne    .end\r
+        stc                                           ; set carry.\r
+    .end:\r
+        ret
\ No newline at end of file
index 032a95ca5ab3b508783095b8e5e8c194dbcc22cd..b047c86868640ea6f620e804128ae4869fc2ff46 100755 (executable)
 ;-----------------------------------;\r
 ;  variables containing CMOS data   ;\r
 ;-----------------------------------;\r
 ;-----------------------------------;\r
 ;  variables containing CMOS data   ;\r
 ;-----------------------------------;\r
-         century         db   0                      ; latest century,\r
-         year            db   0                      ; year,\r
-         month           db   0                      ; month,\r
-         day             db   0                      ; day (1 = sunday),\r
-         hour            db   0                      ; hour,\r
-         minute          db   0                      ; minute and\r
-         second          db   0                      ; second read in from CMOS.\r
+    century   db   0                                  ; latest century,\r
+    year      db   0                                  ; year,\r
+    month     db   0                                  ; month,\r
+    day       db   0                                  ; day (1 = sunday),\r
+    hour      db   0                                  ; hour,\r
+    minute    db   0                                  ; minute and\r
+    second    db   0                                  ; second read in from CMOS.\r
 \r
 \r
 ;-------------------------;\r
 ;  save info from CMOS    ;\r
 ;-------------------------;\r
 get_cmos_data:\r
 \r
 \r
 ;-------------------------;\r
 ;  save info from CMOS    ;\r
 ;-------------------------;\r
 get_cmos_data:\r
-         push    ax\r
+        push   ax\r
 \r
 \r
-         mov     al, 0x00                            ; get the "second" byte\r
-         out     0x70, al\r
-         in      al, 0x71\r
-         mov     [second], al                        ; save it.\r
+        mov    al, 0x00                               ; get the "second" byte\r
+        out    0x70, al\r
+        in     al, 0x71\r
+        mov    [second], al                           ; save it.\r
 \r
 \r
-         mov     al, 0x02                            ; get the "minute" byte\r
-         out     0x70, al\r
-         in      al, 0x71\r
-         mov     [minute], al\r
+        mov    al, 0x02                               ; get the "minute" byte\r
+        out    0x70, al\r
+        in     al, 0x71\r
+        mov    [minute], al\r
 \r
 \r
-         mov     al, 0x04                            ; get the "hour" byte\r
-         out     0x70, al\r
-         in      al, 0x71\r
-         mov     [hour], al\r
+        mov    al, 0x04                               ; get the "hour" byte\r
+        out    0x70, al\r
+        in     al, 0x71\r
+        mov    [hour], al\r
 \r
 \r
-         mov     al, 0x07                            ; get the "day" byte\r
-         out     0x70, al\r
-         in      al, 0x71\r
-         mov     [day], al\r
+        mov    al, 0x07                               ; get the "day" byte\r
+        out    0x70, al\r
+        in     al, 0x71\r
+        mov    [day], al\r
 \r
 \r
-         mov     al, 0x08                            ; get the "month" byte\r
-         out     0x70, al\r
-         in      al, 0x71\r
-         mov     [month], al\r
+        mov    al, 0x08                               ; get the "month" byte\r
+        out    0x70, al\r
+        in     al, 0x71\r
+        mov    [month], al\r
 \r
 \r
-         mov     al, 0x09                            ; get the "year" byte\r
-         out     0x70, al\r
-         in      al, 0x71\r
-         mov     [year], al\r
+        mov    al, 0x09                               ; get the "year" byte\r
+        out    0x70, al\r
+        in     al, 0x71\r
+        mov    [year], al\r
 \r
 \r
-         mov     al, 0x32                            ; get the "century" byte\r
-         out     0x70, al\r
-         in      al, 0x71\r
-         mov     [century], al\r
+        mov    al, 0x32                               ; get the "century" byte\r
+        out    0x70, al\r
+        in     al, 0x71\r
+        mov    [century], al\r
 \r
 \r
-         pop     ax\r
-         ret\r
+        pop    ax\r
+        ret\r
 \r
 ;------------------------------------------------;\r
 ;   calculate binary from BCD                    ;\r
 \r
 ;------------------------------------------------;\r
 ;   calculate binary from BCD                    ;\r
@@ -69,15 +69,15 @@ get_cmos_data:
 ;                              out: al = bin     ;\r
 ;------------------------------------------------;\r
 BCD2bin:\r
 ;                              out: al = bin     ;\r
 ;------------------------------------------------;\r
 BCD2bin:\r
-         push    ebx\r
-         mov     bl, al                              ; bl = al mod 16\r
-         and     bl, 0x0F\r
-         shr     al, 4                               ; al = al / 16\r
-         mov     bh, 10\r
-         mul     bh                                  ; multiply by 10\r
-         add     al, bl                              ; add in low nib\r
-         pop     ebx\r
-         ret\r
+        push   ebx\r
+        mov    bl, al                                 ; bl = al mod 16\r
+        and    bl, 0x0F\r
+        shr    al, 4                                  ; al = al / 16\r
+        mov    bh, 10\r
+        mul    bh                                     ; multiply by 10\r
+        add    al, bl                                 ; add in low nib\r
+        pop    ebx\r
+        ret\r
 \r
 \r
 ;------------------------------------------------;\r
 \r
 \r
 ;------------------------------------------------;\r
@@ -86,11 +86,11 @@ BCD2bin:
 ;                              out: ax = ASCII   ;\r
 ;------------------------------------------------;\r
 BCD2ascii:\r
 ;                              out: ax = ASCII   ;\r
 ;------------------------------------------------;\r
 BCD2ascii:\r
-         push    ecx\r
-         mov     ah, al\r
-         and     ax, 0xF00F                          ; mask bits\r
-         shr     ah, 4                               ; right shift ah to get unpacked BCD\r
-         or      ax, 0x3030                          ; combine with 30 to get ASCII\r
-         xchg    ah, al                              ; swap for ASCII storage convention\r
-         pop     ecx\r
-         ret
\ No newline at end of file
+      push   ecx\r
+      mov    ah, al\r
+      and    ax, 0xF00F                               ; mask bits\r
+      shr    ah, 4                                    ; right shift ah to get unpacked BCD\r
+      or     ax, 0x3030                               ; combine with 30 to get ASCII\r
+      xchg   ah, al                                   ; swap for ASCII storage convention\r
+      pop    ecx\r
+      ret
\ No newline at end of file
index 01bb35805d8c7cf9c3d92582db931888f21e732b..3d2319ea6dade2eadf676741a9bb70787bf20ffa 100755 (executable)
@@ -62,7 +62,7 @@ bos_init:
     ;--------------;\r
     ;  setup IDT   ;\r
     ;--------------;\r
     ;--------------;\r
     ;  setup IDT   ;\r
     ;--------------;\r
-        mov    edi, u_isr                             ; isr.inc\r
+        mov    esi, u_isr                             ; isr.inc\r
         call   init_idt                               ; idt.inc\r
         mov    esi, idt_list                          ; idt.inc\r
         call   set_idt_list                           ; idt.inc\r
         call   init_idt                               ; idt.inc\r
         mov    esi, idt_list                          ; idt.inc\r
         call   set_idt_list                           ; idt.inc\r
index 6076213625e52bb27557fa2e70b3fdf07ddbadbc..9e6bb61baf1e88ea669690a36187bf3eeab312a5 100755 (executable)
 \r
 \r
 ;-------------------------------------------;\r
 \r
 \r
 ;-------------------------------------------;\r
-;  remap PICs to:  cl = pic1  ch = pic2     ;\r
+;  remap PICs                               ;\r
+;                in:  cl = pic1             ;\r
+;                     ch = pic2             ;\r
 ;-------------------------------------------;\r
 remap_pics:\r
 ;-------------------------------------------;\r
 remap_pics:\r
-         push    ax\r
-         push    dx\r
+        push   ax\r
+        push   dx\r
 \r
 \r
-         mov     al, 0x11                            ; IWC1\r
-         out     0x20, al\r
-         out     0xA0, al\r
+        mov    al, 0x11                               ; IWC1\r
+        out    0x20, al\r
+        out    0xA0, al\r
 \r
 \r
-         mov     al, cl                              ; IWC2\r
-         out     0x21, al\r
-         mov     al, ch\r
-         out     0xA1, al\r
+        mov    al, cl                                 ; IWC2\r
+        out    0x21, al\r
+        mov    al, ch\r
+        out    0xA1, al\r
 \r
 \r
-         mov     al, 0x04                            ; IWC3\r
-         out     0x21, al\r
-         mov     al, 0x02\r
-         out     0xA1, al\r
+        mov    al, 0x04                               ; IWC3\r
+        out    0x21, al\r
+        mov    al, 0x02\r
+        out    0xA1, al\r
 \r
 \r
-         mov     al, 0x01                            ; IWC4\r
-         out     0x21, al\r
-         out     0xA1, al\r
+        mov    al, 0x01                               ; IWC4\r
+        out    0x21, al\r
+        out    0xA1, al\r
 \r
 \r
-         pop     dx\r
-         pop     ax\r
-         ret\r
+        pop    dx\r
+        pop    ax\r
+        ret\r
 \r
 \r
 ;----------------------;\r
 ;  disable all IRQs.   ;\r
 ;----------------------;\r
 disable_irqs:\r
 \r
 \r
 ;----------------------;\r
 ;  disable all IRQs.   ;\r
 ;----------------------;\r
 disable_irqs:\r
-         push    ax\r
+        push   ax\r
 \r
 \r
-         mov     al, 0xFF\r
-         out     0x21, al\r
-         out     0xA1, al\r
+        mov    al, 0xFF\r
+        out    0x21, al\r
+        out    0xA1, al\r
 \r
 \r
-         pop     ax\r
-         ret\r
+        pop    ax\r
+        ret\r
 \r
 \r
 ;---------------------;\r
 ;  enable all IRQs.   ;\r
 ;---------------------;\r
 enable_irqs:\r
 \r
 \r
 ;---------------------;\r
 ;  enable all IRQs.   ;\r
 ;---------------------;\r
 enable_irqs:\r
-         push    ax\r
+        push   ax\r
 \r
 \r
-         mov     al, 0x00\r
-         out     0x21, al\r
-         out     0xA1, al\r
+        mov    al, 0x00\r
+        out    0x21, al\r
+        out    0xA1, al\r
 \r
 \r
-         pop     ax\r
-         ret\r
+        pop    ax\r
+        ret\r
 \r
 \r
 ;-----------------------------;\r
 ;  enable an IRQ.  cl = irq   ;\r
 ;-----------------------------;\r
 enable_irq:\r
 \r
 \r
 ;-----------------------------;\r
 ;  enable an IRQ.  cl = irq   ;\r
 ;-----------------------------;\r
 enable_irq:\r
-         push    ax\r
-         push    cx\r
+        push   ax\r
+        push   cx\r
 \r
 \r
-         cmp     cl, 8\r
-         jb      .master\r
+        cmp    cl, 8\r
+        jb     .master\r
 \r
 \r
-         sub     cl, 8\r
-         mov     ah, 1\r
-         shl     ah, cl\r
-         xor     ah, 0xFF\r
+        sub    cl, 8\r
+        mov    ah, 1\r
+        shl    ah, cl\r
+        xor    ah, 0xFF\r
 \r
 \r
-         in      al, 0xA1\r
-         and     al, ah\r
-         out     0xA1, al\r
+        in     al, 0xA1\r
+        and    al, ah\r
+        out    0xA1, al\r
 \r
 \r
-         pop     cx\r
-         pop     ax\r
-         ret\r
-  .master:\r
-         mov     ah, 1\r
-         shl     ah, cl\r
-         xor     ah, 0xFF\r
+        pop    cx\r
+        pop    ax\r
+        ret\r
+    .master:\r
+        mov    ah, 1\r
+        shl    ah, cl\r
+        xor    ah, 0xFF\r
 \r
 \r
-         in      al, 0x21\r
-         and     al, ah\r
-         out     0x21, al\r
+        in     al, 0x21\r
+        and    al, ah\r
+        out    0x21, al\r
 \r
 \r
-         pop     cx\r
-         pop     ax\r
-         ret\r
+        pop    cx\r
+        pop    ax\r
+        ret\r
 \r
 \r
 ;------------------------------;\r
 \r
 \r
 ;------------------------------;\r
-;  disable an IRQ.  cl = irq   ;\r
+;  disable an IRQ.             ;\r
+;                in: cl = irq  ;\r
 ;------------------------------;\r
 disable_irq:\r
 ;------------------------------;\r
 disable_irq:\r
-         push    ax\r
-         push    cx\r
-\r
-         cmp     cl, 8\r
-         jb      .master\r
-\r
-         sub     cl, 8\r
-         mov     ah, 1\r
-         shl     ah, cl\r
-\r
-         in      al, 0xA1\r
-         or      al, ah\r
-         out     0xA1, al\r
-\r
-         pop     cx\r
-         pop     ax\r
-         ret\r
-  .master:\r
-         mov     ah, 1\r
-         shl     ah, cl\r
-\r
-         in      al, 0x21\r
-         or      al, ah\r
-         out     0x21, al\r
-\r
-         pop     cx\r
-         pop     ax\r
-         ret
\ No newline at end of file
+        push   ax\r
+        push   cx\r
+\r
+        cmp    cl, 8\r
+        jb     .master\r
+\r
+        sub    cl, 8\r
+        mov    ah, 1\r
+        shl    ah, cl\r
+\r
+        in     al, 0xA1\r
+        or     al, ah\r
+        out    0xA1, al\r
+\r
+        pop    cx\r
+        pop    ax\r
+        ret\r
+    .master:\r
+        mov    ah, 1\r
+        shl    ah, cl\r
+\r
+        in     al, 0x21\r
+        or     al, ah\r
+        out    0x21, al\r
+\r
+        pop    cx\r
+        pop    ax\r
+        ret
\ No newline at end of file
index 29088eb4e685f4f9975d813ce147243d7f3cb230..aa2a335a87ed8ba13198c594c26afaf463b88bc9 100755 (executable)
@@ -9,47 +9,47 @@
 ;-----------------;\r
 ;   variables     ;\r
 ;-----------------;\r
 ;-----------------;\r
 ;   variables     ;\r
 ;-----------------;\r
-         timer_wait      dd   0                      ; time to wait\r
-         timer_counter   dd   0, 0                   ; time since BOS started\r
-         call_list       dd   0, 0, 0, 0, 0          ; functions to call\r
+    timer_wait      dd   0                            ; time to wait\r
+    timer_counter   dd   0, 0                         ; time since BOS started\r
+    call_list       dd   0, 0, 0, 0, 0                ; functions to call\r
 \r
 \r
 ;---------------------------;\r
 ;      Timer IRQ(0)         ;\r
 ;---------------------------;\r
 timer:\r
 \r
 \r
 ;---------------------------;\r
 ;      Timer IRQ(0)         ;\r
 ;---------------------------;\r
 timer:\r
-         add     dword [timer_counter], 1            ; it's just a 64-bit\r
-         adc     dword [timer_counter+4], 0          ; counter since boot.\r
-\r
-         cmp     [timer_wait], 0                     ; "delay" countdown.\r
-         je      .test1\r
-         dec     [timer_wait]\r
-\r
-     .test1:                                         ; checks for calls to\r
-         cmp     [call_list], dword 0                ; do before we quit.\r
-         je      .test2\r
-         call    dword [call_list]\r
-     .test2:\r
-         cmp     [call_list+4], dword 0\r
-         je      .test3\r
-         call    dword [call_list+4]\r
-     .test3:\r
-         cmp     [call_list+8], dword 0\r
-         je      .test4\r
-         call    dword [call_list+8]\r
-     .test4:\r
-         cmp     [call_list+12], dword 0\r
-         je      .test5\r
-         call    dword [call_list+12]\r
-     .test5:\r
-         cmp     [call_list+16], dword 0\r
-         je      .end\r
-         call    dword [call_list+16]\r
-\r
-     .end:\r
-         mov     al, 0x20\r
-         out     0x20, al\r
-         ret\r
+        add    dword [timer_counter], 1               ; it's just a 64-bit\r
+        adc    dword [timer_counter+4], 0             ; counter since boot.\r
+\r
+        cmp    [timer_wait], 0                        ; "delay" countdown.\r
+        je     .test1\r
+        dec    [timer_wait]\r
+\r
+    .test1:                                           ; checks for calls to\r
+        cmp    [call_list], dword 0                   ; do before we quit.\r
+        je     .test2\r
+        call   dword [call_list]\r
+    .test2:\r
+        cmp    [call_list+4], dword 0\r
+        je     .test3\r
+        call   dword [call_list+4]\r
+    .test3:\r
+        cmp    [call_list+8], dword 0\r
+        je     .test4\r
+        call   dword [call_list+8]\r
+    .test4:\r
+        cmp    [call_list+12], dword 0\r
+        je     .test5\r
+        call   dword [call_list+12]\r
+    .test5:\r
+        cmp    [call_list+16], dword 0\r
+        je     .end\r
+        call   dword [call_list+16]\r
+\r
+    .end:\r
+        mov    al, 0x20\r
+        out    0x20, al\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -59,35 +59,35 @@ timer:
 ;                  out: eax = 0 if OK            ;\r
 ;------------------------------------------------;\r
 add_timercall:\r
 ;                  out: eax = 0 if OK            ;\r
 ;------------------------------------------------;\r
 add_timercall:\r
-         cmp     [call_list], 0\r
-         jne     .test2\r
-         mov     [call_list], ebx\r
-         jmp     .end\r
-     .error:\r
-         mov     eax, 1\r
-         ret\r
-     .test2:\r
-         cmp     [call_list+4], 0                    ; since i am so lazy\r
-         jne     .test3                              ; and a loop can be\r
-         mov     [call_list+4], ebx                  ; rather complicated\r
-         jmp     .end                                ; for this stuff, i\r
-     .test3:                                         ; check for each one..\r
-         cmp     [call_list+8], 0                    ; after all, it's only 5.\r
-         jne     .test4\r
-         mov     [call_list+8], ebx\r
-         jmp     .end\r
-     .test4:\r
-         cmp     [call_list+12], 0\r
-         jne     .test5\r
-         mov     [call_list+12], ebx\r
-         jmp     .end\r
-     .test5:\r
-         cmp     [call_list+16], 0\r
-         jne     .error\r
-         mov     [call_list+16], ebx\r
-     .end:\r
-         xor     eax, eax\r
-         ret\r
+        cmp    [call_list], 0\r
+        jne    .test2\r
+        mov    [call_list], ebx\r
+        jmp    .end\r
+    .error:\r
+        mov    eax, 1\r
+        ret\r
+    .test2:\r
+        cmp    [call_list+4], 0                       ; since i am so lazy\r
+        jne    .test3                                 ; and a loop can be\r
+        mov    [call_list+4], ebx                     ; rather complicated\r
+        jmp    .end                                   ; for this stuff, i\r
+    .test3:                                           ; check for each one..\r
+        cmp    [call_list+8], 0                       ; after all, it's only 5.\r
+        jne    .test4\r
+        mov    [call_list+8], ebx\r
+        jmp    .end\r
+    .test4:\r
+        cmp    [call_list+12], 0\r
+        jne    .test5\r
+        mov    [call_list+12], ebx\r
+        jmp    .end\r
+    .test5:\r
+        cmp    [call_list+16], 0\r
+        jne    .error\r
+        mov    [call_list+16], ebx\r
+    .end:\r
+        xor    eax, eax\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -97,35 +97,35 @@ add_timercall:
 ;                  out: eax = 0 if OK             ;\r
 ;-------------------------------------------------;\r
 remove_timercall:\r
 ;                  out: eax = 0 if OK             ;\r
 ;-------------------------------------------------;\r
 remove_timercall:\r
-         cmp     [call_list], ebx\r
-         jne     .test2\r
-         mov     [call_list], dword 0\r
-         jmp     .end\r
-     .error:\r
-         mov     eax, 1\r
-         ret\r
-     .test2:\r
-         cmp     [call_list+4], ebx\r
-         jne     .test3\r
-         mov     [call_list+4], dword 0\r
-         jmp     .end\r
-     .test3:\r
-         cmp     [call_list+8], ebx\r
-         jne     .test4\r
-         mov     [call_list+8], dword 0\r
-         jmp     .end\r
-     .test4:\r
-         cmp     [call_list+12], ebx\r
-         jne     .test5\r
-         mov     [call_list+12], dword 0\r
-         jmp     .end\r
-     .test5:\r
-         cmp     [call_list+16], ebx\r
-         jne     .error\r
-         mov     [call_list+16], dword 0\r
-     .end:\r
-         xor     eax, eax\r
-         ret\r
+        cmp    [call_list], ebx\r
+        jne    .test2\r
+        mov    [call_list], dword 0\r
+        jmp    .end\r
+    .error:\r
+        mov    eax, 1\r
+        ret\r
+    .test2:\r
+        cmp    [call_list+4], ebx\r
+        jne    .test3\r
+        mov    [call_list+4], dword 0\r
+        jmp    .end\r
+    .test3:\r
+        cmp    [call_list+8], ebx\r
+        jne    .test4\r
+        mov    [call_list+8], dword 0\r
+        jmp    .end\r
+    .test4:\r
+        cmp    [call_list+12], ebx\r
+        jne    .test5\r
+        mov    [call_list+12], dword 0\r
+        jmp    .end\r
+    .test5:\r
+        cmp    [call_list+16], ebx\r
+        jne    .error\r
+        mov    [call_list+16], dword 0\r
+    .end:\r
+        xor    eax, eax\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -135,11 +135,11 @@ remove_timercall:
 ;           out: nothing                     ;\r
 ;--------------------------------------------;\r
 delay:\r
 ;           out: nothing                     ;\r
 ;--------------------------------------------;\r
 delay:\r
-         mov     [timer_wait], ecx                   ; mov value to "timer"\r
-     .loop:\r
-         cmp     [timer_wait], 0\r
-         jne     .loop\r
-         ret\r
+        mov    [timer_wait], ecx                      ; mov value to "timer"\r
+    .loop:\r
+        cmp    [timer_wait], 0\r
+        jne    .loop\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -153,9 +153,9 @@ delay:
 ;           out: ecx = pointer to counter    ;\r
 ;--------------------------------------------;\r
 active_delay:\r
 ;           out: ecx = pointer to counter    ;\r
 ;--------------------------------------------;\r
 active_delay:\r
-         mov     [timer_wait], ecx                   ; mov value to "timer"\r
-         mov     ecx, timer_wait                     ; let caller check value\r
-         ret\r
+        mov    [timer_wait], ecx                      ; mov value to "timer"\r
+        mov    ecx, timer_wait                        ; let caller check value\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -163,12 +163,12 @@ active_delay:
 ;     set PIT to 100Hz         ;\r
 ;------------------------------;\r
 set_pit_freq:\r
 ;     set PIT to 100Hz         ;\r
 ;------------------------------;\r
 set_pit_freq:\r
-         push    eax\r
-         mov     al, 0x34                            ; set to 100Hz, 0x34 = 00110100b\r
-         out     0x43, al\r
-         mov     al, 0x9B                            ; lsb    1193180 / 1193\r
-         out     0x40, al\r
-         mov     al, 0x2E                            ; msb\r
-         out     0x40, al\r
-         pop     eax\r
-         ret
\ No newline at end of file
+        push   eax\r
+        mov    al, 0x34                               ; set to 100Hz, 0x34 = 00110100b\r
+        out    0x43, al\r
+        mov    al, 0x9B                               ; lsb    1193180 / 1193\r
+        out    0x40, al\r
+        mov    al, 0x2E                               ; msb\r
+        out    0x40, al\r
+        pop    eax\r
+        ret
\ No newline at end of file
index 5b4a8d8a3942b843e50b44ad86fe1aa990fcd343..c6b28417e5f84963be8440b0db960d04dbb04849 100644 (file)
@@ -1,11 +1,25 @@
 ;----------------------------------------------------------;\r
 ;----------------------------------------------------------;\r
-; BOS kernel                Christoffer Bubach, 2003-2005. ;\r
+; BOS kernel                Christoffer Bubach, 2003-2015. ;\r
 ;----------------------------------------------------------;\r
 ;                                                          ;\r
 ;----------------------------------------------------------;\r
 ;                                                          ;\r
-;    set/modify IDT entries                                ;\r
+;   Set/modify IDT entries                                 ;\r
 ;                                                          ;\r
 ;----------------------------------------------------------;\r
 \r
 ;                                                          ;\r
 ;----------------------------------------------------------;\r
 \r
+;-----------------------------------------------------;\r
+;                                                     ;\r
+; IDT entry structure                                 ;\r
+;                                                     ;\r
+;   16bit - entry offset bits 0..15                   ;\r
+;   16bit - code segment selector in GDT or LDT       ;\r
+;   8bit  - unused, set to 0                          ;\r
+;   8bit  - type and attributes                       ;\r
+;              -  0xE = 32bit intterrupt              ;\r
+;              -  0x8 = Present bit = 1               ;\r
+;   16bit - entry offset bits 16..31                  ;\r
+;                                                     ;\r
+;   middle section for code segment 08 = 0x8E000008   ;\r
+;-----------------------------------------------------;\r
 \r
 \r
 ;--------------------------------------------------;\r
 \r
 \r
 ;--------------------------------------------------;\r
 init_idt:\r
         push   eax\r
         push   ecx\r
 init_idt:\r
         push   eax\r
         push   ecx\r
+        push   edi\r
 \r
 \r
+        xor    edi, edi\r
         xor    ecx, ecx\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
+        add    edi, [idtr.address]\r
+    .l1:                                              ; loop full IDT table\r
+        mov    eax, esi\r
+        mov    word [edi], ax                         ; set handler lower offset\r
+        add    edi, 2\r
 \r
 \r
-        mov    dword [(0x6c00+ecx)], 0x8E000008       ; 0x6c00 is where\r
-        add    ecx, 4                                 ; we put the IDT\r
+        mov    dword [edi], 0x8E000008                ; set IDT segment and attributes\r
+        add    edi, 4\r
 \r
         mov    eax, esi\r
         shr    eax, 16\r
 \r
         mov    eax, esi\r
         shr    eax, 16\r
-        mov    [(0x6c00+ecx)], ax\r
-        add    ecx, 2\r
+        mov    word [edi], ax                         ; set handler high offset\r
+        add    edi, 2\r
 \r
 \r
-        cmp    ecx, 0x800                             ; 256 ints\r
-        jb     .l1                                    ; * 8 bytes each\r
+        add    cx, 8                                  ; 8byte *\r
+        cmp    cx, word [idtr.size]                   ; 256 ints\r
+        jb     .l1                                    ; = done?\r
 \r
 \r
+        pop    edi\r
         pop    ecx\r
         pop    eax\r
         ret\r
         pop    ecx\r
         pop    eax\r
         ret\r
@@ -45,30 +64,30 @@ init_idt:
 ;      edi = int function pointer      ;\r
 ;--------------------------------------;\r
 set_int:\r
 ;      edi = int function pointer      ;\r
 ;--------------------------------------;\r
 set_int:\r
-               push   eax\r
-               push   ecx\r
+        push   eax\r
+        push   ecx\r
 \r
 \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
+        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
 \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
 \r
-               mov    dword [(0x6c00+ecx)], 0x8E000008\r
-               add    ecx, 4\r
+        mov    dword [(0x6c00+ecx)], 0x8E000008\r
+        add    ecx, 4\r
 \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
 \r
-               pop    ecx\r
-               pop    eax\r
-               ret\r
+        pop    ecx\r
+        pop    eax\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -78,15 +97,15 @@ set_int:
 ;      out: esi = address or 0 if none present   ;\r
 ;------------------------------------------------;\r
 get_int:\r
 ;      out: esi = address or 0 if none present   ;\r
 ;------------------------------------------------;\r
 get_int:\r
-               push   eax\r
+        push   eax\r
 \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
 \r
-               pop    eax\r
-               ret\r
+        pop    eax\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -96,24 +115,24 @@ get_int:
 ;      in:  esi = pointer to int list    ;\r
 ;----------------------------------------;\r
 set_idt_list:\r
 ;      in:  esi = pointer to int list    ;\r
 ;----------------------------------------;\r
 set_idt_list:\r
-               push   eax\r
-               push   edi\r
-\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
+        push   eax\r
+        push   edi\r
+\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
 \r
 \r
 \r
 \r
 \r
 \r
index b8bafea997b08be7b850166e3b375fe2c526fce1..eaa01f50c5327cb0da08fcded5e6975e25089bcc 100755 (executable)
Binary files a/kernel/kernel.sys and b/kernel/kernel.sys differ