VirtualBox

Changeset 4178 in vbox


Ignore:
Timestamp:
Aug 16, 2007 3:07:51 PM (17 years ago)
Author:
vboxsync
Message:

Solaris changes.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r4082 r4178  
    12381238TEMPLATE_VBOXGC_CXXFLAGS            = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -fno-exceptions -fno-rtti $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden)
    12391239TEMPLATE_VBOXGC_CFLAGS              = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden)
    1240 TEMPLATE_VBOXGC_LDFLAGS             = -nostdlib -Bsymbolic
    1241 # temporarily, must fix the loader.
    1242 TEMPLATE_VBOXGC_LDFLAGS            += -S
    1243 TEMPLATE_VBOXGC_LDFLAGS.release     = -S
     1240ifeq ($(BUILD_TARGET),solaris)
     1241 TEMPLATE_VBOXGC_LDFLAGS            = -B symbolic
     1242else
     1243 TEMPLATE_VBOXGC_LDFLAGS             = -nostdlib -Bsymbolic
     1244 # temporarily, must fix the loader.
     1245 TEMPLATE_VBOXGC_LDFLAGS            += -S
     1246 TEMPLATE_VBOXGC_LDFLAGS.release     = -S
     1247endif
    12441248TEMPLATE_VBOXGC_LIBS                = \
    12451249        $(VBOX_GCC32_LIBGCC) # instricts
     
    13351339TEMPLATE_VBOXR0_CFLAGS.amd64        = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables -ffreestanding
    13361340TEMPLATE_VBOXR0_CXXFLAGS.amd64      = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables
    1337 TEMPLATE_VBOXR0_LDFLAGS             = -nostdlib -Bsymbolic
    1338 # temporarily, must fix the loader.
    1339 TEMPLATE_VBOXR0_LDFLAGS            += -S
    1340 TEMPLATE_VBOXR0_LDFLAGS.release     = -S
     1341ifeq ($(BUILD_TARGET),solaris)
     1342 TEMPLATE_VBOXR0_LDFLAGS             = -B symbolic
     1343else
     1344 TEMPLATE_VBOXR0_LDFLAGS             = -nostdlib -Bsymbolic
     1345 # temporarily, must fix the loader.
     1346 TEMPLATE_VBOXR0_LDFLAGS            += -S
     1347 TEMPLATE_VBOXR0_LDFLAGS.release     = -S
     1348endif
     1349
    13411350TEMPLATE_VBOXR0_LIBS                = \
    13421351        $(VBOX_GCC_LIBGCC) # instricts
     
    14561465## The Solaris /usr/include.
    14571466VBOX_SOLARIS_SYS_INCS ?= /usr/include
    1458 
    14591467TEMPLATE_VBOXR0DRV_TOOL                = $(VBOX_GCC_TOOL)
    14601468TEMPLATE_VBOXR0DRV_DEFS                = _KERNEL _STRICT_STDC IN_RING0 IN_RT_R0
     
    14651473# exclude -Wall because of solaris headers' pragma ident warnings that gcc refuses to supress!!
    14661474TEMPLATE_VBOXR0DRV_CFLAGS              = -Wno-trigraphs -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) \
    1467         -Wmissing-prototypes -Wstrict-prototypes \
     1475        -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs \
    14681476        -O2 -ffreestanding -nodefaultlibs -fno-strict-aliasing -fno-common -std=c99
    14691477## *************************** SOLARISTODO  ******************
  • trunk/src/VBox/Frontends/VBoxBFE/Makefile.kmk

    r4071 r4178  
    8080        SDLConsole.cpp \
    8181        SDLFramebuffer.cpp
     82VBoxBFE_SOURCES.solaris = \
     83    SDLConsole.cpp \
     84    SDLFramebuffer.cpp
    8285
    8386VBoxBFE_INCS = \
  • trunk/src/VBox/HostDrivers/Support/Makefile.kmk

    r4163 r4178  
    250250vboxdrv_LIBS          = $(PATH_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
    251251vboxdrv_SOURCES       = \
    252         $(BUILD_TARGET)/SUPDrv-$(BUILD_TARGET).c
    253 #       SUPDRVShared.c
     252        $(BUILD_TARGET)/SUPDrv-$(BUILD_TARGET).c \
     253        SUPDRVShared.c
    254254endif # solaris
    255255
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c

    r4071 r4178  
    3232#include <sys/ddi.h>
    3333#include <sys/sunddi.h>
     34#include <sys/file.h>
    3435
    3536#include "SUPDRV.h"
     
    3738#include <iprt/process.h>
    3839#include <iprt/initterm.h>
     40#include <iprt/alloc.h>
    3941
    4042
     
    5456static int VBoxDrvSolarisRead(dev_t Dev, struct uio* pUio, cred_t* pCred);
    5557static int VBoxDrvSolarisWrite(dev_t Dev, struct uio* pUio, cred_t* pCred);
    56 static int VBoxDrvSolarisIoctl (dev_t Dev, int Cmd, intptr_t Arg, int mode,cred_t* pCred, int* pVal);
     58static int VBoxDrvSolarisIOCtl (dev_t Dev, int Cmd, intptr_t pArgs, int mode, cred_t* pCred, int* pVal);
    5759
    5860static int VBoxDrvSolarisAttach(dev_info_t* pDip, ddi_attach_cmd_t Cmd);
    5961static int VBoxDrvSolarisDetach(dev_info_t* pDip, ddi_detach_cmd_t Cmd);
    6062
    61 static int VBoxDrvSolarisErr2Native(int rc);
     63static int VBoxSupDrvErr2SolarisErr(int rc);
     64static int VBoxDrvSolarisIOCtlSlow(PSUPDRVSESSION pSession, int Cmd, int Mode, intptr_t pArgs);
    6265
    6366
     
    7780    VBoxDrvSolarisRead,
    7881    VBoxDrvSolarisWrite,
    79     VBoxDrvSolarisIoctl,
     82    VBoxDrvSolarisIOCtl,
    8083    nodev,                  /* c devmap */
    8184    nodev,                  /* c mmap */
     
    100103    VBoxDrvSolarisAttach,
    101104    VBoxDrvSolarisDetach,
    102     nodev,          /* reset */
     105    nodev,                  /* reset */
    103106    &g_VBoxDrvSolarisCbOps,
    104107    (struct bus_ops *)0,
     
    126129};
    127130
    128 /** Track module instances */
    129 dev_info_t* g_pVBoxDrvSolarisDip;
     131/** State info. each our kernel module instances */
     132typedef struct
     133{
     134    dev_info_t*     pDip;   /* Device handle */
     135} vbox_devstate_t;
    130136
    131137/** Opaque pointer to state */
     
    152158    cmn_err(CE_CONT, "VBoxDrvSolaris _init");
    153159
    154     int e = ddi_soft_state_init(&g_pVBoxDrvSolarisState, sizeof (g_pVBoxDrvSolarisDip), 1);
     160    int e = ddi_soft_state_init(&g_pVBoxDrvSolarisState, sizeof (vbox_devstate_t), 1);
    155161    if (e != 0)
    156162        return e;
     
    175181}
    176182
    177 int _info (struct modinfo* pModInfo)
     183int _info (struct modinfo *pModInfo)
    178184{
    179185    cmn_err(CE_CONT, "VBoxDrvSolaris _info");
     
    184190 * User context entry points
    185191 */
    186 static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t* pCred)
     192static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred)
    187193{
    188194    cmn_err(CE_CONT, "VBoxDrvSolarisOpen");
     
    193199    /*
    194200     * Create a new session.
    195      */
    196 #if 1
    197     rc = VINF_SUCCESS;
    198 #else
     201     * Sessions in Solaris driver are mostly useless. It's however needed
     202     * in VBoxDrvSolarisIOCtlSlow() while calling supdrvIOCtl()
     203     */
    199204    rc = supdrvCreateSession(&g_DevExt, &pSession);
    200205    if (RT_SUCCESS(rc))
    201206    {
     207        cmn_err(CE_NOTE,"supdrvCreateSession success");
    202208        RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    203209        unsigned        iHash;
     
    216222        g_apSessionHashTab[iHash] = pSession;
    217223        RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
    218     }
    219 #endif
    220     return VBoxDrvSolarisErr2Native(rc);
    221 }
    222 
    223 static int VBoxDrvSolarisClose(dev_t pDev, int flag, int otyp, cred_t* cred)
     224        cmn_err(CE_NOTE,"VBoxDrvSolarisOpen success");
     225    }
     226
     227    return VBoxSupDrvErr2SolarisErr(rc);
     228}
     229
     230static int VBoxDrvSolarisClose(dev_t pDev, int flag, int otyp, cred_t *cred)
    224231{
    225232    cmn_err(CE_CONT, "VBoxDrvSolarisClose");
     233
     234    RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
     235    const RTPROCESS Process = RTProcSelf();
     236    const unsigned  iHash = SESSION_HASH(Process);
     237    PSUPDRVSESSION  pSession;
     238
     239    /*
     240     * Remove from the hash table.
     241     */
     242    RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     243    pSession = g_apSessionHashTab[iHash];
     244    if (pSession)
     245    {
     246        if (pSession->Process == Process)
     247        {
     248            g_apSessionHashTab[iHash] = pSession->pNextHash;
     249            pSession->pNextHash = NULL;
     250        }
     251        else
     252        {
     253            PSUPDRVSESSION pPrev = pSession;
     254            pSession = pSession->pNextHash;
     255            while (pSession)
     256            {
     257                if (pSession->Process == Process)
     258                {
     259                    pPrev->pNextHash = pSession->pNextHash;
     260                    pSession->pNextHash = NULL;
     261                    break;
     262                }
     263
     264                /* next */
     265                pPrev = pSession;
     266                pSession = pSession->pNextHash;
     267            }
     268        }
     269    }
     270    RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     271    if (!pSession)
     272    {
     273        OSDBGPRINT(("VBoxDrvSolarisClose: WHAT?!? pSession == NULL! This must be a mistake... pid=%d (close)\n",
     274                    (int)Process));
     275        return DDI_FAILURE;
     276    }
     277
     278    /*
     279     * Close the session.
     280     */
     281    supdrvCloseSession(&g_DevExt, pSession);
    226282    return DDI_SUCCESS;
    227283}
     
    252308    int rc = VINF_SUCCESS;
    253309    int instance = 0;
    254 
     310    vbox_devstate_t* pState;
     311   
    255312    switch (enmCmd)
    256313    {
     
    258315        {
    259316            instance = ddi_get_instance (pDip);
    260             g_pVBoxDrvSolarisDip = pDip;
    261317
    262318            if (ddi_soft_state_zalloc(g_pVBoxDrvSolarisState, instance) != DDI_SUCCESS)
     
    265321                return DDI_FAILURE;
    266322            }
    267 
     323           
     324            pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, instance);
     325           
    268326            /*
    269327             * Initialize IPRT R0 driver, which internally calls OS-specific r0 init.
     
    281339                     * Initialize the session hash table.
    282340                     */
    283                     //memset(g_apSessionHashTab, 0, sizeof(g_apSessionHashTab));
    284                     //rc = RTSpinlockCreate(&g_Spinlock);
     341                    memset(g_apSessionHashTab, 0, sizeof(g_apSessionHashTab));
     342                    rc = RTSpinlockCreate(&g_Spinlock);
    285343                    if (RT_SUCCESS(rc))
    286344                    {
     
    288346                         * Register ourselves as a character device, pseudo-driver
    289347                         */
    290                         if (ddi_create_minor_node(g_pVBoxDrvSolarisDip, "0", S_IFCHR,
     348                        if (ddi_create_minor_node(pDip, "0", S_IFCHR,
    291349                                instance, DDI_PSEUDO, 0) == DDI_SUCCESS)
    292350                        {
     351                            pState->pDip = pDip;
     352                            ddi_report_dev(pDip);
     353                           
    293354                            cmn_err(CE_CONT, "VBoxDrvSolarisAttach: successful.");
    294355                            return DDI_SUCCESS;
     
    296357
    297358                        /* Is this really necessary? */
    298                         ddi_remove_minor_node(g_pVBoxDrvSolarisDip, NULL);
     359                        ddi_remove_minor_node(pDip, NULL);
    299360                        cmn_err(CE_NOTE,"VBoxDrvSolarisAttach: ddi_create_minor_node failed.");
    300361
    301                         //RTSpinlockDestroy(g_Spinlock);
    302                         //g_Spinlock = NIL_RTSPINLOCK;
     362                        RTSpinlockDestroy(g_Spinlock);
     363                        g_Spinlock = NIL_RTSPINLOCK;
    303364                    }
    304365                    else
    305366                        cmn_err(CE_NOTE, "VBoxDrvSolarisAttach: RTSpinlockCreate failed");
    306                     //supdrvDeleteDevExt(&g_DevExt);
     367                    supdrvDeleteDevExt(&g_DevExt);
    307368                }
    308369                else
     
    312373            else
    313374                cmn_err(CE_NOTE, "VBoxDrvSolarisAttach: failed to init R0Drv");
    314             //memset(&g_DevExt, 0, sizeof(g_DevExt));
     375            memset(&g_DevExt, 0, sizeof(g_DevExt));
    315376            break;
    316377        }
     
    331392 * @return  corresponding solaris error code.
    332393 */
    333 static int VBoxDrvSolarisDetach(dev_info_t* pDip, ddi_detach_cmd_t enmCmd)
     394static int VBoxDrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)
    334395{
    335396    int rc = VINF_SUCCESS;
    336     int instance = ddi_get_instance(pDip);
     397    int instance;
     398    register vbox_devstate_t* pState;
    337399
    338400    cmn_err(CE_CONT, "VBoxDrvSolarisDetach");
     
    341403        case DDI_DETACH:
    342404        {
    343             g_pVBoxDrvSolarisDip = NULL;
    344             ddi_get_soft_state(g_pVBoxDrvSolarisState, instance);
     405            instance = ddi_get_instance(pDip);
     406            pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, instance);
     407
    345408            ddi_remove_minor_node(pDip, NULL);
    346409            ddi_soft_state_free(g_pVBoxDrvSolarisState, instance);
     410           
     411            rc = supdrvDeleteDevExt(&g_DevExt);
     412            AssertRC(rc);
     413
     414            rc = RTSpinlockDestroy(g_Spinlock);
     415            AssertRC(rc);
     416            g_Spinlock = NIL_RTSPINLOCK;
     417
     418            RTR0Term();
     419
     420            memset(&g_DevExt, 0, sizeof(g_DevExt));
    347421            cmn_err(CE_CONT, "VBoxDrvSolarisDetach: Clean Up Done.");
    348            
    349             //rc = supdrvDeleteDevExt(&g_DevExt);
    350             //AssertRC(rc);
    351 
    352             //rc = RTSpinlockDestroy(g_Spinlock);
    353             //AssertRC(rc);
    354             //g_Spinlock = NIL_RTSPINLOCK;
    355 
    356             RTR0Term();
    357 
    358             memset(&g_DevExt, 0, sizeof(g_DevExt));
    359 
    360422            return DDI_SUCCESS;
    361423        }
     
    371433 * @param   Dev             Device number
    372434 * @param   Cmd             Operation identifier
    373  * @param   Arg             Arguments from user to driver
    374  * @param   Mode            Information bitfield (read/write, address space etc)
     435 * @param   pArg            Arguments from user to driver
     436 * @param   Mode            Information bitfield (read/write, address space etc.)
    375437 * @param   pCred           User credentials
    376438 * @param   pVal            Return value for calling process.
     
    378440 * @return  corresponding solaris error code.
    379441 */
    380 static int VBoxDrvSolarisIoctl(dev_t Dev, int Cmd, intptr_t Arg, int Mode, cred_t* pCred, int* pVal)
    381 {
    382     cmn_err(CE_CONT, "VBoxDrvSolarisIoctl");
    383     return DDI_SUCCESS;
    384 }
    385 
    386 /**
    387  * Converts an supdrv error code to a Solaris error code.
    388  *
    389  * @returns corresponding Solaris error code.
     442static int VBoxDrvSolarisIOCtl (dev_t Dev, int Cmd, intptr_t pArgs, int Mode, cred_t* pCred, int* pVal)
     443{
     444    RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
     445    const RTPROCESS     Process = RTProcSelf();
     446    const unsigned      iHash = SESSION_HASH(Process);
     447    PSUPDRVSESSION      pSession;
     448
     449    cmn_err(CE_CONT, "VBoxDrvSolarisIOCtl\n");
     450    /*
     451     * Find the session.
     452     */
     453    RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     454    pSession = g_apSessionHashTab[iHash];
     455    if (pSession && pSession->Process != Process)
     456    {
     457        do pSession = pSession->pNextHash;
     458        while (pSession && pSession->Process != Process);
     459    }
     460    RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     461    if (!pSession)
     462    {
     463        OSDBGPRINT(("VBoxSupDrvIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x\n",
     464                    (int)Process, Cmd));
     465        return EINVAL;
     466    }
     467
     468    /*
     469     * Deal with the two high-speed IOCtl that takes it's arguments from
     470     * the session and iCmd, and only returns a VBox status code.
     471     */
     472#ifdef VBOX_WITHOUT_IDT_PATCHING
     473    if (    Cmd == SUP_IOCTL_FAST_DO_RAW_RUN
     474        ||  Cmd == SUP_IOCTL_FAST_DO_HWACC_RUN
     475        ||  Cmd == SUP_IOCTL_FAST_DO_NOP)
     476        return supdrvIOCtlFast(Cmd, &g_DevExt, pSession);
     477#endif
     478
     479    return VBoxDrvSolarisIOCtlSlow(pSession, Cmd, Mode, pArgs);
     480}
     481
     482/**
     483 * Worker for VBoxSupDrvIOCtl that takes the slow IOCtl functions.
     484 *
     485 * @returns Solaris errno.
     486 *
     487 * @param pSession  The session.
     488 * @param Cmd       The IOCtl command.
     489 * @param Mode      Information bitfield (for specifying ownership of data)
     490 * @param pArgs     Pointer to the kernel copy of the SUPDRVIOCTLDATA buffer.
     491 */
     492static int VBoxDrvSolarisIOCtlSlow(PSUPDRVSESSION pSession, int Cmd, int Mode, intptr_t pArgs)
     493{
     494    int                 rc;
     495    void               *pvBuf = NULL;
     496    unsigned long       cbBuf = 0;
     497    unsigned            cbOut = 0;
     498    PSUPDRVIOCTLDATA    pArgData = (PSUPDRVIOCTLDATA)pArgs;
     499
     500    cmn_err(CE_CONT, "VBoxDrvSolarisIOCtlSlow\n");
     501   /*
     502     * Allocate and copy user space input data buffer to kernel space.
     503     */
     504    if (pArgData->cbIn > 0 || pArgData->cbOut > 0)
     505    {
     506        cbBuf = max(pArgData->cbIn, pArgData->cbOut);
     507        pvBuf = RTMemTmpAlloc(cbBuf);
     508
     509        if (pvBuf == NULL)
     510        {
     511            OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: failed to allocate buffer of %d bytes.\n", cbBuf));
     512            return ENOMEM;
     513        }
     514       
     515        rc = ddi_copyin(pArgData->pvIn, pvBuf, cbBuf, Mode);
     516       
     517        if (rc != 0)
     518        {
     519            OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: ddi_copyin(%p,%d) failed.\n", pArgData->pvIn, cbBuf));
     520
     521            RTMemTmpFree(pvBuf);
     522            return EFAULT;
     523        }
     524    }
     525   
     526    /*
     527     * Process the IOCtl.
     528     */
     529    rc = supdrvIOCtl(Cmd, &g_DevExt, pSession, pvBuf, pArgData->cbIn, pvBuf, pArgData->cbOut, &cbOut);
     530   
     531    /*
     532     * Copy ioctl data and output buffer back to user space.
     533     */
     534    if (rc != 0)
     535        rc = VBoxSupDrvErr2SolarisErr(rc);
     536    else if (cbOut > 0)
     537    {
     538        if (pvBuf != NULL && cbOut <= cbBuf)
     539        {
     540            rc = ddi_copyout(pvBuf, pArgData->pvOut, cbOut, Mode);
     541            if (rc != 0)
     542                OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: ddi_copyout(,%p,%d) failed.\n", pArgData->pvOut, cbBuf));
     543        }
     544        else
     545        {
     546            OSDBGPRINT(("WHAT!?! supdrvIOCtl messed up! cbOut=%d cbBuf=%d pvBuf=%p\n", cbOut, cbBuf, pvBuf));
     547            rc = EPERM;
     548        }
     549    }
     550
     551    OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: returns %d cbOut=%d\n", rc, cbOut));
     552    return rc;
     553}
     554
     555
     556/**
     557 * Converts an supdrv error code to a solaris error code.
     558 *
     559 * @returns corresponding solaris error code.
    390560 * @param   rc  supdrv error code (SUPDRV_ERR_* defines).
    391561 */
    392 static int VBoxDrvSolarisErr2Native(int rc)
     562static int VBoxSupDrvErr2SolarisErr(int rc)
    393563{
    394564    switch (rc)
     
    408578    return EPERM;
    409579}
     580
     581/**
     582 * Initializes any OS specific object creator fields.
     583 */
     584void VBOXCALL   supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession)
     585{
     586    NOREF(pObj);
     587    NOREF(pSession);
     588}
     589
     590
     591/**
     592 * Checks if the session can access the object.
     593 *
     594 * @returns true if a decision has been made.
     595 * @returns false if the default access policy should be applied.
     596 *
     597 * @param   pObj        The object in question.
     598 * @param   pSession    The session wanting to access the object.
     599 * @param   pszObjName  The object name, can be NULL.
     600 * @param   prc         Where to store the result when returning true.
     601 */
     602bool VBOXCALL   supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc)
     603{
     604    NOREF(pObj);
     605    NOREF(pSession);
     606    NOREF(pszObjName);
     607    NOREF(prc);
     608    return false;
     609}
     610
     611RTDECL(int) SUPR0Printf(const char *pszFormat, ...)
     612{
     613    va_list     args;
     614    char        szMsg[512];
     615
     616    va_start(args, pszFormat);
     617    vsnprintf(szMsg, sizeof(szMsg) - 1, pszFormat, args);
     618    va_end(args);
     619
     620    szMsg[sizeof(szMsg) - 1] = '\0';
     621    printf("%s", szMsg);
     622    return 0;
     623}
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp

    r4071 r4178  
     1/* $Id$ */
    12/** @file
    23 *
     
    3738#include <sys/fcntl.h>
    3839#include <sys/ioctl.h>
     40
    3941#include <fcntl.h>
    4042#include <errno.h>
    4143#include <unistd.h>
    4244#include <stdlib.h>
     45#include <stdio.h>
    4346
    4447
     
    4649*   Defined Constants And Macros                                               *
    4750*******************************************************************************/
    48 #define DEVICE_NAME     "/dev/vboxdrv"
     51#define DEVICE_NAME     "/devices/pseudo/vboxdrv@0:0"
    4952
    5053
     
    150153
    151154    if (ioctl(g_hDevice, uFunction, &Args) >= 0)
    152         return 0;
    153     /* This is the reverse operation of the one found in SUPDrv-linux.c */
     155        return 0;
     156       
     157    /* This is the reverse operation of the one found in SUPDrv-solaris.c */
    154158    switch (errno)
    155159    {
    156160        case EACCES: return VERR_GENERAL_FAILURE;
    157161        case EINVAL: return VERR_INVALID_PARAMETER;
    158         case ENOSYS: return VERR_INVALID_MAGIC;
     162        case EILSEQ: return VERR_INVALID_MAGIC;
     163        case ENOSYS: return VERR_VERSION_MISMATCH;
    159164        case ENXIO:  return VERR_INVALID_HANDLE;
    160165        case EFAULT: return VERR_INVALID_POINTER;
    161166        case ENOLCK: return VERR_LOCK_FAILED;
    162167        case EEXIST: return VERR_ALREADY_LOADED;
     168        case EPERM:  return VERR_PERMISSION_DENIED;
    163169    }
    164170
  • trunk/src/VBox/Runtime/Makefile.kmk

    r4155 r4178  
    871871        generic/RTAssertDoBreakpoint-generic.cpp \
    872872        generic/RTLogWriteDebugger-generic.cpp \
     873        generic/RTTimerCreate-generic.cpp \
    873874        RTErrConvertFromErrno.cpp \
    874875        string/memchr.asm \
     
    880881        r0drv/solaris/process-r0drv-solaris.c \
    881882        r0drv/solaris/semevent-r0drv-solaris.c \
     883        r0drv/solaris/semeventmulti-r0drv-solaris.c \
    882884        r0drv/solaris/semfastmutex-r0drv-solaris.c \
    883885        r0drv/solaris/spinlock-r0drv-solaris.c \
    884886        r0drv/solaris/thread-r0drv-solaris.c \
    885         r0drv/solaris/thread2-r0drv-solaris.c
     887        r0drv/solaris/thread2-r0drv-solaris.c \
     888        r0drv/solaris/time-r0drv-solaris.c \
     889        generic/timer-generic.cpp
    886890
    887891## PORTME: Porters create and add their selection of platform specific Ring-0 Driver files here.
  • trunk/src/VBox/Runtime/r0drv/solaris/alloc-r0drv-solaris.c

    r4071 r4178  
    3737    PRTMEMHDR pHdr;
    3838    if (fFlags & RTMEMHDR_FLAG_ZEROED)
    39         pHdr = (PRTMEMHDR)kmem_zalloc(cb + sizeof(*pHdr), KM_NOSLEEP);
     39        pHdr = (PRTMEMHDR)kmem_zalloc(cb + sizeof(*pHdr), KM_SLEEP);
    4040    else
    41         pHdr = (PRTMEMHDR)kmem_alloc(cb + sizeof(*pHdr), KM_NOSLEEP);
     41        pHdr = (PRTMEMHDR)kmem_alloc(cb + sizeof(*pHdr), KM_SLEEP);
    4242    if (pHdr)
    4343    {
     
    7474RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb)
    7575{
    76     /* Solaris currently supports allocating contiguous memory
    77      * only for DMA drivers which requires passing the driver's
    78      * device ID, and upper/lower DMA memory limits
    79      * Currently thus disabled since RTMemContAlloc isn't really used
    80      * anywhere significant yet (only in GuestAdditions which is not
    81      * there for Solaris)
    82      * ddi_umem_alloc doesn't allocate contiguous memory!
    83      */
    84     /**@todo Implement RTMemContAlloc on Solaris - there is no way around this. */
     76    /** @todo: implement RTMemContAlloc in Solaris */
     77    /* ddi_umem_alloc without PAGEABLE flag might produce contiguous physical memory, but
     78        the documentation doesn't talk about contiguous at all :(
     79       If we can use ddi_umem_alloc we need to keep track of the ddi_umem_cookie
     80       which kernel allocates, but the ContFree() function only passes us back
     81       the address. Maybe we could for each ContAlloc build a linked list of
     82       structures that have the cookie and corresponding virtual address. */
    8583    return NULL;
    8684}
  • trunk/src/VBox/Runtime/r0drv/solaris/semevent-r0drv-solaris.c

    r4071 r4178  
    5050    uint32_t volatile   cWaking;
    5151    /** The Solaris mutex protecting this structure and pairing up the with the cv. */
    52     struct mutex        Mtx;
     52    kmutex_t            Mtx;
    5353    /** The Solaris condition variable. */
    5454    kcondvar_t          Cnd;
     
    104104    {
    105105        mutex_exit(&pEventInt->Mtx);
     106        cv_destroy(&pEventInt->Cnd);
    106107        mutex_destroy(&pEventInt->Mtx);
    107         cv_destroy(&pEventInt->Cnd);
    108108        RTMemFree(pEventInt);
    109109    }
     
    166166        else
    167167            cTicks = 0;
    168         cTicks += timeout;
     168        timeout += cTicks;
    169169       
    170170        ASMAtomicIncU32(&pEventInt->cWaiters);
     
    178178            {
    179179                rc = VERR_SEM_DESTROYED;
    180                 /** @todo r=bird: better make sure you're the last guy out before doing the cleanup.... */
    181                 mutex_exit(&pEventInt->Mtx);
    182                 cv_destroy(&pEventInt->Cnd);
    183                 mutex_destroy(&pEventInt->Mtx);
    184                 RTMemFree(pEventInt);
    185                 return rc;
     180                if (!ASMAtomicDecU32(&pEventInt->cWaking))
     181                {
     182                    mutex_exit(&pEventInt->Mtx);
     183                    cv_destroy(&pEventInt->Cnd);
     184                    mutex_destroy(&pEventInt->Mtx);
     185                    RTMemFree(pEventInt);
     186                    return rc;
     187                }
    186188            }
    187189
  • trunk/src/VBox/Runtime/r0drv/solaris/semfastmutex-r0drv-solaris.c

    r4071 r4178  
    4242    uint32_t            u32Magic;
    4343    /** The Solaris mutex. */
    44     struct mutex        Mtx;
     44    kmutex_t            Mtx;
    4545} RTSEMFASTMUTEXINTERNAL, *PRTSEMFASTMUTEXINTERNAL;
    4646
  • trunk/src/VBox/Runtime/r0drv/solaris/spinlock-r0drv-solaris.c

    r4071 r4178  
    4141    uint32_t volatile   u32Magic;
    4242    /** A Solaris spinlock. */
    43     struct mutex        Mtx;
     43    kmutex_t            Mtx;
    4444} RTSPINLOCKINTERNAL, *PRTSPINLOCKINTERNAL;
    4545
     
    5959     */
    6060    pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC;
    61     mutex_init(&pSpinlockInt->Mtx, "iprt-spinlock", MUTEX_SPIN, NULL);
     61    mutex_init(&pSpinlockInt->Mtx, "IPRT Spinlock", MUTEX_SPIN, NULL);
    6262    *pSpinlock = pSpinlockInt;
    6363    return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r0drv/solaris/the-solaris-kernel.h

    r4071 r4178  
    2929#include <sys/sdt.h>
    3030#include <sys/schedctl.h>
     31#include <sys/time.h>
    3132
    32 /* commented for now
     33/* commented for now 
    3334#include <iprt/cdefs.h>
    34 
    3535__BEGIN_DECLS
    36 extern int nanosleep(const struct timespec *, struct timespec *);
    3736
    3837__END_DECLS
  • trunk/src/VBox/Runtime/r0drv/solaris/thread-r0drv-solaris.c

    r4071 r4178  
    3535{
    3636    int cTicks;
    37 
     37    unsigned long timeout;
     38   
    3839    if (!cMillies)
    3940    {
     
    4647    else
    4748        cTicks = 0;
    48    
    49     /* hm, maybe we could also use nanosleep() */
     49#if 0
     50    timeout = ddi_get_lbolt();
     51    timeout += cTicks;
     52 
     53    kcondvar_t cnd;
     54    kmutex_t mtx;
     55    mutex_init(&mtx, "IPRT Sleep Mutex", MUTEX_DRIVER, NULL);
     56    cv_init(&cnd, "IPRT Sleep CV", CV_DRIVER, NULL);
     57    mutex_enter(&mtx);
     58    cv_timedwait (&cnd, &mtx, 9000 * timeout);
     59    mutex_exit(&mtx);
     60    cv_destroy(&cnd);
     61    mutex_destroy(&mtx);
     62#endif
     63
     64#if 1
    5065    delay(cTicks);
    51    
    52 /*   Hmm, no same effect as using delay()
     66#endif
     67
     68#if 0
     69    /*   Hmm, no same effect as using delay() */
    5370    struct timespec t;
    5471    t.tv_sec = 0;
    5572    t.tv_nsec = cMillies * 1000000L;
    5673    nanosleep (&t, NULL);
    57 */   
     74#endif
     75
    5876    return VINF_SUCCESS;
    5977}
  • trunk/src/VBox/Runtime/r0drv/solaris/thread2-r0drv-solaris.c

    r4071 r4178  
    3939
    4040
    41 /** @todo Solaris native threading, when more info. on priority etc. (namely default prio value) is available */
    4241int rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType)
    4342{
     
    5655    }
    5756
    58     THREAD_CHANGE_PRI(curthread, iPriority);
     57    pri_t threadPrio = iPriority;
     58    curthread->t_pri = threadPrio;
    5959    return VINF_SUCCESS;
    6060}
     
    8888{
    8989    int rc;
    90     /** @todo passing hardcoded priority: 52. Find what default priority to pass */
     90    /** @todo Passing hardcoded priority of 52, Find correct default priority */
    9191    /* We know its from 0 to 127 priority, but what's the default?? */
    9292    kthread_t* pKernThread = thread_create(NULL, NULL, rtThreadNativeMain, pThreadInt, 0,
    9393                                           curproc, LMS_USER, 52);
    94     if (rc == 0)
     94    if (pKernThread)
    9595    {
    9696        *pNativeThread = (RTNATIVETHREAD)pKernThread;
  • trunk/src/recompiler/InnoTek/crt/stdio.h

    r4071 r4178  
    3939
    4040#if defined(RT_OS_SOLARIS)
    41 /** @todo check solaris' floatingpoint.h as to why we do this */
     41/** @todo Check solaris' floatingpoint.h as to why we do this */
    4242# define _FILEDEFED
    4343#endif
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