Import backup from 2003-08-11
This commit is contained in:
parent
9035beda29
commit
1c3e9ebdc4
20
bootdef.inc
20
bootdef.inc
@ -1,9 +1,17 @@
|
|||||||
|
|
||||||
%define BOOT_FAT_SEG 0x07E0 ;right after boot sector
|
%define VERSION "0.1.2" ;HOS version
|
||||||
%define BOOT_ROOT_SEG 0x0900 ;right after FAT
|
|
||||||
%define BOOT_STAGE2_SEG 0x0B00 ;right after KERNEL_SEG
|
%define BOOT_FAT_SEG 0x07E0 ;right after boot sector
|
||||||
%define BOOT_STAGE2_ADD 0xB000 ;address of stage2 to jump to, org at
|
%define BOOT_ROOT_SEG 0x0900 ;right after FAT
|
||||||
%define BOOT_KERNEL_SEG 0x0AC0 ;right after ROOT_DIR
|
%define BOOT_KERNEL_SEG 0x0AC0 ;right after ROOT_DIR
|
||||||
%define BOOT_KERNEL_ADD 0x100000 ;final pmode kernel destination - physical
|
%define BOOT_STAGE2_SEG 0x0B00 ;right after KERNEL_SEG
|
||||||
|
%define BOOT_STAGE2_ADD 0xB000 ;address of stage2 to jump to, org at
|
||||||
|
%define BOOT_KERNEL_ADD 0x100000 ;final pmode kernel destination - physical
|
||||||
|
|
||||||
|
%define BOOT_DATA_SEG 0x9000 ;data gathered by stage2 loader goes here
|
||||||
|
|
||||||
|
%define BOOT_HASRD 0x0000 ;1
|
||||||
|
|
||||||
|
|
||||||
|
%define BOOT_RD_ADD 0x200000 ;2mb for ram disk
|
||||||
|
%define BOOT_DRIVE 0x7C24 ;1 - boot drive
|
||||||
|
24
kernel.asm
24
kernel.asm
@ -1,7 +1,11 @@
|
|||||||
|
|
||||||
|
%include "bootdef.inc"
|
||||||
|
|
||||||
bits 32
|
bits 32
|
||||||
|
|
||||||
org 0x100000
|
org BOOT_KERNEL_ADD
|
||||||
|
|
||||||
|
call cls
|
||||||
|
|
||||||
mov esi, msg
|
mov esi, msg
|
||||||
mov edi, 0xb8000
|
mov edi, 0xb8000
|
||||||
@ -19,6 +23,24 @@ msg_done:
|
|||||||
|
|
||||||
jmp $
|
jmp $
|
||||||
|
|
||||||
|
cls:
|
||||||
|
push eax
|
||||||
|
push ecx
|
||||||
|
push edi
|
||||||
|
|
||||||
|
mov edi, 0xb8000
|
||||||
|
mov ecx, 2000
|
||||||
|
mov eax, 0x0700
|
||||||
|
cls_loop:
|
||||||
|
stosw
|
||||||
|
loop cls_loop
|
||||||
|
|
||||||
|
pop edi
|
||||||
|
pop ecx
|
||||||
|
pop eax
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
msg:
|
msg:
|
||||||
db "This kernel is located at 0x100000! Aren't you glad?", 0
|
db "This kernel is located at 0x100000! Aren't you glad?", 0
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ brFSID DB 'FAT12 ' ; 0036h - File System ID
|
|||||||
;------------------------------------------------------------------------
|
;------------------------------------------------------------------------
|
||||||
|
|
||||||
start:
|
start:
|
||||||
|
jmp 0:jmphere ;ensure that cs=0 and ip=0x7c...
|
||||||
|
jmphere:
|
||||||
;dl=drive number, save it!
|
;dl=drive number, save it!
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
@ -133,6 +135,8 @@ error:
|
|||||||
jmp $ ;halt! no kernel file found!
|
jmp $ ;halt! no kernel file found!
|
||||||
|
|
||||||
found_file: ;ds:si points to root dir entry
|
found_file: ;ds:si points to root dir entry
|
||||||
|
xor ax, ax
|
||||||
|
mov gs, ax
|
||||||
mov ax, BOOT_STAGE2_SEG
|
mov ax, BOOT_STAGE2_SEG
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
@ -148,7 +152,7 @@ readstage2_loop:
|
|||||||
push ax
|
push ax
|
||||||
call getCHSfromCluster
|
call getCHSfromCluster
|
||||||
mov ax, 0x0201
|
mov ax, 0x0201
|
||||||
mov dl, 0 ;[brDrive]
|
mov dl, [gs:BOOT_DRIVE]
|
||||||
xor bx, bx
|
xor bx, bx
|
||||||
int 0x13
|
int 0x13
|
||||||
mov bx, es
|
mov bx, es
|
||||||
|
148
stage2.asm
148
stage2.asm
@ -33,6 +33,8 @@ error:
|
|||||||
jmp $ ;halt! no kernel file found!
|
jmp $ ;halt! no kernel file found!
|
||||||
|
|
||||||
found_file: ;ds:si points to root dir entry of kernel file
|
found_file: ;ds:si points to root dir entry of kernel file
|
||||||
|
xor ax, ax
|
||||||
|
mov gs, ax
|
||||||
mov ax, [ds:si+26]
|
mov ax, [ds:si+26]
|
||||||
mov bx, BOOT_FAT_SEG
|
mov bx, BOOT_FAT_SEG
|
||||||
mov ds, bx ;ds points to beginning of FAT
|
mov ds, bx ;ds points to beginning of FAT
|
||||||
@ -44,7 +46,7 @@ readkernel_loop:
|
|||||||
push ax
|
push ax
|
||||||
call getCHSfromCluster
|
call getCHSfromCluster
|
||||||
mov ax, 0x0201
|
mov ax, 0x0201
|
||||||
mov dl, 0 ;[brDrive]
|
mov dl, [gs:BOOT_DRIVE]
|
||||||
mov bx, BOOT_KERNEL_SEG
|
mov bx, BOOT_KERNEL_SEG
|
||||||
mov es, bx
|
mov es, bx
|
||||||
xor bx, bx
|
xor bx, bx
|
||||||
@ -81,10 +83,146 @@ odd_cluster:
|
|||||||
got_cluster:
|
got_cluster:
|
||||||
jmp readkernel_loop
|
jmp readkernel_loop
|
||||||
|
|
||||||
readkernel_done:
|
;------------------------------------------------------
|
||||||
|
readkernel_done: ;-------------put more real mode init stuff here!
|
||||||
|
;----ask to load RD from floppy
|
||||||
|
mov ax, 0xb800
|
||||||
|
mov es, ax
|
||||||
|
xor ax, ax
|
||||||
|
mov ds, ax
|
||||||
|
xor di, di
|
||||||
|
mov cx, 2000
|
||||||
|
mov ax, 0x0700
|
||||||
|
cls_loop:
|
||||||
|
stosw
|
||||||
|
loop cls_loop
|
||||||
|
|
||||||
|
mov dx, 0x3d4 ;move cursor off screen...
|
||||||
|
mov al, 0x0e
|
||||||
|
out dx, al
|
||||||
|
inc dx
|
||||||
|
mov al, 0xff
|
||||||
|
out dx, al
|
||||||
|
dec dx
|
||||||
|
mov al, 0x0f
|
||||||
|
out dx, al
|
||||||
|
inc dx
|
||||||
|
out dx, al
|
||||||
|
|
||||||
|
xor di, di
|
||||||
|
mov si, txt_welcome
|
||||||
|
mov ah, 0x1f
|
||||||
|
call puts
|
||||||
|
|
||||||
|
mov di, 160
|
||||||
|
mov si, txt_rd1
|
||||||
|
mov ah, 7
|
||||||
|
call puts
|
||||||
|
|
||||||
|
mov si, txt_rd2
|
||||||
|
mov di, 160*2
|
||||||
|
call puts
|
||||||
|
|
||||||
|
mov di, 160*3
|
||||||
|
mov si, txt_input
|
||||||
|
call puts
|
||||||
|
|
||||||
|
get_rd:
|
||||||
|
xor ax, ax
|
||||||
|
int 0x16
|
||||||
|
cmp al, '1'
|
||||||
|
jz got_rd
|
||||||
|
cmp al, '2'
|
||||||
|
jnz get_rd
|
||||||
|
got_rd:
|
||||||
|
stosb
|
||||||
|
sub al, '1'
|
||||||
|
push ds
|
||||||
|
mov bx, BOOT_DATA_SEG ;segment for data to send kernel
|
||||||
|
mov ds, bx
|
||||||
|
mov [ds:BOOT_HASRD], al
|
||||||
|
pop ds ;ds=0
|
||||||
|
cmp al, 0 ;dont load rd
|
||||||
|
jz no_rd
|
||||||
|
|
||||||
|
mov cx, 80
|
||||||
|
mov edi, 0xb8000+160*4
|
||||||
|
filler_loop:
|
||||||
|
mov word [ds:edi], 0x0400+176
|
||||||
|
inc edi
|
||||||
|
inc edi
|
||||||
|
loop filler_loop
|
||||||
|
mov cx, 80 ;80 cylinders to read
|
||||||
|
xor si, si
|
||||||
|
mov edi, BOOT_RD_ADD ;ram disk address
|
||||||
|
read_cylinder:
|
||||||
|
push cx
|
||||||
|
mov bx, 0x0100
|
||||||
|
mov es, bx
|
||||||
|
xor bx, bx
|
||||||
|
mov ax, 0x0224
|
||||||
|
mov cx, si
|
||||||
|
mov ch, cl
|
||||||
|
mov cl, 1
|
||||||
|
xor dx, dx
|
||||||
|
mov dl, [gs:BOOT_DRIVE]
|
||||||
|
int 0x13
|
||||||
|
|
||||||
|
mov ebx, 0xb8000
|
||||||
|
add bx, si
|
||||||
|
shl bl, 1
|
||||||
|
mov word [ds:ebx+160*4], 0x0200+219
|
||||||
|
|
||||||
|
push si
|
||||||
|
mov esi, 0x1000
|
||||||
|
mov cx, 0x2400
|
||||||
|
copydisk_loop:
|
||||||
|
mov ax, [ds:esi]
|
||||||
|
inc esi
|
||||||
|
inc esi
|
||||||
|
mov [ds:edi], ax
|
||||||
|
inc edi
|
||||||
|
inc edi
|
||||||
|
loop copydisk_loop
|
||||||
|
|
||||||
|
pop si ;what cylinder# we are on...
|
||||||
|
inc si
|
||||||
|
pop cx
|
||||||
|
loop read_cylinder
|
||||||
|
|
||||||
|
no_rd:
|
||||||
|
xor ax, ax
|
||||||
|
mov ds, ax
|
||||||
|
mov ax, 0xb800
|
||||||
|
mov es, ax
|
||||||
|
mov si, txt_vesa
|
||||||
|
mov di, 160*5
|
||||||
|
mov ah, 7
|
||||||
|
call puts
|
||||||
|
|
||||||
|
|
||||||
|
xor ax, ax
|
||||||
|
int 0x16
|
||||||
|
|
||||||
jmp go_pm
|
jmp go_pm
|
||||||
|
|
||||||
|
puts:
|
||||||
|
lodsb
|
||||||
|
or al, al
|
||||||
|
jz puts_done
|
||||||
|
stosb
|
||||||
|
mov al, ah
|
||||||
|
stosb
|
||||||
|
jmp puts
|
||||||
|
puts_done:
|
||||||
|
ret
|
||||||
|
|
||||||
|
txt_welcome: db " Welcome to HOS v", VERSION, "! ", 0
|
||||||
|
txt_rd1: db "1. Do not load an initial ram disk", 0
|
||||||
|
txt_rd2: db "2. Load initial ram disk from floppy", 0
|
||||||
|
txt_input: db "Enter your selection: ", 0
|
||||||
|
txt_vesa: db "VESA version: ", 0
|
||||||
|
|
||||||
;------------------------------------------------------
|
;------------------------------------------------------
|
||||||
getCHSfromCluster:
|
getCHSfromCluster:
|
||||||
;input: ax=lba of sector on floppy (0-2879)
|
;input: ax=lba of sector on floppy (0-2879)
|
||||||
@ -148,12 +286,10 @@ pmode:
|
|||||||
mov ax, KERNEL_DATA
|
mov ax, KERNEL_DATA
|
||||||
mov es, ax
|
mov es, ax
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
|
mov fs, ax
|
||||||
|
mov gs, ax
|
||||||
jmp KERNEL_CODE:BOOT_KERNEL_ADD
|
jmp KERNEL_CODE:BOOT_KERNEL_ADD
|
||||||
|
|
||||||
kernel: db "KERNEL BIN"
|
kernel: db "KERNEL BIN"
|
||||||
k_count: dw 0
|
|
||||||
|
|
||||||
times 510-($-$$) db 0
|
|
||||||
|
|
||||||
db 0x55, 0xaa
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user