summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-09-04 20:17:49 +0200
committerMichal Idziorek <m.i@gmx.at>2014-09-04 20:17:49 +0200
commit487ecc1615ccc0368f1520c1146b2b43cdab6577 (patch)
tree07d9e36182251b485e344fbb6e8182e2805a9572
parent44dcbdf16674bc727503ca748f95eec847755b2f (diff)
working on bootloader. we will need stage 2...
-rw-r--r--boot/disk_load_16.asm131
-rw-r--r--boot/mbr.asm12
-rw-r--r--boot/vesa_setup_16.asm2
-rw-r--r--data/fill.asm2
4 files changed, 111 insertions, 36 deletions
diff --git a/boot/disk_load_16.asm b/boot/disk_load_16.asm
index 2fa88ee..eae15a0 100644
--- a/boot/disk_load_16.asm
+++ b/boot/disk_load_16.asm
@@ -9,6 +9,21 @@
DISK_LOAD:
db "D",0
+DISK_LOAD_ERROR
+ db "E",0
+Head:
+ db 0
+Track:
+ db 0
+Sector:
+ db 1
+LBA:
+ dw 0 ;; starts at zero!
+Sectors:
+ dw 80
+Heads:
+ dw 2
+
;disk_load routune (load dh sectors from drive dl to es:bx)
;lba mode has 52 sectors hardcoded!
@@ -16,47 +31,113 @@ disk_load_16:
pusha
+;;; ; check if LBA is supported
+;;; pusha
+;;; mov ah,0x41
+;;; mov bx,0x55aa
+;;; int 0x13
+;;; jnc disk_load_lba
+;;; popa
- ; check if LBA is supported
- pusha
- mov ah,0x41
- mov bx,0x55aa
- int 0x13
- jnc disk_load_lba
- popa
+ disk_load_next:
+
+ call ESBX
; load using CHS
+;; mov al,80 ;read dh sectors (amount)
+;; mov cx,[LBA]
+;; cmp cx,0
+;; jne disk_read_normal
+;; mov al,79 ;read dh sectors (amount)
+;; disk_read_normal
+
+ mov al,1
+
+ mov cl,[Sector] ;sector
+ mov ch,[Track] ;cyl
+
+ mov dl,[BOOT_DRIVE]
+ mov dh,[Head] ;head
+
mov ah,0x02 ;BIOS read sector func
- mov al,dh ;read dh sectors (amount)
- mov ch,0x00 ;cyl 0
- mov dh,0x00 ;head 0
- mov cl,0x02 ;start at sector 2
-;
int 0x13 ;bios interrupt
- mov bx, DISK_LOAD
+ jnc disk_read_ok ;ready becaue of error :(
+
+ mov bx, DISK_LOAD_ERROR
call print_string
- popa
- ret
-
- ; load using LBA
+ jmp $
-disk_load_lba:
+ disk_read_ok:
- popa
+ mov ax,[LBA]
+
+ cmp ax,880
+ je disk_load_ready
- xor ah,ah
- mov ah,0x42
- lea si,[lba_adr]
- int 0x13
- jc skip_print
mov bx, DISK_LOAD
call print_string
- skip_print:
+
+ add ax,1 ;conver LBA to CHS
+ mov [LBA],ax
+
+ call LBACHS
+
+ jmp disk_load_next
+
+ disk_load_ready:
+
+ jmp $
popa
ret
+
+ESBX:
+
+ xor dx,dx
+ xor dx,dx
+ mov ax,[LBA]
+ mov bx,0x200
+ mul bx
+ mov bx,ax
+ add dx,1
+ shl dx,12
+ mov es,dx
+
+ret
+
+
+ ; load using LBA
+
+;;;disk_load_lba:
+;;;
+;;; popa
+;;;
+;;; xor ah,ah
+;;; mov ah,0x42
+;;; lea si,[lba_adr]
+;;; int 0x13
+;;; jc skip_print
+;;; mov bx, DISK_LOAD
+;;; call print_string
+;;; skip_print:
+;;;
+;;; popa
+;;; ret
+;;;
+LBACHS:
+ xor dx, dx ; prepare dx:ax for operation
+ div WORD [Sectors] ; divide by sectors per track
+ inc dl ; add 1 (obsolute sector formula)
+ mov BYTE [Sector], dl
+
+ xor dx, dx ; prepare dx:ax for operation
+ div WORD [Heads] ; mod by number of heads (Absolue head formula)
+ mov BYTE [Head], dl ; everything else was already done from the first formula
+
+ mov BYTE [Track], al ; not much else to do :)
+ ret
lba_adr:
diff --git a/boot/mbr.asm b/boot/mbr.asm
index 4513100..a854615 100644
--- a/boot/mbr.asm
+++ b/boot/mbr.asm
@@ -111,14 +111,8 @@ boot_16:
;
; ;remember BOOT_DRIVE (as was set by BIOS)
mov [BOOT_DRIVE],dl
-;
-; ;Load the KERNEL (sectors starting at sector 2)
- mov ax,KERNEL_SECTOR
- mov es,ax
- mov bx,KERNEL_OFFSET
- mov dh, 53 ; for lba mode this is hardcoded anyway
- mov dl, [BOOT_DRIVE]
+; ;Load the IMAGE
call disk_load_16
;
@@ -139,7 +133,7 @@ boot_16:
; je a20check ;hang if a20 is disabled!
; ;VESA: also setup vesa stuff before entering 32 bit protected mode
- call VesaSetup
+; call VesaSetup
;
; ;finally lets enter Protected mode!!!
call switch_to_pm
@@ -175,7 +169,7 @@ boot_32_pm:
;fill partition table (4x16byte) with zeroes.
;(otherwise my Acer Aspire will not boot)
-times 64 db 0x0
+;times 64 db 0x0
;so we get identified as MBR
times 510-($-$$) db 0x0
diff --git a/boot/vesa_setup_16.asm b/boot/vesa_setup_16.asm
index 96e16e2..f21cbff 100644
--- a/boot/vesa_setup_16.asm
+++ b/boot/vesa_setup_16.asm
@@ -39,7 +39,7 @@ VesaSetup:
int 0x10
cmp ax,0x004f
je vesa_ok3
- vesa_err3
+ vesa_err3:
mov bx, VESA_CHECK3
call print_string
jmp vesa_err3
diff --git a/data/fill.asm b/data/fill.asm
index 49be4d3..216a328 100644
--- a/data/fill.asm
+++ b/data/fill.asm
@@ -7,4 +7,4 @@
;
;
-times 1474560 db 0x00
+times 1474560 db 0x69