Entering unreal mode

This commit is contained in:
Thomas Oltmann 2025-07-04 15:51:51 +02:00
parent bc400a814b
commit 1015d79280
2 changed files with 32 additions and 15 deletions

View file

@ -5,8 +5,7 @@
all: boot.bin all: boot.bin
clean: clean:
rm -f *.o rm -f *.o boot.elf boot.bin
rm -f boot.elf boot.bin
config.mk: | config.default.mk config.mk: | config.default.mk
cp config.default.mk $@ cp config.default.mk $@
@ -14,8 +13,8 @@ config.mk: | config.default.mk
boot.bin: boot.elf boot.bin: boot.elf
objcopy -O binary --only-section=.text boot.elf $@ objcopy -O binary --only-section=.text boot.elf $@
boot.elf: boot16.o fernlader.ld boot.elf: lboot.o fernlader.ld
$(LD) $(LDFLAGS) -o $@ boot16.o $(LD) $(LDFLAGS) -o $@ lboot.o
.S.o: .S.o:
$(CC) $(CFLAGS) -c -o $@ $(@:.o=.S) $(CC) $(CFLAGS) -c -o $@ $(@:.o=.S)

View file

@ -7,21 +7,23 @@
_start: cli _start: cli
cld cld
mov %cs, %ax // we keep our text and data close to each other
xor %ax, %ax
mov %ax, %ds mov %ax, %ds
mov $message, %si mov $msg_start, %si
call print call print
mov $msg_a20, %si
call print
call enable_a20 call enable_a20
lea message, %si mov $msg_unreal, %si
call print call print
call unreal
lgdt gdt_ptr mov $msg_fin, %si
call print
call enter_prot
1: hlt 1: hlt
jmp 1b jmp 1b
@ -31,11 +33,24 @@ enable_a20: // TODO more thorough implementation
outb %al, $0x92 outb %al, $0x92
ret ret
enter_prot: mov %cr0, %eax unreal: push %ds
or $1, %al lgdt gdt_ptr
mov %cr0, %eax
or $0x01, %al
mov %eax, %cr0 mov %eax, %cr0
ret 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 print: xor %bx, %bx
1: lodsb 1: lodsb
@ -72,4 +87,7 @@ gdt: // entry 0: null descriptor
gdt_ptr: .word gdt_size-1 gdt_ptr: .word gdt_size-1
.long gdt .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"