summaryrefslogtreecommitdiff
path: root/boot1
diff options
context:
space:
mode:
Diffstat (limited to 'boot1')
-rw-r--r--boot1/Makefile13
-rw-r--r--boot1/disk_load_16.asm103
-rw-r--r--boot1/mbr.asm106
-rw-r--r--boot1/print_string_16.asm115
4 files changed, 0 insertions, 337 deletions
diff --git a/boot1/Makefile b/boot1/Makefile
deleted file mode 100644
index b9b2e24..0000000
--- a/boot1/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-#master boot record
-
-include ../Makefile.common
-
-MBR=mbr.bin
-
-ASM_SOURCES=$(wildcard *.asm)
-
-$(MBR): $(ASM_SOURCES)
-
-clean:
- -rm $(MBR)
-
diff --git a/boot1/disk_load_16.asm b/boot1/disk_load_16.asm
deleted file mode 100644
index 6d1e4b3..0000000
--- a/boot1/disk_load_16.asm
+++ /dev/null
@@ -1,103 +0,0 @@
-;
-;disk_load_16
-;
-
-[bits 16]
-
-STR_LBA:
- db "LBA Support Detected",0
-
-STR_CHS:
- db "No CHS Support!)",0
-
-STR_ERROR:
- db "Disk Read Error",0
-
-STR_DONE:
- db "Stage 2 Loaded",0
-
-disk_load_16:
-
- pusha
-
- ; check if LBA is supported
- mov ah,0x41
- mov bx,0x55aa
- int 0x13
- jnc disk_load_lba
- jmp disk_load_chs
-
-disk_load_lba:
-
- mov bx, STR_LBA
- call print_string
- call print_nextline
-
- mov dl,[BOOT_DRIVE]
- xor ah,ah
- mov ah,0x42
-
- mov bx,0
- mov ds,bx
- lea si,[lba_adr]
-
- int 0x13
- jnc disk_load_finish
- jmp disk_load_error
-
-disk_load_chs:
-
- mov bx, STR_CHS
- call print_string
- call print_nextline
- jmp $
-
- mov bx,0 ;target es:bx
- mov es,bx
- mov bx,0x7e00
-
- mov al,50 ;number of sectors to read
- mov ah,0x02 ;BIOS read sector func
-
- mov cl,2 ; sector
- mov ch,0 ; cylinder
-
- mov dl,[BOOT_DRIVE]
- mov dh,0 ;head
-
- int 0x13 ;bios interrupt
-
- jnc disk_load_finish
-
-disk_load_error:
-
- call print_nextline
- mov bx, STR_ERROR
- call print_string
- call print_nextline
- jmp $
-
-disk_load_finish:
-
- call print_nextline
- mov bx, STR_DONE
- call print_string
- call print_nextline
-
-
- popa
- 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 0x7e00
- dw 0x7e00 ; target addr. offset
- dw 0x0000 ; target addr. sector
-
- dd 1 ; first sector to read
- dd 0
diff --git a/boot1/mbr.asm b/boot1/mbr.asm
deleted file mode 100644
index c0a555d..0000000
--- a/boot1/mbr.asm
+++ /dev/null
@@ -1,106 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;
-; FOOL-OS Master Boot Record
-;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;
-; This is the Master Boot Record for x86
-;
-; We are limited to 512 bytes (one sector)
-; minus 64 bytes for the partition table
-; minus 2 bytes formagic number (0xaa55)
-;
-; all we do here is :
-;
-; 1. Put the Stack at 0x07bff (it is counting down)
-; 2. Remeber Boot Drive at [BOOT_DRIVE]
-; 3. Print PR message and Boot Drive number
-; 4. Load Second Stage Bootloader from Boot Drive at next sector
-; 5. Show Info Message after successfull loading
-; 6. Jump to 2nd Stage Boot Loader
-;
-; Refer to a memory map as needed:
-; http://wiki.osdev.org/Memory_Map_(x86)
-
-; Everything here is 16bit
-[bits 16]
-
-; Per definition this will be loaded by the BIOS at 0x7c00
-[org 0x7c00]
-
-; skip constants and includes
-jmp stage1
-
-; string constants (null terminated)
-STR_1: db "Fool Loader Stage 1. v0.1",0
-STR_2: db "Starting Stage 2",0
-STR_BOOT: db "Boot drive: ",0
-
-; some space (one byte) to remember the Boot Drive
-BOOT_DRIVE: db 0xff
-
-; include print and disk load routines
-%include "print_string_16.asm"
-%include "disk_load_16.asm"
-
-; Here we start!
-stage1:
-
- ; first of all, setup the stack (right under our MBR)
- ; ~30KB space guaranteed
- mov bp,0x07bff
- mov sp,bp
-
- ; remember BOOT_DRIVE (as was set by BIOS in dl)
- mov [BOOT_DRIVE],dl
-
- ; clear screen and print PR message
- call print_clear
- call print_nextline
-
- mov bx, STR_1
- call print_string
- call print_nextline
-
-
- ; print bootdrive number
- mov bx, STR_BOOT
- call print_string
-
- mov al,[BOOT_DRIVE]
- call print_hex_byte
- call print_nextline
-
-
- ; Actually Load the Second Stage Bootloader!
- call disk_load_16
-
-
- ; show info message that 2nd Stage was loaded
- mov bx, STR_2
- call print_string
- call print_nextline
- call print_nextline
-
-
- ; save Boot Drive in dl for second stage
- mov dl,[BOOT_DRIVE]
-
-
- ; jump to the next sector where we loaded the 2nd stage
- jmp 0x7e00
-
-
- ; nothing essential under this line
- ; we need this to follow some mbr standards
-
- ; fill at least 4x16byte with zeroes. (partition table)
- ; (otherwise my Acer Aspire will not boot)
- times 64 db 0x0
-
- ; fill rest with zeroes
- times 510-($-$$) db 0x0
-
- ; magic number so we get identified as MBR
- dw 0xaa55
-
diff --git a/boot1/print_string_16.asm b/boot1/print_string_16.asm
deleted file mode 100644
index 9f81a87..0000000
--- a/boot1/print_string_16.asm
+++ /dev/null
@@ -1,115 +0,0 @@
-[bits 16]
-
-BLANK:
- db 0x12
-
-SPACE:
- db " ",0
-
-;print_string routine ([bx])
-;this routine will print a null terminated string at [bx] to the screen.
-print_string:
-
- pusha ;push all registers
- mov ah,0x0e
-
- print_string_loop:
-
- ;check if value at [bx] is "\0" (end of string)
- mov cl,[bx]
- cmp cl,0
- je print_string_finish
-
- ;otherwise instruct BIOS to print the current char
- mov al,cl
- int 0x10
-
- ;proceed with next char
- inc bx
- jmp print_string_loop
-
- print_string_finish:
-
- popa ;pop all registers
- ret ;return to caller
-
-print_clear:
-
-pusha
- mov ah,0x6 ;func
- mov al,0 ;scroll one line
- mov bh,[BLANK] ;blank char
-
- mov ch,0 ;upper left corner
- mov cl,0
- mov dh,20 ;lower right corner
- mov dl,40
- int 0x10
-
- mov ah,0x2
- mov bh,0
- mov dl,0
- mov dh,20
- int 0x10
-popa
-
-print_nextline:
-
- pusha
-
- mov ah,0x6 ;func
- mov al,1 ;scroll one line
- mov bh,[BLANK] ;blank char
-
- mov ch,0 ;upper left corner
- mov cl,0
- mov dh,20 ;lower right corner
- mov dl,40
- int 0x10
-
-
- mov ah,0x3
- mov bh,0
- int 0x10
-
-
- mov ah,0x2
- mov dl,0
- int 0x10
-
- mov bx,SPACE
- call print_string
-
- popa
- ret
-
-
-;print byte from al to screen
- print_hex_byte:
-
- pusha
-
- mov [.temp],al
- shr al,4
- cmp al,10
- sbb al,69h
- das
-
- mov ah,0Eh
- int 10h
-
- mov al,[.temp]
- ror al,4
- shr al,4
- cmp al,10
- sbb al,69h
- das
-
- mov ah,0Eh
- int 10h
-
-popa
-
- ret
-
- .temp db 0