Entering unreal mode
This commit is contained in:
parent
bc400a814b
commit
1015d79280
2 changed files with 32 additions and 15 deletions
7
Makefile
7
Makefile
|
|
@ -5,8 +5,7 @@
|
|||
all: boot.bin
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f boot.elf boot.bin
|
||||
rm -f *.o boot.elf boot.bin
|
||||
|
||||
config.mk: | config.default.mk
|
||||
cp config.default.mk $@
|
||||
|
|
@ -14,8 +13,8 @@ config.mk: | config.default.mk
|
|||
boot.bin: boot.elf
|
||||
objcopy -O binary --only-section=.text boot.elf $@
|
||||
|
||||
boot.elf: boot16.o fernlader.ld
|
||||
$(LD) $(LDFLAGS) -o $@ boot16.o
|
||||
boot.elf: lboot.o fernlader.ld
|
||||
$(LD) $(LDFLAGS) -o $@ lboot.o
|
||||
|
||||
.S.o:
|
||||
$(CC) $(CFLAGS) -c -o $@ $(@:.o=.S)
|
||||
|
|
|
|||
|
|
@ -7,21 +7,23 @@
|
|||
_start: cli
|
||||
cld
|
||||
|
||||
mov %cs, %ax
|
||||
// we keep our text and data close to each other
|
||||
xor %ax, %ax
|
||||
mov %ax, %ds
|
||||
|
||||
mov $message, %si
|
||||
mov $msg_start, %si
|
||||
call print
|
||||
|
||||
mov $msg_a20, %si
|
||||
call print
|
||||
call enable_a20
|
||||
|
||||
lea message, %si
|
||||
mov $msg_unreal, %si
|
||||
call print
|
||||
call unreal
|
||||
|
||||
lgdt gdt_ptr
|
||||
|
||||
call enter_prot
|
||||
|
||||
mov $msg_fin, %si
|
||||
call print
|
||||
1: hlt
|
||||
jmp 1b
|
||||
|
||||
|
|
@ -31,9 +33,22 @@ enable_a20: // TODO more thorough implementation
|
|||
outb %al, $0x92
|
||||
ret
|
||||
|
||||
enter_prot: mov %cr0, %eax
|
||||
or $1, %al
|
||||
unreal: push %ds
|
||||
lgdt gdt_ptr
|
||||
|
||||
mov %cr0, %eax
|
||||
or $0x01, %al
|
||||
mov %eax, %cr0
|
||||
ljmp $0x8, $1f
|
||||
|
||||
1: mov $0x10, %cx
|
||||
mov %cx, %ds
|
||||
|
||||
and $0xFE, %al
|
||||
mov %eax, %cr0
|
||||
ljmp $0x0, $2f
|
||||
|
||||
2: pop %ds
|
||||
ret
|
||||
|
||||
print: xor %bx, %bx
|
||||
|
|
@ -72,4 +87,7 @@ gdt: // entry 0: null descriptor
|
|||
gdt_ptr: .word gdt_size-1
|
||||
.long gdt
|
||||
|
||||
message: .asciz "Hello, World!\r\n"
|
||||
msg_start: .asciz "Netboot via fernlader v1 ...\r\n"
|
||||
msg_a20: .asciz " * Enabling A20\r\n"
|
||||
msg_unreal: .asciz " * Unreal Mode\r\n"
|
||||
msg_fin: .asciz "Finished.\r\n"
|
||||
Loading…
Add table
Reference in a new issue