VirtualBox

Changeset 15300 in vbox


Ignore:
Timestamp:
Dec 11, 2008 12:02:12 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
40723
Message:

dynamic REM selector

Location:
trunk/src/recompiler_new
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler_new/Makefile.kmk

    r15280 r15300  
    2727#
    2828VBOX_PATH_RECOMPILER_SRC := $(PATH_SUB_CURRENT)
     29
     30# For 32-bit targets when enabled 64-bit guests we build 2 REM DLLs:
     31#  with 64-bit support (slow and buggy at the moment) VBOXREM64
     32#  only 32-bit support (faster, stable, but not suitable for 64-bit guests) VBOXREM32
     33# During the runtime, we load appropriate library from VBOXREM, depending on guest settings.
     34# 64-bit targets have 64-bit enabled REM by default, so is not part of this mess
     35if1of (x86, $(KBUILD_TARGET_ARCH))
     36 ifdef VBOX_WITH_64_BITS_GUESTS
     37   VBOX_USE_REM64 := 1
     38 endif
     39endif
     40
    2941
    3042TEMPLATE_DUMMY = dummy template (move to kBuild) ## @todo Will be there in the next update, remove this.
     
    5971endif
    6072
    61 
    62 # VBOX_WITH_64_BITS_GUESTS = 1
    63 
    64 # For 32-bit targets when enabled 64-bit guests we build 2 REM DLLs:
    65 #  with 64-bit support (slow and buggy at the moment) VBOXREM64
    66 #  only 32-bit support (faster, stable, but not suitable for 64-bit guests) VBOXREM
    67 # During the runtime, we load appropriate library, depending on guest settings.
    68 if1of (x86, $(KBUILD_TARGET_ARCH))
    69  ifdef VBOX_WITH_64_BITS_GUESTS
    70   USE_VBOXREM64 := 1
    71  endif
    72 else
    73  USE_VBOXREM64 :=
    74 endif
    75 
    76 
    7773#
    7874# Target lists (some of them anyways).
     
    8177 SYSMODS     += VBoxREM2
    8278endif
    83 ifeq ($(KBUILD_TARGET),win)
    84  DLLS        += VBoxREM
    85 else
    86  ## @todo this is wrong, proper DLLS are DLLS not IMPORT_LIBS. nice try ;-)
    87  IMPORT_LIBS += VBoxREM
     79
     80ifndef VBOX_USE_REM64
     81 ifeq ($(KBUILD_TARGET),win)
     82  DLLS        += VBoxREM
     83 else
     84  ## @todo this is wrong, proper DLLS are DLLS not IMPORT_LIBS. nice try ;-)
     85  IMPORT_LIBS += VBoxREM
     86 endif
    8887endif
    8988
     
    199198
    200199
    201 ifdef USE_VBOXREM64
    202 #
    203 # The VBoxREM64 module, for targeting 64-bit guests on 32-bit systems.
    204 #
    205 # Currently we never mix USE_VBOXREM64 and VBoxREM2, so can always use VBoxREM
    206 ## @todo: assert for that? use $(REM_MOD) instead?
    207 # But loading logic got to be updated too.
    208 ifeq ($(KBUILD_TARGET), win)
    209  DLL                      += VBoxREM64
    210 else
    211  ## @todo see comment above.
    212  IMPORT_LIBS              += VBoxREM64
    213 endif
    214 VBoxREM64_EXTENDS          = $(REM_MOD)
    215 VBoxREM64_EXTENDS_BY       = appending
    216 VBoxREM64_DEFS             = VBOX_ENABLE_VBOXREM64
     200ifdef VBOX_USE_REM64
     201 # kmk doesn't work the way it should wrt EXTENDS and variable value evaluation
     202 VBoxREM32_EXTENDS := $(REM_MOD)
     203 VBoxREM32_EXTEND_BY := appending
     204 VBoxREM32_TEMPLATE := $(VBoxREM_TEMPLATE)
     205 VBoxREM32_DEFS := $($(REM_MOD)_DEFS)
     206 VBoxREM32_INCS := $($(REM_MOD)_INCS)
     207 VBoxREM32_SOURCES := $($(REM_MOD)_SOURCES)
     208 VBoxREM32_LIBS := $($(REM_MOD)_LIBS) $(LIB_VMM) $(LIB_RUNTIME)
     209
     210 VBoxREM64_EXTENDS = $(REM_MOD)
     211 VBoxREM64_EXTEND_BY = appending
     212 VBoxREM64_TEMPLATE := $(VBoxREM_TEMPLATE)
     213 VBoxREM64_DEFS := $($(REM_MOD)_DEFS) VBOX_ENABLE_VBOXREM64
     214 VBoxREM64_INCS := $($(REM_MOD)_INCS)
     215 VBoxREM64_SOURCES := $($(REM_MOD)_SOURCES)
     216 VBoxREM64_LIBS := $($(REM_MOD)_LIBS) $(LIB_VMM) $(LIB_RUNTIME)
     217
     218 VBoxREMSel_TEMPLATE    = VBOXR3
     219 VBoxREMSel_NAME        = VBoxREM
     220 VBoxREMSel_DEFS        = IN_REM_R3 $(if $(VBOX_WITH_VMI),VBOX_WITH_VMI,)    \
     221                          VBOX_WITH_NEW_RECOMPILER VBOX_USE_BITNESS_SELECTOR
     222 VBoxREMSel_SOURCES     = VBoxREMWrapper.cpp
     223
     224 ifeq ($(KBUILD_TARGET), win)
     225  DLL                  += VBoxREM32 VBoxREM64 VBoxREMSel
     226 else
     227  IMPORT_LIBS          += VBoxREM32 VBoxREM64 VBoxREMSel
     228 endif
     229
    217230endif # USE_VBOXREM64
    218231
  • trunk/src/recompiler_new/VBoxREMWrapper.cpp

    r15284 r15300  
    179179# define USE_REM_IMPORT_JUMP_GLUE
    180180#endif
    181 
    182181
    183182/*******************************************************************************
     
    19441943#endif
    19451944
     1945#ifdef VBOX_USE_BITNESS_SELECTOR
     1946/**
     1947 * Loads real REM object, resolves all exports (imports are done by native loader).
     1948 *
     1949 * @returns VBox status code.
     1950 */
     1951static int remLoadProperObj(PVM pVM)
     1952{
     1953    size_t  offFilename;
     1954    char    szPath[RTPATH_MAX];
     1955    bool use64 = true;
     1956    int rc = RTPathAppPrivateArch(szPath, sizeof(szPath) - 32);
     1957    AssertRCReturn(rc, rc);
     1958    offFilename = strlen(szPath);
     1959
     1960    /*
     1961     * Load the VBoxREM32/64 object/DLL.
     1962     */
     1963    strcpy(&szPath[offFilename], use64 ? "/VBoxREM64" : "/VBoxREM32");
     1964    rc = RTLdrLoad(szPath, &g_ModREM2);
     1965    if (RT_SUCCESS(rc))
     1966    {
     1967        if (RT_SUCCESS(rc))
     1968        {
     1969            /*
     1970             * Resolve exports.
     1971             */
     1972            unsigned i;
     1973            for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
     1974            {
     1975                void* Value;
     1976                rc = RTLdrGetSymbol(g_ModREM2, g_aExports[i].pszName, &Value);
     1977                AssertMsgRC(rc, ("%s rc=%Rrc\n", g_aExports[i].pszName, rc));
     1978                if (RT_FAILURE(rc))
     1979                    break;
     1980                *(void **)g_aExports[i].pv = Value;
     1981            }
     1982        }
     1983    }
     1984   
     1985    return rc;
     1986}
     1987
     1988/**
     1989 * Unloads the real REM object.
     1990 */
     1991static void remUnloadProperObj(void)
     1992{
     1993    unsigned i;
     1994
     1995    /* close module. */
     1996    RTLdrClose(g_ModREM2);
     1997    g_ModREM2 = NIL_RTLDRMOD;
     1998}
     1999#endif
     2000
    19462001
    19472002REMR3DECL(int) REMR3Init(PVM pVM)
     
    19492004#ifdef USE_REM_STUBS
    19502005    return VINF_SUCCESS;
     2006#elif VBOX_USE_BITNESS_SELECTOR
     2007    if (!pfnREMR3Init)
     2008    {
     2009        int rc = remLoadProperObj(pVM);
     2010        if (RT_FAILURE(rc))
     2011            return rc;
     2012    }
     2013    return pfnREMR3Init(pVM);
    19512014#else
    19522015    if (!pfnREMR3Init)
     
    19642027#ifdef USE_REM_STUBS
    19652028    return VINF_SUCCESS;
     2029#elif VBOX_USE_BITNESS_SELECTOR
     2030    int rc;
     2031    Assert(VALID_PTR(pfnREMR3Term));
     2032    rc = pfnREMR3Term(pVM);
     2033    remUnloadProperObj();
     2034    return rc;
    19662035#else
    19672036    int rc;
  • trunk/src/recompiler_new/VBoxRecompiler.c

    r15284 r15300  
    245245    uint32_t u32Dummy;
    246246    int rc;
     247
     248#ifdef VBOX_ENABLE_VBOXREM64
     249    LogRel(("Using 64-bit aware REM\n"));
     250#endif
    247251
    248252    /*
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