11 ;; make sure we are running on a 386+
13 ;; while we're still in real mode, detect system hardware via BIOS
15 call GET_EQUIPMENT_LIST
19 ;; switch the processor into protected mode, keep ints disabled
27 ;; Jump to 32 bit code, this completes the transition to protected mode
28 db 0x66 ; operand size override prefix
30 dd (BOOT1SEG<<4) + setup_32 ; want to jump here
31 dw (1<<3) ; ...in the kernel code segment
35 ;; set up data segment registers
43 ;; create an initial stack
44 mov esp, KERN_STACK + 4096
47 ;; create a stack frame, pass ptr to hardware block as param
48 mov eax, (BOOT1SEG<<4)+BIOS_HARDWARE_BLOCK
50 push (BOOT1SEG<<4)+.HANG
51 jmp (1<<3):0x00010000 ; entry point of kernel
59 ; ----------------------------------------------------------------------
64 wEquipmentBitvector dw 0x0000
66 wSystemClock dw 0x0000
68 NUM_GDT_ENTRIES equ 3 ; number of entries in GDT
69 GDT_ENTRY_SZ equ 8 ; size of a single GDT entry
73 ; Descriptor 0 is not used
79 ; Descriptor 1: kernel code segment
80 dw 0xFFFF ; bytes 0 and 1 of segment size
81 dw 0x0000 ; bytes 0 and 1 of segment base address
82 db 0x00 ; byte 2 of segment base address
83 db 0x9A ; present, DPL=0, non-system, code, non-conforming,
84 ; readable, not accessed
85 db 0xCF ; granularity=page, 32 bit code, upper nibble of size
86 db 0x00 ; byte 3 of segment base address
88 ; Descriptor 2: kernel data and stack segment
89 ; NOTE: what Intel calls an "expand-up" segment
90 ; actually means that the stack will grow DOWN,
91 ; towards lower memory. So, we can use this descriptor
92 ; for both data and stack references.
93 dw 0xFFFF ; bytes 0 and 1 of segment size
94 dw 0x0000 ; bytes 0 and 1 of segment base address
95 db 0x00 ; byte 2 of segment base address
96 db 0x92 ; present, DPL=0, non-system, data, expand-up,
97 ; writable, not accessed
98 db 0xCF ; granularity=page, big, upper nibble of size
99 db 0x00 ; byte 3 of segment base address
102 dw NUM_GDT_ENTRIES*GDT_ENTRY_SZ ; limit
103 dd (BOOT1SEG<<4) + GDT ; base address
110 %include "hardware.asm"