- 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 # other implicit rules
%.o : %.c %.o : %.c
$(CC) -c $(CFLAGS) -o $@ $< $(CC) -c $(CFLAGS) -o $@ $<
%.o : %.asm
$(ASM) $(ASMFLAGS) -o $@ $<
default: default:
$(MAKE) all $(MAKE) all
@ -22,8 +20,13 @@ all:
make_initrd: make_initrd.o make_initrd: make_initrd.o
$(CC) $(CFLAGS) -o make_initrd $< $(LDFLAGS) $(CC) $(CFLAGS) -o make_initrd $< $(LDFLAGS)
SCC: scc_setup.bin: scc_setup.asm
$(ASM) $(ASMFLAGS) -o scc_entry.bin scc_entry.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 . cp ../metalsvm.bin .
chmod a-x *.bin chmod a-x *.bin
. ./prepare.sh . ./prepare.sh

View file

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

View file

@ -1,2 +1,2 @@
# pid object file # pid mch-route mch-dest-id mch-offset-base testcase
0x00 ./metalsvm.obj 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 file is part of metalsvm.
; This is the kernel's entry point. We could either call main here, ; This is the kernel's entry point. We switch to the protected mode
; or we can use this to setup the stack or other nice stuff, like ; and jump to our kernel.
; perhaps setting up the GDT and segments. Please note that interrupts
; are disabled at this point: More on interrupts later!
[BITS 16] [BITS 16]
SECTION .text SECTION .text
GLOBAL _start GLOBAL _start
ORG 0 ORG 0x90200
_start:
jmp _realstart
msg db "Hello from MetalSVM bootloader!!",0
struc GDT_STR struc GDT_STR
s0_15: resw 1 s0_15: resw 1
b0_15: resw 1 b0_15: resw 1
@ -35,8 +38,8 @@ ORG 0
endstruc endstruc
gdt_start dw gdt_size gdt_start dw gdt_size
gdt_ptr dd 0 gdt_ptr dd dummy_descriptor
dummy_descriptor: istruc GDT_STR dummy_descriptor: istruc GDT_STR
at s0_15, dw 0 at s0_15, dw 0
at b0_15, dw 0 at b0_15, dw 0
@ -56,7 +59,7 @@ ORG 0
at b24_31, db 0 at b24_31, db 0
iend 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 data32_descriptor: istruc GDT_STR
at s0_15, dw 0x0ffff at s0_15, dw 0x0ffff
at b0_15, dw 0 at b0_15, dw 0
@ -66,8 +69,7 @@ ORG 0
at b24_31, db 0 at b24_31, db 0
iend iend
gdt_size equ $-(dummy_descriptor) gdt_size equ $ - (dummy_descriptor) - 1
msg db "0ello from MetalSVM bootloader!!",0
enable_A20: enable_A20:
call a20wait call a20wait
@ -111,37 +113,23 @@ a20wait2:
ret ret
_realstart: _realstart:
cli lgdt [gdt_start]
cld
mov [msg], BYTE 'H'
mov ax, dummy_descriptor
mov [gdt_ptr], ax
mov bx, gdt_start
lgdt [bx]
; call enable_A20 ; call enable_A20
; switch to protected mode by setting PE bit ; switch to protected mode by setting PE bit
; we also clear the VM bit
mov eax, cr0 mov eax, cr0
or eax, 0x1 or al, 0x1
and eax, 0x7FFFFFFF
mov cr0, eax mov cr0, eax
; far jump ; far jump to the 32bit code
db 0x66 ; Prefix for 32-bit jmp dword 0x08 : _pmstart
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
[BITS 32] [BITS 32]
_pmstart: _pmstart:
; MetalSVM support Multiboot ; MetalSVM support Multiboot
; => Therefore, we switch to the same machine state. Afterwards, we jump to our kernel ; => Therefore, we switch to the same machine state. Afterwards, we jump to our kernel
xor eax, eax
mov ax, 0x10 mov ax, 0x10
mov ds, ax mov ds, ax
mov es, ax mov es, ax
@ -149,13 +137,7 @@ _pmstart:
mov gs, ax mov gs, ax
mov ss, ax mov ss, ax
mov eax, 0x2BAD002 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 jmp 0x08 : 0x100000
TIMES 4080 - ($-$$) DB 0 TIMES 4096-($-$$) DB 0
[BITS 16]
_start:
jmp _realstart
TIMES 4096 - ($-$$) DB 0