projects
/
bootcensus
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
second stage boot loader now loads the main program
[bootcensus]
/
src
/
boot
/
boot.s
diff --git
a/src/boot/boot.s
b/src/boot/boot.s
index
bf32820
..
50817a3
100644
(file)
--- a/
src/boot/boot.s
+++ b/
src/boot/boot.s
@@
-15,7
+15,7
@@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
.code16
# along with this program. If not, see <https://www.gnu.org/licenses/>.
.code16
- .section .boot,"a"
+ .section .boot,"ax"
.set stack_top, 0x7be0
.set read_retries, 0x7be8
.set stack_top, 0x7be0
.set read_retries, 0x7be8
@@
-65,15
+65,16
@@
boot:
call read_sectors
jmp boot2_addr
call read_sectors
jmp boot2_addr
- .set ARG_NSECT, 6
- .set ARG_SIDX, 4
-
loading_msg: .asciz "\nLoad "
driveno_msg: .asciz "Drv:"
loading_msg: .asciz "\nLoad "
driveno_msg: .asciz "Drv:"
+ .global sect_per_track
sect_per_track: .short 18
sect_per_track: .short 18
+ .global num_cylinders
num_cylinders: .short 80
num_cylinders: .short 80
+ .global num_heads
num_heads: .short 2
num_heads: .short 2
+ .global heads_mask
heads_mask: .byte 1
get_drive_chs:
heads_mask: .byte 1
get_drive_chs:
@@
-88,10
+89,10
@@
get_drive_chs:
mov $8, %ah
int $0x13
mov $8, %ah
int $0x13
- jnc .Lok
+ jnc ok
ret
ret
-.Lok: xor %eax, %eax
+ok: xor %eax, %eax
mov %ch, %al
mov %cl, %ah
rol $2, %ah
mov %ch, %al
mov %cl, %ah
rol $2, %ah
@@
-118,6
+119,10
@@
get_drive_chs:
call print_num
ret
call print_num
ret
+
+ .set ARG_NSECT, 6
+ .set ARG_SIDX, 4
+
# read_sectors(first, num)
read_sectors:
push %bp
# read_sectors(first, num)
read_sectors:
push %bp
@@
-147,7
+152,7
@@
read_sector:
movw $3, read_retries
movw $3, read_retries
-.Lread_try:
+read_try:
# calculate the track (sidx / sectors_per_track)
mov 4(%bp), %ax
# calculate the track (sidx / sectors_per_track)
mov 4(%bp), %ax
@@
-179,22
+184,22
@@
read_sector:
mov $0x0201, %ax
movb drive_number, %dl
int $0x13
mov $0x0201, %ax
movb drive_number, %dl
int $0x13
- jnc .Lread_ok
+ jnc read_ok
# abort after 3 attempts
decw read_retries
# abort after 3 attempts
decw read_retries
- jz .Lread_fail
+ jz read_fail
# error detected, reset controller and retry
xor %ah, %ah
int $0x13
# error detected, reset controller and retry
xor %ah, %ah
int $0x13
- jmp .Lread_try
+ jmp read_try
-.Lread_fail:
+read_fail:
mov 4(%bp), %ax
jmp abort_read
mov 4(%bp), %ax
jmp abort_read
-.Lread_ok:
+read_ok:
mov $46, %ax
call print_char
mov $46, %ax
call print_char
@@
-227,12
+232,12
@@
print_str:
0: mov (%si), %al
cmp $0, %al
0: mov (%si), %al
cmp $0, %al
- jz .Lend
+ jz end
call print_char
inc %si
jmp 0b
call print_char
inc %si
jmp 0b
-.Lend: popa
+end: popa
ret
# expects character in al
ret
# expects character in al
@@
-267,14
+272,14
@@
print_num:
movw $scratchbuf + scratchbuf_size, %si
movb $0, (%si)
mov $10, %ebx
movw $scratchbuf + scratchbuf_size, %si
movb $0, (%si)
mov $10, %ebx
-.Lconvloop:
+convloop:
xor %edx, %edx
div %ebx
add $48, %dl
dec %si
mov %dl, (%si)
cmp $0, %eax
xor %edx, %edx
div %ebx
add $48, %dl
dec %si
mov %dl, (%si)
cmp $0, %eax
- jnz .Lconvloop
+ jnz convloop
call print_str
call print_str
@@
-322,7
+327,6
@@
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
@@
-336,9
+340,9
@@
ser_putchar:
0: mov %al, %ah
# wait until the transmit register is empty
mov $UART_LSTAT, %dx
0: mov %al, %ah
# wait until the transmit register is empty
mov $UART_LSTAT, %dx
-.Lwait: in %dx, %al
+wait: in %dx, %al
and $LST_TREG_EMPTY, %al
and $LST_TREG_EMPTY, %al
- jz .Lwait
+ jz wait
mov $UART_DATA, %dx
mov %ah, %al
out %al, %dx
mov $UART_DATA, %dx
mov %ah, %al
out %al, %dx