projects
/
bootcensus
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed partial loading bug
[bootcensus]
/
src
/
boot
/
boot.s
diff --git
a/src/boot/boot.s
b/src/boot/boot.s
index
8ba4a11
..
b9e1a76
100644
(file)
--- a/
src/boot/boot.s
+++ b/
src/boot/boot.s
@@
-1,12
+1,15
@@
.code16
.section .boot,"a"
.code16
.section .boot,"a"
+ .set scratchbuf, 0x7b00
+
+boot:
cli
cld
# move stack to just below the code
xor %ax, %ax
mov %ax, %ss
cli
cld
# move stack to just below the code
xor %ax, %ax
mov %ax, %ss
- mov $0x7c00, %sp
+ mov $0x7b00, %sp
# use the code segment for data access
mov %cs, %ax
mov %ax, %ds
# use the code segment for data access
mov %cs, %ax
mov %ax, %ds
@@
-16,9
+19,6
@@
call setup_serial
call setup_serial
- mov $_boot2_size, %eax
- call print_num
-
# load the second stage boot loader and jump to it
mov $_boot2_size, %eax
mov %eax, %ebx
# load the second stage boot loader and jump to it
mov $_boot2_size, %eax
mov %eax, %ebx
@@
-37,9
+37,6
@@
call read_sectors
jmp boot2_addr
call read_sectors
jmp boot2_addr
- cli
- hlt
-
.set SECT_PER_TRACK, 18
.set ARG_NSECT, 6
.set SECT_PER_TRACK, 18
.set ARG_NSECT, 6
@@
-66,10
+63,7
@@
read_sectors:
ret
.set VAR_ATTEMPTS, -2
ret
.set VAR_ATTEMPTS, -2
-str_rdsec_msg: .asciz "rdsec: "
-str_cyl_msg: .asciz " C "
-str_head_msg: .asciz " H "
-str_sec_msg: .asciz " S "
+#str_rdsec_msg: .asciz "rdsec: "
# read_sector(sidx)
read_sector:
# read_sector(sidx)
read_sector:
@@
-84,8
+78,8
@@
read_sector:
.Lread_try:
# calculate the track (sidx / sectors_per_track)
mov 4(%bp), %ax
.Lread_try:
# calculate the track (sidx / sectors_per_track)
mov 4(%bp), %ax
- mov $str_rdsec_msg, %si
- call print_str_num16
+# mov $str_rdsec_msg, %si
+# call print_str_num16
xor %dx, %dx
mov $SECT_PER_TRACK, %cx
xor %dx, %dx
mov $SECT_PER_TRACK, %cx
@@
-104,23
+98,6
@@
read_sector:
inc %al
or %al, %cl
inc %al
or %al, %cl
- mov $str_cyl_msg, %si
- mov %cx, %ax
- rol $2, %al
- and $3, %al
- ror $8, %ax
- call print_str_num16
-
- mov $str_head_msg, %si
- xor %ax, %ax
- mov %dh, %al
- call print_str_num16
-
- mov $str_sec_msg, %si
- mov %cl, %al
- and $0x3f, %ax
- call print_str_num16
-
# ah = 2 (read), al = 1 sectors
mov $0x0201, %ax
movb drive_number, %dl
# ah = 2 (read), al = 1 sectors
mov $0x0201, %ax
movb drive_number, %dl
@@
-141,9
+118,14
@@
read_sector:
jmp abort_read
.Lread_ok:
jmp abort_read
.Lread_ok:
+ # DBG print first dword
+# mov $str_read_error + 4, %si
+# mov %es:(%bx), %eax
+# call print_str_num
+
# increment es:bx accordingly (advance es if bx overflows)
add $512, %bx
# increment es:bx accordingly (advance es if bx overflows)
add $512, %bx
- jno 0f
+ jnc 0f
mov %es, %ax
add $4096, %ax
mov %ax, %es
mov %es, %ax
add $4096, %ax
mov %ax, %es
@@
-154,12
+136,11
@@
read_sector:
pop %bp
ret
pop %bp
ret
-str_read_error: .asciz "err read sector: "
+str_read_error: .asciz "err read sect: "
abort_read:
mov $str_read_error, %si
call print_str_num16
abort_read:
mov $str_read_error, %si
call print_str_num16
- cli
hlt
cursor_x: .byte 0
hlt
cursor_x: .byte 0
@@
-170,6
+151,8
@@
print_str_num:
call print_str
pop %eax
call print_num
call print_str
pop %eax
call print_num
+ mov $13, %al
+ call ser_putchar
mov $10, %al
call ser_putchar
ret
mov $10, %al
call ser_putchar
ret
@@
-210,13
+193,14
@@
print_str:
ret
# expects number in eax
ret
# expects number in eax
+ .global print_num
print_num:
# save registers
push %es
pusha
xor %cx, %cx
print_num:
# save registers
push %es
pusha
xor %cx, %cx
- movw $numbuf, %si
+ movw $scratchbuf, %si
mov $10, %ebx
0: xor %edx, %edx
mov $10, %ebx
0: xor %edx, %edx
@@
-300,6
+284,7
@@
setup_serial:
ret
# expects a character in al
ret
# expects a character in al
+ .global ser_putchar
ser_putchar:
push %dx
ser_putchar:
push %dx
@@
-328,7
+313,6
@@
ser_putstr:
drive_number: .byte 0
drive_number: .byte 0
-numbuf: .space 8
.org 510
.byte 0x55
.byte 0xaa
.org 510
.byte 0x55
.byte 0xaa