VirtualBox

Changeset 59259 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Jan 6, 2016 2:53:27 AM (9 years ago)
Author:
vboxsync
Message:

bs3kit: More IDT handling (mainly 32-bit).

Location:
trunk/src/VBox/ValidationKit/bootsectors/bs3kit
Files:
4 added
10 edited
1 copied

Legend:

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

    r59258 r59259  
    523523        bs3-cmn-Trap32Init.c \
    524524        bs3-cmn-Trap32SetGate.c \
     525        bs3-cmn-Trap64SetGate.c \
     526        bs3-cmn-TrapSetHandler.c \
    525527       ../../../Runtime/common/asm/ASMBitFirstClear.asm \
    526528       ../../../Runtime/common/asm/ASMBitFirstSet.asm \
     
    588590        bs3-mode-SwitchToPAE32.asm \
    589591        bs3-mode-SwitchToLM64.asm \
     592        bs3-mode-SwitchToLM32.asm \
     593        bs3-mode-SwitchToLM16.asm \
    590594        bs3-mode-EnteredMode.asm \
    591595        bs3-mode-PagingGetRootForPP16.asm \
     
    594598        bs3-mode-PagingGetRootForPAE32.asm \
    595599        bs3-mode-PagingGetRootForLM64.asm \
     600        bs3-mode-TrapSystemCallHandler.asm \
    596601
    597602# The 16-bit real mode BS3Kit library.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm

    r59258 r59259  
    3232
    3333BS3_BEGIN_DATA32
    34 ;; Easy to access flat address of Bs3Idt32GenericEntries.
    35 BS3_GLOBAL_DATA g_Bs3Idt32GenericEntriesFlatAddr, 4
    36         dd Bs3Idt32GenericEntries
     34;; Easy to access flat address of Bs3Trap32GenericEntries.
     35BS3_GLOBAL_DATA g_Bs3Trap32GenericEntriesFlatAddr, 4
     36        dd Bs3Trap32GenericEntries
    3737
    3838;; Pointer C trap handlers.
    39 BS3_GLOBAL_DATA g_apfnBs3Trap32Handlers, 1024
     39BS3_GLOBAL_DATA g_apfnBs3TrapHandlers_c32, 1024
    4040        resd 256
    4141
     
    4949; Generic entry points for IDT handlers, 8 byte spacing.
    5050;
    51 BS3_PROC_BEGIN Bs3Idt32GenericEntries
    52 %macro Bs3Idt32GenericEntry 1
     51BS3_PROC_BEGIN Bs3Trap32GenericEntries
     52%macro Bs3Trap32GenericEntry 1
    5353        db      06ah, i                 ; push imm8 - note that this is a signextended value.
    5454        jmp     %1
     
    5858
    5959%assign i 0                             ; start counter.
    60         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 0
    61         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 1
    62         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 2
    63         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 3
    64         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 4
    65         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 5
    66         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 6
    67         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 7
    68         Bs3Idt32GenericEntry bs3Idt32GenericTrapErrCode ; 8
    69         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 9
    70         Bs3Idt32GenericEntry bs3Idt32GenericTrapErrCode ; a
    71         Bs3Idt32GenericEntry bs3Idt32GenericTrapErrCode ; b
    72         Bs3Idt32GenericEntry bs3Idt32GenericTrapErrCode ; c
    73         Bs3Idt32GenericEntry bs3Idt32GenericTrapErrCode ; d
    74         Bs3Idt32GenericEntry bs3Idt32GenericTrapErrCode ; e
    75         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; f  (reserved)
    76         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 10
    77         Bs3Idt32GenericEntry bs3Idt32GenericTrapErrCode ; 11
    78         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 12
    79         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 13
    80         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 14
    81         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 15 (reserved)
    82         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 16 (reserved)
    83         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 17 (reserved)
    84         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 18 (reserved)
    85         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 19 (reserved)
    86         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 1a (reserved)
    87         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 1b (reserved)
    88         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 1c (reserved)
    89         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 1d (reserved)
    90         Bs3Idt32GenericEntry bs3Idt32GenericTrapErrCode ; 1e
    91         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt   ; 1f (reserved)
     60        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 0
     61        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 1
     62        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 2
     63        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 3
     64        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 4
     65        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 5
     66        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 6
     67        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 7
     68        Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 8
     69        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 9
     70        Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; a
     71        Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; b
     72        Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; c
     73        Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; d
     74        Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; e
     75        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; f  (reserved)
     76        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 10
     77        Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 11
     78        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 12
     79        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 13
     80        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 14
     81        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 15 (reserved)
     82        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 16 (reserved)
     83        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 17 (reserved)
     84        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 18 (reserved)
     85        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 19 (reserved)
     86        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 1a (reserved)
     87        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 1b (reserved)
     88        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 1c (reserved)
     89        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 1d (reserved)
     90        Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 1e
     91        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt   ; 1f (reserved)
    9292%rep 224
    93         Bs3Idt32GenericEntry bs3Idt32GenericTrapOrInt
     93        Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt
    9494%endrep
    95 BS3_PROC_END  Bs3Idt32GenericEntries
     95BS3_PROC_END  Bs3Trap32GenericEntries
    9696
    9797
     
    101101; Trap or interrupt (no error code).
    102102;
    103 BS3_PROC_BEGIN bs3Idt32GenericTrapOrInt
     103BS3_PROC_BEGIN bs3Trap32GenericTrapOrInt
    104104        pushfd
    105105        cli
     
    121121        mov     [esp + BS3TRAPFRAME.uErrCd], edx
    122122        mov     [esp + BS3TRAPFRAME.uErrCd + 4], edx
    123         jmp     bs3Idt32GenericCommon
    124 BS3_PROC_END   bs3Idt32GenericTrapOrInt
     123        jmp     bs3Trap32GenericCommon
     124BS3_PROC_END   bs3Trap32GenericTrapOrInt
    125125
    126126
     
    128128; Trap with error code.
    129129;
    130 BS3_PROC_BEGIN bs3Idt32GenericTrapErrCode
     130BS3_PROC_BEGIN bs3Trap32GenericTrapErrCode
    131131        pushfd
    132132        cli
     
    150150        xor     edx, edx
    151151        mov     [esp + BS3TRAPFRAME.uErrCd + 4], edx
    152         jmp     bs3Idt32GenericCommon
    153 BS3_PROC_END   bs3Idt32GenericTrapErrCode
     152        jmp     bs3Trap32GenericCommon
     153BS3_PROC_END   bs3Trap32GenericTrapErrCode
    154154
    155155
     
    170170; @param    edx     Zero (0).
    171171;
    172 BS3_PROC_BEGIN bs3Idt32GenericCommon
     172BS3_PROC_BEGIN bs3Trap32GenericCommon
    173173        ;
    174174        ; Fake EBP frame.
     
    301301        ;
    302302        movzx   ebx, byte [esp + BS3TRAPFRAME.bXcpt]
    303         mov     eax, [BS3_DATA_NM(g_apfnBs3Trap32Handlers) + ebx * 4]
     303        mov     eax, [BS3_DATA_NM(g_apfnBs3TrapHandlers_c32) + ebx * 4]
    304304        or      eax, eax
    305305        jnz     .call_handler
     
    320320        hlt
    321321        jmp     .panic
    322 BS3_PROC_END   bs3Idt32GenericCommon
    323 
     322BS3_PROC_END   bs3Trap32GenericCommon
     323
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-PrintChr.asm

    r58675 r59259  
    3434        push    xBP
    3535        mov     xBP, xSP
    36         push    sAX
    37         push    sCX
     36        push    xAX
     37        push    xCX
    3838        push    xBX
    39 
    40         ; Load the char.
    41         movzx   eax, byte [xBP + xCB*2]
    4239
    4340%ifdef TMPL_16BIT
     
    4744        jnz     .protected_mode
    4845
     46        mov     al, [xBP + xCB*2]       ; Load the char
    4947        mov     bx, 0ff00h
    5048        mov     ah, 0eh
     
    5553%endif
    5654
    57         mov     ecx, eax
    58         mov     eax, BS3_SYSCALL_PRINT_CHR
     55        mov     cl, [xBP + xCB*2]       ; Load the char
     56        mov     ax, BS3_SYSCALL_PRINT_CHR
    5957        int     BS3_TRAP_SYSCALL
    6058
    6159.return:
    6260        pop     xBX
    63         pop     sCX
    64         pop     sAX
     61        pop     xCX
     62        pop     xAX
    6563        leave
    6664        BS3_CALL_CONV_EPILOG 1
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap32Init.c

    r59258 r59259  
    3737    while (iIdt-- > 0)
    3838        Bs3Trap32SetGate(iIdt, X86_SEL_TYPE_SYS_386_INT_GATE, 0 /*bDpl*/,
    39                          BS3_SEL_R0_CS32, BS3_DATA_NM(g_Bs3Idt32GenericEntriesFlatAddr) + iIdt * 8, 0 /*cParams*/);
     39                         BS3_SEL_R0_CS32, BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr) + iIdt * 8, 0 /*cParams*/);
    4040    /** @todo Init TSS for double faults and stuff. */
    4141}
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-Trap64SetGate.c

    r59258 r59259  
    11/* $Id$ */
    22/** @file
    3  * BS3Kit - Bs3Trap32SetGate
     3 * BS3Kit - Bs3Trap64SetGate
    44 */
    55
     
    3232
    3333
    34 BS3_DECL(void) Bs3Trap32SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams)
     34BS3_DECL(void) Bs3Trap64SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst)
    3535{
    36     X86DESC BS3_FAR *pIdte = &BS3_DATA_NM(Bs3Idt32)[iIdt];
     36    X86DESC64 BS3_FAR *pIdte = &BS3_DATA_NM(Bs3Idt64)[iIdt];
    3737
    3838    BS3_ASSERT(bDpl <= 3);
    3939    BS3_ASSERT(bType <= 7);
    40     BS3_ASSERT(cParams <= 15);
     40    BS3_ASSERT(bIst <= 7);
    4141    pIdte->Gate.u16OffsetLow    = (uint16_t)off;
    42     pIdte->Gate.u16OffsetHigh   = (uint16_t)(off >> 16);
     42    pIdte->Gate.u16OffsetHigh   = (uint16_t)((uint32_t)off >> 16);
     43    pIdte->Gate.u32OffsetTop    = (uint32_t)(off >> 32);
    4344    pIdte->Gate.u16Sel          = uSel;
    44     pIdte->Gate.u4ParmCount     = cParams;
     45    pIdte->Gate.u3IST           = bIst;
    4546    pIdte->Gate.u4Type          = bType;
    4647    pIdte->Gate.u2Dpl           = bDpl;
    47     pIdte->Gate.u4Reserved      = 0;
     48    pIdte->Gate.u5Reserved      = 0;
    4849    pIdte->Gate.u1DescType      = 0; /* system */
    4950    pIdte->Gate.u1Present       = 1;
     51    pIdte->Gate.u32Reserved     = 0;
     52
    5053}
    5154
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-EnteredMode.asm

    r59242 r59259  
    55
    66;
    7 ; Copyright (C) 2007-2015 Oracle Corporation
     7; Copyright (C) 2007-2016 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    4646BS3_BEGIN_DATA16
    4747TMPL_BEGIN_TEXT
     48extern               TMPL_NM(Bs3TrapSystemCallHandler)
    4849        xor     ax, ax
    4950        mov     ss, ax
     
    5253        mov     es, ax
    5354
     55        mov     word [ss: BS3_TRAP_SYSCALL*4], TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16
     56        mov     word [ss: BS3_TRAP_SYSCALL*4 + 2], BS3TEXT16
     57
    5458%elif TMPL_BITS == 16
    5559BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt16
     
    5761BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss16DoubleFault
    5862TMPL_BEGIN_TEXT
     63;BS3_EXTERN_CMN      Bs3Trap32SetGate
     64;extern              TMPL_NM(Bs3TrapSystemCallHandler)
    5965        jmp     BS3_SEL_R0_CS16:.reloaded_cs
    6066.reloaded_cs:
     
    8086        mov     es, ax
    8187
     88;        push    0                       ; cParams
     89;        push    TMPL_NM(Bs3TrapSystemCallHandler) wrt BS3TEXT16
     90;        push    BS3_SEL_R0_CS16
     91;        push    3                       ; DPL
     92;        push    X86_SEL_TYPE_SYS_286_INT_GATE
     93;        push    BS3_TRAP_SYSCALL
     94;        call    Bs3Trap16SetGate
     95;        add     sp, xCB * 6
     96
    8297%elif TMPL_BITS == 32
    8398BS3_EXTERN_SYSTEM16 Bs3Lidt_Idt32
     
    85100BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss32DoubleFault
    86101TMPL_BEGIN_TEXT
     102%ifndef TMPL_CMN_LM
     103BS3_EXTERN_CMN      Bs3Trap32SetGate
     104extern              TMPL_NM(Bs3TrapSystemCallHandler)
     105%else
     106BS3_EXTERN_CMN      Bs3Trap64SetGate
     107extern              Bs3TrapSystemCallHandler_lm64
     108%endif
     109
    87110        mov     ax, BS3_SEL_R0_SS32
    88111        mov     ss, ax
     
    105128        mov     es, ax
    106129
     130 %ifndef TMPL_CMN_LM
     131        push    0                       ; cParams
     132        push    TMPL_NM(Bs3TrapSystemCallHandler) wrt FLAT
     133        push    BS3_SEL_R0_CS32
     134        push    3                       ; DPL
     135        push    X86_SEL_TYPE_SYS_386_INT_GATE
     136        push    BS3_TRAP_SYSCALL
     137        call    Bs3Trap32SetGate
     138        add     esp, xCB * 6
     139 %else
     140        push    0                       ; cParams
     141        push    0                       ; upper offset
     142        push    Bs3TrapSystemCallHandler_lm64 wrt FLAT
     143        push    BS3_SEL_R0_CS64
     144        push    3                       ; DPL
     145        push    AMD64_SEL_TYPE_SYS_INT_GATE
     146        push    BS3_TRAP_SYSCALL
     147        call    Bs3Trap64SetGate
     148        add     esp, xCB * 6
     149%endif
    107150
    108151%elif TMPL_BITS == 64
     
    110153BS3_EXTERN_SYSTEM16 Bs3Gdte_Tss64
    111154TMPL_BEGIN_TEXT
     155;BS3_EXTERN_CMN      Bs3Trap64SetGate
     156;extern              TMPL_NM(Bs3TrapSystemCallHandler)
    112157        mov     ax, BS3_SEL_R0_DS64
    113158        mov     ss, ax
     
    129174        mov     es, ax
    130175
     176;        push    0                       ; cParams
     177;        push    TMPL_NM(Bs3TrapSystemCallHandler) wrt FLAT
     178;        push    BS3_SEL_R0_CS16
     179;        push    3                       ; DPL
     180;        push    AMD64_SEL_TYPE_SYS_INT_GATE
     181;        push    BS3_TRAP_SYSCALL
     182;        call    Bs3Trap64SetGate
     183;        add     sp, xCB * 6
     184
    131185%else
    132186 %error "TMPL_BITS"
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM64.asm

    r59245 r59259  
    2929
    3030;;
    31 ; Switch to PAE paged protected mode from any other mode.
     31; Switch to 64-bit long mode from any other mode.
    3232;
    3333; @cproto   BS3_DECL(void) Bs3SwitchToLM64(void);
    3434;
    35 ; @uses     Nothing (except high 32-bit register parts), upper part of ESP is
    36 ;           cleared if caller is in 16-bit mode.
     35; @uses     Nothing (except possibly high 32-bit and/or upper 64-bit register parts).
    3736;
    38 ; @remarks  Obviously returns to 32-bit mode, even if the caller was
    39 ;           in 16-bit or 64-bit mode.  It doesn't not preserve the callers
    40 ;           ring, but instead changes to ring-0.
     37; @remarks  Obviously returns to 64-bit mode, even if the caller was in 16-bit
     38;           or 32-bit mode.  It doesn't not preserve the callers ring, but
     39;           instead changes to ring-0.
    4140;
    4241BS3_PROC_BEGIN_MODE Bs3SwitchToLM64
     
    5251
    5352%else
    54  %if TMPL_BITS == 16
    55         push    word 0                  ; save space for extending the return value.
    56  %endif
     53        ;
     54        ; Switch to LM32 and then switch to 64-bits (IDT & TSS are the same for
     55        ; LM16, LM32 and LM64, unlike the rest).
     56        ;
     57        ; (The long mode switching code is going via 32-bit protected mode, so
     58        ; Bs3SwitchToLM32 contains the actual code for switching to avoid
     59        ; unnecessary 32-bit -> 64-bit -> 32-bit trips.)
     60        ;
     61        extern  TMPL_NM(Bs3SwitchToLM32)
     62        call    TMPL_NM(Bs3SwitchToLM32)
     63        BS3_SET_BITS 32
    5764
    58         ;
    59         ; Switch to 32-bit protected mode (for identify mapped pages).
    60         ;
    61         extern  TMPL_NM(Bs3SwitchToPE32)
    62         call    TMPL_NM(Bs3SwitchToPE32)
    63         BS3_SET_BITS 32
    64  %if TMPL_BITS == 16
    65         jmp     .thirty_two_bit_segment
    66 BS3_BEGIN_TEXT32
    67 .thirty_two_bit_segment:
    68  %endif
    69 
    70         push    eax
    71         push    ecx
    72         push    edx
    73         pushfd
    74 
    75         ;
    76         ; Make sure both PAE and PSE are enabled (requires pentium pro).
    77         ;
    78         mov     eax, cr4
    79         mov     ecx, eax
    80         or      eax, X86_CR4_PAE | X86_CR4_PSE
    81         cmp     eax, ecx
    82         je      .cr4_is_fine
    83         mov     cr4, eax
    84 .cr4_is_fine:
    85 
    86         ;
    87         ; Get the page directory (returned in eax).
    88         ; Will lazy init page tables.
    89         ;
    90         extern NAME(Bs3PagingGetRootForLM64_pe32)
    91         call   NAME(Bs3PagingGetRootForLM64_pe32)
    92 
    93         cli
    94         mov     cr3, eax
    95 
    96         ;
    97         ; Enable long mode in EFER.
    98         ;
    99         mov     ecx, MSR_K6_EFER
    100         rdmsr
    101         or      eax, MSR_K6_EFER_LME
    102         wrmsr
    103 
    104         ;
    105         ; Enable paging and thereby activating LM64.
    106         ;
    107 BS3_EXTERN_SYSTEM16 Bs3Lgdt_Gdt
    108 BS3_BEGIN_TEXT32
    109         mov     eax, cr0
    110         or      eax, X86_CR0_PG
    111         mov     cr0, eax
    112         jmp     .in_lm32
    113 .in_lm32:
    114 
    115         ;
    116         ; Call rountine for doing mode specific setups.
    117         ;
    118         extern  NAME(Bs3EnteredMode_lm32)
    119         call    NAME(Bs3EnteredMode_lm32)
    120 
    121         ;
    122         ; Restore ecx, eax and flags (IF).
    123         ;
    124  %if TMPL_BITS == 16
    125         movzx   eax, word [esp + 16 + 2] ; Load return address.
    126         add     eax, BS3_ADDR_BS3TEXT16  ; Convert it to a flat address.
    127         mov     [esp + 16], eax          ; Store it in the place right for 32-bit returns.
    128  %endif
    129         popfd
    130         pop     edx
    131         pop     ecx
    132         pop     eax
    133 
    134         ;
    135         ; Now go to 32-bit mode.
    136         ;
    137         extern  NAME(Bs3SwitchTo64Bit_c32)
    138         jmp     NAME(Bs3SwitchTo64Bit_c32)
    139 
    140  %if TMPL_BITS != 32
    141 TMPL_BEGIN_TEXT
    142  %endif
     65        extern  _Bs3SwitchTo64Bit_c32
     66        jmp     _Bs3SwitchTo64Bit_c32
    14367%endif
    14468BS3_PROC_END_MODE   Bs3SwitchToLM64
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-footer.mac

    r58628 r59259  
    6767
    6868%undef TMPL_NM
     69%undef TMPL_NM_U
    6970%undef BS3_CMN_NM
    70 %undef TMPL_MODE
     71%undef TMPL_UNDESCORE
     72%undef TMPL_MODE_UNAME
     73%undef TMPL_MODE_LNAME
    7174%undef TMPL_MODE_STR
    7275%undef TMPL_16BIT
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-template-header.mac

    r59245 r59259  
    9494 %define TMPL_NM(Name)          _ %+ Name %+ _rm
    9595 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
     96 %define TMPL_UNDERSCORE        _
     97 %define TMPL_MODE_LNAME        rm
     98 %define TMPL_MODE_UNAME        RM
    9699 %define TMPL_MODE_STR          'real mode'
    97100 %define TMPL_HAVE_BIOS
     
    143146 %define TMPL_NM(Name)          _ %+ Name %+ _pe16
    144147 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
     148 %define TMPL_UNDERSCORE        _
     149 %define TMPL_MODE_LNAME        pe16
     150 %define TMPL_MODE_UNAME        PE16
    145151 %define TMPL_MODE_STR          '16-bit unpaged protected mode'
    146152%endif
     
    190196 %define TMPL_NM(Name)          _ %+ Name %+ _pe32
    191197 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
     198 %define TMPL_UNDERSCORE        _
     199 %define TMPL_MODE_LNAME        pe32
     200 %define TMPL_MODE_UNAME        PE32
    192201 %define TMPL_MODE_STR          '32-bit unpaged protected mode'
    193202%endif
     
    238247 %define TMPL_NM(Name)          _ %+ Name %+ _pev86
    239248 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
     249 %define TMPL_UNDERSCORE        _
     250 %define TMPL_MODE_LNAME        pev86
     251 %define TMPL_MODE_UNAME        PEV86
    240252 %define TMPL_MODE_STR          'v8086 unpaged protected mode'
    241253%endif
     
    285297 %define TMPL_NM(Name)          _ %+ Name %+ _pp16
    286298 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
     299 %define TMPL_UNDERSCORE        _
     300 %define TMPL_MODE_LNAME        pp16
     301 %define TMPL_MODE_UNAME        PP16
    287302 %define TMPL_MODE_STR          '16-bit paged protected mode'
    288303%endif
     
    332347 %define TMPL_NM(Name)          _ %+ Name %+ _pp32
    333348 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
     349 %define TMPL_UNDERSCORE        _
     350 %define TMPL_MODE_LNAME        pp32
     351 %define TMPL_MODE_UNAME        PP32
    334352 %define TMPL_MODE_STR          '32-bit paged protected mode'
    335353%endif
     
    378396 %define TMPL_BITS              16
    379397 %define TMPL_PTR_DEF           dw
    380  %define TMPL_NM(Name)          Name %+ _ppv86
    381  %define BS3_CMN_NM(Name)       Name %+ _c86
     398 %define TMPL_NM(Name)          _ %+ Name %+ _ppv86
     399 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c86
     400 %define TMPL_UNDERSCORE        _
     401 %define TMPL_MODE_LNAME        ppv86
     402 %define TMPL_MODE_UNAME        PPV86
    382403 %define TMPL_MODE_STR          'v8086 paged protected mode'
    383404%endif
     
    427448 %define TMPL_NM(Name)          _ %+ Name %+ _pae16
    428449 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
     450 %define TMPL_UNDERSCORE        _
     451 %define TMPL_MODE_LNAME        pae16
     452 %define TMPL_MODE_UNAME        PAE16
    429453 %define TMPL_MODE_STR          '16-bit pae protected mode'
    430454%endif
     
    474498 %define TMPL_NM(Name)          _ %+ Name %+ _pae32
    475499 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
     500 %define TMPL_UNDERSCORE        _
     501 %define TMPL_MODE_LNAME        pae32
     502 %define TMPL_MODE_UNAME        PAE32
    476503 %define TMPL_MODE_STR          '32-bit pae protected mode'
    477504%endif
     
    522549 %define TMPL_NM(Name)          _ %+ Name %+ _paev86
    523550 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c86
     551 %define TMPL_UNDERSCORE        _
     552 %define TMPL_MODE_LNAME        paev86
     553 %define TMPL_MODE_UNAME        PAEV86
    524554 %define TMPL_MODE_STR          'v8086 pae protected mode'
    525555%endif
     
    569599 %define TMPL_NM(Name)          _ %+ Name %+ _lm16
    570600 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c16
     601 %define TMPL_UNDERSCORE        _
     602 %define TMPL_MODE_LNAME        lm16
     603 %define TMPL_MODE_UNAME        LM16
    571604 %define TMPL_MODE_STR          '16-bit long mode'
    572605%endif
     
    616649 %define TMPL_NM(Name)          _ %+ Name %+ _lm32
    617650 %define BS3_CMN_NM(Name)       _ %+ Name %+ _c32
     651 %define TMPL_UNDERSCORE        _
     652 %define TMPL_MODE_LNAME        lm32
     653 %define TMPL_MODE_UNAME        LM32
    618654 %define TMPL_MODE_STR          '32-bit long mode'
    619655%endif
     
    663699 %define TMPL_NM(Name)          Name %+ _lm64   ; No underscore (C/C++ compatibility).
    664700 %define BS3_CMN_NM(Name)       Name %+ _c64    ; No underscore (C/C++ compatibility).
     701 %define TMPL_UNDERSCORE
     702 %define TMPL_MODE_LNAME        lm64
     703 %define TMPL_MODE_UNAME        LM64
    665704 %define TMPL_MODE_STR          '64-bit long mode'
    666705%endif
     
    668707%ifndef TMPL_MODE_STR
    669708 %error "internal error"
     709%endif
     710
     711%ifnidn TMPL_UNDERSCORE,_; RT_CONCAT3 doesn't work with TMPL_UNDERSCORE being empty. duh.
     712 %ifidn RT_CONCAT(TestName_,TMPL_MODE_LNAME),TMPL_NM(TestName)
     713 %else
     714  %error internal error: RT_CONCAT(TestName_,TMPL_MODE_LNAME) vs TMPL_NM(TestName)
     715 %endif
     716%else
     717 %ifidn RT_CONCAT3(TMPL_UNDERSCORE,TestName_,TMPL_MODE_LNAME),TMPL_NM(TestName)
     718 %else
     719  %error internal error: RT_CONCAT3(TMPL_UNDERSCORE,TestName_,TMPL_MODE_LNAME) vs TMPL_NM(TestName)
     720 %endif
     721%endif
     722
     723; TMPL_NM version with uppercased suffix and no underscore separating them.
     724%ifnidn TMPL_UNDERSCORE,_
     725 %define TMPL_NM_U(Name)        Name %+ TMPL_MODE_UNAME
     726%else
     727 %define TMPL_NM_U(Name)        TMPL_UNDERSCORE %+ Name %+ TMPL_MODE_UNAME
    670728%endif
    671729
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r59258 r59259  
    447447
    448448
     449/** The system call vector. */
     450#define BS3_TRAP_SYSCALL        UINT8_C(0x20)
     451
     452/** @name System call numbers (ax).
     453 * Paramenters are generally passed in registers specific to each system call.
     454 * @{ */
     455/** Print char (cl). */
     456#define BS3_SYSCALL_PRINT_CHR   UINT16_C(0x0001)
     457/** Print string (pointer in ds:[e]si, length in cx). */
     458#define BS3_SYSCALL_PRINT_STR   UINT16_C(0x0002)
     459/** Switch to ring-0. */
     460#define BS3_SYSCALL_TO_RING0    UINT16_C(0x0003)
     461/** Switch to ring-1. */
     462#define BS3_SYSCALL_TO_RING1    UINT16_C(0x0004)
     463/** Switch to ring-2. */
     464#define BS3_SYSCALL_TO_RING2    UINT16_C(0x0005)
     465/** Switch to ring-3. */
     466#define BS3_SYSCALL_TO_RING3    UINT16_C(0x0006)
     467/** @} */
     468
     469
    449470
    450471/** @defgroup grp_bs3kit_system System structures
     
    16841705 * @param   cParams     The parameter count (for call gates).
    16851706 */
    1686 BS3_DECL(void) Bs3Trap32SetGate(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams);
    1687 
    1688 /** The address of Bs3Idt32GenericEntries.
    1689  * Bs3Idt32GenericEntries is an array of interrupt/trap/whatever entry
     1707BS3_DECL(void) Bs3Trap32SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams);
     1708BS3_DECL(void) Bs3Trap32SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); /**< @copydoc Bs3Trap32SetGate_c16 */
     1709BS3_DECL(void) Bs3Trap32SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); /**< @copydoc Bs3Trap32SetGate_c16 */
     1710#define Bs3Trap32SetGate BS3_CMN_NM(Bs3Trap32SetGate) /**< Selects #Bs3Trap32SetGate_c16, #Bs3Trap32SetGate_c32 or #Bs3Trap32SetGate_c64. */
     1711
     1712/** The address of Bs3Trap32GenericEntries.
     1713 * Bs3Trap32GenericEntries is an array of interrupt/trap/whatever entry
    16901714 * points, 8 bytes each, that will create a register frame and call the generic
    16911715 * C compatible trap handlers. */
    1692 extern uint32_t BS3_DATA_NM(g_Bs3Idt32GenericEntriesFlatAddr);
     1716extern uint32_t BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr);
     1717
     1718/**
     1719 * Modifies the 64-bit IDT entry specified by @a iIdt.
     1720 *
     1721 * @param   iIdt        The index of the IDT entry to set.
     1722 * @param   bType       The gate type (X86_SEL_TYPE_SYS_XXX).
     1723 * @param   bDpl        The DPL.
     1724 * @param   uSel        The handler selector.
     1725 * @param   off         The handler offset (if applicable).
     1726 * @param   bIst        The interrupt stack to use.
     1727 */
     1728BS3_DECL(void) Bs3Trap64SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst);
     1729BS3_DECL(void) Bs3Trap64SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); /**< @copydoc Bs3Trap64SetGate_c16 */
     1730BS3_DECL(void) Bs3Trap64SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); /**< @copydoc Bs3Trap64SetGate_c16 */
     1731#define Bs3Trap64SetGate BS3_CMN_NM(Bs3Trap64SetGate) /**< Selects #Bs3Trap64SetGate_c16, #Bs3Trap64SetGate_c32 or #Bs3Trap64SetGate_c64. */
     1732
     1733/** The address of Bs3Trap64GenericEntries.
     1734 * Bs3Trap64GenericEntries is an array of interrupt/trap/whatever entry
     1735 * points, 8 bytes each, that will create a register frame and call the generic
     1736 * C compatible trap handlers. */
     1737extern uint32_t BS3_DATA_NM(g_Bs3Trap64GenericEntriesFlatAddr);
     1738
     1739/**
     1740 * C-style trap handler.
     1741 *
     1742 * Upon return Bs3Trap16ResumeFrame_c16, #Bs3Trap32ResumeFrame_c32, or
     1743 * Bs3Trap64ResumeFrame_c64 will be called depending on the current template
     1744 * context.
     1745 *
     1746 * @param   pTrapFrame  The trap frame.  Registers can be modified.
     1747 */
     1748typedef BS3_DECL_CALLBACK(void) FNBS3TRAPHANDLER(PBS3TRAPFRAME pTrapFrame);
     1749/** Pointer to a trap handler (current template context). */
     1750typedef FNBS3TRAPHANDLER *PFNBS3TRAPHANDLER;
     1751
     1752/**
     1753 * Sets a trap handler (C/C++/assembly) for the current bitness.
     1754 *
     1755 * When using a 32-bit IDT, only #Bs3TrapSetHandler_c32 will have any effect.
     1756 * Likewise, when using a 16-bit IDT, only Bs3TrapSetHandler_c16 will make any
     1757 * difference.  Ditto 64-bit.
     1758 *
     1759 * Rational: It's mainly a C API, can't easily mix function pointers from other
     1760 * bit counts in C.  Use assembly helpers or something if that is necessary.
     1761 * Besides, most of the real trap handling goes thru the default handler with
     1762 * help of trap records.
     1763 *
     1764 * @returns Previous handler.
     1765 * @param   iIdt        The index of the IDT entry to set.
     1766 * @param   pfnHandler  Pointer to the handler.
     1767 */
     1768BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c16(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler);
     1769BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c32(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); /**< @copydoc Bs3Trap32SetHandler_c16 */
     1770BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c64(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); /**< @copydoc Bs3Trap32SetHandler_c16 */
     1771#define Bs3Trap32SetHandler BS3_CMN_NM(Bs3Trap32SetHandler) /**< Selects #Bs3Trap32SetHandler_c16, #Bs3Trap32SetHandler_c32 or #Bs3Trap32SetHandler_c64. */
    16931772
    16941773/** @} */
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac

    r59258 r59259  
    637637
    638638;; The system call vector.
    639 %define BS3_TRAP_SYSCALL        20h
    640 
    641 ;; @name System call numbers
     639%define BS3_TRAP_SYSCALL            20h
     640
     641;; @name System call numbers (ax)
    642642;; @{
    643643;; Print char (cl).
    644 %define BS3_SYSCALL_PRINT_CHR   0ca110001h
     644%define BS3_SYSCALL_PRINT_CHR       0001h
     645;; Print string (pointer in ds:[e]si, length in cx).
     646%define BS3_SYSCALL_PRINT_STR       0002h
    645647;; Switch to ring-0.
    646 %define BS3_SYSCALL_TO_RING0    0ca110002h
     648%define BS3_SYSCALL_TO_RING0        0003h
    647649;; Switch to ring-1.
    648 %define BS3_SYSCALL_TO_RING1    0ca110003h
     650%define BS3_SYSCALL_TO_RING1        0004h
    649651;; Switch to ring-2.
    650 %define BS3_SYSCALL_TO_RING2    0ca110004h
     652%define BS3_SYSCALL_TO_RING2        0005h
    651653;; Switch to ring-3.
    652 %define BS3_SYSCALL_TO_RING3    0ca110005h
     654%define BS3_SYSCALL_TO_RING3        0006h
     655;; The last system call value.
     656%define BS3_SYSCALL_LAST            BS3_SYSCALL_TO_RING3
    653657;; @}
    654658
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