VirtualBox

Changeset 58694 in vbox for trunk


Ignore:
Timestamp:
Nov 15, 2015 9:56:46 PM (9 years ago)
Author:
vboxsync
Message:

bs3kit: Defined GDT, IDTs, TSSes and an empty LDT.

Location:
trunk/src/VBox/ValidationKit/bootsectors/bs3kit
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r58680 r58694  
    165165endif
    166166
     167#
    167168# BS3Kit template for assembly and 16-bit code.
     169#
    168170# Note! Using -d1 as -d1+ and -d2 causes suboptimal code to be generated (strlen
    169171#       reloading string pointer argument all the time).
     
    192194#       disable 1014, 1023, 2120, 1080
    193195
     196# linker options:
     197#      system dos:                 Link a 16-bit DOS binary.
     198#      output raw ...:             Produce a raw DOS binary for loading at flat address 10000h.
     199#                                  The following is for ordering segments.
     200#      option start=_start:         The start symbol in bs3-first-xxx.asm.
     201#      debug codeview/dwarf all:   Full debug information either in codeview or dwarf.
     202#      option symfile:             Produce a separate symbol file with the debug info.
     203#      option map:                 Produce a map file.
     204#      option statics:             ?
     205#      option verbose:             Verbose map file?
     206#       option disable 1014:        Disable warning about
     207#       option disable 1080:        Disable warning about
     208#       option disable 1150:        Disable warning about
     209#
     210# Note! We're pushing DATA16 to 0x20000 because it's impossible to force wlink
     211#       to give us a real-mode + GDT compatible alignment (0ffffff80h), i.e.
     212#       real-mode address on the form 0fff8:0000.
    194213TEMPLATE_VBoxBS3KitImg_LDFLAGS  = system dos \
    195214        debug $(BS3_OW_DBG_LDOPT) all \
     
    199218        output raw offset=0x10000 \
    200219        order \
    201          clname BS3CODE16  segaddr=0x1000 \
     220         clname BS3CODE16 segaddr=0x1000 \
    202221          segment BS3TEXT16 \
    203           segment text \
     222          segment BS3TEXT16_END \
     223        clname BS3SYSTEM16 segaddr=0x2000 \
     224         segment BS3SYSTEM16 \
    204225         clname FAR_DATA \
    205           segment BS3DATA16 \
     226          segment BS3DATA16 segaddr=0x2700 \
    206227          segment BS3DATA16CONST \
    207228          segment BS3DATA16CONST2 \
    208229          segment BS3DATA16_DATA \
     230          segment BS3DATA16_END \
    209231          segment BS3DATA32 \
    210232          segment BS3DATA32_CONST \
     
    221243          segment .rdata \
    222244        clname DATA \
    223           segment BS3DATA64 \
     245          segment BS3DATA64 \
    224246          segment DATA64 \
    225247          segment .data
     
    334356bs3kit-common-16_TEMPLATE = VBoxBS3KitImg
    335357bs3kit-common-16_DEFS     = TMPL_PE16 BS3_CMN_ONLY
    336 bs3kit-common-16_SOURCES  = $(VBOX_BS3KIT_COMMON_SOURCES)
     358bs3kit-common-16_SOURCES  = $(VBOX_BS3KIT_COMMON_SOURCES) \
     359        bs3-system-data.asm
    337360
    338361# The 32-bit BS3Kit library.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-bootsector.asm

    r58609 r58694  
    104104
    105105        ; save the registers.
    106         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.rax], eax
    107         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.rsp], esp
    108         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.rbp], ebp
     106        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.rax], eax
     107        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.rsp], esp
     108        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.rbp], ebp
    109109        mov     ax, ss
    110         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.ss], ax
     110        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.ss], ax
    111111        mov     ax, ds
    112         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.ds], ax
     112        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.ds], ax
    113113        mov     ax, es
    114         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.es], ax
     114        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.es], ax
    115115        mov     ax, fs
    116         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.fs], ax
     116        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.fs], ax
    117117        mov     ax, gs
    118118
     
    124124        mov     gs, ax
    125125        mov     ss, ax
    126         mov     esp, BS3_STACK_ADDR
    127         mov     [esp],  eax             ; clear the first 16 bytes
    128         mov     [esp + 04h],  eax
    129         mov     [esp + 08h],  eax       ; fake rbp.
    130         mov     [esp + 0ch],  eax       ; fake ebp and bp
     126        mov     esp, BS3_ADDR_STACK
    131127        mov     ebp, esp
     128        mov     [ebp], eax               ; clear the first 16 bytes (terminates the ebp chain)
     129        mov     [ebp + 04h], eax
     130        mov     [ebp + 08h], eax
     131        mov     [ebp + 0ch], eax
    132132
    133133        ; Save more registers now that ds is known and the stack is usable.
    134134        pushfd
    135135        pop     eax
    136         mov     [BS3_REG_SAVE_ADDR + BS3REGS.rflags], eax
    137         mov     [BS3_REG_SAVE_ADDR + BS3REGS.rbx], ebx
    138         mov     [BS3_REG_SAVE_ADDR + BS3REGS.rcx], ecx
    139         mov     [BS3_REG_SAVE_ADDR + BS3REGS.rdx], edx
    140         mov     [BS3_REG_SAVE_ADDR + BS3REGS.rsi], esi
    141         mov     [BS3_REG_SAVE_ADDR + BS3REGS.rdi], edi
     136        mov     [BS3_ADDR_REG_SAVE + BS3REGS.rflags], eax
     137        mov     [BS3_ADDR_REG_SAVE + BS3REGS.rbx], ebx
     138        mov     [BS3_ADDR_REG_SAVE + BS3REGS.rcx], ecx
     139        mov     [BS3_ADDR_REG_SAVE + BS3REGS.rdx], edx
     140        mov     [BS3_ADDR_REG_SAVE + BS3REGS.rsi], esi
     141        mov     [BS3_ADDR_REG_SAVE + BS3REGS.rdi], edi
    142142        mov     eax, cr2
    143         mov     [BS3_REG_SAVE_ADDR + BS3REGS.cr2], eax
     143        mov     [BS3_ADDR_REG_SAVE + BS3REGS.cr2], eax
    144144        mov     eax, cr3
    145         mov     [BS3_REG_SAVE_ADDR + BS3REGS.cr3], eax
     145        mov     [BS3_ADDR_REG_SAVE + BS3REGS.cr3], eax
    146146        mov     eax, cr4
    147         mov     [BS3_REG_SAVE_ADDR + BS3REGS.cr4], eax
    148         mov     byte [BS3_REG_SAVE_ADDR + BS3REGS.cBits], 16
     147        mov     [BS3_ADDR_REG_SAVE + BS3REGS.cr4], eax
     148        mov     byte [BS3_ADDR_REG_SAVE + BS3REGS.cBits], 16
    149149        xor     eax, eax
    150         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.cs], ax
     150        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.cs], ax
    151151        mov     ax, start
    152         mov     [cs:BS3_REG_SAVE_ADDR + BS3REGS.rip], eax
     152        mov     [cs:BS3_ADDR_REG_SAVE + BS3REGS.rip], eax
    153153
    154154        ; Make sure caching is enabled and alignment is off.
    155155        mov     eax, cr0
    156         mov     [BS3_REG_SAVE_ADDR + BS3REGS.cr0], eax
     156        mov     [BS3_ADDR_REG_SAVE + BS3REGS.cr0], eax
    157157        and     eax, ~(X86_CR0_NW | X86_CR0_CD | X86_CR0_AM)
    158158        mov     cr0, eax
     
    165165        ; Call the user 'main' procedure (shouldn't return).
    166166        ;
    167         call    1000h:0000h
     167        call    BS3_SEL_TEXT16:0000h
    168168
    169169        ; Panic/hang.
     
    214214        mov     esi, [g_cLargeTotalSectors]
    215215        dec     esi
    216         mov     di, BS3_LOAD_ADDR / 16  ; The current load segment.
     216        mov     di, BS3_ADDR_LOAD / 16  ; The current load segment.
    217217        mov     cx, 0002h               ; ch/cylinder=0 (0-based); cl/sector=2 (1-based)
    218218        xor     dh, dh                  ; dh/head=0
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-rm.asm

    r58628 r58694  
    2525;
    2626
     27
     28
    2729%include "bs3kit.mac"
    2830
     31
    2932;
    30 ; Just in case this helps the linker, define all the segments.
     33; Define all the segments and their grouping, just to get that right once at
     34; the start of everything.
    3135;
     36
     37; 16-bit text
    3238BS3_BEGIN_TEXT16
     39BS3_GLOBAL_DATA Bs3Text16_StartOfSegment, 0
    3340
     41%ifdef ASM_FORMAT_ELF
     42section BS3TEXT16_END   align=2 progbits alloc exec nowrite
     43%else
     44section BS3TEXT16_END   align=2 CLASS=BS3CODE16 PUBLIC USE16
     45%endif
     46BS3_GLOBAL_DATA Bs3Text16_EndOfSegment, 0
     47
     48%ifndef ASM_FORMAT_ELF
     49GROUP CGROUP16 BS3TEXT16 BS3TEXT16_END
     50%endif
     51
     52; 16-bit data
    3453BS3_BEGIN_DATA16
     54BS3_GLOBAL_DATA Bs3Data16_StartOfSegment, 0
     55    db      10,13,'eye-catcher: BS3DATA16',10,13
     56%ifdef ASM_FORMAT_ELF
     57section BS3DATA16CONST  align=2   progbits alloc noexec write
     58section BS3DATA16CONST2 align=2   progbits alloc noexec write
     59section BS3DATA16_DATA  align=2   progbits alloc noexec write
     60section BS3DATA16_END   align=2   progbits alloc noexec write
     61%else
     62section BS3DATA16CONST  align=2   CLASS=FAR_DATA PUBLIC USE16
     63section BS3DATA16CONST2 align=2   CLASS=FAR_DATA PUBLIC USE16
     64section BS3DATA16_DATA  align=2   CLASS=FAR_DATA PUBLIC USE16
     65section BS3DATA16_END   align=2   CLASS=FAR_DATA PUBLIC USE16
     66%endif
     67BS3_GLOBAL_DATA Bs3Data16_EndOfSegment, 0
    3568
     69%ifndef ASM_FORMAT_ELF
     70GROUP BS3DATA16_GROUP BS3DATA16 BS3DATA16CONST BS3DATA16CONST2 BS3DATA16_END
     71%endif
     72
     73; 32-bit text
    3674BS3_BEGIN_TEXT32
     75BS3_GLOBAL_DATA Bs3Text32_StartOfSegment, 0
     76    db      10,13,'eye-catcher: BS3TEXT32',10,13
    3777
     78%ifdef ASM_FORMAT_ELF
     79section BS3TEXT32_END   align=1 progbits alloc exec nowrite
     80%else
     81section BS3TEXT32_END   align=1 CLASS=BS3CODE32 PUBLIC USE32 FLAT
     82%endif
     83BS3_GLOBAL_DATA Bs3Text32_EndOfSegment, 0
     84
     85; 64-bit text
     86BS3_BEGIN_TEXT64
     87BS3_GLOBAL_DATA Bs3Text64_StartOfSegment, 0
     88    db      10,13,'eye-catcher: BS3TEXT64',10,13
     89
     90%ifdef ASM_FORMAT_ELF
     91section BS3TEXT64_END   align=1 progbits alloc exec nowrite
     92%else
     93section BS3TEXT64_END   align=1 CLASS=CODE PUBLIC USE32 FLAT
     94%endif
     95BS3_GLOBAL_DATA Bs3Text64_EndOfSegment, 0
     96
     97; 32-bit data
    3898BS3_BEGIN_DATA32
     99BS3_GLOBAL_DATA Bs3Data32_StartOfSegment, 0
     100    db      10,13,'eye-catcher: BS3DATA32',10,13
     101%ifdef ASM_FORMAT_ELF
     102section BS3DATA32_END   align=16   progbits alloc noexec write
     103%else
     104section BS3DATA32_END   align=16   CLASS=FAR_DATA PUBLIC USE32 FLAT
     105%endif
     106BS3_GLOBAL_DATA Bs3Data32_EndOfSegment, 0
    39107
    40 BS3_BEGIN_TEXT64
     108; 64-bit data
     109BS3_BEGIN_DATA64
     110BS3_GLOBAL_DATA Bs3Data64_StartOfSegment, 0
     111    db      10,13,'eye-catcher: BS3DATA64',10,13
     112%ifdef ASM_FORMAT_ELF
     113section BS3DATA64_END   align=16   progbits alloc noexec write
     114%else
     115section BS3DATA64_END   align=16   CLASS=DATA PUBLIC USE32 FLAT
     116%endif
     117BS3_GLOBAL_DATA Bs3Data64_EndOfSegment, 0
    41118
    42 BS3_BEGIN_DATA64
     119BS3_BEGIN_SYSTEM16
     120
    43121
    44122
     
    49127extern BS3_CMN_NM(Bs3Shutdown)
    50128extern NAME(Main_rm)
    51 extern _Bs3PrintStrSpacesColonSpace_c16
    52 extern _Bs3PrintStrSpacesColonSpace_c32
    53 extern Bs3PrintStrSpacesColonSpace_c64
    54129
     130BS3_BEGIN_SYSTEM16
     131extern BS3_DATA_NM(Bs3Gdt)
     132extern BS3_DATA_NM(Bs3Lgdt_Gdt)
    55133
    56134;
     
    59137BS3_BEGIN_TEXT16
    60138GLOBALNAME start
     139    jmp     .after_eye_catcher
     140    db      10,13,'eye-catcher: BS3TEXT16',10,13
     141.after_eye_catcher:
     142mov     ax, BS3SYSTEM16
     143mov     ds, ax
     144lgdt    [BS3_DATA_NM(Bs3Lgdt_Gdt)]
     145mov ax, X86_CR0_PE
     146lmsw ax
     147cli
     148hlt
     149
    61150    mov     ax, BS3DATA16
    62151    mov     es, ax
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r58675 r58694  
    3636# undef  IN_RING0
    3737#endif
     38#include <iprt/x86.h>
    3839
    3940
    4041/** @defgroup grp_bs3kit     BS3Kit
    4142 * @{ */
     43
     44
     45/** @name BS3_ADDR_XXX - Static Memory Allocation
     46 * @{ */
     47/** The flat load address for the code after the bootsector. */
     48#define BS3_ADDR_LOAD           0x10000
     49/** Where we save the boot registers during init.
     50 * Located right before the code. */
     51#define BS3_ADDR_REG_SAVE       (BS3_ADDR_LOAD - sizeof(BS3REGS) - 8)
     52/** Where the stack starts (initial RSP value).
     53 * Located 16 bytes (assumed by boot sector) before the saved registers.
     54 * SS.BASE=0. The size is a little short of 32KB  */
     55#define BS3_ADDR_STACK          (BS3_ADDR_REG_SAVE - 16)
     56/** The ring-0 stack (8KB) for ring transitions. */
     57#define BS3_ADDR_STACK_R0       0x06000
     58/** The ring-1 stack (8KB) for ring transitions. */
     59#define BS3_ADDR_STACK_R1       0x04000
     60/** The ring-2 stack (8KB) for ring transitions. */
     61#define BS3_ADDR_STACK_R2       0x02000
     62/** IST1 ring-0 stack for long mode (4KB), used for double faults elsewhere. */
     63#define BS3_ADDR_STACK_R0_IST1  0x09000
     64/** IST2 ring-0 stack for long mode (3KB), used for spare 0 stack elsewhere. */
     65#define BS3_ADDR_STACK_R0_IST2  0x08000
     66/** IST3 ring-0 stack for long mode (1KB). */
     67#define BS3_ADDR_STACK_R0_IST3  0x07400
     68/** IST4 ring-0 stack for long mode (1KB), used for spare 1 stack elsewhere. */
     69#define BS3_ADDR_STACK_R0_IST4  0x07000
     70/** IST5 ring-0 stack for long mode (1KB). */
     71#define BS3_ADDR_STACK_R0_IST5  0x06c00
     72/** IST6 ring-0 stack for long mode (1KB). */
     73#define BS3_ADDR_STACK_R0_IST6  0x06800
     74/** IST7 ring-0 stack for long mode (1KB). */
     75#define BS3_ADDR_STACK_R0_IST7  0x06400
     76
     77/** The base address of the BS3TEXT16 segment (same as BS3_LOAD_ADDR).
     78 * @sa BS3_SEL_TEXT16 */
     79#define BS3_ADDR_BS3TEXT16      0x10000
     80/** The base address of the BS3SYSTEM16 segment.
     81 * @sa BS3_SEL_SYSTEM16 */
     82#define BS3_ADDR_BS3SYSTEM16    0x20000
     83/** The base address of the BS3DATA16 segment.
     84 * @sa BS3_SEL_DATA16 */
     85#define BS3_ADDR_BS3DATA16      0x27000
     86/** @} */
     87
     88/** @name BS3_SEL_XXX - GDT selector assignments.
     89 *
     90 * The real mode segment numbers for BS16TEXT, BS16DATA and BS16SYSTEM are
     91 * present in the GDT, this allows the 16-bit C/C++ and assembly code to
     92 * continue using the real mode segment values in ring-0 protected mode.
     93 *
     94 * The three segments have fixed locations:
     95 * | segment     | flat address | real mode segment |
     96 * | ----------- | ------------ | ----------------- |
     97 * | BS3TEXT16   |   0x00010000 |             1000h |
     98 * | BS3SYSTEM16 |   0x00020000 |             2000h |
     99 * | BS3DATA16   |   0x00027000 |             2700h |
     100 *
     101 * This means that we've got a lot of GDT space to play around with.
     102 *
     103 * @{ */
     104#define BS3_SEL_LDT                 0x0010 /**< The LDT selector for Bs3Ldt. */
     105#define BS3_SEL_TSS16               0x0020 /**< The 16-bit TSS selector. */
     106#define BS3_SEL_TSS16_DF            0x0028 /**< The 16-bit TSS selector for double faults. */
     107#define BS3_SEL_TSS16_SPARE0        0x0030 /**< The 16-bit TSS selector for testing. */
     108#define BS3_SEL_TSS16_SPARE1        0x0038 /**< The 16-bit TSS selector for testing. */
     109#define BS3_SEL_TSS32               0x0040 /**< The 32-bit TSS selector. */
     110#define BS3_SEL_TSS32_DF            0x0048 /**< The 32-bit TSS selector for double faults. */
     111#define BS3_SEL_TSS32_SPARE0        0x0050 /**< The 32-bit TSS selector for testing. */
     112#define BS3_SEL_TSS32_SPARE1        0x0058 /**< The 32-bit TSS selector for testing. */
     113#define BS3_SEL_TSS32_IOBP_IRB      0x0060 /**< The 32-bit TSS selector with I/O permission and interrupt redirection bitmaps. */
     114#define BS3_SEL_TSS32_IRB           0x0068 /**< The 32-bit TSS selector with only interrupt redirection bitmap (IOPB stripped by limit). */
     115#define BS3_SEL_TSS64               0x0070 /**< The 64-bit TSS selector. */
     116#define BS3_SEL_TSS64_SPARE0        0x0080 /**< The 64-bit TSS selector. */
     117#define BS3_SEL_TSS64_SPARE1        0x0090 /**< The 64-bit TSS selector. */
     118#define BS3_SEL_TSS64_IOBP          0x00a0 /**< The 64-bit TSS selector. */
     119
     120#define BS3_SEL_VMMDEV_MMIO16       0x00f8 /**< Selector for accessing the VMMDev MMIO segment at 0100000h from 16-bit code. */
     121
     122#define BS3_SEL_R0_FIRST            0x0100 /**< The first selector in the ring-0 block. */
     123#define BS3_SEL_R0_CS16             0x0100 /**< ring-0: 16-bit code selector,  base 0x10000. */
     124#define BS3_SEL_R0_DS16             0x0108 /**< ring-0: 16-bit data selector,  base 0x23000. */
     125#define BS3_SEL_R0_SS16             0x0110 /**< ring-0: 16-bit stack selector, base 0x00000. */
     126#define BS3_SEL_R0_CS32             0x0118 /**< ring-0: 32-bit flat code selector. */
     127#define BS3_SEL_R0_DS32             0x0120 /**< ring-0: 32-bit flat data selector. */
     128#define BS3_SEL_R0_SS32             0x0128 /**< ring-0: 32-bit flat stack selector. */
     129#define BS3_SEL_R0_CS64             0x0130 /**< ring-0: 64-bit flat code selector. */
     130#define BS3_SEL_R0_DS64             0x0138 /**< ring-0: 64-bit flat data & stack selector. */
     131#define BS3_SEL_R0_CS16_EO          0x0140 /**< ring-0: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
     132#define BS3_SEL_R0_CS16_CNF         0x0148 /**< ring-0: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
     133#define BS3_SEL_R0_CS16_CNF_EO      0x0150 /**< ring-0: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
     134#define BS3_SEL_R0_CS32_EO          0x0158 /**< ring-0: 32-bit execute-only code selector, not accessed, flat. */
     135#define BS3_SEL_R0_CS32_CNF         0x0160 /**< ring-0: 32-bit conforming code selector, not accessed, flat. */
     136#define BS3_SEL_R0_CS32_CNF_EO      0x0168 /**< ring-0: 32-bit execute-only conforming code selector, not accessed, flat. */
     137#define BS3_SEL_R0_CS64_EO          0x0170 /**< ring-0: 64-bit execute-only code selector, not accessed, flat. */
     138#define BS3_SEL_R0_CS64_CNF         0x0178 /**< ring-0: 64-bit conforming code selector, not accessed, flat. */
     139#define BS3_SEL_R0_CS64_CNF_EO      0x0180 /**< ring-0: 64-bit execute-only conforming code selector, not accessed, flat. */
     140
     141#define BS3_SEL_R1_FIRST            0x0200 /**< The first selector in the ring-1 block. */
     142#define BS3_SEL_R1_CS16             0x0200 /**< ring-1: 16-bit code selector,  base 0x10000. */
     143#define BS3_SEL_R1_DS16             0x0208 /**< ring-1: 16-bit data selector,  base 0x23000. */
     144#define BS3_SEL_R1_SS16             0x0210 /**< ring-1: 16-bit stack selector, base 0x00000. */
     145#define BS3_SEL_R1_CS32             0x0218 /**< ring-1: 32-bit flat code selector. */
     146#define BS3_SEL_R1_DS32             0x0220 /**< ring-1: 32-bit flat data selector. */
     147#define BS3_SEL_R1_SS32             0x0228 /**< ring-1: 32-bit flat stack selector. */
     148#define BS3_SEL_R1_CS64             0x0230 /**< ring-1: 64-bit flat code selector. */
     149#define BS3_SEL_R1_DS64             0x0238 /**< ring-1: 64-bit flat data & stack selector. */
     150#define BS3_SEL_R1_CS16_EO          0x0240 /**< ring-1: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
     151#define BS3_SEL_R1_CS16_CNF         0x0248 /**< ring-1: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
     152#define BS3_SEL_R1_CS16_CNF_EO      0x0250 /**< ring-1: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
     153#define BS3_SEL_R1_CS32_EO          0x0258 /**< ring-1: 32-bit execute-only code selector, not accessed, flat. */
     154#define BS3_SEL_R1_CS32_CNF         0x0260 /**< ring-1: 32-bit conforming code selector, not accessed, flat. */
     155#define BS3_SEL_R1_CS32_CNF_EO      0x0268 /**< ring-1: 32-bit execute-only conforming code selector, not accessed, flat. */
     156#define BS3_SEL_R1_CS64_EO          0x0270 /**< ring-1: 64-bit execute-only code selector, not accessed, flat. */
     157#define BS3_SEL_R1_CS64_CNF         0x0278 /**< ring-1: 64-bit conforming code selector, not accessed, flat. */
     158#define BS3_SEL_R1_CS64_CNF_EO      0x0280 /**< ring-1: 64-bit execute-only conforming code selector, not accessed, flat. */
     159
     160#define BS3_SEL_R2_FIRST            0x0300 /**< The first selector in the ring-2 block. */
     161#define BS3_SEL_R2_CS16             0x0300 /**< ring-2: 16-bit code selector,  base 0x10000. */
     162#define BS3_SEL_R2_DS16             0x0308 /**< ring-2: 16-bit data selector,  base 0x23000. */
     163#define BS3_SEL_R2_SS16             0x0310 /**< ring-2: 16-bit stack selector, base 0x00000. */
     164#define BS3_SEL_R2_CS32             0x0318 /**< ring-2: 32-bit flat code selector. */
     165#define BS3_SEL_R2_DS32             0x0320 /**< ring-2: 32-bit flat data selector. */
     166#define BS3_SEL_R2_SS32             0x0328 /**< ring-2: 32-bit flat stack selector. */
     167#define BS3_SEL_R2_CS64             0x0330 /**< ring-2: 64-bit flat code selector. */
     168#define BS3_SEL_R2_DS64             0x0338 /**< ring-2: 64-bit flat data & stack selector. */
     169#define BS3_SEL_R2_CS16_EO          0x0340 /**< ring-2: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
     170#define BS3_SEL_R2_CS16_CNF         0x0348 /**< ring-2: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
     171#define BS3_SEL_R2_CS16_CNF_EO      0x0350 /**< ring-2: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
     172#define BS3_SEL_R2_CS32_EO          0x0358 /**< ring-2: 32-bit execute-only code selector, not accessed, flat. */
     173#define BS3_SEL_R2_CS32_CNF         0x0360 /**< ring-2: 32-bit conforming code selector, not accessed, flat. */
     174#define BS3_SEL_R2_CS32_CNF_EO      0x0368 /**< ring-2: 32-bit execute-only conforming code selector, not accessed, flat. */
     175#define BS3_SEL_R2_CS64_EO          0x0370 /**< ring-2: 64-bit execute-only code selector, not accessed, flat. */
     176#define BS3_SEL_R2_CS64_CNF         0x0378 /**< ring-2: 64-bit conforming code selector, not accessed, flat. */
     177#define BS3_SEL_R2_CS64_CNF_EO      0x0380 /**< ring-2: 64-bit execute-only conforming code selector, not accessed, flat. */
     178
     179#define BS3_SEL_R3_FIRST            0x0400 /**< The first selector in the ring-3 block. */
     180#define BS3_SEL_R3_CS16             0x0400 /**< ring-3: 16-bit code selector,  base 0x10000. */
     181#define BS3_SEL_R3_DS16             0x0408 /**< ring-3: 16-bit data selector,  base 0x23000. */
     182#define BS3_SEL_R3_SS16             0x0410 /**< ring-3: 16-bit stack selector, base 0x00000. */
     183#define BS3_SEL_R3_CS32             0x0418 /**< ring-3: 32-bit flat code selector. */
     184#define BS3_SEL_R3_DS32             0x0420 /**< ring-3: 32-bit flat data selector. */
     185#define BS3_SEL_R3_SS32             0x0428 /**< ring-3: 32-bit flat stack selector. */
     186#define BS3_SEL_R3_CS64             0x0430 /**< ring-3: 64-bit flat code selector. */
     187#define BS3_SEL_R3_DS64             0x0438 /**< ring-3: 64-bit flat data & stack selector. */
     188#define BS3_SEL_R3_CS16_EO          0x0440 /**< ring-3: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
     189#define BS3_SEL_R3_CS16_CNF         0x0448 /**< ring-3: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
     190#define BS3_SEL_R3_CS16_CNF_EO      0x0450 /**< ring-3: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
     191#define BS3_SEL_R3_CS32_EO          0x0458 /**< ring-3: 32-bit execute-only code selector, not accessed, flat. */
     192#define BS3_SEL_R3_CS32_CNF         0x0460 /**< ring-3: 32-bit conforming code selector, not accessed, flat. */
     193#define BS3_SEL_R3_CS32_CNF_EO      0x0468 /**< ring-3: 32-bit execute-only conforming code selector, not accessed, flat. */
     194#define BS3_SEL_R3_CS64_EO          0x0470 /**< ring-3: 64-bit execute-only code selector, not accessed, flat. */
     195#define BS3_SEL_R3_CS64_CNF         0x0478 /**< ring-3: 64-bit conforming code selector, not accessed, flat. */
     196#define BS3_SEL_R3_CS64_CNF_EO      0x0480 /**< ring-3: 64-bit execute-only conforming code selector, not accessed, flat. */
     197
     198#define BS3_SEL_SPARE_FIRST         0x0500 /**< The first selector in the spare block */
     199#define BS3_SEL_SPARE_00            0x0500 /**< Spare selector number 00h. */
     200#define BS3_SEL_SPARE_01            0x0508 /**< Spare selector number 01h. */
     201#define BS3_SEL_SPARE_02            0x0510 /**< Spare selector number 02h. */
     202#define BS3_SEL_SPARE_03            0x0518 /**< Spare selector number 03h. */
     203#define BS3_SEL_SPARE_04            0x0520 /**< Spare selector number 04h. */
     204#define BS3_SEL_SPARE_05            0x0528 /**< Spare selector number 05h. */
     205#define BS3_SEL_SPARE_06            0x0530 /**< Spare selector number 06h. */
     206#define BS3_SEL_SPARE_07            0x0538 /**< Spare selector number 07h. */
     207#define BS3_SEL_SPARE_08            0x0540 /**< Spare selector number 08h. */
     208#define BS3_SEL_SPARE_09            0x0548 /**< Spare selector number 09h. */
     209#define BS3_SEL_SPARE_0a            0x0550 /**< Spare selector number 0ah. */
     210#define BS3_SEL_SPARE_0b            0x0558 /**< Spare selector number 0bh. */
     211#define BS3_SEL_SPARE_0c            0x0560 /**< Spare selector number 0ch. */
     212#define BS3_SEL_SPARE_0d            0x0568 /**< Spare selector number 0dh. */
     213#define BS3_SEL_SPARE_0e            0x0570 /**< Spare selector number 0eh. */
     214#define BS3_SEL_SPARE_0f            0x0578 /**< Spare selector number 0fh. */
     215#define BS3_SEL_SPARE_10            0x0580 /**< Spare selector number 10h. */
     216#define BS3_SEL_SPARE_11            0x0588 /**< Spare selector number 11h. */
     217#define BS3_SEL_SPARE_12            0x0590 /**< Spare selector number 12h. */
     218#define BS3_SEL_SPARE_13            0x0598 /**< Spare selector number 13h. */
     219#define BS3_SEL_SPARE_14            0x05a0 /**< Spare selector number 14h. */
     220#define BS3_SEL_SPARE_15            0x05a8 /**< Spare selector number 15h. */
     221#define BS3_SEL_SPARE_16            0x05b0 /**< Spare selector number 16h. */
     222#define BS3_SEL_SPARE_17            0x05b8 /**< Spare selector number 17h. */
     223#define BS3_SEL_SPARE_18            0x05c0 /**< Spare selector number 18h. */
     224#define BS3_SEL_SPARE_19            0x05c8 /**< Spare selector number 19h. */
     225#define BS3_SEL_SPARE_1a            0x05d0 /**< Spare selector number 1ah. */
     226#define BS3_SEL_SPARE_1b            0x05d8 /**< Spare selector number 1bh. */
     227#define BS3_SEL_SPARE_1c            0x05e0 /**< Spare selector number 1ch. */
     228#define BS3_SEL_SPARE_1d            0x05e8 /**< Spare selector number 1dh. */
     229#define BS3_SEL_SPARE_1e            0x05f0 /**< Spare selector number 1eh. */
     230#define BS3_SEL_SPARE_1f            0x05f8 /**< Spare selector number 1fh. */
     231
     232#define BS3_SEL_TILED               0x0600 /**< 16-bit data tiling: First - base=0x00000000, limit=64KB. */
     233#define BS3_SEL_TILED_LAST          0x0df8 /**< 16-bit data tiling: Last  - base=0x00ff0000, limit=64KB. */
     234#define BS3_SEL_TILED_AREA_SIZE     0x001000000 /**< 16-bit data tiling: Size of addressable area, in bytes. (16 MB) */
     235
     236#define BS3_SEL_FREE_PART1          0x0e00 /**< Free selector space - part \#1. */
     237#define BS3_SEL_FREE_PART1_LAST     0x0ff8 /**< Free selector space - part \#1, last entry. */
     238
     239#define BS3_SEL_TEXT16              0x1000 /**< The BS3TEXT16 selector. */
     240
     241#define BS3_SEL_FREE_PART2          0x1008 /**< Free selector space - part \#2. */
     242#define BS3_SEL_FREE_PART2_LAST     0x1ff8 /**< Free selector space - part \#2, last entry. */
     243
     244#define BS3_SEL_SYSTEM16            0x2000 /**< The BS3SYSTEM16 selector. */
     245
     246#define BS3_SEL_FREE_PART3          0x2008 /**< Free selector space - part \#3. */
     247#define BS3_SEL_FREE_PART3_LAST     0x26f8 /**< Free selector space - part \#3, last entry. */
     248
     249#define BS3_SEL_DATA16              0x2700 /**< The BS3DATA16 selector. */
     250
     251#define BS3_SEL_GDT_LIMIT           0x2707 /**< The GDT limit. */
     252/** @} */
     253
    42254
    43255/** @def BS3_FAR
     
    88300 */
    89301#define BS3_CMN_NM(a_Name)  RT_CONCAT3(a_Name,_c,ARCH_BITS)
     302
     303/**
     304 * Constructs a data name.
     305 *
     306 * Example: BS3_DATA_NM(Bs3Gdt)
     307 *
     308 * @param   a_Name      The name of the global variable.
     309 */
     310#if ARCH_BITS == 64
     311# define BS3_DATA_NM(a_Name)  RT_CONCAT(_,a_Name)
     312#else
     313# define BS3_DATA_NM(a_Name)  a_Name
     314#endif
    90315
    91316/**
     
    140365
    141366
     367/** @defgroup grp_bs3kit_system System structures
     368 * @{ */
     369/** The GDT, indexed by BS3_SEL_XXX shifted by 3. */
     370extern X86DESC BS3_DATA_NM(Bs3Gdt)[(BS3_SEL_GDT_LIMIT + 1) / 8];
     371
     372extern X86DESC64 BS3_DATA_NM(Bs3Gdt_Ldt);                   /**< @see BS3_SEL_LDT */
     373extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16);                  /**< @see BS3_SEL_TSS16  */
     374extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16DoubleFault);       /**< @see BS3_SEL_TSS16_DF */
     375extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16Spare0);            /**< @see BS3_SEL_TSS16_SPARE0 */
     376extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16Spare1);            /**< @see BS3_SEL_TSS16_SPARE1 */
     377extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32);                  /**< @see BS3_SEL_TSS32 */
     378extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32DoubleFault);       /**< @see BS3_SEL_TSS32_DF */
     379extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32Spare0);            /**< @see BS3_SEL_TSS32_SPARE0 */
     380extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32Spare1);            /**< @see BS3_SEL_TSS32_SPARE1 */
     381extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32IobpIntRedirBm);    /**< @see BS3_SEL_TSS32_IOBP_IRB */
     382extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32IntRedirBm);        /**< @see BS3_SEL_TSS32_IRB */
     383extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64);                  /**< @see BS3_SEL_TSS64 */
     384extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Spare0);            /**< @see BS3_SEL_TSS64_SPARE0 */
     385extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Spare1);            /**< @see BS3_SEL_TSS64_SPARE1 */
     386extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Iobp);              /**< @see BS3_SEL_TSS64_IOBP */
     387extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_MMIO16);              /**< @see BS3_SEL_VMMDEV_MMIO16 */
     388
     389extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_First);               /**< @see BS3_SEL_R0_FIRST */
     390extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16);                /**< @see BS3_SEL_R0_CS16 */
     391extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS16);                /**< @see BS3_SEL_R0_DS16 */
     392extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_SS16);                /**< @see BS3_SEL_R0_SS16 */
     393extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32);                /**< @see BS3_SEL_R0_CS32 */
     394extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS32);                /**< @see BS3_SEL_R0_DS32 */
     395extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_SS32);                /**< @see BS3_SEL_R0_SS32 */
     396extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64);                /**< @see BS3_SEL_R0_CS64 */
     397extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS64);                /**< @see BS3_SEL_R0_DS64 */
     398extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_EO);             /**< @see BS3_SEL_R0_CS16_EO */
     399extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_CNF);            /**< @see BS3_SEL_R0_CS16_CNF */
     400extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_CND_EO);         /**< @see BS3_SEL_R0_CS16_CNF_EO */
     401extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_EO);             /**< @see BS3_SEL_R0_CS32_EO */
     402extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF);            /**< @see BS3_SEL_R0_CS32_CNF */
     403extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF_EO);         /**< @see BS3_SEL_R0_CS32_CNF_EO */
     404extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_EO);             /**< @see BS3_SEL_R0_CS64_EO */
     405extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF);            /**< @see BS3_SEL_R0_CS64_CNF */
     406extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF_EO);         /**< @see BS3_SEL_R0_CS64_CNF_EO */
     407
     408extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_First);               /**< @see BS3_SEL_R1_FIRST */
     409extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16);                /**< @see BS3_SEL_R1_CS16 */
     410extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS16);                /**< @see BS3_SEL_R1_DS16 */
     411extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_SS16);                /**< @see BS3_SEL_R1_SS16 */
     412extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32);                /**< @see BS3_SEL_R1_CS32 */
     413extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS32);                /**< @see BS3_SEL_R1_DS32 */
     414extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_SS32);                /**< @see BS3_SEL_R1_SS32 */
     415extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64);                /**< @see BS3_SEL_R1_CS64 */
     416extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS64);                /**< @see BS3_SEL_R1_DS64 */
     417extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_EO);             /**< @see BS3_SEL_R1_CS16_EO */
     418extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_CNF);            /**< @see BS3_SEL_R1_CS16_CNF */
     419extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_CND_EO);         /**< @see BS3_SEL_R1_CS16_CNF_EO */
     420extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_EO);             /**< @see BS3_SEL_R1_CS32_EO */
     421extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF);            /**< @see BS3_SEL_R1_CS32_CNF */
     422extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF_EO);         /**< @see BS3_SEL_R1_CS32_CNF_EO */
     423extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_EO);             /**< @see BS3_SEL_R1_CS64_EO */
     424extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF);            /**< @see BS3_SEL_R1_CS64_CNF */
     425extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF_EO);         /**< @see BS3_SEL_R1_CS64_CNF_EO */
     426
     427extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_First);               /**< @see BS3_SEL_R2_FIRST */
     428extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16);                /**< @see BS3_SEL_R2_CS16 */
     429extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS16);                /**< @see BS3_SEL_R2_DS16 */
     430extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_SS16);                /**< @see BS3_SEL_R2_SS16 */
     431extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32);                /**< @see BS3_SEL_R2_CS32 */
     432extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS32);                /**< @see BS3_SEL_R2_DS32 */
     433extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_SS32);                /**< @see BS3_SEL_R2_SS32 */
     434extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64);                /**< @see BS3_SEL_R2_CS64 */
     435extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS64);                /**< @see BS3_SEL_R2_DS64 */
     436extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_EO);             /**< @see BS3_SEL_R2_CS16_EO */
     437extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_CNF);            /**< @see BS3_SEL_R2_CS16_CNF */
     438extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_CND_EO);         /**< @see BS3_SEL_R2_CS16_CNF_EO */
     439extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_EO);             /**< @see BS3_SEL_R2_CS32_EO */
     440extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF);            /**< @see BS3_SEL_R2_CS32_CNF */
     441extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF_EO);         /**< @see BS3_SEL_R2_CS32_CNF_EO */
     442extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_EO);             /**< @see BS3_SEL_R2_CS64_EO */
     443extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF);            /**< @see BS3_SEL_R2_CS64_CNF */
     444extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF_EO);         /**< @see BS3_SEL_R2_CS64_CNF_EO */
     445
     446extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_First);               /**< @see BS3_SEL_R3_FIRST */
     447extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16);                /**< @see BS3_SEL_R3_CS16 */
     448extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS16);                /**< @see BS3_SEL_R3_DS16 */
     449extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_SS16);                /**< @see BS3_SEL_R3_SS16 */
     450extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32);                /**< @see BS3_SEL_R3_CS32 */
     451extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS32);                /**< @see BS3_SEL_R3_DS32 */
     452extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_SS32);                /**< @see BS3_SEL_R3_SS32 */
     453extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64);                /**< @see BS3_SEL_R3_CS64 */
     454extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS64);                /**< @see BS3_SEL_R3_DS64 */
     455extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_EO);             /**< @see BS3_SEL_R3_CS16_EO */
     456extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_CNF);            /**< @see BS3_SEL_R3_CS16_CNF */
     457extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_CND_EO);         /**< @see BS3_SEL_R3_CS16_CNF_EO */
     458extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_EO);             /**< @see BS3_SEL_R3_CS32_EO */
     459extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF);            /**< @see BS3_SEL_R3_CS32_CNF */
     460extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF_EO);         /**< @see BS3_SEL_R3_CS32_CNF_EO */
     461extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_EO);             /**< @see BS3_SEL_R3_CS64_EO */
     462extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF);            /**< @see BS3_SEL_R3_CS64_CNF */
     463extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF_EO);         /**< @see BS3_SEL_R3_CS64_CNF_EO */
     464
     465extern X86DESC BS3_DATA_NM(Bs3GdteSpare00); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_00 */
     466extern X86DESC BS3_DATA_NM(Bs3GdteSpare01); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_01 */
     467extern X86DESC BS3_DATA_NM(Bs3GdteSpare02); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_02 */
     468extern X86DESC BS3_DATA_NM(Bs3GdteSpare03); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_03 */
     469extern X86DESC BS3_DATA_NM(Bs3GdteSpare04); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_04 */
     470extern X86DESC BS3_DATA_NM(Bs3GdteSpare05); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_05 */
     471extern X86DESC BS3_DATA_NM(Bs3GdteSpare06); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_06 */
     472extern X86DESC BS3_DATA_NM(Bs3GdteSpare07); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_07 */
     473extern X86DESC BS3_DATA_NM(Bs3GdteSpare08); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_08 */
     474extern X86DESC BS3_DATA_NM(Bs3GdteSpare09); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_09 */
     475extern X86DESC BS3_DATA_NM(Bs3GdteSpare0a); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0a */
     476extern X86DESC BS3_DATA_NM(Bs3GdteSpare0b); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0b */
     477extern X86DESC BS3_DATA_NM(Bs3GdteSpare0c); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0c */
     478extern X86DESC BS3_DATA_NM(Bs3GdteSpare0d); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0d */
     479extern X86DESC BS3_DATA_NM(Bs3GdteSpare0e); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0e */
     480extern X86DESC BS3_DATA_NM(Bs3GdteSpare0f); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0f */
     481extern X86DESC BS3_DATA_NM(Bs3GdteSpare10); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_10 */
     482extern X86DESC BS3_DATA_NM(Bs3GdteSpare11); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_11 */
     483extern X86DESC BS3_DATA_NM(Bs3GdteSpare12); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_12 */
     484extern X86DESC BS3_DATA_NM(Bs3GdteSpare13); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_13 */
     485extern X86DESC BS3_DATA_NM(Bs3GdteSpare14); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_14 */
     486extern X86DESC BS3_DATA_NM(Bs3GdteSpare15); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_15 */
     487extern X86DESC BS3_DATA_NM(Bs3GdteSpare16); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_16 */
     488extern X86DESC BS3_DATA_NM(Bs3GdteSpare17); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_17 */
     489extern X86DESC BS3_DATA_NM(Bs3GdteSpare18); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_18 */
     490extern X86DESC BS3_DATA_NM(Bs3GdteSpare19); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_19 */
     491extern X86DESC BS3_DATA_NM(Bs3GdteSpare1a); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1a */
     492extern X86DESC BS3_DATA_NM(Bs3GdteSpare1b); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1b */
     493extern X86DESC BS3_DATA_NM(Bs3GdteSpare1c); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1c */
     494extern X86DESC BS3_DATA_NM(Bs3GdteSpare1d); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1d */
     495extern X86DESC BS3_DATA_NM(Bs3GdteSpare1e); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1e */
     496extern X86DESC BS3_DATA_NM(Bs3GdteSpare1f); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1f */
     497
     498/** GDTs setting up the tiled 16-bit access to the first 16 MBs of memory.
     499 * @see BS3_SEL_TILED, BS3_SEL_TILED_LAST, BS3_SEL_TILED_AREA_SIZE */
     500extern X86DESC BS3_DATA_NM(Bs3GdteTiled)[256];
     501/** Free GDTes, part \#1. */
     502extern X86DESC BS3_DATA_NM(Bs3GdteFreePart1)[64];
     503/** The BS3CODE16 GDT entry. @see BS3_SEL_TEXT16   */
     504extern X86DESC BS3_DATA_NM(Bs3Gdte_CODE16);
     505/** Free GDTes, part \#2. */
     506extern X86DESC BS3_DATA_NM(Bs3GdteFreePart2)[511];
     507/** The BS3SYSTEM16 GDT entry. */
     508extern X86DESC BS3_DATA_NM(Bs3Gdte_SYSTEM16);
     509/** Free GDTes, part \#3. */
     510extern X86DESC BS3_DATA_NM(Bs3GdteFreePart3)[223];
     511/** The BS3DATA16 GDT entry. */
     512extern X86DESC BS3_DATA_NM(Bs3Gdte_DATA16);
     513/** The end of the GDT (exclusive). */
     514extern X86DESC BS3_DATA_NM(Bs3GdtEnd);
     515
     516/** The default 16-bit TSS. */
     517extern X86TSS16  BS3_DATA_NM(Bs3Tss16);
     518extern X86TSS16  BS3_DATA_NM(Bs3Tss16DoubleFault);
     519extern X86TSS16  BS3_DATA_NM(Bs3Tss16Spare0);
     520extern X86TSS16  BS3_DATA_NM(Bs3Tss16Spare1);
     521/** The default 32-bit TSS. */
     522extern X86TSS32  BS3_DATA_NM(Bs3Tss32);
     523extern X86TSS32  BS3_DATA_NM(Bs3Tss32DoubleFault);
     524extern X86TSS32  BS3_DATA_NM(Bs3Tss32Spare0);
     525extern X86TSS32  BS3_DATA_NM(Bs3Tss32Spare1);
     526/** The default 64-bit TSS. */
     527extern X86TSS64  BS3_DATA_NM(Bs3Tss64);
     528extern X86TSS64  BS3_DATA_NM(Bs3Tss64Spare0);
     529extern X86TSS64  BS3_DATA_NM(Bs3Tss64Spare1);
     530extern X86TSS64  BS3_DATA_NM(Bs3Tss64WithIopb);
     531extern X86TSS32  BS3_DATA_NM(Bs3Tss32WithIopb);
     532/** Interrupt redirection bitmap used by Bs3Tss32WithIopb. */
     533extern uint8_t   BS3_DATA_NM(Bs3SharedIntRedirBm)[32];
     534/** I/O permission bitmap used by Bs3Tss32WithIopb and Bs3Tss64WithIopb. */
     535extern uint8_t   BS3_DATA_NM(Bs3SharedIobp)[8192+2];
     536/** End of the I/O permission bitmap (exclusive). */
     537extern uint8_t   BS3_DATA_NM(Bs3SharedIobpEnd);
     538/** 16-bit IDT. */
     539extern X86DESC   BS3_DATA_NM(Bs3Idt16)[256];
     540/** 32-bit IDT. */
     541extern X86DESC   BS3_DATA_NM(Bs3Idt32)[256];
     542/** 64-bit IDT. */
     543extern X86DESC64 BS3_DATA_NM(Bs3Idt64)[256];
     544/** Structure for the LIDT instruction for loading the 16-bit IDT. */
     545extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt16);
     546/** Structure for the LIDT instruction for loading the 32-bit IDT. */
     547extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt32);
     548/** Structure for the LIDT instruction for loading the 64-bit IDT. */
     549extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt64);
     550/** Structure for the LIDT instruction for loading the real mode interrupt
     551 *  vector table.. */
     552extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Ivt);
     553/** Structure for the LGDT instruction for loading the GDT. */
     554extern X86XDTR64 BS3_DATA_NM(Bs3Lgdt_Gdt);
     555/** The LDT (all entries are empty, fill in for testing). */
     556extern X86DESC   BS3_DATA_NM(Bs3Ldt)[118];
     557/** The end of the LDT (exclusive).   */
     558extern X86DESC   BS3_DATA_NM(Bs3LdtEnd);
     559
     560
     561
     562
    142563/** @defgroup grp_bs3kit_cmn    Common Functions and Data
    143564 *
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac

    r58675 r58694  
    127127  %define BS3_BEGIN_TEXT16_NOT_FIRST
    128128  %ifdef ASM_FORMAT_ELF
    129         section BS3TEXT16 align=1 progbits alloc exec nowrite
     129        section BS3TEXT16 align=2 progbits alloc exec nowrite
    130130  %else
    131         section BS3TEXT16 align=1 CLASS=BS3CODE16 PUBLIC USE16
    132   %endif
    133 
     131        section BS3TEXT16 align=2 CLASS=BS3CODE16 PUBLIC USE16
     132  %endif
    134133 %else
    135134        section BS3TEXT16
     
    206205 %endif
    207206        BS3_SET_BITS 64
     207%endmacro
     208
     209;; The system data segment containing the GDT, TSSes and IDTs.
     210%macro BS3_BEGIN_SYSTEM16 0
     211 %ifndef  BS3_BEGIN_SYSTEM16_NOT_FIRST
     212  %define BS3_BEGIN_SYSTEM16_NOT_FIRST
     213  %ifdef ASM_FORMAT_ELF
     214        section BS3SYSTEM16 align=16 progbits alloc noexec write
     215  %else
     216        section BS3SYSTEM16 align=16 CLASS=BS3SYSTEM16 PUBLIC USE16
     217  %endif
     218 %else
     219        section BS3SYSTEM16
     220 %endif
     221        BS3_SET_BITS 16
    208222%endmacro
    209223
     
    275289
    276290;;
     291; Mangles a 16-bit and 32-bit accessible data name.
     292; @remarks Requires the use of the BS3_SET_BITS macro instead of the BITS directive.
     293%define BS3_DATA_NM(a_Name)     _ %+ a_Name
     294
     295;;
    277296; Extern macro which mangles a DATA16 symbol correctly, redefining the
    278297; unmangled name to the mangled one for ease of use.
     
    310329%endif
    311330%1:
     331%endmacro
     332
     333;;
     334; Global data unmangled label.
     335;
     336; @param    %1  The unmangled name.
     337; @param    %2  The size (0 is fine).
     338;
     339%macro BS3_GLOBAL_DATA 2
     340BS3_GLOBAL_NAME_EX BS3_DATA_NM(%1), , %2
    312341%endmacro
    313342
     
    457486; @{
    458487;; The flat load address for the code after the bootsector.
    459 %define BS3_LOAD_ADDR           010000h
     488%define BS3_ADDR_LOAD           010000h
    460489;; Where we save the boot registers during init.
    461490; Located right before the code.
    462 %define BS3_REG_SAVE_ADDR       (BS3_LOAD_ADDR - BS3REGS_size - 8)
     491%define BS3_ADDR_REG_SAVE       (BS3_ADDR_LOAD - BS3REGS_size - 8)
    463492;; Where the stack starts (initial RSP value).
    464 ; Located right before the saved registers. SS.BASE=0.
    465 %define BS3_STACK_ADDR          (BS3_REG_SAVE_ADDR - 16)
     493; Located 16 bytes (assumed by boot sector) before the saved registers. SS.BASE=0.
     494%define BS3_ADDR_STACK          (BS3_ADDR_REG_SAVE - 16)
     495;; The ring-0 stack (8KB) for ring transitions.
     496%define BS3_ADDR_STACK_R0       006000h
     497;; The ring-1 stack (8KB) for ring transitions.
     498%define BS3_ADDR_STACK_R1       004000h
     499;; The ring-2 stack (8KB) for ring transitions.
     500%define BS3_ADDR_STACK_R2       002000h
     501;; IST1 ring-0 stack for long mode (4KB), used for double faults elsewhere.
     502%define BS3_ADDR_STACK_R0_IST1  009000h
     503;; IST2 ring-0 stack for long mode (3KB), used for spare 0 stack elsewhere.
     504%define BS3_ADDR_STACK_R0_IST2  008000h
     505;; IST3 ring-0 stack for long mode (1KB).
     506%define BS3_ADDR_STACK_R0_IST3  007400h
     507;; IST4 ring-0 stack for long mode (1KB), used for spare 1 stack elsewhere.
     508%define BS3_ADDR_STACK_R0_IST4  007000h
     509;; IST5 ring-0 stack for long mode (1KB).
     510%define BS3_ADDR_STACK_R0_IST5  006c00h
     511;; IST6 ring-0 stack for long mode (1KB).
     512%define BS3_ADDR_STACK_R0_IST6  006800h
     513;; IST7 ring-0 stack for long mode (1KB).
     514%define BS3_ADDR_STACK_R0_IST7  006400h
     515
     516;; The base address of the BS3TEXT16 segment (same as BS3_LOAD_ADDR).
     517;; @sa BS3_SEL_TEXT16
     518%define BS3_ADDR_BS3TEXT16      010000h
     519;; The base address of the BS3SYSTEM16 segment.
     520;; @sa BS3_SEL_SYSTEM16
     521%define BS3_ADDR_BS3SYSTEM16    020000h
     522;; The base address of the BS3DATA16 segment.
     523;; @sa BS3_SEL_DATA16
     524%define BS3_ADDR_BS3DATA16      027000h
    466525;; @}
    467526
     
    535594;; @}
    536595
    537 %endif
    538 
     596
     597
     598;; @name BS3_SEL_XXX - GDT selectors
     599;; @{
     600
     601%define BS3_SEL_LDT                 0010h ;;< The LDT selector (requires setting up).
     602%define BS3_SEL_TSS16               0020h ;;< The 16-bit TSS selector.
     603%define BS3_SEL_TSS16_DF            0028h ;;< The 16-bit TSS selector for double faults.
     604%define BS3_SEL_TSS16_SPARE0        0030h ;;< The 16-bit TSS selector for testing.
     605%define BS3_SEL_TSS16_SPARE1        0038h ;;< The 16-bit TSS selector for testing.
     606%define BS3_SEL_TSS32               0040h ;;< The 32-bit TSS selector.
     607%define BS3_SEL_TSS32_DF            0048h ;;< The 32-bit TSS selector for double faults.
     608%define BS3_SEL_TSS32_SPARE0        0050h ;;< The 32-bit TSS selector for testing.
     609%define BS3_SEL_TSS32_SPARE1        0058h ;;< The 32-bit TSS selector for testing.
     610%define BS3_SEL_TSS32_IOBP_IRB      0060h ;;< The 32-bit TSS selector with I/O permission and interrupt redirection bitmaps.
     611%define BS3_SEL_TSS32_IRB           0068h ;;< The 32-bit TSS selector with only interrupt redirection bitmap (IOPB stripped by limit).
     612%define BS3_SEL_TSS64               0070h ;;< The 64-bit TSS selector.
     613%define BS3_SEL_TSS64_SPARE0        0080h ;;< The 64-bit TSS selector.
     614%define BS3_SEL_TSS64_SPARE1        0090h ;;< The 64-bit TSS selector.
     615%define BS3_SEL_TSS64_IOBP          00a0h ;;< The 64-bit TSS selector.
     616
     617%define BS3_SEL_TSS16               0020h ;;< The 16-bit TSS selector.
     618%define BS3_SEL_TSS16_DF            0028h ;;< The 16-bit TSS selector for double faults.
     619%define BS3_SEL_TSS32               0030h ;;< The 32-bit TSS selector.
     620%define BS3_SEL_TSS32_DF            0038h ;;< The 32-bit TSS selector for double faults.
     621%define BS3_SEL_TSS64               0040h ;;< The 64-bit TSS selector.
     622%define BS3_SEL_VMMDEV_MMIO16       00f8h ;;< Selector for accessing the VMMDev MMIO segment at 0100000h from 16-bit code.
     623
     624%define BS3_SEL_R0_FIRST            0100h ;;< The first selector in the ring-0 block.
     625%define BS3_SEL_R0_CS16             0100h ;;< ring-0: 16-bit code selector,  base 0x10000.
     626%define BS3_SEL_R0_DS16             0108h ;;< ring-0: 16-bit data selector,  base 0x23000.
     627%define BS3_SEL_R0_SS16             0110h ;;< ring-0: 16-bit stack selector, base 0x00000.
     628%define BS3_SEL_R0_CS32             0118h ;;< ring-0: 32-bit flat code selector.
     629%define BS3_SEL_R0_DS32             0120h ;;< ring-0: 32-bit flat data selector.
     630%define BS3_SEL_R0_SS32             0128h ;;< ring-0: 32-bit flat stack selector.
     631%define BS3_SEL_R0_CS64             0130h ;;< ring-0: 64-bit flat code selector.
     632%define BS3_SEL_R0_DS64             0138h ;;< ring-0: 64-bit flat data & stack selector.
     633%define BS3_SEL_R0_CS16_EO          0140h ;;< ring-0: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base.
     634%define BS3_SEL_R0_CS16_CNF         0148h ;;< ring-0: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base.
     635%define BS3_SEL_R0_CS16_CNF_EO      0150h ;;< ring-0: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base.
     636%define BS3_SEL_R0_CS32_EO          0158h ;;< ring-0: 32-bit execute-only code selector, not accessed, flat.
     637%define BS3_SEL_R0_CS32_CNF         0160h ;;< ring-0: 32-bit conforming code selector, not accessed, flat.
     638%define BS3_SEL_R0_CS32_CNF_EO      0168h ;;< ring-0: 32-bit execute-only conforming code selector, not accessed, flat.
     639%define BS3_SEL_R0_CS64_EO          0170h ;;< ring-0: 64-bit execute-only code selector, not accessed, flat.
     640%define BS3_SEL_R0_CS64_CNF         0178h ;;< ring-0: 64-bit conforming code selector, not accessed, flat.
     641%define BS3_SEL_R0_CS64_CNF_EO      0180h ;;< ring-0: 64-bit execute-only conforming code selector, not accessed, flat.
     642
     643%define BS3_SEL_R1_FIRST            0200h ;;< The first selector in the ring-1 block.
     644%define BS3_SEL_R1_CS16             0200h ;;< ring-1: 16-bit code selector,  base 0x10000.
     645%define BS3_SEL_R1_DS16             0208h ;;< ring-1: 16-bit data selector,  base 0x23000.
     646%define BS3_SEL_R1_SS16             0210h ;;< ring-1: 16-bit stack selector, base 0x00000.
     647%define BS3_SEL_R1_CS32             0218h ;;< ring-1: 32-bit flat code selector.
     648%define BS3_SEL_R1_DS32             0220h ;;< ring-1: 32-bit flat data selector.
     649%define BS3_SEL_R1_SS32             0228h ;;< ring-1: 32-bit flat stack selector.
     650%define BS3_SEL_R1_CS64             0230h ;;< ring-1: 64-bit flat code selector.
     651%define BS3_SEL_R1_DS64             0238h ;;< ring-1: 64-bit flat data & stack selector.
     652%define BS3_SEL_R1_CS16_EO          0240h ;;< ring-1: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base.
     653%define BS3_SEL_R1_CS16_CNF         0248h ;;< ring-1: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base.
     654%define BS3_SEL_R1_CS16_CNF_EO      0250h ;;< ring-1: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base.
     655%define BS3_SEL_R1_CS32_EO          0258h ;;< ring-1: 32-bit execute-only code selector, not accessed, flat.
     656%define BS3_SEL_R1_CS32_CNF         0260h ;;< ring-1: 32-bit conforming code selector, not accessed, flat.
     657%define BS3_SEL_R1_CS32_CNF_EO      0268h ;;< ring-1: 32-bit execute-only conforming code selector, not accessed, flat.
     658%define BS3_SEL_R1_CS64_EO          0270h ;;< ring-1: 64-bit execute-only code selector, not accessed, flat.
     659%define BS3_SEL_R1_CS64_CNF         0278h ;;< ring-1: 64-bit conforming code selector, not accessed, flat.
     660%define BS3_SEL_R1_CS64_CNF_EO      0280h ;;< ring-1: 64-bit execute-only conforming code selector, not accessed, flat.
     661
     662%define BS3_SEL_R2_FIRST            0300h ;;< The first selector in the ring-2 block.
     663%define BS3_SEL_R2_CS16             0300h ;;< ring-2: 16-bit code selector,  base 0x10000.
     664%define BS3_SEL_R2_DS16             0308h ;;< ring-2: 16-bit data selector,  base 0x23000.
     665%define BS3_SEL_R2_SS16             0310h ;;< ring-2: 16-bit stack selector, base 0x00000.
     666%define BS3_SEL_R2_CS32             0318h ;;< ring-2: 32-bit flat code selector.
     667%define BS3_SEL_R2_DS32             0320h ;;< ring-2: 32-bit flat data selector.
     668%define BS3_SEL_R2_SS32             0328h ;;< ring-2: 32-bit flat stack selector.
     669%define BS3_SEL_R2_CS64             0330h ;;< ring-2: 64-bit flat code selector.
     670%define BS3_SEL_R2_DS64             0338h ;;< ring-2: 64-bit flat data & stack selector.
     671%define BS3_SEL_R2_CS16_EO          0340h ;;< ring-2: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base.
     672%define BS3_SEL_R2_CS16_CNF         0348h ;;< ring-2: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base.
     673%define BS3_SEL_R2_CS16_CNF_EO      0350h ;;< ring-2: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base.
     674%define BS3_SEL_R2_CS32_EO          0358h ;;< ring-2: 32-bit execute-only code selector, not accessed, flat.
     675%define BS3_SEL_R2_CS32_CNF         0360h ;;< ring-2: 32-bit conforming code selector, not accessed, flat.
     676%define BS3_SEL_R2_CS32_CNF_EO      0368h ;;< ring-2: 32-bit execute-only conforming code selector, not accessed, flat.
     677%define BS3_SEL_R2_CS64_EO          0370h ;;< ring-2: 64-bit execute-only code selector, not accessed, flat.
     678%define BS3_SEL_R2_CS64_CNF         0378h ;;< ring-2: 64-bit conforming code selector, not accessed, flat.
     679%define BS3_SEL_R2_CS64_CNF_EO      0380h ;;< ring-2: 64-bit execute-only conforming code selector, not accessed, flat.
     680
     681%define BS3_SEL_R3_FIRST            0400h ;;< The first selector in the ring-3 block.
     682%define BS3_SEL_R3_CS16             0400h ;;< ring-3: 16-bit code selector,  base 0x10000.
     683%define BS3_SEL_R3_DS16             0408h ;;< ring-3: 16-bit data selector,  base 0x23000.
     684%define BS3_SEL_R3_SS16             0410h ;;< ring-3: 16-bit stack selector, base 0x00000.
     685%define BS3_SEL_R3_CS32             0418h ;;< ring-3: 32-bit flat code selector.
     686%define BS3_SEL_R3_DS32             0420h ;;< ring-3: 32-bit flat data selector.
     687%define BS3_SEL_R3_SS32             0428h ;;< ring-3: 32-bit flat stack selector.
     688%define BS3_SEL_R3_CS64             0430h ;;< ring-3: 64-bit flat code selector.
     689%define BS3_SEL_R3_DS64             0438h ;;< ring-3: 64-bit flat data & stack selector.
     690%define BS3_SEL_R3_CS16_EO          0440h ;;< ring-3: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base.
     691%define BS3_SEL_R3_CS16_CNF         0448h ;;< ring-3: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base.
     692%define BS3_SEL_R3_CS16_CNF_EO      0450h ;;< ring-3: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base.
     693%define BS3_SEL_R3_CS32_EO          0458h ;;< ring-3: 32-bit execute-only code selector, not accessed, flat.
     694%define BS3_SEL_R3_CS32_CNF         0460h ;;< ring-3: 32-bit conforming code selector, not accessed, flat.
     695%define BS3_SEL_R3_CS32_CNF_EO      0468h ;;< ring-3: 32-bit execute-only conforming code selector, not accessed, flat.
     696%define BS3_SEL_R3_CS64_EO          0470h ;;< ring-3: 64-bit execute-only code selector, not accessed, flat.
     697%define BS3_SEL_R3_CS64_CNF         0478h ;;< ring-3: 64-bit conforming code selector, not accessed, flat.
     698%define BS3_SEL_R3_CS64_CNF_EO      0480h ;;< ring-3: 64-bit execute-only conforming code selector, not accessed, flat.
     699
     700%define BS3_SEL_SPARE_FIRST         0500h ;;< The first selector in the spare block
     701%define BS3_SEL_SPARE_00            0500h ;;< Spare selector number 00h.
     702%define BS3_SEL_SPARE_01            0508h ;;< Spare selector number 01h.
     703%define BS3_SEL_SPARE_02            0510h ;;< Spare selector number 02h.
     704%define BS3_SEL_SPARE_03            0518h ;;< Spare selector number 03h.
     705%define BS3_SEL_SPARE_04            0520h ;;< Spare selector number 04h.
     706%define BS3_SEL_SPARE_05            0528h ;;< Spare selector number 05h.
     707%define BS3_SEL_SPARE_06            0530h ;;< Spare selector number 06h.
     708%define BS3_SEL_SPARE_07            0538h ;;< Spare selector number 07h.
     709%define BS3_SEL_SPARE_08            0540h ;;< Spare selector number 08h.
     710%define BS3_SEL_SPARE_09            0548h ;;< Spare selector number 09h.
     711%define BS3_SEL_SPARE_0a            0550h ;;< Spare selector number 0ah.
     712%define BS3_SEL_SPARE_0b            0558h ;;< Spare selector number 0bh.
     713%define BS3_SEL_SPARE_0c            0560h ;;< Spare selector number 0ch.
     714%define BS3_SEL_SPARE_0d            0568h ;;< Spare selector number 0dh.
     715%define BS3_SEL_SPARE_0e            0570h ;;< Spare selector number 0eh.
     716%define BS3_SEL_SPARE_0f            0578h ;;< Spare selector number 0fh.
     717%define BS3_SEL_SPARE_10            0580h ;;< Spare selector number 10h.
     718%define BS3_SEL_SPARE_11            0588h ;;< Spare selector number 11h.
     719%define BS3_SEL_SPARE_12            0590h ;;< Spare selector number 12h.
     720%define BS3_SEL_SPARE_13            0598h ;;< Spare selector number 13h.
     721%define BS3_SEL_SPARE_14            05a0h ;;< Spare selector number 14h.
     722%define BS3_SEL_SPARE_15            05a8h ;;< Spare selector number 15h.
     723%define BS3_SEL_SPARE_16            05b0h ;;< Spare selector number 16h.
     724%define BS3_SEL_SPARE_17            05b8h ;;< Spare selector number 17h.
     725%define BS3_SEL_SPARE_18            05c0h ;;< Spare selector number 18h.
     726%define BS3_SEL_SPARE_19            05c8h ;;< Spare selector number 19h.
     727%define BS3_SEL_SPARE_1a            05d0h ;;< Spare selector number 1ah.
     728%define BS3_SEL_SPARE_1b            05d8h ;;< Spare selector number 1bh.
     729%define BS3_SEL_SPARE_1c            05e0h ;;< Spare selector number 1ch.
     730%define BS3_SEL_SPARE_1d            05e8h ;;< Spare selector number 1dh.
     731%define BS3_SEL_SPARE_1e            05f0h ;;< Spare selector number 1eh.
     732%define BS3_SEL_SPARE_1f            05f8h ;;< Spare selector number 1fh.
     733
     734%define BS3_SEL_TILED               0600h  ;;< 16-bit data tiling: First - base=0x00000000, limit=64KB.
     735%define BS3_SEL_TILED_LAST          0df8h  ;;< 16-bit data tiling: Last  - base=0x00ff0000, limit=64KB.
     736%define BS3_SEL_TILED_AREA_SIZE     001000000h ;;< 16-bit data tiling: Size of addressable area, in bytes. (16 MB)
     737
     738%define BS3_SEL_FREE_PART1          0e00h ;;< Free selector space - part \#1.
     739%define BS3_SEL_FREE_PART1_LAST     0ff8h ;;< Free selector space - part \#1, last entry.
     740
     741%define BS3_SEL_TEXT16              1000h ;;< The BS3TEXT16 selector.
     742
     743%define BS3_SEL_FREE_PART2          1008h ;;< Free selector space - part \#2.
     744%define BS3_SEL_FREE_PART2_LAST     1ff8h ;;< Free selector space - part \#2, last entry.
     745
     746%define BS3_SEL_SYSTEM16            2000h ;;< The BS3SYSTEM16 selector.
     747
     748%define BS3_SEL_FREE_PART3          2008h ;;< Free selector space - part \#3.
     749%define BS3_SEL_FREE_PART3_LAST     26f8h ;;< Free selector space - part \#3, last entry.
     750
     751%define BS3_SEL_DATA16              2700h ;;< The BS3DATA16 selector.
     752
     753%define BS3_SEL_GDT_LIMIT           2707h ;;< The GDT limit.
     754
     755;; @}
     756
     757
     758;
     759; Sanity checks.
     760;
     761%if BS3_ADDR_BS3TEXT16 != BS3_ADDR_LOAD
     762 %error "BS3_ADDR_BS3TEXT16 and BS3_ADDR_LOAD are out of sync"
     763%endif
     764%if (BS3_ADDR_BS3TEXT16 / 16) != BS3_SEL_TEXT16
     765 %error "BS3_ADDR_BS3TEXT16 and BS3_SEL_TEXT16 are out of sync"
     766%endif
     767%if (BS3_ADDR_BS3DATA16 / 16) != BS3_SEL_DATA16
     768 %error "BS3_ADDR_BS3DATA16 and BS3_SEL_DATA16 are out of sync"
     769%endif
     770%if (BS3_ADDR_BS3SYSTEM16 / 16) != BS3_SEL_SYSTEM16
     771 %error "BS3_ADDR_BS3SYSTEM16 and BS3_SEL_SYSTEM16 are out of sync"
     772%endif
     773
     774%endif
     775
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette