VirtualBox

Changeset 60578 in vbox


Ignore:
Timestamp:
Apr 19, 2016 3:26:34 PM (9 years ago)
Author:
vboxsync
Message:

bs3kit: made it easier to move 16-bit templated C code to other segments.

Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
11 edited
2 copied

Legend:

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

    r60572 r60578  
    7878# @param    1   The target name.
    7979# @param    2   List of functions.
    80 BS3KIT_FN_GEN_NEARSTUBS = $(foreach fn,$2,$(evalcall2 def_Bs3KitGenNearStubSource,$1,_$(fn)_c16,_$(fn)_f16))
     80BS3KIT_FN_GEN_CMN_NEARSTUBS = $(foreach fn,$2,$(evalcall2 def_Bs3KitGenNearStubSource,$1,_$(fn)_c16,_$(fn)_f16))
    8181
    8282##
     
    118118               '      push    ax' \
    119119               '      jmp     $3 wrt CGROUP16'
     120endef
     121
     122
     123##
     124# Macro for generating far-call aliases for zero or more 16-bit C or assembly functions.
     125# @param    1   The target name.
     126# @param    2   List of functions.
     127BS3KIT_FN_GEN_CMN_FARSTUBS = $(foreach fn,$2,$(evalcall2 def_Bs3KitGenFarStubSource,$1,$(fn),_f16,_c16))
     128
     129##
     130# Macro for generating far-call aliases for zero or more 16-bit C mode functions.
     131# @param    1   The target name.
     132# @param    2   List of mode functions.
     133BS3KIT_FN_GEN_MODE_FARSTUBS = $(foreach fn,$2,$(foreach suff, \
     134        _rm \
     135        _pe16 \
     136        _pe16_v86 \
     137        _pe32_16 \
     138        _pev86 \
     139        _pp16 \
     140        _pp16_v86 \
     141        _pp32_16 \
     142        _ppv86 \
     143        _pae16 \
     144        _pae16_v86 \
     145        _pae32_16 \
     146        _paev86 \
     147        _lm16 \
     148        ,$(evalcall2 def_Bs3KitGenFarStubSource,$1,$(fn),$(suff)_far,$(suff))
     149
     150# @param    1   The target name.
     151# @param    2   The function and amount of parameters.
     152# @param    3   The far function suffix.
     153# @param    4   The near function suffix.
     154define def_Bs3KitGenFarStubSource
     155$(eval local fn2 = $(firstword $(subst :, $(SP), $2)))
     156$(eval local cbParam = $(lastword $(subst :, $(SP), $2)))
     157
     158$1_SOURCES += $$($1_0_OUTDIR)/stub_$(fn2)$3.asm
     159$1_CLEAN   += $$($1_0_OUTDIR)/stub_$(fn2)$3.asm
     160$$$$($1_0_OUTDIR)/stub_$(fn2)$3.asm: $$(VBOX_PATH_BOOTSECTORS_SRC)/Config.kmk | $$$$(dir $$$$@)
     161        $(QUIET)$(APPEND) -tn $$@ \
     162                '%include "bs3kit.mac"' \
     163        'BS3_BEGIN_TEXT16' \
     164               '      extern  _$(fn2)$4' \
     165        'BS3_BEGIN_TEXT16_FARSTUBS' \
     166                'BS3_PROC_BEGIN _$(fn2)$3' \
     167               '      CPU 8086' \
     168               '      inc     bp' \
     169               '      push    bp' \
     170               '      mov     bp, sp' \
     171               '%assign offParam $(cbParam)' \
     172               '%rep $(cbParam) / 2' \
     173               '      push    word [bp + 2 + 4 + offParam - 2]' \
     174               '%assign offParam offParam - 2' \
     175               '%endrep' \
     176               '      call    _$(fn2)$4' \
     177               '      add     sp, $(cbParam)' \
     178               '      pop     bp' \
     179               '      dec     bp' \
     180               '      retf' \
     181                'BS3_PROC_END _$(fn2)$3' \
     182               ''
    120183endef
    121184
  • trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk

    r60194 r60578  
    241241        bs3-cpu-basic-2-c.c \
    242242        bs3-cpu-basic-2.asm \
    243        bs3kit/bs3-cmn-instantiate.c16 \
     243       bs3kit/bs3-cmn-instantiate-x0.c16 \
    244244       bs3kit/bs3-cmn-instantiate.c32 \
    245245       bs3kit/bs3-cmn-instantiate.c64
    246 bs3-cpu-basic-2-template.o:: $$(addprefix $$(bs3-cpu-basic-2_0_OUTDIR)/bs3kit/bs3-cmn-instantiate,.o16 .o32 .o64)
     246bs3-cpu-basic-2-template.o:: \
     247        $$(bs3-cpu-basic-2_0_OUTDIR)/bs3kit/bs3-cmn-instantiate-x0.o16 \
     248        $$(bs3-cpu-basic-2_0_OUTDIR)/bs3kit/bs3-cmn-instantiate.o32 \
     249        $$(bs3-cpu-basic-2_0_OUTDIR)/bs3kit/bs3-cmn-instantiate.o64
    247250endif
    248251
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.c

    r60539 r60578  
    258258    else
    259259        fExtraEfl = X86_EFL_RF;
     260#if 0 /** @todo Running on an AMD Phenom II X6 1100T under AMD-V I'm not getting good X86_EFL_RF results.  Enable this to get on with other work.  */
     261    fExtraEfl = pTrapCtx->Ctx.rflags.u32 & X86_EFL_RF;
     262#endif
    260263    Bs3TestCheckRegCtxEx(&pTrapCtx->Ctx, pStartCtx, 0 /*cbIpAdjust*/, 0 /*cbSpAdjust*/, fExtraEfl, g_pszTestMode, g_usBs3TestStep);
    261264    if (Bs3TestSubErrorCount() != cErrorsBefore)
     
    404407    Ctx80.rsp.u -= 0x300;
    405408    Ctx80.rip.u  = (uintptr_t)BS3_FP_OFF(&TMPL_NM(bs3CpuBasic2_Int80));
    406 # if TMPL_BITS == 32
     409# if TMPL_BITS == 16
     410    Ctx80.cs = BS3_MODE_IS_RM_OR_V86(g_bTestMode) ? BS3_SEL_TEXT16 : BS3_SEL_R0_CS16;
     411# elif TMPL_BITS == 32
    407412    g_uBs3TrapEipHint = Ctx80.rip.u32;
    408413# endif
     
    15231528     * Re-initialize the IDT.
    15241529     */
    1525     TMPL_NM(Bs3TrapInit)();
     1530    TMPL_FAR_NM(Bs3TrapInit)();
    15261531    return bRet;
    15271532}
     
    15491554     * Re-initialize the IDT.
    15501555     */
    1551     TMPL_NM(Bs3TrapInit)();
     1556    TMPL_FAR_NM(Bs3TrapInit)();
    15521557    return 0;
    15531558#elif TMPL_MODE == BS3_MODE_RM
     
    15951600     * Re-initialize the IDT.
    15961601     */
    1597     TMPL_NM(Bs3TrapInit)();
     1602    TMPL_FAR_NM(Bs3TrapInit)();
    15981603    return 0;
    15991604}
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r60557 r60578  
    201201        bs3-c16-CreateHybridFarRet.asm
    202202bs3kit-common-16_bs3-cmn-UInt64Div.c_CFLAGS = -oh -d0 # -d1+ vs -d0 saves 0x6a3-0x577 = 0x12C (300)!
    203 bs3kit-common-16_VBOX_NEAR_TO_FAR_FUNCTIONS := \
     203bs3kit-common-16_VBOX_NEAR_TO_FAR_CMN_FUNCTIONS := \
    204204        $(sort $(subst bs3-cmn-,Bs3,$(basename $(filter-out \
    205205                %Data.c \
     
    221221        Bs3TrapInit \
    222222
    223 $(call BS3KIT_FN_GEN_NEARSTUBS,bs3kit-common-16,$(bs3kit-common-16_VBOX_NEAR_TO_FAR_FUNCTIONS))
     223bs3kit-common-16_VBOX_FAR_TO_NEAR_CMN_FUNCTIONS := \
     224        ASMMemFirstMismatchingU8:8 \
     225        ASMMemFirstNonZero:6 \
     226
     227$(call BS3KIT_FN_GEN_CMN_NEARSTUBS,bs3kit-common-16,$(bs3kit-common-16_VBOX_NEAR_TO_FAR_CMN_FUNCTIONS))
    224228$(call BS3KIT_FN_GEN_MODE_NEARSTUBS,bs3kit-common-16,$(bs3kit-common-16_VBOX_NEAR_TO_FAR_MODE_FUNCTIONS))
     229$(call BS3KIT_FN_GEN_CMN_FARSTUBS,bs3kit-common-16,$(bs3kit-common-16_VBOX_FAR_TO_NEAR_CMN_FUNCTIONS))
    225230
    226231# The 32-bit BS3Kit library.
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-instantiate-x0.c16

    r60566 r60578  
    11/* $Id$ */
    22/** @file
    3  * BS3Kit - 16-bit common C template instantiator.
     3 * BS3Kit - 16-bit common C template instantiator, using the BS3X0TEXT16 segment.
    44 */
    55
     
    2525 */
    2626
    27 
     27#define BS3_USE_X0_TEXT_SEG 1
    2828#include "bs3-cmn-instantiate-common.h"
    2929
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-instantiate-x1.c16

    r60566 r60578  
    11/* $Id$ */
    22/** @file
    3  * BS3Kit - 16-bit common C template instantiator.
     3 * BS3Kit - 16-bit common C template instantiator, using the BS3X1TEXT16 segment.
    44 */
    55
     
    2525 */
    2626
    27 
     27#define BS3_USE_X1_TEXT_SEG 1
    2828#include "bs3-cmn-instantiate-common.h"
    2929
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchToLM64.asm

    r60557 r60578  
    4141; @remarks  Does not require 20h of parameter scratch space in 64-bit mode.
    4242;
    43 BS3_GLOBAL_NAME_EX TMPL_NM(Bs3SwitchToLM16_Safe), function, 0
     43BS3_GLOBAL_NAME_EX TMPL_NM(Bs3SwitchToLM64_Safe), function, 0
    4444BS3_PROC_BEGIN_MODE Bs3SwitchToLM64, BS3_PBC_NEAR
    4545%ifdef TMPL_LM64
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModes.c

    r60557 r60578  
    2525 */
    2626
    27 /** @todo get this mess into the RM segment! */
    28 
    2927
    3028/*********************************************************************************************************************************
    3129*   Header Files                                                                                                                 *
    3230*********************************************************************************************************************************/
    33 #if defined(__WATCOMC__) && TMPL_MODE == BS3_MODE_RM
    34 /* In real mode we move this blob of code to the RMTEXT16 segment to save space. */
    35 # define BS3_USE_RM_TEXT_SEG 1
     31#if TMPL_MODE == BS3_MODE_RM
     32# define BS3_USE_RM_TEXT_SEG 1 /* Real mode version in RMTEXT16 segment to save space. */
    3633# include "bs3kit-template-header.h"
    3734# include "bs3-cmn-test.h"
    38 # pragma code_seg("BS3RMTEXT16", "BS3CLASS16RMCODE")
    3935#else
    4036# include "bs3kit-template-header.h"
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c

    r60556 r60578  
    3434#include <iprt/asm-amd64-x86.h>
    3535
    36 //#ifdef __WATCOMC__
    37 //# pragma code_seg("BS3RMTEXT16", "BS3CLASS16RMCODE")
    38 //#endif
    39 
    4036
    4137BS3_DECL(void) Bs3InitAll_rm(void)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitGdt.c

    r60557 r60578  
    3232#include <iprt/asm.h>
    3333
    34 #ifdef __WATCOMC__
    35 # pragma code_seg("BS3RMTEXT16", "BS3CLASS16RMCODE")
    36 #endif
    37 
    3834
    3935/*********************************************************************************************************************************
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitMemory.c

    r60556 r60578  
    3232#include "bs3-cmn-memory.h"
    3333#include <iprt/asm.h>
    34 
    35 #ifdef __WATCOMC__
    36 # pragma code_seg("BS3RMTEXT16", "BS3CLASS16RMCODE")
    37 #endif
    3834
    3935
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code.h

    r60527 r60578  
    3030 */
    3131#undef BS3_CMN_MANGLER
    32 #if ARCH_BITS != 16 || !defined(BS3_USE_RM_TEXT_SEG)
     32#if ARCH_BITS != 16 || !defined(BS3_USE_ALT_16BIT_TEXT_SEG)
    3333# define BS3_CMN_MANGLER(a_Function)            BS3_CMN_NM(a_Function)
    3434#else
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r60557 r60578  
    4949#endif
    5050
     51/** @def BS3_USE_ALT_16BIT_TEXT_SEG
     52 * Combines the BS3_USE_RM_TEXT_SEG,  BS3_USE_X0_TEXT_SEG, and
     53 * BS3_USE_X1_TEXT_SEG indicators into a single one. */
     54#if defined(BS3_USE_RM_TEXT_SEG) || defined(BS3_USE_X0_TEXT_SEG) || defined(BS3_USE_X1_TEXT_SEG)
     55# define BS3_USE_ALT_16BIT_TEXT_SEG
     56#else
     57# undef  BS3_USE_ALT_16BIT_TEXT_SEG
     58#endif
     59
    5160/*
    5261 * We may want to reuse some IPRT code in the common name space, so we
     
    5564 * declarations before we can define it. Thus the duplciate effort.)
    5665 */
    57 #if ARCH_BITS != 16 || !defined(BS3_USE_RM_TEXT_SEG)
     66#if ARCH_BITS != 16 || !defined(BS3_USE_ALT_16BIT_TEXT_SEG)
    5867# define RT_MANGLER(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
    5968#else
    6069# define RT_MANGLER(a_Name) RT_CONCAT(a_Name,_f16)
     70# undef RTCALL
     71# define RTCALL __cdecl __far
    6172#endif
    6273#include <iprt/mangling.h>
     
    509520 *
    510521 * @param a_Type        The return type. */
    511 #if ARCH_BITS != 16 || !defined(BS3_USE_RM_TEXT_SEG)
     522#if ARCH_BITS != 16 || !defined(BS3_USE_ALT_16BIT_TEXT_SEG)
    512523# define BS3_DECL(a_Type)  BS3_DECL_NEAR(a_Type)
    513524#else
     
    576587 * Constructs a common function name, far or near as defined by the source.
    577588 *
    578  * Which to use in 16-bit mode is defined by BS3_USE_RM_TEXT_SEG.  In 32-bit and
    579  * 64-bit mode there are no far symbols, only near ones.
     589 * Which to use in 16-bit mode is defined by BS3_USE_ALT_16BIT_TEXT_SEG.  In
     590 * 32-bit and 64-bit mode there are no far symbols, only near ones.
    580591 *
    581592 * Example: BS3_CMN_FN_NM(Bs3Shutdown)
     
    583594 * @param   a_Name      The name of the function.
    584595 */
    585 #if ARCH_BITS != 16 || !defined(BS3_USE_RM_TEXT_SEG)
     596#if ARCH_BITS != 16 || !defined(BS3_USE_ALT_16BIT_TEXT_SEG)
    586597# define BS3_CMN_FN_NM(a_Name)  BS3_CMN_NM(a_Name)
    587598#else
     
    26872698#include "bs3kit-mangling-code.h"
    26882699
    2689 
    2690 #endif
    2691 
     2700/*
     2701 * Change 16-bit text segment if requested.
     2702 */
     2703#if defined(BS3_USE_ALT_16BIT_TEXT_SEG) && ARCH_BITS == 16 && !defined(BS3_DONT_CHANGE_TEXT_SEG)
     2704# if (defined(BS3_USE_RM_TEXT_SEG) + defined(BS3_USE_X0_TEXT_SEG) + defined(BS3_USE_X1_TEXT_SEG)) != 1
     2705#  error "Cannot set more than one alternative 16-bit text segment!"
     2706# elif defined(BS3_USE_RM_TEXT_SEG)
     2707#  pragma code_seg("BS3RMTEXT16", "BS3CLASS16RMCODE")
     2708# elif defined(BS3_USE_X0_TEXT_SEG)
     2709#  pragma code_seg("BS3X0TEXT16", "BS3CLASS16X0CODE")
     2710# elif defined(BS3_USE_X1_TEXT_SEG)
     2711#  pragma code_seg("BS3X1TEXT16", "BS3CLASS16X1CODE")
     2712# else
     2713#  error "Huh? Which alternative text segment did you want again?"
     2714# endif
     2715#endif
     2716
     2717#endif
     2718
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