2021-09-21 15:39:43 +03:00
|
|
|
org 0x7c00
|
|
|
|
bits 16
|
2021-02-21 05:45:24 +03:00
|
|
|
|
|
|
|
jmp skip_bpb
|
|
|
|
nop
|
2021-02-25 03:40:02 +03:00
|
|
|
|
|
|
|
; El Torito Boot Information Table
|
|
|
|
; ↓ Set by mkisofs
|
|
|
|
times 8-($-$$) db 0
|
|
|
|
boot_info:
|
|
|
|
bi_PVD dd 0
|
|
|
|
bi_boot_LBA dd 0
|
|
|
|
bi_boot_len dd 0
|
|
|
|
bi_checksum dd 0
|
|
|
|
bi_reserved times 40 db 0
|
|
|
|
|
|
|
|
times 90-($-$$) db 0
|
2021-02-21 05:45:24 +03:00
|
|
|
|
|
|
|
skip_bpb:
|
|
|
|
cli
|
|
|
|
cld
|
|
|
|
jmp 0x0000:.initialise_cs
|
|
|
|
.initialise_cs:
|
2021-09-21 15:39:43 +03:00
|
|
|
xor si, si
|
|
|
|
mov ds, si
|
|
|
|
mov es, si
|
|
|
|
mov ss, si
|
|
|
|
mov sp, 0x7c00
|
2021-02-21 05:45:24 +03:00
|
|
|
sti
|
|
|
|
|
|
|
|
; int 13h?
|
|
|
|
mov ah, 0x41
|
2021-09-21 15:39:43 +03:00
|
|
|
mov bx, 0x55aa
|
2021-02-21 05:45:24 +03:00
|
|
|
int 0x13
|
2021-09-21 15:39:43 +03:00
|
|
|
jc err.0
|
|
|
|
cmp bx, 0xaa55
|
|
|
|
jne err.1
|
2021-02-21 05:45:24 +03:00
|
|
|
|
2021-02-25 03:40:02 +03:00
|
|
|
; --- Load the decompressor ---
|
|
|
|
mov eax, dword [bi_boot_LBA]
|
2021-09-21 15:39:43 +03:00
|
|
|
add eax, 1
|
|
|
|
mov ecx, stage2.fullsize / 2048
|
2021-02-25 03:40:02 +03:00
|
|
|
; DECOMPRESSOR_LOCATION = 0x70000 = 0x7000:0x0000
|
2021-09-21 15:39:43 +03:00
|
|
|
push 0x7000
|
|
|
|
pop es
|
|
|
|
xor bx, bx
|
2021-02-21 05:45:24 +03:00
|
|
|
call read_2k_sectors
|
2021-09-21 15:39:43 +03:00
|
|
|
jc err.2
|
2021-02-21 05:45:24 +03:00
|
|
|
|
|
|
|
; Enable GDT
|
|
|
|
lgdt [gdt]
|
|
|
|
cli
|
|
|
|
mov eax, cr0
|
|
|
|
or al, 1
|
|
|
|
mov cr0, eax
|
|
|
|
|
|
|
|
jmp 0x08:pmode
|
|
|
|
|
|
|
|
err:
|
2021-09-21 15:39:43 +03:00
|
|
|
.2:
|
|
|
|
inc si
|
|
|
|
.1:
|
|
|
|
inc si
|
|
|
|
.0:
|
|
|
|
add si, '0' | (0x4f << 8)
|
|
|
|
|
|
|
|
push 0xb800
|
|
|
|
pop es
|
|
|
|
mov word [es:0], si
|
|
|
|
|
|
|
|
sti
|
|
|
|
.h: hlt
|
|
|
|
jmp .h
|
2021-02-21 05:45:24 +03:00
|
|
|
|
2021-02-25 03:40:02 +03:00
|
|
|
%include 'read_2k_sectors.asm'
|
2021-02-25 03:24:54 +03:00
|
|
|
%include '../gdt.asm'
|
2021-02-21 05:45:24 +03:00
|
|
|
|
2021-09-21 15:39:43 +03:00
|
|
|
bits 32
|
2021-02-21 05:45:24 +03:00
|
|
|
pmode:
|
|
|
|
mov eax, 0x10
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
mov fs, ax
|
|
|
|
mov gs, ax
|
|
|
|
mov ss, ax
|
|
|
|
|
2021-02-25 03:40:02 +03:00
|
|
|
; Time to handle control over to the decompressor
|
2021-09-21 15:39:43 +03:00
|
|
|
push 2
|
|
|
|
and edx, 0xff
|
2021-02-21 05:45:24 +03:00
|
|
|
push edx ; Boot drive
|
2021-09-21 15:39:43 +03:00
|
|
|
push stage2.size
|
|
|
|
push (stage2 - decompressor) + 0x70000
|
|
|
|
call 0x70000
|
2021-02-25 03:40:02 +03:00
|
|
|
|
|
|
|
; Align stage2 to 2K ON DISK
|
2021-09-21 15:39:43 +03:00
|
|
|
times 2048-($-$$) db 0
|
|
|
|
decompressor:
|
2022-01-16 08:09:36 +03:00
|
|
|
%strcat DECOMPRESSOR_PATH BUILDDIR, '/decompressor-build/decompressor.bin'
|
2021-11-20 10:32:06 +03:00
|
|
|
incbin DECOMPRESSOR_PATH
|
2021-02-25 03:40:02 +03:00
|
|
|
|
2021-09-21 15:39:43 +03:00
|
|
|
align 16
|
|
|
|
stage2:
|
2022-02-03 12:38:43 +03:00
|
|
|
%strcat STAGE2_PATH BUILDDIR, '/common-bios/stage2.bin.gz'
|
2021-11-20 10:32:06 +03:00
|
|
|
incbin STAGE2_PATH
|
2021-09-21 15:39:43 +03:00
|
|
|
.size: equ $ - stage2
|
|
|
|
|
|
|
|
times ((($-$$)+2047) & ~2047)-($-$$) db 0
|
|
|
|
.fullsize: equ $ - decompressor
|