VirtualBox

Changeset 16095 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 20, 2009 5:24:02 PM (16 years ago)
Author:
vboxsync
Message:

Additions/Linux: fixed a todo and corrected terminology

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/module/vboxmod.c

    r16062 r16095  
    365365}
    366366
    367 /** Jump buffer structure for hcgm guest-host data copies. */
    368 typedef struct hgcm_jump_buffer
     367/** Bounce buffer structure for hcgm guest-host data copies. */
     368typedef struct hgcm_bounce_buffer
    369369{
    370370    /** Kernel memory address. */
     
    374374    /** Buffer size. */
    375375    size_t cb;
    376 } hgcm_jump_buffer;
    377 
    378 /** Create a jump buffer in kernel space for user space memory. */
    379 static int vboxadd_hgcm_alloc_buffer(hgcm_jump_buffer **ppBuf, void *pUser,
    380                                      size_t cb)
    381 {
    382     hgcm_jump_buffer *pBuf = NULL;
     376} hgcm_bounce_buffer;
     377
     378/** Create a bounce buffer in kernel space for user space memory. */
     379static int vboxadd_hgcm_alloc_buffer(hgcm_bounce_buffer **ppBuf, void *pUser,
     380                                     size_t cb, bool copy)
     381{
     382    hgcm_bounce_buffer *pBuf = NULL;
    383383    void *pKernel = NULL;
    384384    int rc = 0;
     
    394394    }
    395395    if (   rc >= 0
     396        && copy
    396397        && copy_from_user(pKernel, pUser, cb) != 0)
    397398        rc = -EFAULT;
     
    410411}
    411412
    412 /** Free a kernel space jump buffer for user space memory. */
    413 static int vboxadd_hgcm_free_buffer(hgcm_jump_buffer *pBuf)
     413/** Free a kernel space bounce buffer for user space memory. */
     414static int vboxadd_hgcm_free_buffer(hgcm_bounce_buffer *pBuf, bool copy)
    414415{
    415416    int rc = 0;
    416417    AssertPtrReturn(pBuf, -EINVAL);
    417     if (copy_to_user(pBuf->pUser, pBuf->pKernel, pBuf->cb) != 0) /** @todo r=bird: This isn't entirely correct for LinAddr_In buffers. */
     418    if (copy && copy_to_user(pBuf->pUser, pBuf->pKernel, pBuf->cb) != 0)
    418419        rc = -EFAULT;
    419420    kfree(pBuf->pKernel);  /* We want to do this whatever the outcome. */
     
    458459                void *pv = (void *) pParm->u.Pointer.u.linearAddr;
    459460                uint32_t u32Size = pParm->u.Pointer.size;
    460                 hgcm_jump_buffer *MemObj = NULL;
    461                 rc = vboxadd_hgcm_alloc_buffer(&MemObj, pv, u32Size);
     461                hgcm_bounce_buffer *MemObj = NULL;
     462                rc = vboxadd_hgcm_alloc_buffer(&MemObj, pv, u32Size,
     463                         pParm->type != VMMDevHGCMParmType_LinAddr_Out /* copy */);
    462464                if (rc >= 0) {
    463465                    ppvCtx[iParm] = MemObj;
     
    495497            if (ppvCtx[iParm] != NULL)
    496498            {
    497                 hgcm_jump_buffer *MemObj = (hgcm_jump_buffer *)ppvCtx[iParm];
    498                 int rc2 = vboxadd_hgcm_free_buffer(MemObj);
     499                hgcm_bounce_buffer *MemObj = (hgcm_bounce_buffer *)ppvCtx[iParm];
     500                int rc2 = vboxadd_hgcm_free_buffer(MemObj,
     501                                  pParm->type != VMMDevHGCMParmType_LinAddr_In /* copy */);
    499502                if (rc >= 0 && rc2 < 0)
    500503                    rc = rc2;  /* Report the first error. */
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