VirtualBox

Changeset 41212 in vbox


Ignore:
Timestamp:
May 8, 2012 3:55:06 PM (13 years ago)
Author:
vboxsync
Message:

Additions/solaris: updates to the streams driver.

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris-streams.c

    r41020 r41212  
    2424# include <sys/conf.h>
    2525# include <sys/modctl.h>
     26# include <sys/msio.h>
    2627# include <sys/mutex.h>
    2728# include <sys/pci.h>
     
    2930# include <sys/ddi.h>
    3031# include <sys/ddi_intr.h>
     32# include <sys/open.h>
     33# include <sys/strsun.h>
     34# include <sys/stropts.h>
    3135# include <sys/sunddi.h>
    32 # include <sys/open.h>
    3336# include <sys/sunldi.h>
     37# include <sys/vuid_event.h>
     38# include <sys/vuid_wheel.h>
    3439# include <sys/file.h>
    3540#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
     
    4853#include <iprt/cdefs.h>
    4954#include <iprt/asm.h>
     55#include <iprt/string.h>
    5056
    5157#ifdef TESTCASE  /* Include this last as we . */
     
    163169    nochpoll,               /* c poll */
    164170    ddi_prop_op,            /* property ops */
    165     g_vbgr0SolStreamTab,
     171    &g_vbgr0SolStreamTab,
    166172    D_NEW | D_MP,           /* compat. flag */
    167173};
     
    260266/** The IRQ Mutex */
    261267static kmutex_t             g_IrqMutex;
     268/** Layered device handle for kernel keep-attached opens */
     269static ldi_handle_t         g_LdiHandle = NULL;
     270/** Ref counting for IDCOpen calls */
     271static uint64_t             g_cLdiOpens = 0;
     272/** The Mutex protecting the LDI handle in IDC opens */
     273static kmutex_t             g_LdiMtx;
    262274
    263275
     
    281293        rc = RTLogCreate(&pRelLogger, 0 /* fFlags */, "all",
    282294                         "VBOX_RELEASE_LOG", RT_ELEMENTS(s_apszGroups), s_apszGroups,
    283                          RTLOGDEST_STDOUT | RTLOGDEST_DEBUGGER, NULL);
     295                           RTLOGDEST_STDOUT | RTLOGDEST_DEBUGGER
     296                         | RTLOGDEST_USER, NULL);
    284297        if (RT_SUCCESS(rc))
    285298            RTLogRelSetDefaultInstance(pRelLogger);
     
    295308        else
    296309            LogRel((DEVICE_NAME ":failed to disable autounloading!\n"));
    297         /* Initialise the node state mutex.  This will be taken in the ISR. */
    298         mutex_init(&g_StateMutex, NULL, MUTEX_DRIVER,
    299                    DDI_INTR_PRI(uIntrPriority));
    300310        rc = mod_install(&g_vbgr0SolModLinkage);
    301311    }
     
    306316    }
    307317
     318    LogRel((DEVICE_NAME ": initialisation returning %d.\n", rc));
    308319    return rc;
    309320}
     
    325336    int rc;
    326337
    327     LogFlow((DEVICE_NAME ":_fini\n"));
     338    LogRelFlow((DEVICE_NAME ":_fini\n"));
    328339    rc = mod_remove(&g_vbgr0SolModLinkage);
    329340    mutex_destroy(&g_StateMutex);
     
    384395    NOREF(fFlag);
    385396    NOREF(pCred);
    386     LogFlow((DEVICE_NAME "::Open\n"));
     397    LogRelFlow((DEVICE_NAME "::Open\n"));
    387398
    388399    /*
     
    393404     */
    394405    if (fMode)
     406    {
     407        LogRelFlow((DEVICE_NAME "::Open: invalid attempt to clone device."));
    395408        return EINVAL;
     409    }
    396410
    397411    for (cInstance = 1; cInstance < MAX_OPEN_NODES; cInstance++)
     
    406420    if (!pState)
    407421    {
    408         Log((DEVICE_NAME "::Open: too many open instances."));
     422        LogRelFlow((DEVICE_NAME "::Open: too many open instances."));
    409423        return ENXIO;
    410424    }
     
    421435        WR(pReadQueue)->q_ptr = (char *)pState;
    422436        pReadQueue->q_ptr = (char *)pState;
    423         qprocson(pState->pWriteQueue);
    424         Log((DEVICE_NAME "::Open: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf()));
     437        qprocson(pReadQueue);
     438        LogRel((DEVICE_NAME "::Open: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf()));
    425439        return 0;
    426440    }
     
    452466        return EFAULT;
    453467    }
    454     qprocsoff(pState->pWriteQueue);
     468    qprocsoff(pReadQueue);
    455469    pSession = pState->pSession;
    456470    vbgr0SolResetSoftState(pState);
     
    506520int vbgr0SolWPut(queue_t *pWriteQueue, mblk_t *pMBlk)
    507521{
    508     PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr;
    509    
    510     LogFlowFunc((DEVICE_NAME "::\n"));
     522    LogRelFlowFunc((DEVICE_NAME "::\n"));
    511523    switch (pMBlk->b_datap->db_type)
    512524    {
     
    603615static void testWPutTransparent(RTTEST hTest, unsigned i);
    604616static void testWPutIOCDataIn(RTTEST hTest, unsigned i);
     617static void testWPutIOCDataOut(RTTEST hTest, unsigned i);
    605618
    606619/** Test WPut's handling of different IOCtls, which is bulk of the logic in
     
    620633        if (g_asTestWPut[i].fCanTransparent && g_asTestWPut[i].cbDataIn)
    621634            testWPutIOCDataIn(hTest, i);
     635        if (g_asTestWPut[i].fCanTransparent && g_asTestWPut[i].cbDataOut)
     636            testWPutIOCDataOut(hTest, i);
    622637    }
    623638}
     
    773788    AssertReturnVoid(pMBlk);
    774789    AssertReturnVoidStmt(pMBlkCont, freemsg(pMBlk));
    775     AssertReturnVoid(g_asTestWPut[i].cbDataIn);
    776790    RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "%s: i=%u\n", __PRETTY_FUNCTION__,
    777791                 i);
     792    AssertReturnVoidStmt(g_asTestWPut[i].cbDataIn, freemsg(pMBlk));
    778793    RT_ZERO(aQueues);
    779794    doInitQueues(&aQueues[0]);
     
    784799    pMBlk->b_datap->db_type = M_IOCDATA;
    785800    pCopyResp->cp_cmd = g_asTestWPut[i].iIOCCmd;
     801    if (g_asTestWPut[i].cbDataOut)
     802        pCopyResp->cp_private = USER_ADDRESS;
    786803    AssertReturnVoid(g_asTestWPut[i].cbData <= MSG_DATA_SIZE);
    787804    memcpy(pMBlkCont->b_rptr, g_asTestWPut[i].pvDataIn, g_asTestWPut[i].cbDataIn);
     
    820837    freemsg(pMBlk);
    821838}
     839
     840
     841/** Simulate sending follow-on IOCData messages to a transparent IOCtl to WPut
     842 * with the parameters from table line @a i. */
     843void testWPutIOCDataOut(RTTEST hTest, unsigned i)
     844{
     845    queue_t aQueues[2];
     846    dev_t device = 0;
     847    struct msgb *pMBlk = allocb(sizeof(struct copyresp), BPRI_MED);
     848    struct copyresp *pCopyResp = pMBlk ? (struct copyresp *)pMBlk->b_rptr
     849                                       : NULL;
     850    int rc, cFormat = 0;
     851
     852    AssertReturnVoid(pMBlk);
     853    AssertReturnVoidStmt(g_asTestWPut[i].cbDataOut, freemsg(pMBlk));
     854    RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "%s: i=%u\n", __PRETTY_FUNCTION__,
     855                 i);
     856    RT_ZERO(aQueues);
     857    doInitQueues(&aQueues[0]);
     858    rc = vbgr0SolOpen(RD(&aQueues[0]), &device, 0, 0, NULL);
     859    RTTEST_CHECK_MSG(hTest, rc == 0, (hTest, "i=%u, rc=%d\n", i, rc));
     860    RTTEST_CHECK_MSG(hTest,    g_aOpenNodeStates[1].pWriteQueue
     861                            == WR(&aQueues[0]), (hTest, "i=%u\n", i));
     862    pMBlk->b_datap->db_type = M_IOCDATA;
     863    pCopyResp->cp_cmd = g_asTestWPut[i].iIOCCmd;
     864    rc = vbgr0SolWPut(WR(&aQueues[0]), pMBlk);
     865    RTTEST_CHECK_MSG(hTest, pMBlk->b_datap->db_type == M_IOCACK,
     866                     (hTest, "i=%u, db_type=%u\n", i,
     867                      (unsigned) pMBlk->b_datap->db_type));
     868    if (!g_asTestWPut[i].rcExp)
     869        RTTEST_CHECK_MSG(hTest, RD(&aQueues[0])->q_first == pMBlk,
     870                         (hTest, "i=%u\n", i));
     871    vbgr0SolClose(RD(&aQueues[1]), 0, NULL);
     872    freemsg(pMBlk);
     873}
    822874#endif
    823875
     
    904956{
    905957    struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr;
    906     int iCmd = pIOCBlk->ioc_cmd, iCmdType = iCmd & ~0xff;
     958    int iCmd = pIOCBlk->ioc_cmd, iCmdType = iCmd & (0xff << 8);
    907959    size_t cbBuffer;
    908960    enum IOCTLDIRECTION enmDirection;
    909961
    910     LogFlowFunc((DEVICE_NAME "::iCmdType=%c, iCmd=%d\n", iCmdType, iCmd));
     962    LogFlowFunc((DEVICE_NAME "::iCmdType=%c, iCmd=%d\n",
     963                 (char) (iCmdType >> 8), iCmd));
    911964    switch (iCmdType)
    912965    {
     
    928981        }
    929982        case 'V' << 8:
     983            return ENOTTY;
    930984            return vbgr0SolHandleIOCtl(pWriteQueue, pMBlk, vbgr0SolGuestIOCtl,
    931985                                       iCmd, 0, UNSPECIFIED);
     
    9771031{
    9781032    struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr;
    979     PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr;
    9801033
    9811034    if (pMBlk->b_datap->db_type == M_IOCDATA)
     
    14731526                    if (g_pIntr)
    14741527                    {
    1475                         size_t IntrAllocated;
     1528                        int IntrAllocated;
    14761529                        unsigned i;
    14771530                        rc = ddi_intr_alloc(pDip, g_pIntr, IntrType, 0, IntrCount, &IntrAllocated, DDI_INTR_ALLOC_NORMAL);
     
    14871540                                mutex_init(&g_IrqMutex, NULL, MUTEX_DRIVER, DDI_INTR_PRI(uIntrPriority));
    14881541
     1542                                /* Initialise the node state mutex.  This will
     1543                                 * be taken in the ISR. */
     1544                                mutex_init(&g_StateMutex, NULL, MUTEX_DRIVER,
     1545                                           DDI_INTR_PRI(uIntrPriority));
    14891546                                /* Assign interrupt handler functions and enable interrupts. */
    14901547                                for (i = 0; i < IntrAllocated; i++)
  • trunk/src/VBox/Additions/common/VBoxGuest/testcase/solaris.h

    r41020 r41212  
    140140#define FE_PAIR_DELTA           2
    141141#define FE_PAIR_ABSOLUTE        3
     142
     143typedef struct __ldi_handle             *ldi_handle_t;
    142144
    143145typedef enum
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