VirtualBox

Ignore:
Timestamp:
Apr 23, 2012 9:07:36 AM (13 years ago)
Author:
vboxsync
Message:

Additions/common/VBoxGuest: Solaris streams version update.

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

Legend:

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

    r40584 r41020  
    549549# define CBMSIOSRES (sizeof(g_TestResolution))
    550550
    551 static inline void testSetResolution(RTTEST hTest, queue_t *pWriteQueue,
     551static inline bool testSetResolution(RTTEST hTest, queue_t *pWriteQueue,
    552552                                     struct msgb *pMBlk)
    553553{
    554554    PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr;
    555     RTTEST_CHECK_MSG(hTest,    pState->cMaxScreenX
    556                             == g_TestResolution.width - 1,
    557                      (hTest, "pState->cMaxScreenX=%d\n", pState->cMaxScreenX));
    558     RTTEST_CHECK_MSG(hTest,    pState->cMaxScreenY
    559                             == g_TestResolution.height - 1,
    560                      (hTest, "pState->cMaxScreenY=%d\n", pState->cMaxScreenY));
     555    RTTEST_CHECK_MSG_RET(hTest,    pState->cMaxScreenX
     556                               == g_TestResolution.width - 1,
     557                         (hTest, "pState->cMaxScreenX=%d\n",
     558                          pState->cMaxScreenX), false);
     559    RTTEST_CHECK_MSG_RET(hTest,    pState->cMaxScreenY
     560                               == g_TestResolution.height - 1,
     561                         (hTest, "pState->cMaxScreenY=%d\n",
     562                          pState->cMaxScreenY), false);
     563    return true;
    561564}
    562565
     
    571574    size_t cbDataOut;
    572575    int rcExp;
    573     void (*pfnExtra)(RTTEST hTest, queue_t *pWriteQueue, struct msgb *pMBlk);
     576    bool (*pfnExtra)(RTTEST hTest, queue_t *pWriteQueue, struct msgb *pMBlk);
    574577    bool fCanTransparent;
    575578} g_asTestWPut[] =
     
    599602static void testWPutStreams(RTTEST hTest, unsigned i);
    600603static void testWPutTransparent(RTTEST hTest, unsigned i);
     604static void testWPutIOCDataIn(RTTEST hTest, unsigned i);
    601605
    602606/** Test WPut's handling of different IOCtls, which is bulk of the logic in
     
    609613    for (i = 0; i < RT_ELEMENTS(g_asTestWPut); ++i)
    610614    {
     615        AssertReturnVoid(g_asTestWPut[i].cbDataIn <= g_asTestWPut[i].cbData);
     616        AssertReturnVoid(g_asTestWPut[i].cbDataOut <= g_asTestWPut[i].cbData);
    611617        testWPutStreams(hTest, i);
    612618        if (g_asTestWPut[i].fCanTransparent)
    613619            testWPutTransparent(hTest, i);
    614     }
    615 }
     620        if (g_asTestWPut[i].fCanTransparent && g_asTestWPut[i].cbDataIn)
     621            testWPutIOCDataIn(hTest, i);
     622    }
     623}
     624
     625
     626#define MSG_DATA_SIZE 1024
    616627
    617628/** Simulate sending a streams IOCtl to WPut with the parameters from table
     
    621632    queue_t aQueues[2];
    622633    dev_t device = 0;
    623     struct msgb MBlk, MBlkCont;
    624     struct datab DBlk;
    625     struct iocblk IOCBlk;
     634    struct msgb *pMBlk = allocb(sizeof(struct iocblk), BPRI_MED);
     635    struct msgb *pMBlkCont = allocb(MSG_DATA_SIZE, BPRI_MED);
     636    struct iocblk *pIOCBlk = pMBlk ? (struct iocblk *)pMBlk->b_rptr : NULL;
    626637    int rc, cFormat = 0;
    627     unsigned char acData[1024];
    628 
     638
     639    AssertReturnVoid(pMBlk);
     640    AssertReturnVoidStmt(pMBlkCont, freemsg(pMBlk));
    629641    RT_ZERO(aQueues);
    630642    doInitQueues(&aQueues[0]);
     
    633645    RTTEST_CHECK_MSG(hTest,    g_aOpenNodeStates[1].pWriteQueue
    634646                            == WR(&aQueues[0]), (hTest, "i=%u\n", i));
    635     RT_ZERO(MBlk);
    636     RT_ZERO(DBlk);
    637     RT_ZERO(IOCBlk);
    638     RT_ZERO(MBlkCont);
    639     RT_ZERO(acData);
    640     DBlk.db_type = M_IOCTL;
    641     IOCBlk.ioc_cmd = g_asTestWPut[i].iIOCCmd;
    642     IOCBlk.ioc_count = g_asTestWPut[i].cbData;
    643     AssertReturnVoid(g_asTestWPut[i].cbData <= sizeof(acData));
    644     AssertReturnVoid(g_asTestWPut[i].cbDataIn <= g_asTestWPut[i].cbData);
    645     AssertReturnVoid(g_asTestWPut[i].cbDataOut <= g_asTestWPut[i].cbData);
    646     memcpy(acData, g_asTestWPut[i].pvDataIn, g_asTestWPut[i].cbDataIn);
    647     MBlkCont.b_rptr = acData;
    648     MBlkCont.b_wptr = acData + g_asTestWPut[i].cbData;
    649     MBlk.b_cont = &MBlkCont;
    650     MBlk.b_rptr = (unsigned char *)&IOCBlk;
    651     MBlk.b_wptr = (unsigned char *)&IOCBlk + sizeof(IOCBlk);
    652     MBlk.b_datap = &DBlk;
    653     rc = vbgr0SolWPut(WR(&aQueues[0]), &MBlk);
    654     RTTEST_CHECK_MSG(hTest, IOCBlk.ioc_error == g_asTestWPut[i].rcExp,
     647    pMBlk->b_datap->db_type = M_IOCTL;
     648    pIOCBlk->ioc_cmd = g_asTestWPut[i].iIOCCmd;
     649    pIOCBlk->ioc_count = g_asTestWPut[i].cbData;
     650    AssertReturnVoid(g_asTestWPut[i].cbData <= MSG_DATA_SIZE);
     651    memcpy(pMBlkCont->b_rptr, g_asTestWPut[i].pvDataIn,
     652           g_asTestWPut[i].cbDataIn);
     653    pMBlk->b_cont = pMBlkCont;
     654    rc = vbgr0SolWPut(WR(&aQueues[0]), pMBlk);
     655    RTTEST_CHECK_MSG(hTest, pIOCBlk->ioc_error == g_asTestWPut[i].rcExp,
    655656                     (hTest, "i=%u, IOCBlk.ioc_error=%d\n", i,
    656                       IOCBlk.ioc_error));
    657     RTTEST_CHECK_MSG(hTest, IOCBlk.ioc_count == g_asTestWPut[i].cbDataOut,
    658                      (hTest, "i=%u, ioc_count=%u\n", i, IOCBlk.ioc_count));
    659     RTTEST_CHECK_MSG(hTest, !memcmp(acData, g_asTestWPut[i].pvDataOut,
     657                      pIOCBlk->ioc_error));
     658    RTTEST_CHECK_MSG(hTest, pIOCBlk->ioc_count == g_asTestWPut[i].cbDataOut,
     659                     (hTest, "i=%u, ioc_count=%u\n", i, pIOCBlk->ioc_count));
     660    RTTEST_CHECK_MSG(hTest, !memcmp(pMBlkCont->b_rptr,
     661                                    g_asTestWPut[i].pvDataOut,
    660662                                    g_asTestWPut[i].cbDataOut),
    661663                     (hTest, "i=%u\n", i));
    662664    /* Hack to ensure that miocpullup() gets called when needed. */
    663665    if (g_asTestWPut[i].cbData > 0)
    664         RTTEST_CHECK_MSG(hTest, MBlk.b_flag == 1, (hTest, "i=%u\n", i));
     666        RTTEST_CHECK_MSG(hTest, pMBlk->b_flag == 1, (hTest, "i=%u\n", i));
    665667    if (!g_asTestWPut[i].rcExp)
    666         RTTEST_CHECK_MSG(hTest, RD(&aQueues[0])->q_first = &MBlk,
     668        RTTEST_CHECK_MSG(hTest, RD(&aQueues[0])->q_first == pMBlk,
    667669                         (hTest, "i=%u\n", i));
    668670    if (g_asTestWPut[i].pfnExtra)
    669         g_asTestWPut[i].pfnExtra(hTest, WR(&aQueues[0]), &MBlk);
     671        if (!g_asTestWPut[i].pfnExtra(hTest, WR(&aQueues[0]), pMBlk))
     672            RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "Called from %s.\n",
     673                         __PRETTY_FUNCTION__);
    670674    vbgr0SolClose(RD(&aQueues[1]), 0, NULL);
    671 }
    672 
     675    freemsg(pMBlk);
     676}
     677
     678
     679#define USER_ADDRESS 0xfeedbacc
    673680
    674681/** Simulate sending a transparent IOCtl to WPut with the parameters from table
     
    678685    queue_t aQueues[2];
    679686    dev_t device = 0;
    680     struct msgb MBlk, MBlkCont;
    681     struct datab DBlk;
    682     struct iocblk IOCBlk;
    683     struct copyreq *pCopyReq = (struct copyreq *)&IOCBlk;
     687    struct msgb *pMBlk = allocb(sizeof(struct iocblk), BPRI_MED);
     688    struct msgb *pMBlkCont = allocb(sizeof(void *), BPRI_MED);
     689    struct iocblk *pIOCBlk = pMBlk ? (struct iocblk *)pMBlk->b_rptr : NULL;
     690    struct copyreq *pCopyReq;
    684691    int rc, cFormat = 0;
    685     unsigned char acData[1024];
    686 
    687     if (g_asTestWPut[i].cbDataIn == 0 && g_asTestWPut[i].cbDataOut != 0)
    688         return;  /* This case will be handled once the current ones work. */
     692
     693    /* if (g_asTestWPut[i].cbDataIn == 0 && g_asTestWPut[i].cbDataOut != 0)
     694        return; */  /* This case will be handled once the current ones work. */
     695    AssertReturnVoid(pMBlk);
     696    AssertReturnVoidStmt(pMBlkCont, freemsg(pMBlk));
    689697    RT_ZERO(aQueues);
    690698    doInitQueues(&aQueues[0]);
     
    693701    RTTEST_CHECK_MSG(hTest,    g_aOpenNodeStates[1].pWriteQueue
    694702                            == WR(&aQueues[0]), (hTest, "i=%u\n", i));
    695     RT_ZERO(MBlk);
    696     RT_ZERO(DBlk);
    697     RT_ZERO(IOCBlk);
    698     RT_ZERO(MBlkCont);
    699     RT_ZERO(acData);
    700     DBlk.db_type = M_IOCTL;
    701     IOCBlk.ioc_cmd = g_asTestWPut[i].iIOCCmd;
    702     IOCBlk.ioc_count = TRANSPARENT;
    703     AssertReturnVoid(g_asTestWPut[i].cbData <= sizeof(acData));
    704     AssertReturnVoid(g_asTestWPut[i].cbDataIn <= g_asTestWPut[i].cbData);
    705     AssertReturnVoid(g_asTestWPut[i].cbDataOut <= g_asTestWPut[i].cbData);
    706     memcpy(acData, g_asTestWPut[i].pvDataIn, g_asTestWPut[i].cbDataIn);
    707     MBlkCont.b_rptr = acData;
    708     MBlkCont.b_wptr = acData + g_asTestWPut[i].cbData;
    709     MBlk.b_cont = &MBlkCont;
    710     MBlk.b_rptr = (unsigned char *)&IOCBlk;
    711     MBlk.b_wptr = (unsigned char *)&IOCBlk + sizeof(IOCBlk);
    712     MBlk.b_datap = &DBlk;
    713     rc = vbgr0SolWPut(WR(&aQueues[0]), &MBlk);
     703    pMBlk->b_datap->db_type = M_IOCTL;
     704    pIOCBlk->ioc_cmd = g_asTestWPut[i].iIOCCmd;
     705    pIOCBlk->ioc_count = TRANSPARENT;
     706    *(void **)pMBlkCont->b_rptr = (void *)USER_ADDRESS;
     707    pMBlk->b_cont = pMBlkCont;
     708    rc = vbgr0SolWPut(WR(&aQueues[0]), pMBlk);
     709    pCopyReq = (struct copyreq *)pMBlk->b_rptr;
    714710    RTTEST_CHECK_MSG(hTest, (   (   g_asTestWPut[i].cbDataIn
    715                                  && (MBlk.b_datap->db_type == M_COPYIN))
     711                                 && (pMBlk->b_datap->db_type == M_COPYIN))
    716712                             || (   g_asTestWPut[i].cbDataOut
    717                                  && (MBlk.b_datap->db_type == M_COPYOUT))
     713                                 && (pMBlk->b_datap->db_type == M_COPYOUT))
    718714                             || (   (g_asTestWPut[i].rcExp == 0)
    719                                  && MBlk.b_datap->db_type == M_IOCACK)
    720                              || (MBlk.b_datap->db_type == M_IOCNAK)),
     715                                 && pMBlk->b_datap->db_type == M_IOCACK)
     716                             || (pMBlk->b_datap->db_type == M_IOCNAK)),
    721717                     (hTest, "i=%u, db_type=%u\n", i,
    722                       (unsigned) MBlk.b_datap->db_type));
     718                      (unsigned) pMBlk->b_datap->db_type));
    723719    /* Our TRANSPARENT IOCtls can only return non-zero if they have no payload.
    724720     * Others should either return zero or be non-TRANSPARENT only. */
    725     if (MBlk.b_datap->db_type == M_IOCNAK)
    726         RTTEST_CHECK_MSG(hTest, IOCBlk.ioc_error == g_asTestWPut[i].rcExp,
     721    if (pMBlk->b_datap->db_type == M_IOCNAK)
     722        RTTEST_CHECK_MSG(hTest, pIOCBlk->ioc_error == g_asTestWPut[i].rcExp,
    727723                         (hTest, "i=%u, IOCBlk.ioc_error=%d\n", i,
    728                           IOCBlk.ioc_error));
     724                          pIOCBlk->ioc_error));
    729725    if (g_asTestWPut[i].cbData)
    730726    {
    731         RTTEST_CHECK_MSG(hTest, pCopyReq->cq_addr == acData,
     727        RTTEST_CHECK_MSG(hTest, pCopyReq->cq_addr == (char *)USER_ADDRESS,
     728                         (hTest, "i=%u, cq_addr=%p\n", i, pCopyReq->cq_addr));
     729        RTTEST_CHECK_MSG(   hTest, pCopyReq->cq_size
     730                         ==   g_asTestWPut[i].cbDataIn
     731                            ? g_asTestWPut[i].cbDataIn
     732                            : g_asTestWPut[i].cbDataOut,
     733                         (hTest, "i=%u, cq_size=%llu\n", i,
     734                          (unsigned long long)pCopyReq->cq_size));
     735    }
     736    /* Implementation detail - check that the private pointer is correctly
     737     * set to the user address *for two direction IOCtls* or NULL otherwise. */
     738    if (g_asTestWPut[i].cbDataIn && g_asTestWPut[i].cbDataOut)
     739        RTTEST_CHECK_MSG(hTest, pCopyReq->cq_private == (mblk_t *)USER_ADDRESS,
     740                         (hTest, "i=%u, cq_private=%p\n", i,
     741                          pCopyReq->cq_private));
     742    else if (   (pMBlk->b_datap->db_type == M_COPYIN)
     743             || (pMBlk->b_datap->db_type == M_COPYOUT))
     744        RTTEST_CHECK_MSG(hTest, !pCopyReq->cq_private,
     745                         (hTest, "i=%u, cq_private=%p\n", i,
     746                          pCopyReq->cq_private));
     747    if (!g_asTestWPut[i].rcExp)
     748        RTTEST_CHECK_MSG(hTest, RD(&aQueues[0])->q_first == pMBlk,
     749                         (hTest, "i=%u\n", i));
     750    if (g_asTestWPut[i].pfnExtra && !g_asTestWPut[i].cbData)
     751        if (!g_asTestWPut[i].pfnExtra(hTest, WR(&aQueues[0]), pMBlk))
     752            RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "Called from %s.\n",
     753                         __PRETTY_FUNCTION__);
     754    vbgr0SolClose(RD(&aQueues[1]), 0, NULL);
     755    freemsg(pMBlk);
     756}
     757
     758
     759/** Simulate sending follow-on IOCData messages to a transparent IOCtl to WPut
     760 * with the parameters from table line @a i. */
     761void testWPutIOCDataIn(RTTEST hTest, unsigned i)
     762{
     763    queue_t aQueues[2];
     764    dev_t device = 0;
     765    struct msgb *pMBlk = allocb(sizeof(struct copyresp), BPRI_MED);
     766    struct msgb *pMBlkCont = allocb(MSG_DATA_SIZE, BPRI_MED);
     767    struct copyresp *pCopyResp = pMBlk ? (struct copyresp *)pMBlk->b_rptr
     768                                       : NULL;
     769    void *pvData = pMBlkCont ? pMBlkCont->b_rptr : NULL;
     770    struct copyreq *pCopyReq;
     771    int rc, cFormat = 0;
     772
     773    AssertReturnVoid(pMBlk);
     774    AssertReturnVoidStmt(pMBlkCont, freemsg(pMBlk));
     775    AssertReturnVoid(g_asTestWPut[i].cbDataIn);
     776    RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "%s: i=%u\n", __PRETTY_FUNCTION__,
     777                 i);
     778    RT_ZERO(aQueues);
     779    doInitQueues(&aQueues[0]);
     780    rc = vbgr0SolOpen(RD(&aQueues[0]), &device, 0, 0, NULL);
     781    RTTEST_CHECK_MSG(hTest, rc == 0, (hTest, "i=%u, rc=%d\n", i, rc));
     782    RTTEST_CHECK_MSG(hTest,    g_aOpenNodeStates[1].pWriteQueue
     783                            == WR(&aQueues[0]), (hTest, "i=%u\n", i));
     784    pMBlk->b_datap->db_type = M_IOCDATA;
     785    pCopyResp->cp_cmd = g_asTestWPut[i].iIOCCmd;
     786    AssertReturnVoid(g_asTestWPut[i].cbData <= MSG_DATA_SIZE);
     787    memcpy(pMBlkCont->b_rptr, g_asTestWPut[i].pvDataIn, g_asTestWPut[i].cbDataIn);
     788    pMBlk->b_cont = pMBlkCont;
     789    rc = vbgr0SolWPut(WR(&aQueues[0]), pMBlk);
     790    pCopyReq = (struct copyreq *)pMBlk->b_rptr;
     791    RTTEST_CHECK_MSG(hTest, (   (   g_asTestWPut[i].cbDataOut
     792                                 && (pMBlk->b_datap->db_type == M_COPYOUT))
     793                             || (   (g_asTestWPut[i].rcExp == 0)
     794                                 && pMBlk->b_datap->db_type == M_IOCACK)
     795                             || (pMBlk->b_datap->db_type == M_IOCNAK)),
     796                     (hTest, "i=%u, db_type=%u\n", i,
     797                      (unsigned) pMBlk->b_datap->db_type));
     798    if (g_asTestWPut[i].cbDataOut)
     799    {
     800        RTTEST_CHECK_MSG(hTest, pCopyReq->cq_addr == (char *)pvData,
    732801                         (hTest, "i=%u, cq_addr=%p\n", i, pCopyReq->cq_addr));
    733802        RTTEST_CHECK_MSG(hTest, pCopyReq->cq_size == g_asTestWPut[i].cbData,
    734803                         (hTest, "i=%u, cq_size=%llu\n", i,
    735804                          (unsigned long long)pCopyReq->cq_size));
    736     }
    737     /* Implementation detail - check that the private pointer is correctly
    738      * set to the user address *for two direction IOCtls* or NULL otherwise. */
    739     if (g_asTestWPut[i].cbDataIn && g_asTestWPut[i].cbDataOut)
    740         RTTEST_CHECK_MSG(hTest, pCopyReq->cq_private == acData,
    741                          (hTest, "i=%u, cq_private=%p\n", i,
    742                           pCopyReq->cq_private));
    743     else if (   (MBlk.b_datap->db_type == M_COPYIN)
    744              || (MBlk.b_datap->db_type == M_COPYOUT))
    745         RTTEST_CHECK_MSG(hTest, !pCopyReq->cq_private,
    746                          (hTest, "i=%u, cq_private=%p\n", i,
    747                           pCopyReq->cq_private));
     805        RTTEST_CHECK_MSG(hTest, !memcmp(pvData, g_asTestWPut[i].pvDataOut,
     806                                        g_asTestWPut[i].cbDataOut),
     807                         (hTest, "i=%u\n", i));
     808    }
     809    RTTEST_CHECK_MSG(hTest, !pCopyReq->cq_private,
     810                     (hTest, "i=%u, cq_private=%p\n", i,
     811                      pCopyReq->cq_private));
    748812    if (!g_asTestWPut[i].rcExp)
    749         RTTEST_CHECK_MSG(hTest, RD(&aQueues[0])->q_first = &MBlk,
     813        RTTEST_CHECK_MSG(hTest, RD(&aQueues[0])->q_first == pMBlk,
    750814                         (hTest, "i=%u\n", i));
    751     if (g_asTestWPut[i].pfnExtra && !g_asTestWPut[i].cbData)
    752         g_asTestWPut[i].pfnExtra(hTest, WR(&aQueues[0]), &MBlk);
     815    if (g_asTestWPut[i].pfnExtra && !g_asTestWPut[i].cbDataOut)
     816        if (!g_asTestWPut[i].pfnExtra(hTest, WR(&aQueues[0]), pMBlk))
     817            RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "Called from %s.\n",
     818                         __PRETTY_FUNCTION__);
    753819    vbgr0SolClose(RD(&aQueues[1]), 0, NULL);
     820    freemsg(pMBlk);
    754821}
    755822#endif
     
    9511018        int err;
    9521019
    953         if (cbData < cbTransparent)
    954             return EINVAL;
    9551020        if (!pMBlk->b_cont)
    9561021            return EINVAL;
     
    10011066        else if (enmDirection == OUT)
    10021067    {
    1003         mblk_t *pMBlkOut = allocb(cbOut, BPRI_MED);
     1068        mblk_t *pMBlkOut = allocb(cbTransparent, BPRI_MED);
    10041069        void *pvData;
    10051070
     
    15671632{
    15681633    queue_t *pReadQueue = RD(pState->pWriteQueue);
    1569     mblk_t *pMBlk = allocb(sizeof(Firm_event, BPRI_HI));
     1634    mblk_t *pMBlk = allocb(sizeof(Firm_event), BPRI_HI);
    15701635    Firm_event *pEvent;
    15711636    AssertReturnVoid(cEvent == LOC_X_ABSOLUTE || cEvent == LOC_Y_ABSOLUTE);
  • trunk/src/VBox/Additions/common/VBoxGuest/testcase/solaris.h

    r40584 r41020  
    4040#define MOD_NOAUTOUNLOAD        0x1
    4141
     42#define M_DATA          0x00
    4243#define M_BREAK         0x08
    4344#define M_PASSFP        0x09
     
    7071#define M_CMD           0x93
    7172
     73#define BPRI_LO         1
     74#define BPRI_MED        2
     75#define BPRI_HI         3
     76
    7277#define FLUSHALL        1
    7378#define FLUSHDATA       0
     
    229234    uint_t      ioc_id;
    230235    uint_t      ioc_flag;
    231     uint_t      ioc_count;
     236    size_t      ioc_count;
    232237    int         ioc_rval;
    233238    int         ioc_error;
     239#if defined(RT_ARCH_AMD64)  /* Actually this should be LP64. */
     240    int         dummy;  /* For simplicity, to ensure the structure size matches
     241                           struct copyreq. */
     242#endif
    234243};
    235244
     
    311320
    312321#define cmn_err(...) do {} while(0)
    313 #define allocb(...) NULL
    314322#define mod_remove(...) 0
    315323#define mod_info(...) 0
     
    332340#define qprocsoff(...) do {} while(0)
    333341#define flushq(...) do {} while(0)
    334 #define freemsg(...) do {} while(0)
    335342#define putnext(...) do {} while(0)
    336343#define ddi_get_instance(...) 0
     
    375382                     mblk_t *pMBlkData);
    376383extern void qreply(queue_t *pQueue, mblk_t *pMBlk);
     384extern mblk_t *allocb(size_t cb, uint_t cPrio);
     385extern void freemsg(mblk_t *pMsg);
    377386
    378387/* API stubs with simple logic */
  • trunk/src/VBox/Additions/common/VBoxGuest/testcase/tstVBoxGuest-solaris.c

    r40584 r41020  
    2020
    2121#include "solaris.h"
     22#include <iprt/alloc.h>
    2223
    2324/******************************************************************************
     
    7576    pCopyReq->cq_private = pvState;
    7677    pCopyReq->cq_size = cbData;
    77     pCopyReq->cq_addr = pvUser ? pvUser : pMBlk->b_cont->b_rptr;
     78    pCopyReq->cq_addr = pvUser ? pvUser : *(void **)pMBlk->b_cont->b_rptr;
    7879    if (pMBlk->b_cont)
    7980    {
     
    9798    pCopyReq->cq_private = pvState;
    9899    pCopyReq->cq_size = cbData;
    99     pCopyReq->cq_addr = pvUser ? pvUser : pMBlk->b_cont->b_rptr;
     100    pCopyReq->cq_addr = pvUser ? pvUser : *(void **)pMBlk->b_cont->b_rptr;
    100101    if (pMBlkData)
    101102    {
     
    113114    OTHERQ(pQueue)->q_first = pMBlk;
    114115}
     116
     117/** @todo reference counting */
     118mblk_t *allocb(size_t cb, uint_t cPrio)
     119{
     120    unsigned char *pch = RTMemAllocZ(cb);
     121    struct msgb *pMBlk = (struct msgb *)RTMemAllocZ(sizeof(struct msgb));
     122    struct datab *pDBlk = (struct datab *)RTMemAllocZ(sizeof(struct datab));
     123    if (!pch || !pMBlk || !pDBlk)
     124    {
     125        RTMemFree(pch);
     126        RTMemFree(pMBlk);
     127        RTMemFree(pDBlk);
     128        return NULL;
     129    }
     130    NOREF(cPrio);
     131    pMBlk->b_rptr = pch;
     132    pMBlk->b_wptr = pMBlk->b_rptr + cb;
     133    pMBlk->b_datap = pDBlk;
     134    pDBlk->db_base = pMBlk->b_rptr;
     135    pDBlk->db_lim = pMBlk->b_wptr;
     136    pDBlk->db_type = M_DATA;
     137    return pMBlk;
     138}
     139
     140/** @todo reference counting */
     141void freemsg(mblk_t *pMBlk)
     142{
     143    if (!pMBlk)
     144        return;
     145    RTMemFree(pMBlk->b_rptr);
     146    RTMemFree(pMBlk->b_datap);
     147    freemsg(pMBlk->b_cont);
     148    RTMemFree(pMBlk);
     149}
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