Bootloader fixes on systems with wrong CS
This commit is contained in:
parent
1aace24eba
commit
f7672dbaf4
|
@ -12,6 +12,14 @@ boot: ; dl comes with disk
|
||||||
; initialize stack
|
; initialize stack
|
||||||
mov sp, 0x7C00
|
mov sp, 0x7C00
|
||||||
|
|
||||||
|
; initialize CS
|
||||||
|
push ax
|
||||||
|
push word .set_cs
|
||||||
|
retf
|
||||||
|
|
||||||
|
.set_cs:
|
||||||
|
|
||||||
|
; save disk number
|
||||||
mov [disk], dl
|
mov [disk], dl
|
||||||
|
|
||||||
mov si, name
|
mov si, name
|
||||||
|
@ -45,16 +53,16 @@ boot: ; dl comes with disk
|
||||||
; TODO rewrite to (eventually) move larger parts at once
|
; TODO rewrite to (eventually) move larger parts at once
|
||||||
; if that is done increase buffer_size_sectors in startup-common to that (max 0x80000 - startup_end)
|
; if that is done increase buffer_size_sectors in startup-common to that (max 0x80000 - startup_end)
|
||||||
load:
|
load:
|
||||||
cmp cx, 128
|
cmp cx, 127
|
||||||
jbe .good_size
|
jbe .good_size
|
||||||
|
|
||||||
pusha
|
pusha
|
||||||
mov cx, 128
|
mov cx, 127
|
||||||
call load
|
call load
|
||||||
popa
|
popa
|
||||||
add ax, 128
|
add ax, 127
|
||||||
add dx, 128 * 512 / 16
|
add dx, 127 * 512 / 16
|
||||||
sub cx, 128
|
sub cx, 127
|
||||||
|
|
||||||
jmp load
|
jmp load
|
||||||
.good_size:
|
.good_size:
|
||||||
|
@ -63,31 +71,7 @@ load:
|
||||||
mov [DAPACK.count], cx
|
mov [DAPACK.count], cx
|
||||||
mov [DAPACK.seg], dx
|
mov [DAPACK.seg], dx
|
||||||
|
|
||||||
mov bx, [DAPACK.addr + 2]
|
call print_dapack
|
||||||
call print_num
|
|
||||||
|
|
||||||
mov bx, [DAPACK.addr]
|
|
||||||
call print_num
|
|
||||||
|
|
||||||
mov al, '#'
|
|
||||||
call print_char
|
|
||||||
|
|
||||||
mov bx, [DAPACK.count]
|
|
||||||
call print_num
|
|
||||||
|
|
||||||
mov al, ' '
|
|
||||||
call print_char
|
|
||||||
|
|
||||||
mov bx, [DAPACK.seg]
|
|
||||||
call print_num
|
|
||||||
|
|
||||||
mov al, ':'
|
|
||||||
call print_char
|
|
||||||
|
|
||||||
mov bx, [DAPACK.buf]
|
|
||||||
call print_num
|
|
||||||
|
|
||||||
call print_line
|
|
||||||
|
|
||||||
mov dl, [disk]
|
mov dl, [disk]
|
||||||
mov si, DAPACK
|
mov si, DAPACK
|
||||||
|
@ -108,16 +92,16 @@ load:
|
||||||
; TODO rewrite to (eventually) move larger parts at once
|
; TODO rewrite to (eventually) move larger parts at once
|
||||||
; if that is done increase buffer_size_sectors in startup-common to that (max 0x80000 - startup_end)
|
; if that is done increase buffer_size_sectors in startup-common to that (max 0x80000 - startup_end)
|
||||||
store:
|
store:
|
||||||
cmp cx, 128
|
cmp cx, 127
|
||||||
jbe .good_size
|
jbe .good_size
|
||||||
|
|
||||||
pusha
|
pusha
|
||||||
mov cx, 128
|
mov cx, 127
|
||||||
call store
|
call store
|
||||||
popa
|
popa
|
||||||
add ax, 128
|
add ax, 127
|
||||||
add dx, 128 * 512 / 16
|
add dx, 127 * 512 / 16
|
||||||
sub cx, 128
|
sub cx, 127
|
||||||
|
|
||||||
jmp store
|
jmp store
|
||||||
.good_size:
|
.good_size:
|
||||||
|
@ -126,6 +110,16 @@ load:
|
||||||
mov [DAPACK.count], cx
|
mov [DAPACK.count], cx
|
||||||
mov [DAPACK.seg], dx
|
mov [DAPACK.seg], dx
|
||||||
|
|
||||||
|
call print_dapack
|
||||||
|
|
||||||
|
mov dl, [disk]
|
||||||
|
mov si, DAPACK
|
||||||
|
mov ah, 0x43
|
||||||
|
int 0x13
|
||||||
|
jc error
|
||||||
|
ret
|
||||||
|
|
||||||
|
print_dapack:
|
||||||
mov bx, [DAPACK.addr + 2]
|
mov bx, [DAPACK.addr + 2]
|
||||||
call print_num
|
call print_num
|
||||||
|
|
||||||
|
@ -150,14 +144,7 @@ load:
|
||||||
mov bx, [DAPACK.buf]
|
mov bx, [DAPACK.buf]
|
||||||
call print_num
|
call print_num
|
||||||
|
|
||||||
call print_line
|
jmp print_line
|
||||||
|
|
||||||
mov dl, [disk]
|
|
||||||
mov si, DAPACK
|
|
||||||
mov ah, 0x43
|
|
||||||
int 0x13
|
|
||||||
jc error
|
|
||||||
ret
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
mov bh, 0
|
mov bh, 0
|
||||||
|
@ -180,7 +167,6 @@ error:
|
||||||
name: db "Redox Loader - Stage One",0
|
name: db "Redox Loader - Stage One",0
|
||||||
errored: db "Could not read disk",0
|
errored: db "Could not read disk",0
|
||||||
finished: db "Redox Loader - Stage Two",0
|
finished: db "Redox Loader - Stage Two",0
|
||||||
line: db 13,10,0
|
|
||||||
|
|
||||||
disk: db 0
|
disk: db 0
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ USE16
|
||||||
|
|
||||||
|
|
||||||
; a newline
|
; a newline
|
||||||
newline: db 0xD, 0xA, 0
|
newline: db 13,10,0
|
||||||
|
|
||||||
; print a string and a newline
|
; print a string and a newline
|
||||||
; IN
|
; IN
|
||||||
|
@ -13,8 +13,7 @@ newline: db 0xD, 0xA, 0
|
||||||
; ax
|
; ax
|
||||||
print_line:
|
print_line:
|
||||||
mov si, newline
|
mov si, newline
|
||||||
call print
|
jmp print
|
||||||
ret
|
|
||||||
|
|
||||||
; print a string
|
; print a string
|
||||||
; IN
|
; IN
|
||||||
|
@ -22,11 +21,13 @@ print_line:
|
||||||
; CLOBBER
|
; CLOBBER
|
||||||
; ax
|
; ax
|
||||||
print:
|
print:
|
||||||
|
cld
|
||||||
|
.loop:
|
||||||
lodsb
|
lodsb
|
||||||
test al, al
|
test al, al
|
||||||
jz .done
|
jz .done
|
||||||
call print_char
|
call print_char
|
||||||
jmp print
|
jmp .loop
|
||||||
.done:
|
.done:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ startup:
|
||||||
; buffersize in multiple of sectors (512 Bytes)
|
; buffersize in multiple of sectors (512 Bytes)
|
||||||
; min 1
|
; min 1
|
||||||
; max (0x70000 - startup_end) / 512
|
; max (0x70000 - startup_end) / 512
|
||||||
buffer_size_sectors equ 128
|
buffer_size_sectors equ 127
|
||||||
; buffer size in Bytes
|
; buffer size in Bytes
|
||||||
buffer_size_bytes equ buffer_size_sectors * 512
|
buffer_size_bytes equ buffer_size_sectors * 512
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue