added svn:ignore to a few directories; kernel linked to virtual address 0xE000_0000 and running there in segmented mode

git-svn-id: svn://anubis/hos/trunk@15 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
josh 2009-06-25 15:02:46 +00:00
parent 13f467ca47
commit 1ba82ac77f
2 changed files with 93 additions and 16 deletions

View File

@ -1,25 +1,101 @@
%define MULTIBOOT_HEADER_MAGIC 0x1BADB002
%define MULTIBOOT_HEADER_FLAGS 0x3
; boot.asm
; Author: Josh Holtrop
; Date: 2009-06-25
; Adapted from HOS 0.16 source
%define MULTIBOOT_HEADER_MAGIC 0x1BADB002
%define MULTIBOOT_HEADER_FLAGS 0x00010003
%define VIRTUAL_OFFSET 0xE0000000 ; kernel virtual addr
%define TEMPORARY_STACK_PHYSICAL 0x01000000-4 ; top of first 16MB
%define TEMPORARY_STACK_VIRTUAL TEMPORARY_STACK_PHYSICAL + VIRTUAL_OFFSET
; Get these symbols from the linker
extern _end, _bss
;**************************************************************************
;* Begin execution from the bootloader here *
;**************************************************************************
[global start]
start:
jmp multiboot_entry
align 4
jmp multiboot_entry ; jump over the multiboot header block
;**************************************************************************
;* Multiboot header data block *
;**************************************************************************
align 4
multiboot_header:
; magic
dd MULTIBOOT_HEADER_MAGIC
; flags
dd MULTIBOOT_HEADER_FLAGS
; checksum
dd -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
dd MULTIBOOT_HEADER_MAGIC ; magic
dd MULTIBOOT_HEADER_FLAGS ; flags
dd -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) ; checksum
dd multiboot_header - VIRTUAL_OFFSET ; header_addr
dd start - VIRTUAL_OFFSET ; load_addr
dd _bss - VIRTUAL_OFFSET ; load_end_addr
dd _end - VIRTUAL_OFFSET ; bss_end_addr
dd multiboot_entry - VIRTUAL_OFFSET ; entry_addr
;**************************************************************************
;* Resume execution *
;**************************************************************************
multiboot_entry:
mov ax, 0x0700 + 'J'
mov [0xB8000+160*10+2*2], ax
lgdt [gdtr_tmp32-VIRTUAL_OFFSET] ; load temporary GDTR
jmp KERNEL_CODE_32_TMP_SEG:segmented_start
looplbl:
hlt
jmp looplbl
;**************************************************************************
;* At this point address 0xE000_0000 is mapped to physical address 0x0 *
;**************************************************************************
segmented_start:
mov cx, KERNEL_DATA_32_TMP_SEG
mov ss, cx
mov ds, cx
mov es, cx
mov gs, cx
mov fs, cx
mov esp, TEMPORARY_STACK_VIRTUAL-4 ; set up temporary stack space
mov ax, 0x0700 + 'J'
mov [VIRTUAL_OFFSET+0xB8000+160*8+4*2], ax
idle_loop:
hlt
jmp idle_loop
;-------------------------------------------------------
[section .rodata]
gdtr_tmp32:
dw gdt_end_tmp32-gdt_tmp32-1
dd gdt_tmp32-VIRTUAL_OFFSET
gdt_tmp32: ; 0 = null descriptor
dd 0
dd 0
; a base of 0x2000_0000, when added to 0xE000_0000 will produce
; 0x0000_0000 physical before paging in effect
KERNEL_CODE_32_TMP_SEG equ $-gdt_tmp32 ; 8
db 0xff ;limit 7:0
db 0xff ;limit 15:8
db 0x00 ;base 7:0
db 0x00 ;base 15:8
db 0x00 ;base 23:16
db 0x9a ;access
db 0xcf ;flags / limit 19:16
db 0x20 ;base 31:24
KERNEL_DATA_32_TMP_SEG equ $-gdt_tmp32 ; 16
db 0xff ;limit 7:0
db 0xff ;limit 15:8
db 0x00 ;base 7:0
db 0x00 ;base 15:8
db 0x00 ;base 23:16
db 0x92 ;access
db 0xcf ;flags / limit 19:16
db 0x20 ;base 31:24
gdt_end_tmp32:

View File

@ -1,7 +1,8 @@
OUTPUT_FORMAT(binary)
ENTRY(start)
SECTIONS
{
.text 0x00100000 : {
.text 0xE0100000 : {
code = .; _code = .; __code = .;
*(.text)
}