mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-08-04 01:36:10 -04:00
Start migrating from floppy to hard disk
Move stage1 into the MBR boot code Move stage2 into the second sector of the hard disk
This commit is contained in:
parent
3f6bc4270a
commit
35ba77cb0f
2
Makefile
2
Makefile
@ -15,6 +15,8 @@ bootloader/bootloader.bin: force_look sectors
|
||||
cd bootloader; $(MAKE)
|
||||
|
||||
thor.flp: bootloader/bootloader.bin
|
||||
dd if=bootloader/stage1.bin of=hdd.img bs=446 count=1 conv=notrunc
|
||||
dd if=bootloader/stage2.bin of=hdd.img bs=512 count=1 seek=1 conv=notrunc
|
||||
cat bootloader/bootloader.bin > thor.bin
|
||||
cat kernel/kernel.bin >> thor.bin
|
||||
cat filler.bin >> thor.bin
|
||||
|
@ -1,5 +1,4 @@
|
||||
display_library: sdl
|
||||
magic_break: enabled=1
|
||||
floppya: 1_44=thor.flp, status=inserted
|
||||
ata0-master: type=disk, path="hdd.img", mode=flat, cylinders=1000, heads=16, spt=63
|
||||
boot:floppy
|
||||
boot: disk
|
@ -11,13 +11,13 @@ stage1.bin: stage1.asm
|
||||
stage2.bin: stage2.asm sectors.asm
|
||||
nasm -w+all -f bin -o stage2.bin stage2.asm
|
||||
|
||||
padding.bin:
|
||||
dd if=/dev/zero of=padding.bin bs=512 count=34
|
||||
#padding.bin:
|
||||
# dd if=/dev/zero of=padding.bin bs=512 count=34
|
||||
|
||||
bootloader.bin: stage1.bin stage2.bin padding.bin
|
||||
bootloader.bin: stage1.bin stage2.bin
|
||||
cat stage1.bin > bootloader.bin
|
||||
cat stage2.bin >> bootloader.bin
|
||||
cat padding.bin >> bootloader.bin
|
||||
# cat padding.bin >> bootloader.bin
|
||||
|
||||
clean:
|
||||
rm -f stage1.bin
|
||||
|
@ -48,6 +48,49 @@ print_16:
|
||||
.done:
|
||||
ret
|
||||
|
||||
print_int_16:
|
||||
push ax
|
||||
push bx
|
||||
push dx
|
||||
push si
|
||||
|
||||
mov ax, di
|
||||
|
||||
xor si, si
|
||||
|
||||
.loop:
|
||||
xor dx, dx
|
||||
mov bx, 10
|
||||
div bx
|
||||
add dx, 48
|
||||
|
||||
push dx
|
||||
inc si
|
||||
|
||||
test ax, ax
|
||||
jne .loop
|
||||
|
||||
.next:
|
||||
test si, si
|
||||
je .exit
|
||||
dec si
|
||||
|
||||
; write the char
|
||||
pop ax
|
||||
|
||||
mov ah, 0Eh
|
||||
int 10h
|
||||
|
||||
jmp .next
|
||||
|
||||
.exit:
|
||||
pop si
|
||||
pop dx
|
||||
pop bx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
key_wait:
|
||||
mov al, 0xD2
|
||||
out 64h, al
|
||||
|
@ -19,6 +19,10 @@ rm_start:
|
||||
mov ss, ax
|
||||
mov sp, 4096
|
||||
|
||||
; Used for disk access
|
||||
xor ax, ax
|
||||
mov gs, ax
|
||||
|
||||
; Set data segment
|
||||
mov ax, 0x7C0
|
||||
mov ds, ax
|
||||
@ -62,6 +66,12 @@ rm_start:
|
||||
|
||||
jc extensions_not_supported
|
||||
|
||||
; Tests
|
||||
|
||||
; This is the partition start
|
||||
; mov di, [gs:(0x1000 + 446 + 8)]
|
||||
; call print_int_16
|
||||
|
||||
; 3. Wait for a key press
|
||||
|
||||
call new_line_16
|
||||
@ -78,36 +88,15 @@ rm_start:
|
||||
mov si, load_msg
|
||||
call print_line_16
|
||||
|
||||
; Reset disk drive
|
||||
xor ax, ax
|
||||
xor ah, ah
|
||||
mov dl, 0
|
||||
int 0x13
|
||||
; Loading the stage 2 from disk
|
||||
|
||||
jc reset_failed
|
||||
|
||||
; Loading the stage 2 from floppy
|
||||
|
||||
bootdev equ 0x0
|
||||
sectors equ 1
|
||||
|
||||
mov ax, 0x90
|
||||
mov es, ax
|
||||
xor bx, bx
|
||||
|
||||
mov ah, 0x2 ; Read sectors from memory
|
||||
mov al, sectors ; Number of sectors to read
|
||||
xor ch, ch ; Cylinder 0
|
||||
mov cl, 2 ; Sector 2
|
||||
xor dh, dh ; Head 0
|
||||
mov dl, bootdev ; Drive
|
||||
mov ah, 0x42
|
||||
mov si, DAP
|
||||
mov dl, 0x80
|
||||
int 0x13
|
||||
|
||||
jc read_failed
|
||||
|
||||
cmp al, sectors
|
||||
jne read_failed
|
||||
|
||||
; Run the stage 2
|
||||
|
||||
jmp dword 0x90:0x0
|
||||
@ -134,7 +123,18 @@ error_end:
|
||||
|
||||
jmp $
|
||||
|
||||
; Datas
|
||||
; Variable Datas
|
||||
|
||||
DAP:
|
||||
.size db 0x10
|
||||
.null db 0x0
|
||||
.count dw 1
|
||||
.offset dw 0
|
||||
.segment dw 0x90
|
||||
.lba dd 1
|
||||
.lba48 dd 0
|
||||
|
||||
; Constants Datas
|
||||
|
||||
header_1 db 'Welcome to Thor OS Bootloader!', 0
|
||||
|
||||
@ -148,5 +148,4 @@ error_end:
|
||||
|
||||
; Make a real bootsector
|
||||
|
||||
times 510-($-$$) db 0
|
||||
dw 0xAA55
|
||||
times 446-($-$$) db 0
|
@ -24,6 +24,8 @@ second_step:
|
||||
mov si, load_kernel
|
||||
call print_line_16
|
||||
|
||||
jmp $
|
||||
|
||||
; Reset disk drive
|
||||
xor ax, ax
|
||||
mov dl, bootdev
|
||||
|
Loading…
x
Reference in New Issue
Block a user