VirtualBox

Changeset 43409 in vbox for trunk


Ignore:
Timestamp:
Sep 22, 2012 6:12:17 PM (12 years ago)
Author:
vboxsync
Message:

Additions/haiku: cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxDev-haiku.c

    r43369 r43409  
    4545 */
    4646
    47 
    48 #define LOG_GROUP LOG_GROUP_SUP_DRV
    49 //#undef LOG_DISABLED
    50 //#define LOG_ENABLED
    51 //#define LOG_ENABLE_FLOW
    52 //#define DO_LOG
     47/*******************************************************************************
     48*   Header Files                                                               *
     49*******************************************************************************/
    5350#include <sys/param.h>
    5451#include <sys/types.h>
     
    7269#define MODULE_NAME "generic/vboxguest"
    7370
     71/*******************************************************************************
     72*   Internal Functions                                                         *
     73*******************************************************************************/
    7474static status_t VBoxGuestHaikuOpen(const char *name, uint32 flags, void **cookie);
    7575static status_t VBoxGuestHaikuClose(void *cookie);
     
    9595
    9696/**
    97  * File open handler
    98  *
     97 * Driver open hook.
     98 *
     99 * @param name          The name of the device as returned by publish_devices.
     100 * @param flags         Open flags.
     101 * @param cookie        Where to store the session pointer.
     102 *
     103 * @return Haiku status code.
    99104 */
    100105static status_t VBoxGuestHaikuOpen(const char *name, uint32 flags, void **cookie)
     
    114119        ASMAtomicIncU32(&cUsers);
    115120        *cookie = pSession;
    116         return 0;
     121        return B_OK;
    117122    }
    118123
     
    123128
    124129/**
    125  * File close handler
    126  *
     130 * Driver close hook.
     131 * @param cookie        The session.
     132 *
     133 * @return Haiku status code.
    127134 */
    128135static status_t VBoxGuestHaikuClose(void *cookie)
     
    134141    RTSpinlockAcquire(g_DevExt.SessionSpinlock);
    135142
    136     //XXX: we don't know if it belongs to this session !
     143    /* @todo we don't know if it belongs to this session!! */
    137144    if (sState.selectSync)
    138145    {
     
    145152
    146153    RTSpinlockRelease(g_DevExt.SessionSpinlock);
    147 
    148     return 0;
    149 }
    150 
    151 
    152 /**
    153  * File free handler
    154  *
     154    return B_OK;
     155}
     156
     157
     158/**
     159 * Driver free hook.
     160 * @param cookie        The session.
     161 *
     162 * @return Haiku status code.
    155163 */
    156164static status_t VBoxGuestHaikuFree(void *cookie)
     
    169177    else
    170178        Log(("VBoxGuestHaikuFree: si_drv1=%p!\n", pSession));
    171     return 0;
    172 }
    173 
    174 
    175 /**
    176  * IOCTL handler
    177  *
     179    return B_OK;
     180}
     181
     182
     183/**
     184 * Driver IOCtl entry.
     185 * @param cookie        The session.
     186 * @param op            The operation to perform.
     187 * @param data          The data associated with the operation.
     188 * @param len           Size of the data in bytes.
     189 *
     190 * @return Haiku status code.
    178191 */
    179192static status_t VBoxGuestHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len)
    180193{
    181194    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
    182     //Log(("VBoxGuestHaikuFree: pSession=%p\n", pSession));
    183     //LogFlow((DRIVER_NAME ":VBoxGuestHaikuIOCtl(, 0x%08x, %p, %d)\n", op, data, len));
    184     Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl(, 0x%08x, %p, %d)\n", op, data, len));
    185 
    186     int rc = 0;
     195    Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl cookie=%p op=0x%08x data=%p len=%lu)\n", cookie, op, data, len));
     196
     197    int rc = B_OK;
    187198
    188199    /*
     
    198209    if (IOCPARM_LEN(ulCmd) != sizeof(VBGLBIGREQ))
    199210    {
    200         Log((DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ)));
     211        Log((DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd),
     212                                                                                        sizeof(VBGLBIGREQ)));
    201213        return ENOTTY;
    202214    }
     
    222234        }
    223235
     236        /** @todo r=ramshankar: replace with RTR0MemUserCopyFrom() */
    224237        rc = user_memcpy(pvBuf, data, len);
    225238        if (RT_UNLIKELY(rc < 0))
     
    268281    RTMemTmpFree(pvBuf);
    269282    return rc;
    270 #if 0
    271 #endif
    272 }
    273 
    274 
     283}
     284
     285
     286/**
     287 * Driver select hook.
     288 *
     289 * @param cookie        The session.
     290 * @param event         The event.
     291 * @param ref           ???
     292 * @param sync          ???
     293 *
     294 * @return Haiku status code.
     295 */
    275296static status_t VBoxGuestHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync)
    276297{
    277298    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
    278299    status_t err = B_OK;
    279     //dprintf(DRIVER_NAME "select(,%d,%p)\n", event, sync);
    280 
    281300
    282301    switch (event)
    283302    {
    284303        case B_SELECT_READ:
    285             //case B_SELECT_ERROR:
    286304            break;
    287305        default:
     
    294312    if (pSession->u32MousePosChangedSeq != u32CurSeq)
    295313    {
    296         //dprintf(DRIVER_NAME "select: notifying now: %p %x\n", sync, event);
    297314        pSession->u32MousePosChangedSeq = u32CurSeq;
    298315        notify_select_event(sync, event);
     
    300317    else if (sState.selectSync == NULL)
    301318    {
    302         //dprintf(DRIVER_NAME "select: caching: %p %x\n", sync, event);
    303319        sState.selectEvent = (uint8_t)event;
    304320        sState.selectRef = (uint32_t)ref;
     
    306322    }
    307323    else
    308     {
    309         //dprintf(DRIVER_NAME "select: dropping: %p %x\n", sync, event);
    310324        err = B_WOULD_BLOCK;
    311     }
    312325
    313326    RTSpinlockRelease(g_DevExt.SessionSpinlock);
    314327
    315328    return err;
    316 #if 0
    317     int fEventsProcessed;
    318 
    319     LogFlow((DRIVER_NAME "::Poll: fEvents=%d\n", fEvents));
    320 
    321     PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
    322     if (RT_UNLIKELY(!VALID_PTR(pSession)))
    323     {
    324         Log((DRIVER_NAME "::Poll: no state data for %s\n", devtoname(pDev)));
    325         return (fEvents & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM));
    326     }
    327 
    328     uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
    329     if (pSession->u32MousePosChangedSeq != u32CurSeq)
    330     {
    331         fEventsProcessed = fEvents & (POLLIN | POLLRDNORM);
    332         pSession->u32MousePosChangedSeq = u32CurSeq;
    333     }
    334     else
    335     {
    336         fEventsProcessed = 0;
    337 
    338         selrecord(td, &g_SelInfo);
    339     }
    340 
    341     return fEventsProcessed;
    342 #endif
    343 }
    344 
    345 
     329}
     330
     331
     332/**
     333 * Driver deselect hook.
     334 * @param cookie        The session.
     335 * @param event         The event.
     336 * @param sync          ???
     337 *
     338 * @return Haiku status code.
     339 */
    346340static status_t VBoxGuestHaikuDeselect(void *cookie, uint8 event, selectsync *sync)
    347341{
     
    367361
    368362
     363/**
     364 * Driver write hook.
     365 * @param cookie            The session.
     366 * @param position          The offset.
     367 * @param data              Pointer to the data.
     368 * @param numBytes          Where to store the number of bytes written.
     369 *
     370 * @return Haiku status code.
     371 */
    369372static status_t VBoxGuestHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes)
    370373{
    371374    *numBytes = 0;
    372     return 0;
    373 }
    374 
    375 
     375    return B_OK;
     376}
     377
     378
     379/**
     380 * Driver read hook.
     381 * @param cookie            The session.
     382 * @param position          The offset.
     383 * @param data              Pointer to the data.
     384 * @param numBytes          Where to store the number of bytes read.
     385 *
     386 * @return Haiku status code.
     387 */
    376388static status_t VBoxGuestHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes)
    377389{
    378390    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
    379391
    380     //dprintf(DRIVER_NAME "read(,,%d)\n", *numBytes);
    381 
    382392    if (*numBytes == 0)
    383         return 0;
     393        return B_OK;
    384394
    385395    uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
     
    387397    {
    388398        pSession->u32MousePosChangedSeq = u32CurSeq;
    389         //dprintf(DRIVER_NAME "read: giving 1 byte\n");
    390399        *numBytes = 1;
    391         return 0;
     400        return B_OK;
    392401    }
    393402
    394403    *numBytes = 0;
    395     return 0;
     404    return B_OK;
    396405}
    397406
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