diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-09-05 02:36:33 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-09-05 02:36:33 +0200 |
| commit | b75c10c9d8c7405ba2f89724b485154d5201c404 (patch) | |
| tree | 6ce30784f4d7bbb5ca2a5cb636da7fa2186bee57 /boot/disk_load_16.asm | |
| parent | 467e19b262d435f1820539bc0c85ed4fa31b9687 (diff) | |
working on bootloaders (lba)
Diffstat (limited to 'boot/disk_load_16.asm')
| -rw-r--r-- | boot/disk_load_16.asm | 102 |
1 files changed, 95 insertions, 7 deletions
diff --git a/boot/disk_load_16.asm b/boot/disk_load_16.asm index 2a209fc..764b80d 100644 --- a/boot/disk_load_16.asm +++ b/boot/disk_load_16.asm @@ -27,14 +27,79 @@ LBA: disk_load_16: + ; check if LBA is supported + mov ah,0x41 + mov bx,0x55aa + int 0x13 + jnc disk_load_lba + jmp disk_load_chs + + +;####################### + +disk_load_lba: + pusha mov bx,0x1000 ;target es:bx mov es,bx mov bx,0 - next_sectors: + next_sectors_lba: + ;show es - target + pusha + mov bx,es + + mov al,bh + call print_hex_byte + + mov al,bl + call print_hex_byte + popa + ;-- + + mov [lba_addr_sector],es + mov ax,[LBA] + mov [lba_first_sector],ax + + mov dl,[BOOT_DRIVE] + + mov ah,0x42 + mov bx,0 + mov ds,bx + lea si,[lba_adr] + int 0x13 + jc disk_read_error + + mov bx,es + add bx,0x0200 + cmp bx,0x9e00 + je disk_load_finish + + mov es,bx + mov bx,0 + + mov ax,[LBA] + add ax,16 + mov [LBA],ax + + jmp next_sectors_lba + +;####################### + + +disk_load_chs: + + pusha + + mov bx,0x1000 ;target es:bx + mov es,bx + mov bx,0 + + next_sectors_chs + + jmp skip_debug pusha mov bx, STR_SPACE @@ -82,7 +147,13 @@ disk_load_16: call print_nextline + skip_debug + + mov ax,[LBA] + + ;calculate chs + call lba_to_chs ; and now READ it! mov al,16 ;number of sectors to read mov dl,[BOOT_DRIVE] @@ -91,7 +162,6 @@ disk_load_16: int 0x13 ;bios interrupt jc disk_read_error - disk_read_error_continue: mov bx,es add bx,0x0200 @@ -105,15 +175,13 @@ disk_load_16: add ax,16 mov [LBA],ax - jmp next_sectors + jmp next_sectors_chs - disk_read_error: - pusha +disk_read_error: mov bx, STR_ERROR call print_string call print_nextline - popa - jmp disk_read_error_continue + jmp $ disk_load_finish: @@ -146,3 +214,23 @@ lba_to_chs: mov ch, al ; not much else to do :) ret +;; here we hold the lba addr +lba_adr: + + dw 0x10 ; size of packet ( 16 byte) + dw 16 ; number of sectors to read + + ; target is 0x10000 + + dw 0x0000 ; target addr. offset + +lba_addr_sector: + dw 0x1000 ; target addr. sector + +lba_first_sector: + dw 10 ; first sector to read + dw 0 + + dd 0 + + ; |
