fernlader/lboot.S

94 lines
2.3 KiB
ArmAsm
Raw Normal View History

2025-07-04 03:10:55 +02:00
// vim: et:sw=12:ts=12:sts=12
.global _start
.text
2025-07-04 04:02:05 +02:00
.code16
2025-07-04 03:10:55 +02:00
2025-07-04 15:29:41 +02:00
_start: cli
cld
2025-07-04 15:51:51 +02:00
// we keep our text and data close to each other
xor %ax, %ax
2025-07-04 04:02:05 +02:00
mov %ax, %ds
2025-07-04 15:51:51 +02:00
mov $msg_start, %si
2025-07-04 15:29:41 +02:00
call print
2025-07-04 15:51:51 +02:00
mov $msg_a20, %si
call print
2025-07-04 15:29:41 +02:00
call enable_a20
2025-07-04 15:51:51 +02:00
mov $msg_unreal, %si
2025-07-04 04:02:05 +02:00
call print
2025-07-04 15:51:51 +02:00
call unreal
2025-07-04 15:29:41 +02:00
2025-07-04 15:51:51 +02:00
mov $msg_fin, %si
call print
2025-07-04 04:02:05 +02:00
1: hlt
jmp 1b
2025-07-04 15:29:41 +02:00
enable_a20: // TODO more thorough implementation
inb $0x92, %al
or $2, %al
outb %al, $0x92
ret
2025-07-04 15:51:51 +02:00
unreal: push %ds
lgdt gdt_ptr
mov %cr0, %eax
or $0x01, %al
2025-07-04 15:29:41 +02:00
mov %eax, %cr0
2025-07-04 15:51:51 +02:00
ljmp $0x8, $1f
1: mov $0x10, %cx
mov %cx, %ds
2025-07-04 15:29:41 +02:00
2025-07-04 15:51:51 +02:00
and $0xFE, %al
mov %eax, %cr0
ljmp $0x0, $2f
2: pop %ds
ret
2025-07-04 15:29:41 +02:00
print: xor %bx, %bx
2025-07-04 04:02:05 +02:00
1: lodsb
or %al, %al
jz 2f
2025-07-04 03:10:55 +02:00
mov $0x0E, %ah
int $0x10
jmp 1b
2025-07-04 04:02:05 +02:00
2025-07-04 15:29:41 +02:00
2: ret
gdt: // entry 0: null descriptor
.word 0
.word 0
.byte 0
.byte 0
.byte 0
.byte 0
// entry 1: code segment
.word 0xFFFF
.word 0
.byte 0
.byte 0b10011010
.byte 0x8F
.byte 0
// entry 2: data segment
.word 0xFFFF
.word 0
.byte 0
.byte 0b10010010
.byte 0x8F
.byte 0
.set gdt_size, .-gdt
gdt_ptr: .word gdt_size-1
.long gdt
2025-07-04 04:02:05 +02:00
2025-07-04 15:51:51 +02:00
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"