VirtualBox

Changeset 1840 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 30, 2007 6:42:46 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
20028
Message:

Support driver interface cleanup.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDRVIOC.h

    r1480 r1840  
    169169
    170170
     171/** SUPCOOKIE_IN magic word. */
     172#define SUPCOOKIE_MAGIC             "The Magic Word!"
     173/** Current interface version.
     174 * The upper 16-bit is the major version, the the lower the minor version.
     175 * When incompatible changes are made, the upper major number has to be changed. */
     176#define SUPDRVIOC_VERSION           0x00040002
     177
    171178/** SUP_IOCTL_COOKIE Input. */
    172179typedef struct SUPCOOKIE_IN
     
    174181    /** Magic word. */
    175182    char            szMagic[16];
    176     /** The requested version number. */
    177     uint32_t        u32Version;
     183    /** The requested interface version number. */
     184    uint32_t        u32ReqVersion;
     185    /** The minimum interface version number. */
     186    uint32_t        u32MinVersion;
    178187} SUPCOOKIE_IN, *PSUPCOOKIE_IN;
    179 
    180 /** SUPCOOKIE_IN magic word. */
    181 #define SUPCOOKIE_MAGIC             "The Magic Word!"
    182 /** Current interface version. */
    183 #define SUPDRVIOC_VERSION           0x00040001
    184188
    185189/** SUP_IOCTL_COOKIE Output. */
     
    190194    /** Session cookie. */
    191195    uint32_t        u32SessionCookie;
    192     /** Interface version. High word(=uint16) is major, low word is minor. */
    193     uint32_t        u32Version;
     196    /** Interface version for this session. */
     197    uint32_t        u32SessionVersion;
     198    /** The actual interface version in the driver. */
     199    uint32_t        u32DriverVersion;
    194200    /** Number of functions available for the SUP_IOCTL_QUERY_FUNCS request. */
    195201    uint32_t        cFunctions;
    196202    /** Session handle. */
    197     PSUPDRVSESSION  pSession;
     203    R0PTRTYPE(PSUPDRVSESSION)   pSession;
    198204} SUPCOOKIE_OUT, *PSUPCOOKIE_OUT;
     205
     206
    199207
    200208/** SUP_IOCTL_QUERY_FUNCS Input. */
     
    202210{
    203211    /** Cookie. */
    204     uint32_t    u32Cookie;
    205     /** Session cookie. */
    206     uint32_t    u32SessionCookie;
     212    uint32_t        u32Cookie;
     213    /** Session cookie. */
     214    uint32_t        u32SessionCookie;
    207215} SUPQUERYFUNCS_IN, *PSUPQUERYFUNCS_IN;
    208216
     
    211219{
    212220    /** Name - mangled. */
    213     char        szName[32];
     221    char            szName[32];
    214222    /** Address. */
    215     void       *pfn;
     223    RTR0PTR         pfn;
    216224} SUPFUNC, *PSUPFUNC;
    217225
     
    220228{
    221229    /** Number of functions returned. */
    222     uint32_t    cFunctions;
     230    uint32_t        cFunctions;
    223231    /** Array of functions. */
    224     SUPFUNC     aFunctions[1];
     232    SUPFUNC         aFunctions[1];
    225233} SUPQUERYFUNCS_OUT, *PSUPQUERYFUNCS_OUT;
     234
    226235
    227236
     
    230239{
    231240    /** Cookie. */
    232     uint32_t    u32Cookie;
    233     /** Session cookie. */
    234     uint32_t    u32SessionCookie;
     241    uint32_t        u32Cookie;
     242    /** Session cookie. */
     243    uint32_t        u32SessionCookie;
    235244} SUPIDTINSTALL_IN, *PSUPIDTINSTALL_IN;
    236245
     
    239248{
    240249    /** Cookie. */
    241     uint8_t     u8Idt;
     250    uint8_t         u8Idt;
    242251} SUPIDTINSTALL_OUT, *PSUPIDTINSTALL_OUT;
    243252
     
    248257{
    249258    /** Cookie. */
    250     uint32_t    u32Cookie;
    251     /** Session cookie. */
    252     uint32_t    u32SessionCookie;
     259    uint32_t        u32Cookie;
     260    /** Session cookie. */
     261    uint32_t        u32SessionCookie;
    253262} SUPIDTREMOVE_IN, *PSUPIDTREMOVE_IN;
    254263
     
    259268{
    260269    /** Cookie. */
    261     uint32_t    u32Cookie;
    262     /** Session cookie. */
    263     uint32_t    u32SessionCookie;
     270    uint32_t        u32Cookie;
     271    /** Session cookie. */
     272    uint32_t        u32SessionCookie;
    264273    /** Start of page range. Must be PAGE aligned. */
    265     RTR3PTR     pvR3;
     274    RTR3PTR         pvR3;
    266275    /** Size of the range. Must be PAGE aligned. */
    267     uint32_t    cb;
     276    uint32_t        cb;
    268277} SUPPINPAGES_IN, *PSUPPINPAGES_IN;
    269278
     
    272281{
    273282    /** Array of pages. */
    274     SUPPAGE     aPages[1];
     283    SUPPAGE         aPages[1];
    275284} SUPPINPAGES_OUT, *PSUPPINPAGES_OUT;
    276285
     
    281290{
    282291    /** Cookie. */
    283     uint32_t    u32Cookie;
    284     /** Session cookie. */
    285     uint32_t    u32SessionCookie;
     292    uint32_t        u32Cookie;
     293    /** Session cookie. */
     294    uint32_t        u32SessionCookie;
    286295    /** Start of page range of a range previuosly pinned. */
    287     RTR3PTR     pvR3;
     296    RTR3PTR         pvR3;
    288297} SUPUNPINPAGES_IN, *PSUPUNPINPAGES_IN;
     298
    289299
    290300
     
    293303{
    294304    /** Cookie. */
    295     uint32_t    u32Cookie;
    296     /** Session cookie. */
    297     uint32_t    u32SessionCookie;
     305    uint32_t        u32Cookie;
     306    /** Session cookie. */
     307    uint32_t        u32SessionCookie;
    298308    /** Number of bytes to allocate. */
    299     uint32_t    cb;
     309    uint32_t        cb;
    300310} SUPCONTALLOC_IN, *PSUPCONTALLOC_IN;
     311
    301312
    302313
     
    305316{
    306317    /** The address of the ring-0 mapping of the allocated memory. */
    307     RTR0PTR     pvR0;
     318    RTR0PTR         pvR0;
    308319    /** The address of the ring-3 mapping of the allocated memory. */
    309     RTR3PTR     pvR3;
     320    RTR3PTR         pvR3;
    310321    /** The physical address of the allocation. */
    311     RTHCPHYS    HCPhys;
     322    RTHCPHYS        HCPhys;
    312323} SUPCONTALLOC_OUT, *PSUPCONTALLOC_OUT;
     324
    313325
    314326
     
    317329{
    318330    /** Cookie. */
    319     uint32_t    u32Cookie;
    320     /** Session cookie. */
    321     uint32_t    u32SessionCookie;
     331    uint32_t        u32Cookie;
     332    /** Session cookie. */
     333    uint32_t        u32SessionCookie;
    322334    /** The ring-3 address of the memory to free. */
    323     RTR3PTR     pvR3;
     335    RTR3PTR         pvR3;
    324336} SUPCONTFREE_IN, *PSUPCONTFREE_IN;
     337
    325338
    326339
     
    329342{
    330343    /** Cookie. */
    331     uint32_t    u32Cookie;
    332     /** Session cookie. */
    333     uint32_t    u32SessionCookie;
     344    uint32_t        u32Cookie;
     345    /** Session cookie. */
     346    uint32_t        u32SessionCookie;
    334347    /** Size of the image we'll be loading. */
    335     uint32_t    cbImage;
     348    uint32_t        cbImage;
    336349    /** Image name.
    337350     * This is the NAME of the image, not the file name. It is used
    338351     * to share code with other processes. (Max len is 32 chars!)  */
    339     char        szName[32];
     352    char            szName[32];
    340353} SUPLDROPEN_IN, *PSUPLDROPEN_IN;
    341354
     
    344357{
    345358    /** The base address of the image. */
    346     void       *pvImageBase;
     359    RTR0PTR         pvImageBase;
    347360    /** Indicate whether or not the image requires loading. */
    348     bool        fNeedsLoading;
     361    bool            fNeedsLoading;
    349362} SUPLDROPEN_OUT, *PSUPLDROPEN_OUT;
     363
    350364
    351365
     
    359373typedef DECLCALLBACK(int) FNR0MODULEINIT(void);
    360374/** Pointer to a FNR0MODULEINIT(). */
    361 typedef FNR0MODULEINIT *PFNR0MODULEINIT;
     375typedef R0PTRTYPE(FNR0MODULEINIT *) PFNR0MODULEINIT;
    362376
    363377/**
     
    367381typedef DECLCALLBACK(void) FNR0MODULETERM(void);
    368382/** Pointer to a FNR0MODULETERM(). */
    369 typedef FNR0MODULETERM *PFNR0MODULETERM;
     383typedef R0PTRTYPE(FNR0MODULETERM *) PFNR0MODULETERM;
    370384
    371385/**
     
    397411        {
    398412            /** The module handle (i.e. address). */
    399             void       *pvVMMR0;
     413            RTR0PTR         pvVMMR0;
    400414            /** Address of VMMR0Entry function. */
    401             void       *pvVMMR0Entry;
     415            RTR0PTR         pvVMMR0Entry;
    402416        } VMMR0;
    403     }           EP;
     417    }               EP;
    404418    /** Address. */
    405     void       *pvImageBase;
     419    RTR0PTR         pvImageBase;
    406420    /** Entry point type. */
    407421    enum { EP_NOTHING, EP_VMMR0 }
    408422                    eEPType;
    409423    /** The offset of the symbol table. */
    410     uint32_t    offSymbols;
     424    uint32_t        offSymbols;
    411425    /** The number of entries in the symbol table. */
    412     uint32_t    cSymbols;
     426    uint32_t        cSymbols;
    413427    /** The offset of the string table. */
    414     uint32_t    offStrTab;
     428    uint32_t        offStrTab;
    415429    /** Size of the string table. */
    416     uint32_t    cbStrTab;
     430    uint32_t        cbStrTab;
    417431    /** Size of image (including string and symbol tables). */
    418     uint32_t    cbImage;
     432    uint32_t        cbImage;
    419433    /** The image data. */
    420     char        achImage[1];
     434    char            achImage[1];
    421435} SUPLDRLOAD_IN, *PSUPLDRLOAD_IN;
     436
    422437
    423438
     
    426441{
    427442    /** Cookie. */
    428     uint32_t    u32Cookie;
    429     /** Session cookie. */
    430     uint32_t    u32SessionCookie;
     443    uint32_t        u32Cookie;
     444    /** Session cookie. */
     445    uint32_t        u32SessionCookie;
    431446    /** Address. */
    432     void       *pvImageBase;
     447    RTR0PTR         pvImageBase;
    433448} SUPLDRFREE_IN, *PSUPLDRFREE_IN;
     449
    434450
    435451
     
    438454{
    439455    /** Cookie. */
    440     uint32_t    u32Cookie;
    441     /** Session cookie. */
    442     uint32_t    u32SessionCookie;
     456    uint32_t        u32Cookie;
     457    /** Session cookie. */
     458    uint32_t        u32SessionCookie;
    443459    /** Address. */
    444     void       *pvImageBase;
     460    RTR0PTR         pvImageBase;
    445461    /** The symbol name (variable length). */
    446     char        szSymbol[1];
     462    char            szSymbol[1];
    447463} SUPLDRGETSYMBOL_IN, *PSUPLDRGETSYMBOL_IN;
    448464
     
    451467{
    452468    /** The symbol address. */
    453     void       *pvSymbol;
     469    RTR0PTR         pvSymbol;
    454470} SUPLDRGETSYMBOL_OUT, *PSUPLDRGETSYMBOL_OUT;
     471
    455472
    456473
     
    459476{
    460477    /** Cookie. */
    461     uint32_t    u32Cookie;
    462     /** Session cookie. */
    463     uint32_t    u32SessionCookie;
     478    uint32_t        u32Cookie;
     479    /** Session cookie. */
     480    uint32_t        u32SessionCookie;
    464481    /** The VM handle. */
    465     PVMR0       pVMR0;
     482    PVMR0           pVMR0;
    466483    /** Which operation to execute. */
    467     uint32_t    uOperation;
     484    uint32_t        uOperation;
    468485    /** The size of the buffer pointed to by pvArg. */
    469     uint32_t    cbArg;
     486    uint32_t        cbArg;
    470487    /** Argument to that operation. */
    471     void       *pvArg;
     488    RTR3PTR         pvArg;
    472489} SUPCALLVMMR0_IN, *PSUPCALLVMMR0_IN;
    473490
     
    476493{
    477494    /** The VBox status code for the operation. */
    478     int32_t     rc;
     495    int32_t         rc;
    479496} SUPCALLVMMR0_OUT, *PSUPCALLVMMR0_OUT;
     497
    480498
    481499
     
    484502{
    485503    /** Cookie. */
    486     uint32_t    u32Cookie;
    487     /** Session cookie. */
    488     uint32_t    u32SessionCookie;
     504    uint32_t        u32Cookie;
     505    /** Session cookie. */
     506    uint32_t        u32SessionCookie;
    489507} SUPGETPAGINGMODE_IN, *PSUPGETPAGINGMODE_IN;
    490508
     
    493511{
    494512    /** The paging mode. */
    495     SUPPAGINGMODE   enmMode;
     513    SUPPAGINGMODE       enmMode;
    496514} SUPGETPAGINGMODE_OUT, *PSUPGETPAGINGMODE_OUT;
     515
    497516
    498517
     
    501520{
    502521    /** Cookie. */
    503     uint32_t    u32Cookie;
    504     /** Session cookie. */
    505     uint32_t    u32SessionCookie;
     522    uint32_t        u32Cookie;
     523    /** Session cookie. */
     524    uint32_t        u32SessionCookie;
    506525    /** Number of pages to allocate. */
    507     uint32_t    cPages;
     526    uint32_t        cPages;
    508527} SUPLOWALLOC_IN, *PSUPLOWALLOC_IN;
    509528
     
    512531{
    513532    /** The ring-3 address of the allocated memory. */
    514     RTR3PTR     pvR3;
     533    RTR3PTR         pvR3;
    515534    /** The ring-0 address of the allocated memory. */
    516     RTR0PTR     pvR0;
     535    RTR0PTR         pvR0;
    517536    /** Array of pages. */
    518     SUPPAGE     aPages[1];
     537    SUPPAGE         aPages[1];
    519538} SUPLOWALLOC_OUT, *PSUPLOWALLOC_OUT;
     539
    520540
    521541
     
    524544{
    525545    /** Cookie. */
    526     uint32_t    u32Cookie;
    527     /** Session cookie. */
    528     uint32_t    u32SessionCookie;
     546    uint32_t        u32Cookie;
     547    /** Session cookie. */
     548    uint32_t        u32SessionCookie;
    529549    /** The ring-3 address of the memory to free. */
    530     RTR3PTR     pvR3;
     550    RTR3PTR         pvR3;
    531551} SUPLOWFREE_IN, *PSUPLOWFREE_IN;
     552
    532553
    533554
     
    536557{
    537558    /** Cookie. */
    538     uint32_t    u32Cookie;
    539     /** Session cookie. */
    540     uint32_t    u32SessionCookie;
     559    uint32_t        u32Cookie;
     560    /** Session cookie. */
     561    uint32_t        u32SessionCookie;
    541562} SUPGIPMAP_IN, *PSUPGIPMAP_IN;
    542563
     
    545566{
    546567    /** Pointer to the read-only usermode GIP mapping for this session. */
    547     PCSUPGLOBALINFOPAGE pGipR3;
     568    R3PTRTYPE(PCSUPGLOBALINFOPAGE) pGipR3;
    548569    /** Pointer to the supervisor mode GIP mapping. */
    549     PCSUPGLOBALINFOPAGE pGipR0;
     570    R0PTRTYPE(PCSUPGLOBALINFOPAGE) pGipR0;
    550571    /** The physical address of the GIP. */
    551     RTHCPHYS    HCPhysGip;
     572    RTHCPHYS                        HCPhysGip;
    552573} SUPGIPMAP_OUT, *PSUPGIPMAP_OUT;
     574
    553575
    554576
     
    557579{
    558580    /** Cookie. */
    559     uint32_t    u32Cookie;
    560     /** Session cookie. */
    561     uint32_t    u32SessionCookie;
     581    uint32_t        u32Cookie;
     582    /** Session cookie. */
     583    uint32_t        u32SessionCookie;
    562584} SUPGIPUNMAP_IN, *PSUPGIPUNMAP_IN;
     585
    563586
    564587
     
    567590{
    568591    /** Cookie. */
    569     uint32_t    u32Cookie;
    570     /** Session cookie. */
    571     uint32_t    u32SessionCookie;
     592    uint32_t        u32Cookie;
     593    /** Session cookie. */
     594    uint32_t        u32SessionCookie;
    572595    /** The ring-0 VM handle (pointer). */
    573     PVMR0       pVMR0;
     596    PVMR0           pVMR0;
    574597} SUPSETVMFORFAST_IN, *PSUPSETVMFORFAST_IN;
    575598
  • trunk/src/VBox/HostDrivers/Support/SUPDRVShared.c

    r1672 r1840  
    644644                ||  cbOut != sizeof(*pOut))
    645645            {
    646                 dprintf(("SUP_IOCTL_COOKIE: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n",
    647                          (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut)));
     646                OSDBGPRINT(("SUP_IOCTL_COOKIE: Invalid input/output sizes. cbIn=%ld expected %ld. cbOut=%ld expected %ld.\n",
     647                            (long)cbIn, (long)sizeof(*pIn), (long)cbOut, (long)sizeof(*pOut)));
    648648                return SUPDRV_ERR_INVALID_PARAM;
    649649            }
    650650            if (strncmp(pIn->szMagic, SUPCOOKIE_MAGIC, sizeof(pIn->szMagic)))
    651651            {
    652                 dprintf(("SUP_IOCTL_COOKIE: invalid magic %.16s\n", pIn->szMagic));
     652                OSDBGPRINT(("SUP_IOCTL_COOKIE: invalid magic %.16s\n", pIn->szMagic));
    653653                return SUPDRV_ERR_INVALID_MAGIC;
    654654            }
    655             if (pIn->u32Version != SUPDRVIOC_VERSION)
    656             {
    657                 dprintf(("SUP_IOCTL_COOKIE: Version mismatch. Requested: %#x  Current: %#x\n", pIn->u32Version, SUPDRVIOC_VERSION));
     655
     656            /*
     657             * Match the version.
     658             * The current logic is very simple, match the major interface version.
     659             */
     660            if (    pIn->u32MinVersion > SUPDRVIOC_VERSION
     661                ||  (pIn->u32ReqVersion & 0xffff0000) != (SUPDRVIOC_VERSION & 0xffff0000))
     662            {
     663                OSDBGPRINT(("SUP_IOCTL_COOKIE: Version mismatch. Requested: %#x  Min: %#x  Current: %#x\n",
     664                            pIn->u32ReqVersion, pIn->u32MinVersion, SUPDRVIOC_VERSION));
     665                pOut->u32Cookie         = 0xffffffff;
     666                pOut->u32SessionCookie  = 0xffffffff;
     667                pOut->u32SessionVersion = 0xffffffff;
     668                pOut->u32DriverVersion  = SUPDRVIOC_VERSION;
     669                pOut->pSession          = NULL;
     670                pOut->cFunctions        = 0;
     671                *pcbReturned = sizeof(*pOut);
    658672                return SUPDRV_ERR_VERSION_MISMATCH;
    659673            }
     
    662676             * Fill in return data and be gone.
    663677             */
    664             /** @todo secure cookie negotiation? */
     678            /** @todo A more secure cookie negotiation? */
    665679            pOut->u32Cookie         = pDevExt->u32Cookie;
    666680            pOut->u32SessionCookie  = pSession->u32Cookie;
    667             pOut->u32Version        = SUPDRVIOC_VERSION;
     681            pOut->u32SessionVersion = SUPDRVIOC_VERSION;
     682            pOut->u32DriverVersion  = SUPDRVIOC_VERSION;
    668683            pOut->pSession          = pSession;
    669684            pOut->cFunctions        = sizeof(g_aFunctions) / sizeof(g_aFunctions[0]);
     
    11461161             * Execute.
    11471162             */
    1148             pOut->rc = pDevExt->pfnVMMR0Entry(pIn->pVMR0, pIn->uOperation, pIn->pvArg);
     1163            pOut->rc = pDevExt->pfnVMMR0Entry(pIn->pVMR0, pIn->uOperation, (void *)pIn->pvArg); /** @todo address the pvArg problem! */
    11491164            *pcbReturned = sizeof(*pOut);
    11501165            return 0;
     
    22322247 * @returns SUPDRV_ERR_* on failure.
    22332248 * @param   pSession        Session to which the GIP mapping should belong.
    2234  * @param   ppGip           Where to store the address of the mapping. (optional)
     2249 * @param   ppGipR3         Where to store the address of the ring-3 mapping. (optional)
    22352250 * @param   pHCPhysGip      Where to store the physical address. (optional)
    22362251 *
     
    22392254 *          and remove the session as a GIP user.
    22402255 */
    2241 SUPR0DECL(int) SUPR0GipMap(PSUPDRVSESSION pSession, PCSUPGLOBALINFOPAGE *ppGip, PRTHCPHYS pHCPhysGid)
    2242 {
    2243     int                     rc = 0;
    2244     PSUPDRVDEVEXT           pDevExt = pSession->pDevExt;
    2245     PCSUPGLOBALINFOPAGE     pGip = NULL;
    2246     RTHCPHYS                HCPhys = NIL_RTHCPHYS;
    2247     dprintf(("SUPR0GipMap: pSession=%p ppGip=%p pHCPhysGid=%p\n", pSession, ppGip, pHCPhysGid));
     2256SUPR0DECL(int) SUPR0GipMap(PSUPDRVSESSION pSession, PRTR3PTR ppGipR3, PRTHCPHYS pHCPhysGid)
     2257{
     2258    int             rc = 0;
     2259    PSUPDRVDEVEXT   pDevExt = pSession->pDevExt;
     2260    RTR3PTR         pGip = NIL_RTR3PTR;
     2261    RTHCPHYS        HCPhys = NIL_RTHCPHYS;
     2262    dprintf(("SUPR0GipMap: pSession=%p ppGipR3=%p pHCPhysGid=%p\n", pSession, ppGipR3, pHCPhysGid));
    22482263
    22492264    /*
    22502265     * Validate
    22512266     */
    2252     if (!ppGip && !pHCPhysGid)
     2267    if (!ppGipR3 && !pHCPhysGid)
    22532268        return 0;
    22542269
     
    22592274         * Map it?
    22602275         */
    2261         if (ppGip)
     2276        if (ppGipR3)
    22622277        {
    22632278#ifdef USE_NEW_OS_INTERFACE
     
    22672282            if (RT_SUCCESS(rc))
    22682283            {
    2269                 pGip = (PCSUPGLOBALINFOPAGE)RTR0MemObjAddress(pSession->GipMapObjR3);
     2284                pGip = (RTR3PTR)RTR0MemObjAddress(pSession->GipMapObjR3);
    22702285                rc = VINF_SUCCESS; /** @todo remove this and replace the !rc below with RT_SUCCESS(rc). */
    22712286            }
     
    22742289                rc = supdrvOSGipMap(pSession->pDevExt, &pSession->pGip);
    22752290            if (!rc)
    2276                 pGip = pSession->pGip;
     2291                pGip = (RTR3PTR)pSession->pGip;
    22772292#endif /* !USE_NEW_OS_INTERFACE */
    22782293        }
     
    23232338    if (pHCPhysGid)
    23242339        *pHCPhysGid = HCPhys;
    2325     if (ppGip)
    2326         *ppGip = pGip;
    2327 
    2328     dprintf(("SUPR0GipMap: returns %d *pHCPhysGid=%lx *ppGip=%p\n", rc, (unsigned long)HCPhys, pGip));
     2340    if (ppGipR3)
     2341        *ppGipR3 = pGip;
     2342
     2343    dprintf(("SUPR0GipMap: returns %d *pHCPhysGid=%lx *ppGipR3=%p\n", rc, (unsigned long)HCPhys, (void *)(uintptr_t)pGip));
    23292344    return rc;
    23302345}
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r1480 r1840  
    115115#endif
    116116/** VMMR0 Load Address. */
    117 static void        *g_pvVMMR0 = NULL;
     117static RTR0PTR      g_pvVMMR0 = NIL_RTR0PTR;
    118118/** Init counter. */
    119119static unsigned     g_cInits = 0;
     
    183183         */
    184184        SUPCOOKIE_IN    In;
    185         SUPCOOKIE_OUT   Out = {0,0};
     185        SUPCOOKIE_OUT   Out = {0,0,0,0,0,NIL_RTR0PTR};
    186186        strcpy(In.szMagic, SUPCOOKIE_MAGIC);
    187         In.u32Version = SUPDRVIOC_VERSION;
     187        In.u32ReqVersion = SUPDRVIOC_VERSION;
     188        if (SUPDRVIOC_VERSION < 0x00050000)
     189            In.u32MinVersion = 0x00040002;
     190        else
     191            In.u32MinVersion = SUPDRVIOC_VERSION & 0xffff0000;
    188192        rc = suplibOsIOCtl(SUP_IOCTL_COOKIE, &In, sizeof(In), &Out, sizeof(Out));
    189193        if (VBOX_SUCCESS(rc))
    190194        {
    191             if (Out.u32Version == SUPDRVIOC_VERSION)
     195            if ((Out.u32SessionVersion & 0xffff0000) == (SUPDRVIOC_VERSION & 0xffff0000))
    192196            {
    193197                /*
     
    239243            }
    240244            else
     245            {
     246                LogRel(("Support driver version mismatch: SessionVersion=%#x DriverVersion=%#x ClientVersion=%#x\n",
     247                        Out.u32SessionVersion, Out.u32DriverVersion, SUPDRVIOC_VERSION));
    241248                rc = VERR_VM_DRIVER_VERSION_MISMATCH;
     249            }
     250        }
     251        else
     252        {
     253             if (rc == VERR_INVALID_PARAMETER) /* for pre 0x00040002 drivers */
     254                 rc = VERR_VM_DRIVER_VERSION_MISMATCH;
     255             if (rc == VERR_VM_DRIVER_VERSION_MISMATCH)
     256                 LogRel(("Support driver version mismatch: DriverVersion=%#x ClientVersion=%#x\n",
     257                         Out.u32DriverVersion, SUPDRVIOC_VERSION));
     258             else
     259                 LogRel(("Support driver version/Cookie negotiations error: rc=%Vrc\n", rc));
    242260        }
    243261
     
    259277    {
    260278        /* name                                     function */
    261         { "SUPR0ObjRegister",                       (void *)0xefef0000 },
    262         { "SUPR0ObjAddRef",                         (void *)0xefef0001 },
    263         { "SUPR0ObjRelease",                        (void *)0xefef0002 },
    264         { "SUPR0ObjVerifyAccess",                   (void *)0xefef0003 },
    265         { "SUPR0LockMem",                           (void *)0xefef0004 },
    266         { "SUPR0UnlockMem",                         (void *)0xefef0005 },
    267         { "SUPR0ContAlloc",                         (void *)0xefef0006 },
    268         { "SUPR0ContFree",                          (void *)0xefef0007 },
    269         { "SUPR0MemAlloc",                          (void *)0xefef0008 },
    270         { "SUPR0MemGetPhys",                        (void *)0xefef0009 },
    271         { "SUPR0MemFree",                           (void *)0xefef000a },
    272         { "SUPR0Printf",                            (void *)0xefef000b },
    273         { "RTMemAlloc",                             (void *)0xefef000c },
    274         { "RTMemAllocZ",                            (void *)0xefef000d },
    275         { "RTMemFree",                              (void *)0xefef000e },
    276         { "RTSemFastMutexCreate",                   (void *)0xefef000f },
    277         { "RTSemFastMutexDestroy",                  (void *)0xefef0010 },
    278         { "RTSemFastMutexRequest",                  (void *)0xefef0011 },
    279         { "RTSemFastMutexRelease",                  (void *)0xefef0012 },
    280         { "RTSemEventCreate",                       (void *)0xefef0013 },
    281         { "RTSemEventSignal",                       (void *)0xefef0014 },
    282         { "RTSemEventWait",                         (void *)0xefef0015 },
    283         { "RTSemEventDestroy",                      (void *)0xefef0016 },
    284         { "RTSpinlockCreate",                       (void *)0xefef0017 },
    285         { "RTSpinlockDestroy",                      (void *)0xefef0018 },
    286         { "RTSpinlockAcquire",                      (void *)0xefef0019 },
    287         { "RTSpinlockRelease",                      (void *)0xefef001a },
    288         { "RTSpinlockAcquireNoInts",                (void *)0xefef001b },
    289         { "RTSpinlockReleaseNoInts",                (void *)0xefef001c },
    290         { "RTThreadNativeSelf",                     (void *)0xefef001d },
    291         { "RTThreadSleep",                          (void *)0xefef001e },
    292         { "RTThreadYield",                          (void *)0xefef001f },
    293         { "RTLogDefaultInstance",                   (void *)0xefef0020 },
    294         { "RTLogRelDefaultInstance",                (void *)0xefef0021 },
    295         { "RTLogSetDefaultInstanceThread",          (void *)0xefef0022 },
    296         { "RTLogLogger",                            (void *)0xefef0023 },
    297         { "RTLogLoggerEx",                          (void *)0xefef0024 },
    298         { "RTLogLoggerExV",                         (void *)0xefef0025 },
    299         { "AssertMsg1",                             (void *)0xefef0026 },
    300         { "AssertMsg2",                             (void *)0xefef0027 },
     279        { "SUPR0ObjRegister",                       0xefef0000 },
     280        { "SUPR0ObjAddRef",                         0xefef0001 },
     281        { "SUPR0ObjRelease",                        0xefef0002 },
     282        { "SUPR0ObjVerifyAccess",                   0xefef0003 },
     283        { "SUPR0LockMem",                           0xefef0004 },
     284        { "SUPR0UnlockMem",                         0xefef0005 },
     285        { "SUPR0ContAlloc",                         0xefef0006 },
     286        { "SUPR0ContFree",                          0xefef0007 },
     287        { "SUPR0MemAlloc",                          0xefef0008 },
     288        { "SUPR0MemGetPhys",                        0xefef0009 },
     289        { "SUPR0MemFree",                           0xefef000a },
     290        { "SUPR0Printf",                            0xefef000b },
     291        { "RTMemAlloc",                             0xefef000c },
     292        { "RTMemAllocZ",                            0xefef000d },
     293        { "RTMemFree",                              0xefef000e },
     294        { "RTSemFastMutexCreate",                   0xefef000f },
     295        { "RTSemFastMutexDestroy",                  0xefef0010 },
     296        { "RTSemFastMutexRequest",                  0xefef0011 },
     297        { "RTSemFastMutexRelease",                  0xefef0012 },
     298        { "RTSemEventCreate",                       0xefef0013 },
     299        { "RTSemEventSignal",                       0xefef0014 },
     300        { "RTSemEventWait",                         0xefef0015 },
     301        { "RTSemEventDestroy",                      0xefef0016 },
     302        { "RTSpinlockCreate",                       0xefef0017 },
     303        { "RTSpinlockDestroy",                      0xefef0018 },
     304        { "RTSpinlockAcquire",                      0xefef0019 },
     305        { "RTSpinlockRelease",                      0xefef001a },
     306        { "RTSpinlockAcquireNoInts",                0xefef001b },
     307        { "RTSpinlockReleaseNoInts",                0xefef001c },
     308        { "RTThreadNativeSelf",                     0xefef001d },
     309        { "RTThreadSleep",                          0xefef001e },
     310        { "RTThreadYield",                          0xefef001f },
     311        { "RTLogDefaultInstance",                   0xefef0020 },
     312        { "RTLogRelDefaultInstance",                0xefef0021 },
     313        { "RTLogSetDefaultInstanceThread",          0xefef0022 },
     314        { "RTLogLogger",                            0xefef0023 },
     315        { "RTLogLoggerEx",                          0xefef0024 },
     316        { "RTLogLoggerExV",                         0xefef0025 },
     317        { "AssertMsg1",                             0xefef0026 },
     318        { "AssertMsg2",                             0xefef0027 },
    301319    };
    302320
     
    10131031    /** @todo call the SUPLoadModule caller.... */
    10141032    /** @todo proper reference counting and such. */
    1015     if (g_pvVMMR0)
     1033    if (g_pvVMMR0 != NIL_RTR0PTR)
    10161034    {
    10171035        void *pvValue;
    1018         if (!SUPGetSymbolR0(g_pvVMMR0, pszSymbol, &pvValue))
     1036        if (!SUPGetSymbolR0((void *)g_pvVMMR0, pszSymbol, &pvValue))
    10191037        {
    10201038            *pValue = (uintptr_t)pvValue;
     
    11621180        {
    11631181            OpenOut.fNeedsLoading = true;
    1164             OpenOut.pvImageBase = (void *)0xef423420;
    1165         }
    1166         *ppvImageBase = OpenOut.pvImageBase;
     1182            OpenOut.pvImageBase = 0xef423420;
     1183        }
     1184        *ppvImageBase = (void *)OpenOut.pvImageBase;
    11671185        if (    VBOX_SUCCESS(rc)
    11681186            &&  OpenOut.fNeedsLoading)
     
    12201238                    pIn->u32Cookie                  = g_u32Cookie;
    12211239                    pIn->u32SessionCookie           = g_u32SessionCookie;
    1222                     pIn->pfnModuleInit              = (PFNR0MODULEINIT)(uintptr_t)ModuleInit;
    1223                     pIn->pfnModuleTerm              = (PFNR0MODULETERM)(uintptr_t)ModuleTerm;
     1240                    pIn->pfnModuleInit              = (RTR0PTR)ModuleInit;
     1241                    pIn->pfnModuleTerm              = (RTR0PTR)ModuleTerm;
    12241242                    if (fIsVMMR0)
    12251243                    {
    12261244                        pIn->eEPType                = pIn->EP_VMMR0;
    12271245                        pIn->EP.VMMR0.pvVMMR0       = OpenOut.pvImageBase;
    1228                         pIn->EP.VMMR0.pvVMMR0Entry  = (void *)(uintptr_t)VMMR0Entry;
     1246                        pIn->EP.VMMR0.pvVMMR0Entry  = (RTR0PTR)VMMR0Entry;
    12291247                    }
    12301248                    else
     
    12741292     *      first unload will free it.
    12751293     */
    1276     if (pvImageBase == g_pvVMMR0)
     1294    if ((RTR0PTR)pvImageBase == g_pvVMMR0)
    12771295    {
    12781296        /*
     
    12871305            g_pfnCallVMMR0 = NULL;
    12881306#endif
    1289             g_pvVMMR0 = NULL;
     1307            g_pvVMMR0 = NIL_RTR0PTR;
    12901308            return VINF_SUCCESS;
    12911309        }
     
    13151333    In.u32Cookie        = g_u32Cookie;
    13161334    In.u32SessionCookie = g_u32SessionCookie;
    1317     In.pvImageBase      = pvImageBase;
     1335    In.pvImageBase      = (RTR0PTR)pvImageBase;
    13181336    int rc = VINF_SUCCESS;
    13191337    if (!g_u32FakeMode)
    13201338        rc = suplibOsIOCtl(SUP_IOCTL_LDR_FREE, &In, sizeof(In), NULL, 0);
    13211339    if (    VBOX_SUCCESS(rc)
    1322         &&  pvImageBase == g_pvVMMR0)
    1323         g_pvVMMR0 = NULL;
     1340        &&  (RTR0PTR)pvImageBase == g_pvVMMR0)
     1341        g_pvVMMR0 = NIL_RTR0PTR;
    13241342    return rc;
    13251343}
     
    13351353    size_t              cchSymbol = strlen(pszSymbol);
    13361354    const size_t        cbIn = RT_OFFSETOF(SUPLDRGETSYMBOL_IN, szSymbol[cchSymbol + 1]);
    1337     SUPLDRGETSYMBOL_OUT Out = { NULL };
     1355    SUPLDRGETSYMBOL_OUT Out = { NIL_RTR0PTR };
    13381356    PSUPLDRGETSYMBOL_IN pIn = (PSUPLDRGETSYMBOL_IN)alloca(cbIn);
    13391357    pIn->u32Cookie        = g_u32Cookie;
    13401358    pIn->u32SessionCookie = g_u32SessionCookie;
    1341     pIn->pvImageBase      = pvImageBase;
     1359    pIn->pvImageBase      = (RTR0PTR)pvImageBase;
    13421360    memcpy(pIn->szSymbol, pszSymbol, cchSymbol + 1);
    13431361    int rc;
     
    13471365    {
    13481366        rc = VINF_SUCCESS;
    1349         Out.pvSymbol = (void *)0xdeadf00d;
     1367        Out.pvSymbol = 0xdeadf00d;
    13501368    }
    13511369    if (VBOX_SUCCESS(rc))
    1352         *ppvValue = Out.pvSymbol;
     1370        *ppvValue = (void *)Out.pvSymbol;
    13531371    return rc;
    13541372}
     
    13641382SUPR3DECL(int) SUPUnloadVMM(void)
    13651383{
    1366     return SUPFreeModule(g_pvVMMR0);
     1384    return SUPFreeModule((void*)g_pvVMMR0);
    13671385}
    13681386
Note: See TracChangeset for help on using the changeset viewer.

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