]> git.proxmox.com Git - mirror_edk2.git/blob - QuarkPlatformPkg/Library/PlatformSecLib/Ia32/Flat32.asm
45e9e6a84a5180d651d580f6bbbbf270de719e93
[mirror_edk2.git] / QuarkPlatformPkg / Library / PlatformSecLib / Ia32 / Flat32.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2013-2015 Intel Corporation.
4 ;
5 ; SPDX-License-Identifier: BSD-2-Clause-Patent
6 ;
7 ; Module Name:
8 ;
9 ; Flat32.asm
10 ;
11 ; Abstract:
12 ;
13 ; This is the code that goes from real-mode to protected mode.
14 ; It consumes the reset vector, configures the stack.
15 ;
16 ;
17 ;------------------------------------------------------------------------------
18
19
20 ;
21 ; Define assembler characteristics
22 ;
23 .586p
24 .model flat, c
25
26 ;
27 ; Include processor definitions
28 ;
29
30 INCLUDE Platform.inc
31
32
33 ;
34 ; CR0 cache control bit definition
35 ;
36 CR0_CACHE_DISABLE EQU 040000000h
37 CR0_NO_WRITE EQU 020000000h
38
39 ;
40 ; External and public declarations
41 ; TopOfStack is used by C code
42 ; SecStartup is the entry point to the C code
43 ; Neither of these names can be modified without
44 ; updating the C code.
45 ;
46 EXTRN PlatformSecLibStartup: NEAR
47 EXTERNDEF C PcdGet32 (PcdEsramStage1Base):DWORD
48
49 ;
50 ; Contrary to the name, this file contains 16 bit code as well.
51 ;
52 _TEXT_REALMODE SEGMENT PARA PUBLIC USE16 'CODE'
53 ASSUME CS:_TEXT_REALMODE, DS:_TEXT_REALMODE
54
55 ;----------------------------------------------------------------------------
56 ;
57 ; Procedure: _ModuleEntryPoint
58 ;
59 ; Input: None
60 ;
61 ; Output: None
62 ;
63 ; Destroys: Assume all registers
64 ;
65 ; Description:
66 ;
67 ; Transition to non-paged flat-model protected mode from a
68 ; hard-coded GDT that provides exactly two descriptors.
69 ; This is a bare bones transition to protected mode only
70 ; used for a while in PEI and possibly DXE.
71 ;
72 ; After enabling protected mode, a far jump is executed to
73 ; transfer to PEI using the newly loaded GDT.
74 ;
75 ; Return: None
76 ;
77 ;----------------------------------------------------------------------------
78 align 16
79 _ModuleEntryPoint PROC C PUBLIC
80
81 ;
82 ; Warm Reset (INIT#) check.
83 ;
84 mov si, 0F000h
85 mov ds, si
86 mov si, 0FFF0h
87 cmp BYTE PTR [si], 0EAh ; Is it warm reset ?
88 jne NotWarmReset ; JIf not.
89
90 mov al, 08
91 mov dx, 0cf9h
92 out dx, al
93 mov al, 055h
94 out 080h, al;
95 jmp $
96 NotWarmReset:
97
98 ;
99 ; Load the GDT table in GdtDesc
100 ;
101 mov esi, OFFSET GdtDesc
102 db 66h
103 lgdt fword ptr cs:[si]
104
105 ;
106 ; Transition to 16 bit protected mode
107 ;
108 mov eax, cr0 ; Get control register 0
109 or eax, 00000003h ; Set PE bit (bit #0) & MP bit (bit #1)
110 mov cr0, eax ; Activate protected mode
111
112 ;
113 ; Now we're in 16 bit protected mode
114 ; Set up the selectors for 32 bit protected mode entry
115 ;
116 mov ax, SYS_DATA_SEL
117 mov ds, ax
118 mov es, ax
119 mov fs, ax
120 mov gs, ax
121 mov ss, ax
122
123 ;
124 ; Transition to Flat 32 bit protected mode
125 ; The jump to a far pointer causes the transition to 32 bit mode
126 ;
127 mov esi, offset ProtectedModeEntryLinearAddress
128 jmp fword ptr cs:[si]
129
130 _ModuleEntryPoint ENDP
131
132 _TEXT_REALMODE ENDS
133
134 .code
135 ;
136 ; Protected mode portion initializes stack, configures cache, and calls C entry point
137 ;
138
139 ;----------------------------------------------------------------------------
140 ;
141 ; Procedure: ProtectedModeEntryPoint
142 ;
143 ; Input: Executing in 32 Bit Protected (flat) mode
144 ; cs: 0-4GB
145 ; ds: 0-4GB
146 ; es: 0-4GB
147 ; fs: 0-4GB
148 ; gs: 0-4GB
149 ; ss: 0-4GB
150 ;
151 ; Output: This function never returns
152 ;
153 ; Destroys:
154 ; ecx
155 ; edi
156 ; esi
157 ; esp
158 ;
159 ; Description:
160 ; Perform any essential early platform initilaisation
161 ; Setup a stack
162 ; Call the main EDKII Sec C code
163 ;
164 ;----------------------------------------------------------------------------
165
166 ProtectedModeEntryPoint PROC NEAR C PUBLIC
167
168 JMP32 stackless_EarlyPlatformInit
169
170 ;
171 ; Set up stack pointer
172 ;
173 mov esp, PcdGet32(PcdEsramStage1Base)
174 mov esi, QUARK_ESRAM_MEM_SIZE_BYTES
175 add esp, esi ; ESP = top of stack (stack grows downwards).
176
177 ;
178 ; Store the the BIST value in EBP
179 ;
180 mov ebp, 00h ; No processor BIST on Quark
181
182 ;
183 ; Push processor count to stack first, then BIST status (AP then BSP)
184 ;
185 mov eax, 1
186 cpuid
187 shr ebx, 16
188 and ebx, 0000000FFh
189 cmp bl, 1
190 jae PushProcessorCount
191
192 ;
193 ; Some processors report 0 logical processors. Effectively 0 = 1.
194 ; So we fix up the processor count
195 ;
196 inc ebx
197
198 PushProcessorCount:
199 push ebx
200
201 ;
202 ; We need to implement a long-term solution for BIST capture. For now, we just copy BSP BIST
203 ; for all processor threads
204 ;
205 xor ecx, ecx
206 mov cl, bl
207 PushBist:
208 push ebp
209 loop PushBist
210
211 ;
212 ; Pass Control into the PEI Core
213 ;
214 call PlatformSecLibStartup
215
216 ;
217 ; PEI Core should never return to here, this is just to capture an invalid return.
218 ;
219 jmp $
220
221 ProtectedModeEntryPoint ENDP
222
223 ;----------------------------------------------------------------------------
224 ;
225 ; Procedure: stackless_EarlyPlatformInit
226 ;
227 ; Input: esp - Return address
228 ;
229 ; Output: None
230 ;
231 ; Destroys:
232 ; eax
233 ; ecx
234 ; dx
235 ; ebp
236 ;
237 ; Description:
238 ; Any essential early platform initialisation required:
239 ; (1) Disable Cache
240 ; (2) Disable NMI's/SMI's
241 ; (3) Setup HMBOUND (defines what memory accesses go to MMIO/RAM)
242 ; (4) Setup eSRAM (provide early memory to the system)
243 ; (5) Setup PCIEXBAR access mechanism
244 ; (6) Open up full SPI flash decode
245 ;
246 ;----------------------------------------------------------------------------
247 stackless_EarlyPlatformInit PROC NEAR C PUBLIC
248
249 ;
250 ; Save return address
251 ;
252 mov ebp, esp
253
254 ;
255 ; Ensure cache is disabled.
256 ;
257 mov eax, cr0
258 or eax, CR0_CACHE_DISABLE + CR0_NO_WRITE
259 invd
260 mov cr0, eax
261
262 ;
263 ; Disable NMI
264 ; Good convention suggests you should read back RTC data port after
265 ; accessing the RTC index port.
266 ;
267 mov al, NMI_DISABLE
268 mov dx, RTC_INDEX
269 out dx, al
270 mov dx, RTC_DATA
271 in al, dx
272
273 ;
274 ; Disable SMI (Disables SMI wire, not SMI messages)
275 ;
276 mov ecx, (OPCODE_SIDEBAND_REG_READ SHL SB_OPCODE_FIELD) OR (HOST_BRIDGE_PORT_ID SHL SB_PORT_FIELD) OR (HMISC2_OFFSET SHL SB_ADDR_FIELD)
277 JMP32 stackless_SideBand_Read
278 and eax, NOT (SMI_EN)
279 mov ecx, (OPCODE_SIDEBAND_REG_WRITE SHL SB_OPCODE_FIELD) OR (HOST_BRIDGE_PORT_ID SHL SB_PORT_FIELD) OR (HMISC2_OFFSET SHL SB_ADDR_FIELD)
280 JMP32 stackless_SideBand_Write
281
282 ;
283 ; Before we get going, check SOC Unit Registers to see if we are required to issue a warm/cold reset
284 ;
285 mov ecx, (OPCODE_SIDEBAND_ALT_REG_READ SHL SB_OPCODE_FIELD) OR (SOC_UNIT_PORT_ID SHL SB_PORT_FIELD) OR (CFGNONSTICKY_W1_OFFSET SHL SB_ADDR_FIELD)
286 JMP32 stackless_SideBand_Read
287 and eax, FORCE_WARM_RESET
288 jz TestForceColdReset ; Zero means bit clear, we're not requested to warm reset so continue as normal
289 jmp IssueWarmReset
290
291 TestForceColdReset:
292 mov ecx, (OPCODE_SIDEBAND_ALT_REG_READ SHL SB_OPCODE_FIELD) OR (SOC_UNIT_PORT_ID SHL SB_PORT_FIELD) OR (CFGSTICKY_W1_OFFSET SHL SB_ADDR_FIELD)
293 JMP32 stackless_SideBand_Read
294 and eax, FORCE_COLD_RESET
295 jz TestHmboundLock ; Zero means bit clear, we're not requested to cold reset so continue as normal
296 jmp IssueColdReset
297
298 ;
299 ; Before setting HMBOUND, check it's not locked
300 ;
301 TestHmboundLock:
302 mov ecx, (OPCODE_SIDEBAND_REG_READ SHL SB_OPCODE_FIELD) OR (HOST_BRIDGE_PORT_ID SHL SB_PORT_FIELD) OR (HMBOUND_OFFSET SHL SB_ADDR_FIELD)
303 JMP32 stackless_SideBand_Read
304 and eax, HMBOUND_LOCK
305 jz ConfigHmbound ; Zero means bit clear, we have the config we want so continue as normal
306 ;
307 ; Failed to config - store sticky bit debug
308 ;
309 mov ecx, (OPCODE_SIDEBAND_ALT_REG_READ SHL SB_OPCODE_FIELD) OR (SOC_UNIT_PORT_ID SHL SB_PORT_FIELD) OR (CFGSTICKY_RW_OFFSET SHL SB_ADDR_FIELD)
310 JMP32 stackless_SideBand_Read
311 or eax, RESET_FOR_HMBOUND_LOCK ; Set the bit we're interested in
312 mov ecx, (OPCODE_SIDEBAND_ALT_REG_WRITE SHL SB_OPCODE_FIELD) OR (SOC_UNIT_PORT_ID SHL SB_PORT_FIELD) OR (CFGSTICKY_RW_OFFSET SHL SB_ADDR_FIELD)
313 JMP32 stackless_SideBand_Write
314 jmp IssueWarmReset
315
316 ;
317 ; Set up the HMBOUND register
318 ;
319 ConfigHmbound:
320 mov eax, HMBOUND_ADDRESS ; Data (Set HMBOUND location)
321 mov ecx, (OPCODE_SIDEBAND_REG_WRITE SHL SB_OPCODE_FIELD) OR (HOST_BRIDGE_PORT_ID SHL SB_PORT_FIELD) OR (HMBOUND_OFFSET SHL SB_ADDR_FIELD)
322 JMP32 stackless_SideBand_Write
323
324 ;
325 ; Enable interrupts to Remote Management Unit when a IMR/SMM/HMBOUND violation occurs.
326 ;
327 mov eax, ENABLE_IMR_INTERRUPT ; Data (Set interrupt enable mask)
328 mov ecx, (OPCODE_SIDEBAND_REG_WRITE SHL SB_OPCODE_FIELD) OR (MEMORY_MANAGER_PORT_ID SHL SB_PORT_FIELD) OR (BIMRVCTL_OFFSET SHL SB_ADDR_FIELD)
329 JMP32 stackless_SideBand_Write
330
331 ;
332 ; Set eSRAM address
333 ;
334 mov eax, PcdGet32 (PcdEsramStage1Base) ; Data (Set eSRAM location)
335 shr eax, 18h ; Data (Set eSRAM location)
336 add eax, BLOCK_ENABLE_PG
337 mov ecx, (OPCODE_SIDEBAND_REG_WRITE SHL SB_OPCODE_FIELD) OR (MEMORY_MANAGER_PORT_ID SHL SB_PORT_FIELD) OR (ESRAMPGCTRL_BLOCK_OFFSET SHL SB_ADDR_FIELD)
338 JMP32 stackless_SideBand_Write
339 ;
340 ; Check that we're not blocked from setting the config that we want.
341 ;
342 mov ecx, (OPCODE_SIDEBAND_REG_READ SHL SB_OPCODE_FIELD) OR (MEMORY_MANAGER_PORT_ID SHL SB_PORT_FIELD) OR (ESRAMPGCTRL_BLOCK_OFFSET SHL SB_ADDR_FIELD)
343 JMP32 stackless_SideBand_Read
344 and eax, BLOCK_ENABLE_PG
345 jnz ConfigPci ; Non-zero means bit set, we have the config we want so continue as normal
346 ;
347 ; Failed to config - store sticky bit debug
348 ;
349 mov ecx, (OPCODE_SIDEBAND_ALT_REG_READ SHL SB_OPCODE_FIELD) OR (SOC_UNIT_PORT_ID SHL SB_PORT_FIELD) OR (CFGSTICKY_RW_OFFSET SHL SB_ADDR_FIELD)
350 JMP32 stackless_SideBand_Read
351 or eax, RESET_FOR_ESRAM_LOCK ; Set the bit we're interested in
352 mov ecx, (OPCODE_SIDEBAND_ALT_REG_WRITE SHL SB_OPCODE_FIELD) OR (SOC_UNIT_PORT_ID SHL SB_PORT_FIELD) OR (CFGSTICKY_RW_OFFSET SHL SB_ADDR_FIELD)
353 JMP32 stackless_SideBand_Write
354 jmp IssueWarmReset
355
356 ;
357 ; Enable PCIEXBAR
358 ;
359 ConfigPci:
360 mov eax, (EC_BASE + EC_ENABLE) ; Data
361 mov ecx, (OPCODE_SIDEBAND_REG_WRITE SHL SB_OPCODE_FIELD) OR (MEMORY_ARBITER_PORT_ID SHL SB_PORT_FIELD) OR (AEC_CTRL_OFFSET SHL SB_ADDR_FIELD)
362 JMP32 stackless_SideBand_Write
363
364 mov eax, (EC_BASE + EC_ENABLE) ; Data
365 mov ecx, (OPCODE_SIDEBAND_REG_WRITE SHL SB_OPCODE_FIELD) OR (HOST_BRIDGE_PORT_ID SHL SB_PORT_FIELD) OR (HECREG_OFFSET SHL SB_ADDR_FIELD)
366 JMP32 stackless_SideBand_Write
367
368 ;
369 ; Open up full 8MB SPI decode
370 ;
371 mov ebx, PCI_CFG OR (ILB_PFA SHL 8) OR BDE ; PCI Configuration address
372 mov eax, DECODE_ALL_REGIONS_ENABLE
373 JMP32 stackless_PCIConfig_Write
374
375 ;
376 ; Enable NMI operation
377 ; Good convention suggests you should read back RTC data port after
378 ; accessing the RTC index port.
379 ;
380 mov al, NMI_ENABLE
381 mov dx, RTC_INDEX
382 out dx, al
383 mov dx, RTC_DATA
384 in al, dx
385
386 ;
387 ; Clear Host Bridge SMI, NMI, INTR fields
388 ;
389 mov ecx, (OPCODE_SIDEBAND_REG_READ SHL SB_OPCODE_FIELD) OR (HOST_BRIDGE_PORT_ID SHL SB_PORT_FIELD) OR (HLEGACY_OFFSET SHL SB_ADDR_FIELD)
390 JMP32 stackless_SideBand_Read
391 and eax, NOT(NMI + SMI + INTR) ; Clear NMI, SMI, INTR fields
392 mov ecx, (OPCODE_SIDEBAND_REG_WRITE SHL SB_OPCODE_FIELD) OR (HOST_BRIDGE_PORT_ID SHL SB_PORT_FIELD) OR (HLEGACY_OFFSET SHL SB_ADDR_FIELD)
393 JMP32 stackless_SideBand_Write
394
395 ;
396 ; Restore return address
397 ;
398 mov esp, ebp
399 RET32
400
401 IssueWarmReset:
402 ;
403 ; Issue Warm Reset request to Remote Management Unit via iLB
404 ;
405 mov ax, CF9_WARM_RESET
406 mov dx, ILB_RESET_REG
407 out dx, ax
408 jmp $ ; Stay here until we are reset.
409
410 IssueColdReset:
411 ;
412 ; Issue Cold Reset request to Remote Management Unit via iLB
413 ;
414 mov ax, CF9_COLD_RESET
415 mov dx, ILB_RESET_REG
416 out dx, ax
417 jmp $ ; Stay here until we are reset.
418
419 stackless_EarlyPlatformInit ENDP
420
421 ;----------------------------------------------------------------------------
422 ;
423 ; Procedure: stackless_SideBand_Read
424 ;
425 ; Input: esp - return address
426 ; ecx[15:8] - Register offset
427 ; ecx[23:16] - Port ID
428 ; ecx[31:24] - Opcode
429 ;
430 ; Output: eax - Data read
431 ;
432 ; Destroys:
433 ; eax
434 ; ebx
435 ; cl
436 ; esi
437 ;
438 ; Description:
439 ; Perform requested sideband read
440 ;
441 ;----------------------------------------------------------------------------
442 stackless_SideBand_Read PROC NEAR C PUBLIC
443
444 mov esi, esp ; Save the return address
445
446 ;
447 ; Load the SideBand Packet Register to generate the transaction
448 ;
449 mov ebx, PCI_CFG OR (HOST_BRIDGE_PFA SHL 8) OR MESSAGE_BUS_CONTROL_REG ; PCI Configuration address
450 mov cl, (ALL_BYTE_EN SHL SB_BE_FIELD) ; Set all Byte Enable bits
451 xchg eax, ecx
452 JMP32 stackless_PCIConfig_Write
453 xchg eax, ecx
454
455 ;
456 ; Read the SideBand Data Register
457 ;
458 mov ebx, PCI_CFG OR (HOST_BRIDGE_PFA SHL 8) OR MESSAGE_DATA_REG ; PCI Configuration address
459 JMP32 stackless_PCIConfig_Read
460
461 mov esp, esi ; Restore the return address
462 RET32
463
464 stackless_SideBand_Read ENDP
465
466 ;----------------------------------------------------------------------------
467 ;
468 ; Procedure: stackless_SideBand_Write
469 ;
470 ; Input: esp - return address
471 ; eax - Data
472 ; ecx[15:8] - Register offset
473 ; ecx[23:16] - Port ID
474 ; ecx[31:24] - Opcode
475 ;
476 ; Output: None
477 ;
478 ; Destroys:
479 ; ebx
480 ; cl
481 ; esi
482 ;
483 ; Description:
484 ; Perform requested sideband write
485 ;
486 ;
487 ;----------------------------------------------------------------------------
488 stackless_SideBand_Write PROC NEAR C PUBLIC
489
490 mov esi, esp ; Save the return address
491
492 ;
493 ; Load the SideBand Data Register with the data
494 ;
495 mov ebx, PCI_CFG OR (HOST_BRIDGE_PFA SHL 8) OR MESSAGE_DATA_REG ; PCI Configuration address
496 JMP32 stackless_PCIConfig_Write
497
498 ;
499 ; Load the SideBand Packet Register to generate the transaction
500 ;
501 mov ebx, PCI_CFG OR (HOST_BRIDGE_PFA SHL 8) OR MESSAGE_BUS_CONTROL_REG ; PCI Configuration address
502 mov cl, (ALL_BYTE_EN SHL SB_BE_FIELD) ; Set all Byte Enable bits
503 xchg eax, ecx
504 JMP32 stackless_PCIConfig_Write
505 xchg eax, ecx
506
507 mov esp, esi ; Restore the return address
508 RET32
509
510 stackless_SideBand_Write ENDP
511
512 ;----------------------------------------------------------------------------
513 ;
514 ; Procedure: stackless_PCIConfig_Write
515 ;
516 ; Input: esp - return address
517 ; eax - Data to write
518 ; ebx - PCI Config Address
519 ;
520 ; Output: None
521 ;
522 ; Destroys:
523 ; dx
524 ;
525 ; Description:
526 ; Perform a DWORD PCI Configuration write
527 ;
528 ;----------------------------------------------------------------------------
529 stackless_PCIConfig_Write PROC NEAR C PUBLIC
530
531 ;
532 ; Write the PCI Config Address to the address port
533 ;
534 xchg eax, ebx
535 mov dx, PCI_ADDRESS_PORT
536 out dx, eax
537 xchg eax, ebx
538
539 ;
540 ; Write the PCI DWORD Data to the data port
541 ;
542 mov dx, PCI_DATA_PORT
543 out dx, eax
544
545 RET32
546
547 stackless_PCIConfig_Write ENDP
548
549 ;----------------------------------------------------------------------------
550 ;
551 ; Procedure: stackless_PCIConfig_Read
552 ;
553 ; Input: esp - return address
554 ; ebx - PCI Config Address
555 ;
556 ; Output: eax - Data read
557 ;
558 ; Destroys:
559 ; eax
560 ; dx
561 ;
562 ; Description:
563 ; Perform a DWORD PCI Configuration read
564 ;
565 ;----------------------------------------------------------------------------
566 stackless_PCIConfig_Read PROC NEAR C PUBLIC
567
568 ;
569 ; Write the PCI Config Address to the address port
570 ;
571 xchg eax, ebx
572 mov dx, PCI_ADDRESS_PORT
573 out dx, eax
574 xchg eax, ebx
575
576 ;
577 ; Read the PCI DWORD Data from the data port
578 ;
579 mov dx, PCI_DATA_PORT
580 in eax, dx
581
582 RET32
583
584 stackless_PCIConfig_Read ENDP
585
586 ;
587 ; ROM-based Global-Descriptor Table for the Tiano PEI Phase
588 ;
589 align 16
590 PUBLIC BootGdtTable
591
592 ;
593 ; GDT[0]: 0x00: Null entry, never used.
594 ;
595 NULL_SEL equ $ - GDT_BASE ; Selector [0]
596 GDT_BASE:
597 BootGdtTable DD 0
598 DD 0
599 ;
600 ; Linear data segment descriptor
601 ;
602 LINEAR_SEL equ $ - GDT_BASE ; Selector [0x8]
603 DW 0FFFFh ; limit 0xFFFF
604 DW 0 ; base 0
605 DB 0
606 DB 092h ; present, ring 0, data, expand-up, writable
607 DB 0CFh ; page-granular, 32-bit
608 DB 0
609 ;
610 ; Linear code segment descriptor
611 ;
612 LINEAR_CODE_SEL equ $ - GDT_BASE ; Selector [0x10]
613 DW 0FFFFh ; limit 0xFFFF
614 DW 0 ; base 0
615 DB 0
616 DB 09Bh ; present, ring 0, data, expand-up, not-writable
617 DB 0CFh ; page-granular, 32-bit
618 DB 0
619 ;
620 ; System data segment descriptor
621 ;
622 SYS_DATA_SEL equ $ - GDT_BASE ; Selector [0x18]
623 DW 0FFFFh ; limit 0xFFFF
624 DW 0 ; base 0
625 DB 0
626 DB 093h ; present, ring 0, data, expand-up, not-writable
627 DB 0CFh ; page-granular, 32-bit
628 DB 0
629
630 ;
631 ; System code segment descriptor
632 ;
633 SYS_CODE_SEL equ $ - GDT_BASE ; Selector [0x20]
634 DW 0FFFFh ; limit 0xFFFF
635 DW 0 ; base 0
636 DB 0
637 DB 09Ah ; present, ring 0, data, expand-up, writable
638 DB 0CFh ; page-granular, 32-bit
639 DB 0
640 ;
641 ; Spare segment descriptor
642 ;
643 SYS16_CODE_SEL equ $ - GDT_BASE ; Selector [0x28]
644 DW 0FFFFh ; limit 0xFFFF
645 DW 0 ; base 0
646 DB 0Fh
647 DB 09Bh ; present, ring 0, code, expand-up, writable
648 DB 00h ; byte-granular, 16-bit
649 DB 0
650 ;
651 ; Spare segment descriptor
652 ;
653 SYS16_DATA_SEL equ $ - GDT_BASE ; Selector [0x30]
654 DW 0FFFFh ; limit 0xFFFF
655 DW 0 ; base 0
656 DB 0
657 DB 093h ; present, ring 0, data, expand-up, not-writable
658 DB 00h ; byte-granular, 16-bit
659 DB 0
660
661 ;
662 ; Spare segment descriptor
663 ;
664 SPARE5_SEL equ $ - GDT_BASE ; Selector [0x38]
665 DW 0 ; limit 0xFFFF
666 DW 0 ; base 0
667 DB 0
668 DB 0 ; present, ring 0, data, expand-up, writable
669 DB 0 ; page-granular, 32-bit
670 DB 0
671 GDT_SIZE EQU $ - BootGDTtable ; Size, in bytes
672
673 ;
674 ; GDT Descriptor
675 ;
676 GdtDesc: ; GDT descriptor
677 DW GDT_SIZE - 1 ; GDT limit
678 DD OFFSET BootGdtTable ; GDT base address
679
680 ProtectedModeEntryLinearAddress LABEL FWORD
681 ProtectedModeEntryLinearOffset LABEL DWORD
682 DD OFFSET ProtectedModeEntryPoint ; Offset of our 32 bit code
683 DW LINEAR_CODE_SEL
684
685 END