- add bootloader for Rock Creek

git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@143 315a16e6-25f9-4109-90ae-ca3045a26c18
This commit is contained in:
stefan 2010-09-07 21:04:31 +00:00
parent b209403ccb
commit e482442e36
5 changed files with 69 additions and 44 deletions

View file

@ -10,8 +10,6 @@ ASMFLAGS = -fbin
# other implicit rules
%.o : %.c
$(CC) -c $(CFLAGS) -o $@ $<
%.o : %.asm
$(ASM) $(ASMFLAGS) -o $@ $<
default:
$(MAKE) all
@ -22,8 +20,13 @@ all:
make_initrd: make_initrd.o
$(CC) $(CFLAGS) -o make_initrd $< $(LDFLAGS)
SCC:
$(ASM) $(ASMFLAGS) -o scc_entry.bin scc_entry.asm
scc_setup.bin: scc_setup.asm
$(ASM) $(ASMFLAGS) -o $@ $<
reset_vector.bin: reset_vector.o
ld --oformat binary -Ttext 0 -melf_i386 -o $@ $<
SCC: scc_setup.bin reset_vector.bin
cp ../metalsvm.bin .
chmod a-x *.bin
. ./prepare.sh

View file

@ -1,2 +1,3 @@
0x00090200 scc_setup.bin
0x00100000 metalsvm.bin
0xfffff000 scc_entry.bin
0xfffff000 reset_vector.bin

View file

@ -1,2 +1,2 @@
# pid object file
0x00 ./metalsvm.obj
# pid mch-route mch-dest-id mch-offset-base testcase
0x00 0x00 6 0x00 metalsvm.obj

39
tools/reset_vector.S Normal file
View file

@ -0,0 +1,39 @@
/*
* QEMU Boot sector to launch a preloaded Linux kernel
* Copyright (c) 2004 Fabrice Bellard
*/
#define LOAD_SEG 0x9000
// define CONFIG_MCEMU_DEBUG 1
.code16
.text
.globl _start
.org 0x0000
.ascii "MetalSVM Boot sector"
_realstart:
#ifdef CONFIG_MCEMU_DEBUG
movl $27, %eax
movw $0xff8, %dx
outl %eax, %dx
movl $0x0010, %eax
movw $0xffc, %dx
outl %eax, %dx
#endif
cli
cld
mov $LOAD_SEG, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
mov %ax, %ss
mov $0x8ffe, %sp
ljmp $LOAD_SEG + 0x20, $0
.org 0x0ff0
_start:
jmp _realstart
_end:
.fill 4096 - _end, 1, 0

View file

@ -16,15 +16,18 @@
;
; This file is part of metalsvm.
; This is the kernel's entry point. We could either call main here,
; or we can use this to setup the stack or other nice stuff, like
; perhaps setting up the GDT and segments. Please note that interrupts
; are disabled at this point: More on interrupts later!
; This is the kernel's entry point. We switch to the protected mode
; and jump to our kernel.
[BITS 16]
SECTION .text
GLOBAL _start
ORG 0
ORG 0x90200
_start:
jmp _realstart
msg db "Hello from MetalSVM bootloader!!",0
struc GDT_STR
s0_15: resw 1
b0_15: resw 1
@ -35,8 +38,8 @@ ORG 0
endstruc
gdt_start dw gdt_size
gdt_ptr dd 0
gdt_ptr dd dummy_descriptor
dummy_descriptor: istruc GDT_STR
at s0_15, dw 0
at b0_15, dw 0
@ -56,7 +59,7 @@ ORG 0
at b24_31, db 0
iend
; 4GB 32-bit data, 92h = 10010010b = Presetn , DPL 00, No System, Data Read/Write
; 4GB 32-bit data, 92h = 10010010b = Present, DPL 00, No System, Data Read/Write
data32_descriptor: istruc GDT_STR
at s0_15, dw 0x0ffff
at b0_15, dw 0
@ -66,8 +69,7 @@ ORG 0
at b24_31, db 0
iend
gdt_size equ $-(dummy_descriptor)
msg db "0ello from MetalSVM bootloader!!",0
gdt_size equ $ - (dummy_descriptor) - 1
enable_A20:
call a20wait
@ -111,37 +113,23 @@ a20wait2:
ret
_realstart:
cli
cld
lgdt [gdt_start]
mov [msg], BYTE 'H'
mov ax, dummy_descriptor
mov [gdt_ptr], ax
mov bx, gdt_start
lgdt [bx]
; call enable_A20
; switch to protected mode by setting PE bit
; we also clear the VM bit
mov eax, cr0
or eax, 0x1
and eax, 0x7FFFFFFF
or al, 0x1
mov cr0, eax
; far jump
db 0x66 ; Prefix for 32-bit
db 0xea ; Opcode for far jump
dd _pmstart ; Offset to start, 32-bit
dw 0x08 ; This is the selector for CODE32_DESCRIPTOR,
; assuming that start address resides in this segment
; far jump to the 32bit code
jmp dword 0x08 : _pmstart
[BITS 32]
_pmstart:
; MetalSVM support Multiboot
; => Therefore, we switch to the same machine state. Afterwards, we jump to our kernel
xor eax, eax
mov ax, 0x10
mov ds, ax
mov es, ax
@ -149,13 +137,7 @@ _pmstart:
mov gs, ax
mov ss, ax
mov eax, 0x2BAD002
xor ebx, ebx ; => it exists n valid multiboot information structure
xor ebx, ebx ; => it exists no valid multiboot information structure
jmp 0x08 : 0x100000
TIMES 4080 - ($-$$) DB 0
[BITS 16]
_start:
jmp _realstart
TIMES 4096 - ($-$$) DB 0
TIMES 4096-($-$$) DB 0