diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-08-27 14:42:44 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-08-27 14:42:44 +0200 |
| commit | 2d20d0d1f720e064b29aa3578aa33b5146a954e5 (patch) | |
| tree | ca0adbc37cb1408ae74bb7ed525b462690baa73e | |
| parent | 5e48d8259fb2857ad4441de77cbacddd50a21ec0 (diff) | |
cleanup boot directory
| -rw-r--r-- | boot/boot16_entry.asm | 11 | ||||
| -rw-r--r-- | boot/common.asm | 115 | ||||
| -rw-r--r-- | boot/mbr.asm | 93 | ||||
| -rw-r--r-- | boot/mbr16.asm | 79 | ||||
| -rw-r--r-- | boot/print16.asm | 28 | ||||
| -rw-r--r-- | boot/test.asm | 48 |
6 files changed, 35 insertions, 339 deletions
diff --git a/boot/boot16_entry.asm b/boot/boot16_entry.asm deleted file mode 100644 index e8d63be..0000000 --- a/boot/boot16_entry.asm +++ /dev/null @@ -1,11 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;; Miguel's FoolOS Helper Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; this will be compiled to an object file and linked with the boot loader -; to simplify the entrance! -; -; -[bits 16] -[extern boot_main] -call boot_main ; jumps in the world of C diff --git a/boot/common.asm b/boot/common.asm deleted file mode 100644 index 323b54f..0000000 --- a/boot/common.asm +++ /dev/null @@ -1,115 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;; Miguel's FoolOS Helper Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -;print_string -;print_hex -;disk_load -; -; -; -; - -[bits 16] - -;/* -;;global data -;STR_HEX_OUT: -; db "0x0000",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_hex routine (dx) -;;will print the value of the bx register as hex to the screen -;print_hex: -; -; pusha -; -; ;begin with last hex val (hex_out[5]) -; mov bx,STR_HEX_OUT+5 -; -; ;lets loop throuth all 4 'digits' -; print_hex_loop: -; -; ;get least significan hex digit to cx -; mov cx,dx -; and cx,0x000F -; -; ;check range (0-9 vs a-f) -; cmp cx,10 -; jl print_hex_setnum -; -; ;set hex a-f -; mov al,'A'-10 -; add al,cl -; jmp print_hex_al -; -; ;set hex 0-9 -; print_hex_setnum: -; mov al,'0' -; add al,cl -; -; ; set hex_out[bx] to al -; print_hex_al: -; mov [bx],al -; -; ;proceed with the next significant hex 'digit' -; dec bx -; shr dx,4 -; -; ;check if finished (otherwise loop) -; cmp bx,STR_HEX_OUT+1 -; jne print_hex_loop -; -; ;output complete hex string and return to caller -; mov bx,STR_HEX_OUT -; call print_string -; popa -; ret -; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;*/ - -;disk_load routune (load dh sectors from drive dl to es:bx) -disk_load: - - pusha - - mov ah,0x02 ;BIOS read sector func - mov al,dh ;read dh sectors (amount) - mov ch,0x00 ;cyl 0 - mov dh,0x00 ;head 0 - mov cl,0x02 ;start at sector 2 - - int 0x13 ;bios interrupt - - popa - ret - diff --git a/boot/mbr.asm b/boot/mbr.asm index 32f1a6f..2beac7b 100644 --- a/boot/mbr.asm +++ b/boot/mbr.asm @@ -6,12 +6,31 @@ ; ; we have just been loaded by the BIOS and are in 16-bits real mode! ; -; THIS IS THE CENTRAL FILE OF THE BOOTLOADER, after we finished we -; are inside the C kernel! +; THIS IS THE CENTRAL FILE OF THE BOOTLOADER, +; +; after we are through, +; the following work has been accomplished (chronologically): +; +; * BOOT_DRIVE is set +; +; * 50 sectors of our kernel are loaded at KERNEL_OFFSET from floppy +; +; * memoru map is available at MEMMAP_OFFSET +; (look at MEMMEP_SIZE_OFFSET for number of entries) +; +; * the vesa mode specified by VESA_MODE_SELECT is set up +; (at VESA_MODES, and VESA_MODE_INFO additional info structs are available) +; +; * 32-bit protected mode was set up. +; +; * A20 gate is open +; +; * PICs are configured +; +; * we are inside the C kernel! ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;we want 16-bit instructions, before we switch to 32-bit protected mode. ;define origin of boot record in memory: 0x7c00 ;this is where the BIOS per definition will put the first @@ -19,42 +38,34 @@ ;The Boot record is identified by the last 2 magic bytes: 0xaa55 (?) [org 0x7c00] -;define where we will load our kernel into memory +;define where we will load our kernel into memory and some +;other memory locations KERNEL_OFFSET equ 0x1000 MEMMAP_SIZE_OFFSET equ 0x7c00+0x600 MEMMAP_OFFSET equ 0x7c00+0x400 VESA_MODES equ 0x8300 VESA_MODE_INFO equ 0x8400 VESA_MODE_SELECT equ 0x4114 -;VESA_MODE_SELECT equ 0x411A +;we want 16-bit instructions, before we switch to 32-bit protected mode. [bits 16] jmp boot_16 ;start boot process +;SOME Global Data, mainly strings BOOT_DRIVE: db 0xff - -;SOME Global Data, mainly strings STR_VERSION: db "v0.2~",0 VESA_CHECK: db "vesa check.",0 -;STR_PROT: -; db "32-bit PM",0 -;STR_LOADED: -; db "loaded",0 - ;lets put our temporary GDT (Global Descriptor Table) here %include "boot/GDT.asm" ;include 16-bit real mode routines (print_string, disk_load) -%include "boot/common.asm" -%include "boot/print16.asm" - -;include 32-bit Protected Mode routines (print_string_pm,print_hex_pm) -;%include "boot/common_pm.asm" +%include "boot/disk_load_16.asm" +%include "boot/print_string_16.asm" ;include our routines for switching to 32-bit protected mode %include "boot/pm.asm" @@ -62,7 +73,7 @@ VESA_CHECK: ;pic mapping %include "boot/pic.asm" -;memory map +;get memory map %include "boot/memmap.asm" ;;;;;;;; BOOT 16-bit real ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -82,21 +93,12 @@ boot_16: ;remember BOOT_DRIVE (as was set by BIOS) mov [BOOT_DRIVE],dl - ;print FoolOS version info -; mov bx, STR_VERSION -; call print_string - - ;Load the KERNEL + ;Load the KERNEL (50 sectors starting at sector 2) mov bx,KERNEL_OFFSET mov dh, 50 ;50 sectors! mov dl, [BOOT_DRIVE] call disk_load - ;print info message that kernel was loaded -; mov bx, STR_LOADED -; call print_string - - ;get memory map from bios before we enter 32 bit protected mode mov ax,0 ; set target address in es:di (0:offset) mov es,ax @@ -104,7 +106,8 @@ boot_16: call BiosGetMemoryMap ; this will also put the number of entries ; of the memory map at MEMMAP_SIZE_OFFSET - ;get vesa modes! + ;VESA: also setup vesa stuff before entering 32 bit protected mode + ;VESA: get all available vesa modes! mov ax,0 ; set target address in es:di (0:offset) mov es,ax mov di,VESA_MODES @@ -119,7 +122,7 @@ boot_16: vesa_ok: ; - ;get info on mode of interest + ;VESA: get vesa info on mode of interest mov ax,0 ; set target address in es:di (0:offset) mov es,ax mov di,VESA_MODE_INFO @@ -134,7 +137,7 @@ boot_16: jmp vesa_err2 vesa_ok2: - ;finally switch to the mode of choice! + ;VESA: finally switch to the mode of choice! mov ax,0x4f02 ;vesa function: Set Mode mov bx,VESA_MODE_SELECT int 0x10 @@ -148,11 +151,6 @@ boot_32_pm: ; we could do ALL This inside the kernel!!!!!! TODO - ;print info message that we are in protected mode! -; mov ecx,160 -; mov ebx,STR_PROT -; call print_string_pm - ;enable A20 ;http://www.brokenthorn.com/Resources/OSDev9.html ;Method 3.1: Enables A20 through keyboard controller @@ -162,32 +160,11 @@ boot_32_pm: ;pic setup call pic_setup - call KERNEL_OFFSET ;jump into our Kernel it - -;idt_descriptor: -; dw idt_end-idt_start-1 -; dd KERNEL_OFFSET -;;;; DEBUGGING STUFF -;times 8 db '@' -;dw interrupt -;times 8 db '@' -;dw interrupt2 -;times 8 db '@' + call KERNEL_OFFSET ;jump into our Kernel! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;so we get identified as MBR times 510-($-$$) db 0 dw 0xaa55 -;interrupt descriptor table (hardcoded address of interrupts:) -;idt_start: -;times 33 db 0x50,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0 -;db 0x59,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0 -;times 253 db 0x50,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0 -;idt_end: - - - - diff --git a/boot/mbr16.asm b/boot/mbr16.asm deleted file mode 100644 index 1abc97d..0000000 --- a/boot/mbr16.asm +++ /dev/null @@ -1,79 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; FoolOS Boot Loader for 16bit entry in C -; -; Copyright 2014 M.Idziorek <m.i@gmx.at> -; -; we have just been loaded by the BIOS and are in 16-bits real mode! -; -; THIS IS THE CENTRAL FILE OF THE 16bit BOOTLOADER, after we finished we -; are inside 16bit C code! -; -;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;we want 16-bit instructions, before we switch to 32-bit protected mode. - -;define origin of boot record in memory: 0x7c00 -;this is where the BIOS per definition will put the first -;512 bytes of data from the boot device -;The Boot record is identified by the last 2 magic bytes: 0xaa55 (?) -[org 0x7c00] - -;define where we will load our "C binary" -BOOT_OFFSET equ 0x1000 - -[bits 16] -jmp boot_16 ;start boot process - -BOOT_DRIVE: - db 0xff - -;SOME Global Data, mainly strings -STR_VERSION: - db "~ Fool Loader 16-bit, v0.1 ~",0 - -;include 16-bit real mode routines (print_string, print_hex, disk_load) -%include "boot/common.asm" -%include "boot/print16.asm" - -;;;;;;;; BOOT 16-bit real ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;lets start - -boot_16: - - ;print version info - mov bx, STR_VERSION - call print_string - - ;setup the stack - mov bp,0x8000 - mov sp,bp - - ;remember BOOT_DRIVE (as was set by BIOS) - mov [BOOT_DRIVE],dl - - ;Load BOOT LOADER from second sector (max 50 sectors) - mov bx,BOOT_OFFSET ;destination in ram - mov dh, 50 ;50 sectors - mov dl, [BOOT_DRIVE] ;source drive - call disk_load - - call BOOT_OFFSET ;jump into our C code - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;so we get identified as MBR -times 510-($-$$) db 0 -dw 0xaa55 - -;interrupt descriptor table (hardcoded address of interrupts:) -;idt_start: -;times 33 db 0x50,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0 -;db 0x59,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0 -;times 253 db 0x50,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0 -;idt_end: - - - - diff --git a/boot/print16.asm b/boot/print16.asm deleted file mode 100644 index 5d8ad5c..0000000 --- a/boot/print16.asm +++ /dev/null @@ -1,28 +0,0 @@ -[bits 16] - -;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 diff --git a/boot/test.asm b/boot/test.asm deleted file mode 100644 index 62110b6..0000000 --- a/boot/test.asm +++ /dev/null @@ -1,48 +0,0 @@ -[org 0x7c00] - -[bits 16] -jmp boot_16 ;start boot process - -STR_VERSION: - - db "FoolOs~",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 - -boot_16: - - mov bx, STR_VERSION - call print_string - - jmp boot_16 - -times 510-($-$$) db 0 -dw 0xaa55 - - - |
