VirtualBox

Changeset 58113 in vbox for trunk


Ignore:
Timestamp:
Oct 8, 2015 10:13:54 AM (9 years ago)
Author:
vboxsync
Message:

VBoxGuest: Vbgd -> VGDrv, cleanups - will probably not build cleanly everywhere. :)

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/log.h

    r58111 r58113  
    745745    LOG_GROUP_USB_WEBCAM,
    746746    /** VBox Guest Additions Driver (VBoxGuest). */
    747     LOG_GROUP_VBGD,
     747    LOG_GROUP_VGDRV,
    748748    /** VBox Guest Additions Library. */
    749749    LOG_GROUP_VBGL,
     
    11451145    "USB_REMOTE",   \
    11461146    "USB_WEBCAM",   \
    1147     "VBGD",         \
     1147    "VGDRV",        \
    11481148    "VBGL",         \
    11491149    "VD",           \
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxDev-haiku.c

    r58053 r58113  
    7272
    7373/*********************************************************************************************************************************
    74 *   Internal Functions                                                                                                           *
     74*   Global Variables                                                                                                             *
    7575*********************************************************************************************************************************/
    76 static status_t VBoxGuestHaikuOpen(const char *name, uint32 flags, void **cookie);
    77 static status_t VBoxGuestHaikuClose(void *cookie);
    78 static status_t VBoxGuestHaikuFree(void *cookie);
    79 static status_t VBoxGuestHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len);
    80 static status_t VBoxGuestHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync);
    81 static status_t VBoxGuestHaikuDeselect(void *cookie, uint8 event, selectsync *sync);
    82 static status_t VBoxGuestHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes);
    83 static status_t VBoxGuestHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes);
    84 
    85 static device_hooks g_VBoxGuestHaikuDeviceHooks =
    86 {
    87     VBoxGuestHaikuOpen,
    88     VBoxGuestHaikuClose,
    89     VBoxGuestHaikuFree,
    90     VBoxGuestHaikuIOCtl,
    91     VBoxGuestHaikuRead,
    92     VBoxGuestHaikuWrite,
    93     VBoxGuestHaikuSelect,
    94     VBoxGuestHaikuDeselect,
    95 };
     76int32 api_version = B_CUR_DRIVER_API_VERSION;
    9677
    9778
     
    10586 * @return Haiku status code.
    10687 */
    107 static status_t VBoxGuestHaikuOpen(const char *name, uint32 flags, void **cookie)
     88static status_t vgdrvHaikuOpen(const char *name, uint32 flags, void **cookie)
    10889{
    10990    int rc;
    11091    PVBOXGUESTSESSION pSession;
    11192
    112     LogFlow((DRIVER_NAME ":VBoxGuestHaikuOpen\n"));
     93    LogFlow((DRIVER_NAME ":vgdrvHaikuOpen\n"));
    11394
    11495    /*
     
    11899    if (RT_SUCCESS(rc))
    119100    {
    120         Log((DRIVER_NAME ":VBoxGuestHaikuOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n",&g_DevExt, pSession, rc,(int)RTProcSelf()));
     101        Log((DRIVER_NAME ":vgdrvHaikuOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n",&g_DevExt, pSession, rc,(int)RTProcSelf()));
    121102        ASMAtomicIncU32(&cUsers);
    122103        *cookie = pSession;
     
    124105    }
    125106
    126     LogRel((DRIVER_NAME ":VBoxGuestHaikuOpen: failed. rc=%d\n", rc));
     107    LogRel((DRIVER_NAME ":vgdrvHaikuOpen: failed. rc=%d\n", rc));
    127108    return RTErrConvertToErrno(rc);
    128109}
     
    135116 * @return Haiku status code.
    136117 */
    137 static status_t VBoxGuestHaikuClose(void *cookie)
    138 {
    139     PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
    140     Log(("VBoxGuestHaikuClose: pSession=%p\n", pSession));
     118static status_t vgdrvHaikuClose(void *cookie)
     119{
     120    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
     121    Log(("vgdrvHaikuClose: pSession=%p\n", pSession));
    141122
    142123    /** @todo r=ramshankar: should we really be using the session spinlock here? */
     
    164145 * @return Haiku status code.
    165146 */
    166 static status_t VBoxGuestHaikuFree(void *cookie)
    167 {
    168     PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
    169     Log(("VBoxGuestHaikuFree: pSession=%p\n", pSession));
     147static status_t vgdrvHaikuFree(void *cookie)
     148{
     149    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
     150    Log(("vgdrvHaikuFree: pSession=%p\n", pSession));
    170151
    171152    /*
     
    178159    }
    179160    else
    180         Log(("VBoxGuestHaikuFree: si_drv1=%p!\n", pSession));
     161        Log(("vgdrvHaikuFree: si_drv1=%p!\n", pSession));
    181162    return B_OK;
    182163}
     
    192173 * @return Haiku status code.
    193174 */
    194 static status_t VBoxGuestHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len)
    195 {
    196     PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
    197     Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl cookie=%p op=0x%08x data=%p len=%lu)\n", cookie, op, data, len));
    198 
    199     int rc = B_OK;
     175static status_t vgdrvHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len)
     176{
     177    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
     178    int rc;
     179    Log(("vgdrvHaikuIOCtl: cookie=%p op=0x%08x data=%p len=%lu)\n", cookie, op, data, len));
    200180
    201181    /*
     
    211191    if (IOCPARM_LEN(ulCmd) != sizeof(VBGLBIGREQ))
    212192    {
    213         Log((DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd),
     193        Log((DRIVER_NAME ": vgdrvHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd),
    214194                                                                                        sizeof(VBGLBIGREQ)));
    215195        return ENOTTY;
     
    219199    if (RT_UNLIKELY(len > _1M * 16))
    220200    {
    221         dprintf(DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", (unsigned)len, data, op);
     201        dprintf(DRIVER_NAME ": vgdrvHaikuIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", (unsigned)len, data, op);
    222202        return EINVAL;
    223203    }
     
    232212        if (RT_UNLIKELY(!pvBuf))
    233213        {
    234             LogRel((DRIVER_NAME ":VBoxGuestHaikuIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", len));
     214            LogRel((DRIVER_NAME ":vgdrvHaikuIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", len));
    235215            return ENOMEM;
    236216        }
     
    241221        {
    242222            RTMemTmpFree(pvBuf);
    243             LogRel((DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p data=%p op=%d. rc=%d\n", pvBuf, data, op, rc));
     223            LogRel((DRIVER_NAME ":vgdrvHaikuIOCtl: user_memcpy failed; pvBuf=%p data=%p op=%d. rc=%d\n", pvBuf, data, op, rc));
    244224            return EFAULT;
    245225        }
     
    247227        {
    248228            RTMemTmpFree(pvBuf);
    249             LogRel((DRIVER_NAME ":VBoxGuestHaikuIOCtl: pvBuf invalid pointer %p\n", pvBuf));
     229            LogRel((DRIVER_NAME ":vgdrvHaikuIOCtl: pvBuf invalid pointer %p\n", pvBuf));
    250230            return EINVAL;
    251231        }
    252232    }
    253     Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl: pSession=%p pid=%d.\n", pSession,(int)RTProcSelf()));
     233    Log(("vgdrvHaikuIOCtl: pSession=%p pid=%d.\n", pSession,(int)RTProcSelf()));
    254234
    255235    /*
     
    263243        if (RT_UNLIKELY(cbDataReturned > len))
    264244        {
    265             Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl: too much output data %d expected %d\n", cbDataReturned, len));
     245            Log(("vgdrvHaikuIOCtl: too much output data %d expected %d\n", cbDataReturned, len));
    266246            cbDataReturned = len;
    267247        }
     
    271251            if (RT_UNLIKELY(rc < 0))
    272252            {
    273                 Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, data, op, rc));
     253                Log(("vgdrvHaikuIOCtl: user_memcpy failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, data, op, rc));
    274254                rc = EFAULT;
    275255            }
     
    278258    else
    279259    {
    280         Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl: VbgdCommonIoCtl failed. rc=%d\n", rc));
     260        Log(("vgdrvHaikuIOCtl: VGDrvCommonIoCtl failed. rc=%d\n", rc));
    281261        rc = EFAULT;
    282262    }
     
    296276 * @return Haiku status code.
    297277 */
    298 static status_t VBoxGuestHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync)
     278static status_t vgdrvHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync)
    299279{
    300280    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
     
    340320 * @return Haiku status code.
    341321 */
    342 static status_t VBoxGuestHaikuDeselect(void *cookie, uint8 event, selectsync *sync)
     322static status_t vgdrvHaikuDeselect(void *cookie, uint8 event, selectsync *sync)
    343323{
    344324    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
     
    372352 * @return Haiku status code.
    373353 */
    374 static status_t VBoxGuestHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes)
     354static status_t vgdrvHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes)
    375355{
    376356    *numBytes = 0;
     
    388368 * @return Haiku status code.
    389369 */
    390 static status_t VBoxGuestHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes)
     370static status_t vgdrvHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes)
    391371{
    392372    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
     
    408388
    409389
    410 int32 api_version = B_CUR_DRIVER_API_VERSION;
    411390
    412391status_t init_hardware()
     
    420399}
    421400
    422 device_hooks* find_device(const char *name)
    423 {
    424     static device_hooks g_VBoxGuestHaikuDeviceHooks =
    425     {
    426         VBoxGuestHaikuOpen,
    427         VBoxGuestHaikuClose,
    428         VBoxGuestHaikuFree,
    429         VBoxGuestHaikuIOCtl,
    430         VBoxGuestHaikuRead,
    431         VBoxGuestHaikuWrite,
    432         VBoxGuestHaikuSelect,
    433         VBoxGuestHaikuDeselect
     401device_hooks *find_device(const char *name)
     402{
     403    static device_hooks s_vgdrvHaikuDeviceHooks =
     404    {
     405        vgdrvHaikuOpen,
     406        vgdrvHaikuClose,
     407        vgdrvHaikuFree,
     408        vgdrvHaikuIOCtl,
     409        vgdrvHaikuRead,
     410        vgdrvHaikuWrite,
     411        vgdrvHaikuSelect,
     412        vgdrvHaikuDeselect,
    434413    };
    435     return &g_VBoxGuestHaikuDeviceHooks;
    436 }
    437 
    438 const char** publish_devices()
    439 {
    440     static const char *devices[] = { DEVICE_NAME, NULL };
    441     return devices;
     414    return &s_vgdrvHaikuDeviceHooks;
     415}
     416
     417const char **publish_devices()
     418{
     419    static const char *s_papszDevices[] = { DEVICE_NAME, NULL };
     420    return s_papszDevices;
    442421}
    443422
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-darwin.cpp

    r58053 r58113  
    2020*   Header Files                                                                                                                 *
    2121*********************************************************************************************************************************/
    22 #define LOG_GROUP LOG_GROUP_VBGD
     22#define LOG_GROUP LOG_GROUP_VGDRV
    2323/*
    2424 * Deal with conflicts first.
     
    7171
    7272
    73 /** PINFO() - always does printf(). */
    74 #define PINFO(fmt, args...) \
    75     printf(fmt "\n", ## args)
    76 
    77 /** PDEBUG() - does printf() with extra debug data on DEBUG build and keep silence on a release one. */
    78 #if DEBUG
    79 # define MODULE_NAME "VBoxGuest"
    80 # define PDEBUG(fmt, args...) \
    81   do { \
    82       printf(MODULE_NAME ": DEBUG: %s:%d %s(): " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ## args); \
    83   } while (0)
    84 #else
    85 # define PDEBUG(fmt, args...) do {} while (0)
    86 #endif
    87 
    88 
    8973/*********************************************************************************************************************************
    9074*   Internal Functions                                                                                                           *
    9175*********************************************************************************************************************************/
    9276RT_C_DECLS_BEGIN
    93 static kern_return_t    VbgdDarwinStart(struct kmod_info *pKModInfo, void *pvData);
    94 static kern_return_t    VbgdDarwinStop(struct kmod_info *pKModInfo, void *pvData);
    95 static int              VbgdDarwinCharDevRemove(void);
    96 
    97 static int              VbgdDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess);
    98 static int              VbgdDarwinClose(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess);
    99 static int              VbgdDarwinIOCtlSlow(PVBOXGUESTSESSION pSession, u_long iCmd, caddr_t pData, struct proc *pProcess);
    100 static int              VbgdDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess);
    101 
    102 static int              VbgdDarwinErr2DarwinErr(int rc);
    103 
    104 static IOReturn         VbgdDarwinSleepHandler(void *pvTarget, void *pvRefCon, UInt32 uMessageType, IOService *pProvider, void *pvMessageArgument, vm_size_t argSize);
     77static kern_return_t    vgdrvDarwinStart(struct kmod_info *pKModInfo, void *pvData);
     78static kern_return_t    vgdrvDarwinStop(struct kmod_info *pKModInfo, void *pvData);
     79static int              vgdrvDarwinCharDevRemove(void);
     80
     81static int              vgdrvDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess);
     82static int              vgdrvDarwinClose(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess);
     83static int              vgdrvDarwinIOCtlSlow(PVBOXGUESTSESSION pSession, u_long iCmd, caddr_t pData, struct proc *pProcess);
     84static int              vgdrvDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess);
     85
     86static int              vgdrvDarwinErr2DarwinErr(int rc);
     87
     88static IOReturn         vgdrvDarwinSleepHandler(void *pvTarget, void *pvRefCon, UInt32 uMessageType, IOService *pProvider, void *pvMessageArgument, vm_size_t argSize);
    10589RT_C_DECLS_END
    10690
     
    178162
    179163KMOD_EXPLICIT_DECL(VBoxGuest, VBOX_VERSION_STRING, _start, _stop)
    180 DECLHIDDEN(kmod_start_func_t *) _realmain = VbgdDarwinStart;
    181 DECLHIDDEN(kmod_stop_func_t *)  _antimain = VbgdDarwinStop;
     164DECLHIDDEN(kmod_start_func_t *) _realmain = vgdrvDarwinStart;
     165DECLHIDDEN(kmod_stop_func_t *)  _antimain = vgdrvDarwinStop;
    182166DECLHIDDEN(int)                 _kext_apple_cc = __APPLE_CC__;
    183167RT_C_DECLS_END
     
    194178static struct cdevsw    g_DevCW =
    195179{
    196     /*.d_open     = */ VbgdDarwinOpen,
    197     /*.d_close    = */ VbgdDarwinClose,
     180    /*.d_open     = */ vgdrvDarwinOpen,
     181    /*.d_close    = */ vgdrvDarwinClose,
    198182    /*.d_read     = */ eno_rdwrt,
    199183    /*.d_write    = */ eno_rdwrt,
    200     /*.d_ioctl    = */ VbgdDarwinIOCtl,
     184    /*.d_ioctl    = */ vgdrvDarwinIOCtl,
    201185    /*.d_stop     = */ eno_stop,
    202186    /*.d_reset    = */ eno_reset,
     
    242226 * Start the kernel module.
    243227 */
    244 static kern_return_t    VbgdDarwinStart(struct kmod_info *pKModInfo, void *pvData)
     228static kern_return_t    vgdrvDarwinStart(struct kmod_info *pKModInfo, void *pvData)
    245229{
    246230    /*
     
    248232     */
    249233    int rc = RTR0Init(0);
    250     if (RT_FAILURE(rc))
    251     {
    252         PDEBUG("VBoxGuest: RTR0Init failed with rc=%d\n", rc);
    253         return KMOD_RETURN_FAILURE;
    254     }
    255 
    256     PDEBUG("VBoxGuest: driver loaded\n");
    257 
     234    if (RT_SUCCESS(rc))
     235    {
     236        Log(("VBoxGuest: driver loaded\n"));
     237        return KMOD_RETURN_SUCCESS;
     238    }
     239
     240    printf("VBoxGuest: RTR0Init failed with rc=%d\n", rc);
     241    return KMOD_RETURN_FAILURE;
     242}
     243
     244
     245/**
     246 * Register VBoxGuest char device
     247 */
     248static int vgdrvDarwinCharDevInit(void)
     249{
     250    int rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestDarwin");
     251    if (RT_SUCCESS(rc))
     252    {
     253        /*
     254         * Registering ourselves as a character device.
     255         */
     256        g_iMajorDeviceNo = cdevsw_add(-1, &g_DevCW);
     257        if (g_iMajorDeviceNo >= 0)
     258        {
     259            g_hDevFsDeviceSys = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR,
     260                                                UID_ROOT, GID_WHEEL, 0666, DEVICE_NAME_SYS);
     261            if (g_hDevFsDeviceSys != NULL)
     262            {
     263                /*
     264                 * Register a sleep/wakeup notification callback.
     265                 */
     266                g_pSleepNotifier = registerPrioritySleepWakeInterest(&vgdrvDarwinSleepHandler, &g_DevExt, NULL);
     267                if (g_pSleepNotifier != NULL)
     268                {
     269                    return KMOD_RETURN_SUCCESS;
     270                }
     271            }
     272        }
     273        vgdrvDarwinCharDevRemove();
     274    }
     275    return KMOD_RETURN_FAILURE;
     276}
     277
     278
     279/**
     280 * Stop the kernel module.
     281 */
     282static kern_return_t vgdrvDarwinStop(struct kmod_info *pKModInfo, void *pvData)
     283{
     284    RTR0TermForced();
     285
     286    printf("VBoxGuest: driver unloaded\n");
    258287    return KMOD_RETURN_SUCCESS;
    259288}
    260289
    261290
    262 /* Register VBoxGuest char device */
    263 static int VbgdDarwinCharDevInit(void)
    264 {
    265     int rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestDarwin");
    266     if (RT_FAILURE(rc))
    267     {
    268         return KMOD_RETURN_FAILURE;
    269     }
    270 
    271     /*
    272      * Registering ourselves as a character device.
    273      */
    274     g_iMajorDeviceNo = cdevsw_add(-1, &g_DevCW);
    275     if (g_iMajorDeviceNo < 0)
    276     {
    277         VbgdDarwinCharDevRemove();
    278         return KMOD_RETURN_FAILURE;
    279     }
    280 
    281     g_hDevFsDeviceSys = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR,
    282                                         UID_ROOT, GID_WHEEL, 0666, DEVICE_NAME_SYS);
    283     if (!g_hDevFsDeviceSys)
    284     {
    285         VbgdDarwinCharDevRemove();
    286         return KMOD_RETURN_FAILURE;
    287     }
    288 
    289     /* Register a sleep/wakeup notification callback */
    290     g_pSleepNotifier = registerPrioritySleepWakeInterest(&VbgdDarwinSleepHandler, &g_DevExt, NULL);
    291     if (g_pSleepNotifier == NULL)
    292     {
    293         VbgdDarwinCharDevRemove();
    294         return KMOD_RETURN_FAILURE;
    295     }
    296 
    297     return KMOD_RETURN_SUCCESS;
    298 }
    299 
    300 
    301 /**
    302  * Stop the kernel module.
    303  */
    304 static kern_return_t VbgdDarwinStop(struct kmod_info *pKModInfo, void *pvData)
    305 {
    306     RTR0TermForced();
    307 
    308     PDEBUG("VBoxGuest: driver unloaded\n");
    309 
    310     return KMOD_RETURN_SUCCESS;
    311 }
    312 
    313 
    314291/* Unregister VBoxGuest char device */
    315 static int
    316 VbgdDarwinCharDevRemove(void)
     292static int vgdrvDarwinCharDevRemove(void)
    317293{
    318294    int rc = KMOD_RETURN_SUCCESS;
     
    361337 * @param   pProcess    The process issuing this request.
    362338 */
    363 static int VbgdDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess)
     339static int vgdrvDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess)
    364340{
    365341    /*
     
    412388        rc = VERR_INVALID_PARAMETER;
    413389
    414     Log(("VbgdDarwinOpen: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, proc_pid(pProcess)));
    415     return VbgdDarwinErr2DarwinErr(rc);
     390    Log(("vgdrvDarwinOpen: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, proc_pid(pProcess)));
     391    return vgdrvDarwinErr2DarwinErr(rc);
    416392}
    417393
     
    420396 * Close device.
    421397 */
    422 static int VbgdDarwinClose(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess)
    423 {
    424     Log(("VbgdDarwinClose: pid=%d\n", (int)RTProcSelf()));
     398static int vgdrvDarwinClose(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess)
     399{
     400    Log(("vgdrvDarwinClose: pid=%d\n", (int)RTProcSelf()));
    425401    Assert(proc_pid(pProcess) == (int)RTProcSelf());
    426402
     
    443419 * @param   pProcess    The process issuing this request.
    444420 */
    445 static int VbgdDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess)
     421static int vgdrvDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess)
    446422{
    447423    //const bool          fUnrestricted = minor(Dev) == 0;
     
    460436    if (!pSession)
    461437    {
    462         Log(("VBoxDrvDarwinIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#lx\n",
    463              (int)Process, iCmd));
     438        Log(("VBoxDrvDarwinIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#lx\n", (int)Process, iCmd));
    464439        return EINVAL;
    465440    }
     
    469444     */
    470445
    471     return VbgdDarwinIOCtlSlow(pSession, iCmd, pData, pProcess);
    472 }
    473 
    474 
    475 /**
    476  * Worker for VbgdDarwinIOCtl that takes the slow IOCtl functions.
     446    return vgdrvDarwinIOCtlSlow(pSession, iCmd, pData, pProcess);
     447}
     448
     449
     450/**
     451 * Worker for vgdrvDarwinIOCtl that takes the slow IOCtl functions.
    477452 *
    478453 * @returns Darwin errno.
     
    483458 * @param pProcess  The calling process.
    484459 */
    485 static int VbgdDarwinIOCtlSlow(PVBOXGUESTSESSION pSession, u_long iCmd, caddr_t pData, struct proc *pProcess)
    486 {
    487     LogFlow(("VbgdDarwinIOCtlSlow: pSession=%p iCmd=%p pData=%p pProcess=%p\n", pSession, iCmd, pData, pProcess));
     460static int vgdrvDarwinIOCtlSlow(PVBOXGUESTSESSION pSession, u_long iCmd, caddr_t pData, struct proc *pProcess)
     461{
     462    LogFlow(("vgdrvDarwinIOCtlSlow: pSession=%p iCmd=%p pData=%p pProcess=%p\n", pSession, iCmd, pData, pProcess));
    488463
    489464
     
    512487        if (RT_UNLIKELY(rc))
    513488        {
    514             Log(("VbgdDarwinIOCtlSlow: copyin(%llx,Hdr,) -> %#x; iCmd=%#lx\n", (unsigned long long)pUser, rc, iCmd));
     489            Log(("vgdrvDarwinIOCtlSlow: copyin(%llx,Hdr,) -> %#x; iCmd=%#lx\n", (unsigned long long)pUser, rc, iCmd));
    515490            return rc;
    516491        }
    517492        if (RT_UNLIKELY(Hdr.u32Magic != VBGLBIGREQ_MAGIC))
    518493        {
    519             Log(("VbgdDarwinIOCtlSlow: bad magic u32Magic=%#x; iCmd=%#lx\n", Hdr.u32Magic, iCmd));
     494            Log(("vgdrvDarwinIOCtlSlow: bad magic u32Magic=%#x; iCmd=%#lx\n", Hdr.u32Magic, iCmd));
    520495            return EINVAL;
    521496        }
     
    523498        if (RT_UNLIKELY(cbReq > _1M*16))
    524499        {
    525             Log(("VbgdDarwinIOCtlSlow: %#x; iCmd=%#lx\n", Hdr.cbData, iCmd));
     500            Log(("vgdrvDarwinIOCtlSlow: %#x; iCmd=%#lx\n", Hdr.cbData, iCmd));
    526501            return EINVAL;
    527502        }
     
    536511        if (RT_UNLIKELY(!pvReqData))
    537512        {
    538             Log(("VbgdDarwinIOCtlSlow: failed to allocate buffer of %d bytes; iCmd=%#lx\n", cbReq, iCmd));
     513            Log(("vgdrvDarwinIOCtlSlow: failed to allocate buffer of %d bytes; iCmd=%#lx\n", cbReq, iCmd));
    539514            return ENOMEM;
    540515        }
     
    542517        if (RT_UNLIKELY(rc))
    543518        {
    544             Log(("VbgdDarwinIOCtlSlow: copyin(%llx,%p,%#x) -> %#x; iCmd=%#lx\n",
     519            Log(("vgdrvDarwinIOCtlSlow: copyin(%llx,%p,%#x) -> %#x; iCmd=%#lx\n",
    545520                 (unsigned long long)pUser, pvReqData, Hdr.cbData, rc, iCmd));
    546521            if (pvPageBuf)
     
    553528    else
    554529    {
    555         Log(("VbgdDarwinIOCtlSlow: huh? cbReq=%#x iCmd=%#lx\n", cbReq, iCmd));
     530        Log(("vgdrvDarwinIOCtlSlow: huh? cbReq=%#x iCmd=%#lx\n", cbReq, iCmd));
    556531        return EINVAL;
    557532    }
     
    571546            if (cbReqRet > cbReq)
    572547            {
    573                 Log(("VbgdDarwinIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbReqRet, cbReq, iCmd));
     548                Log(("vgdrvDarwinIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbReqRet, cbReq, iCmd));
    574549                cbReqRet = cbReq;
    575550            }
    576551            rc = copyout(pvReqData, pUser, cbReqRet);
    577552            if (RT_UNLIKELY(rc))
    578                 Log(("VbgdDarwinIOCtlSlow: copyout(%p,%llx,%#x) -> %d; uCmd=%#lx!\n",
     553                Log(("vgdrvDarwinIOCtlSlow: copyout(%p,%llx,%#x) -> %d; uCmd=%#lx!\n",
    579554                     pvReqData, (unsigned long long)pUser, cbReqRet, rc, iCmd));
    580555
     
    601576        }
    602577
    603         Log(("VbgdDarwinIOCtlSlow: pid=%d iCmd=%lx pData=%p failed, rc=%d\n", proc_pid(pProcess), iCmd, (void *)pData, rc));
     578        Log(("vgdrvDarwinIOCtlSlow: pid=%d iCmd=%lx pData=%p failed, rc=%d\n", proc_pid(pProcess), iCmd, (void *)pData, rc));
    604579        rc = EINVAL;
    605580    }
    606581
    607     Log2(("VbgdDarwinIOCtlSlow: returns %d\n", rc));
     582    Log2(("vgdrvDarwinIOCtlSlow: returns %d\n", rc));
    608583    return rc;
    609584}
     
    627602 * Callback for blah blah blah.
    628603 */
    629 IOReturn VbgdDarwinSleepHandler(void * /* pvTarget */, void *pvRefCon, UInt32 uMessageType, IOService * /* pProvider */, void * /* pvMessageArgument */, vm_size_t /* argSize */)
    630 {
    631     LogFlow(("VBoxGuest: Got sleep/wake notice. Message type was %X\n", (uint)uMessageType));
     604static IOReturn vgdrvDarwinSleepHandler(void *pvTarget, void *pvRefCon, UInt32 uMessageType,
     605                                        IOService *pProvider, void *pvMsgArg, vm_size_t cbMsgArg)
     606{
     607    LogFlow(("VBoxGuest: Got sleep/wake notice. Message type was %x\n", uMessageType));
    632608
    633609    if (uMessageType == kIOMessageSystemWillSleep)
     
    648624 * @param   rc      IPRT status code.
    649625 */
    650 static int VbgdDarwinErr2DarwinErr(int rc)
     626static int vgdrvDarwinErr2DarwinErr(int rc)
    651627{
    652628    switch (rc)
     
    675651
    676652
    677 IOWorkLoop *
    678 org_virtualbox_VBoxGuest::getWorkLoop()
    679 {
    680     /* Handle the case when work loop was not created yet */
    681     if(ASMAtomicCmpXchgU8(&g_fWorkLoopCreated, VBOXGUEST_OBJECT_INITIALIZING, VBOXGUEST_OBJECT_UNINITIALIZED))
     653/**
     654 * Lazy initialization of the m_pWorkLoop member.
     655 *
     656 * @returns m_pWorkLoop.
     657 */
     658IOWorkLoop *org_virtualbox_VBoxGuest::getWorkLoop()
     659{
     660/** @todo r=bird: This is actually a classic RTOnce scenario, except it's
     661 *        tied to a org_virtualbox_VBoxGuest instance.  */
     662    /*
     663     * Handle the case when work loop was not created yet.
     664     */
     665    if (ASMAtomicCmpXchgU8(&g_fWorkLoopCreated, VBOXGUEST_OBJECT_INITIALIZING, VBOXGUEST_OBJECT_UNINITIALIZED))
    682666    {
    683667        m_pWorkLoop = IOWorkLoop::workLoop();
     
    686670            /* Notify the rest of threads about the fact that work
    687671             * loop was successully allocated and can be safely used */
    688             PDEBUG("created new work loop\n");
     672            Log(("VBoxGuest: created new work loop\n"));
    689673            ASMAtomicWriteU8(&g_fWorkLoopCreated, VBOXGUEST_OBJECT_INITIALIZED);
    690674        }
     
    693677            /* Notify the rest of threads about the fact that there was
    694678             * an error during allocation of a work loop */
    695             PDEBUG("unable new work loop\n");
     679            Log(("VBoxGuest: failed to create new work loop!\n"));
    696680            ASMAtomicWriteU8(&g_fWorkLoopCreated, VBOXGUEST_OBJECT_UNINITIALIZED);
    697681        }
    698682    }
     683    /*
     684     * Handle the case when work loop is already create or
     685     * in the process of being.
     686     */
    699687    else
    700688    {
    701         /* Handle the case when work loop is currently being
    702          * created or it was previously failed to create */
    703         uint8_t fWorkLoopCreated = VBOXGUEST_OBJECT_INVALID;
    704         while (fWorkLoopCreated != VBOXGUEST_OBJECT_INITIALIZED
    705             && fWorkLoopCreated != VBOXGUEST_OBJECT_UNINITIALIZED)
    706         {
     689        uint8_t fWorkLoopCreated = ASMAtomicReadU8(&g_fWorkLoopCreated);
     690        while (fWorkLoopCreated == VBOXGUEST_OBJECT_INITIALIZING)
     691        {
     692            thread_block(0);
    707693            fWorkLoopCreated = ASMAtomicReadU8(&g_fWorkLoopCreated);
    708             thread_block(0);
    709         }
    710         if (fWorkLoopCreated == VBOXGUEST_OBJECT_INITIALIZED)
    711             PDEBUG("returned existing work loop");
    712         else
    713             PDEBUG("work loop was not allocated correctly");
     694        }
     695        if (fWorkLoopCreated != VBOXGUEST_OBJECT_INITIALIZED)
     696            Log(("VBoxGuest: No work loop!\n"));
    714697    }
    715698
     
    721704 * Perform pending wake ups in work loop context.
    722705 */
    723 static void
    724 deferredInterruptHandler(OSObject *pOwner, IOInterruptEventSource *pSrc, int cInts)
     706static void vgdrvDarwinDeferredIrqHandler(OSObject *pOwner, IOInterruptEventSource *pSrc, int cInts)
    725707{
    726708    NOREF(pOwner); NOREF(pSrc); NOREF(cInts);
     
    729711}
    730712
     713
    731714/**
    732715 * Callback triggered when interrupt occurs.
    733716 */
    734 static bool
    735 directInterruptHandler(OSObject *pOwner, IOFilterInterruptEventSource *pSrc)
     717static bool vgdrvDarwinDirectIrqHandler(OSObject *pOwner, IOFilterInterruptEventSource *pSrc)
    736718{
    737719    if (!pSrc)
     
    740722    bool fTaken = VGDrvCommonISR(&g_DevExt);
    741723    if (!fTaken) /** @todo r=bird: This looks bogus as we might actually be sharing interrupts with someone. */
    742         PDEBUG("VbgdCommonISR error\n");
     724        Log(("VGDrvCommonISR error\n"));
    743725
    744726    return fTaken;
    745727}
    746728
    747 bool
    748 org_virtualbox_VBoxGuest::setupVmmDevInterrupts(IOService *pProvider)
     729
     730bool org_virtualbox_VBoxGuest::setupVmmDevInterrupts(IOService *pProvider)
    749731{
    750732    IOWorkLoop *pWorkLoop = getWorkLoop();
    751 
    752733    if (!pWorkLoop)
    753734        return false;
    754735
    755736    m_pInterruptSrc = IOFilterInterruptEventSource::filterInterruptEventSource(this,
    756                                                                                &deferredInterruptHandler,
    757                                                                                &directInterruptHandler,
     737                                                                               &vgdrvDarwinDeferredIrqHandler,
     738                                                                               &vgdrvDarwinDirectIrqHandler,
    758739                                                                               pProvider);
    759 
    760     if (kIOReturnSuccess != pWorkLoop->addEventSource(m_pInterruptSrc))
    761     {
    762         m_pInterruptSrc->disable();
    763         m_pInterruptSrc->release();
    764         m_pInterruptSrc = 0;
    765         return false;
    766     }
    767 
    768     m_pInterruptSrc->enable();
    769 
    770     return true;
    771 }
    772 
    773 bool
    774 org_virtualbox_VBoxGuest::disableVmmDevInterrupts(void)
     740    IOReturn rc = pWorkLoop->addEventSource(m_pInterruptSrc);
     741    if (rc == kIOReturnSuccess)
     742    {
     743        m_pInterruptSrc->enable();
     744        return true;
     745    }
     746
     747    m_pInterruptSrc->disable();
     748    m_pInterruptSrc->release();
     749    m_pInterruptSrc = NULL;
     750    return false;
     751}
     752
     753
     754bool org_virtualbox_VBoxGuest::disableVmmDevInterrupts(void)
    775755{
    776756    IOWorkLoop *pWorkLoop = (IOWorkLoop *)getWorkLoop();
     
    785765    pWorkLoop->removeEventSource(m_pInterruptSrc);
    786766    m_pInterruptSrc->release();
    787     m_pInterruptSrc = 0;
     767    m_pInterruptSrc = NULL;
    788768
    789769    return true;
    790770}
     771
    791772
    792773bool org_virtualbox_VBoxGuest::isVmmDev(IOPCIDevice *pIOPCIDevice)
     
    812793bool org_virtualbox_VBoxGuest::start(IOService *pProvider)
    813794{
     795    /*
     796     * Low level initialization / device initialization should be performed only once.
     797     */
     798    if (!ASMAtomicCmpXchgBool(&g_fInstantiated, true, false))
     799        return false;
     800
    814801    if (!IOService::start(pProvider))
    815802        return false;
    816 
    817     /* Low level initialization should be performed only once */
    818     if (!ASMAtomicCmpXchgBool(&g_fInstantiated, true, false))
    819     {
    820         IOService::stop(pProvider);
    821         return false;
    822     }
    823803
    824804    m_pIOPCIDevice = OSDynamicCast(IOPCIDevice, pProvider);
     
    861841                    if (RT_SUCCESS(rc))
    862842                    {
    863                         rc = VbgdDarwinCharDevInit();
     843                        rc = vgdrvDarwinCharDevInit();
    864844                        if (rc == KMOD_RETURN_SUCCESS)
    865845                        {
     
    873853
    874854                            LogRel(("VBoxGuest: Failed to set up interrupts\n"));
    875                             VbgdDarwinCharDevRemove();
     855                            vgdrvDarwinCharDevRemove();
    876856                        }
    877857                        else
     
    901881
    902882    ASMAtomicXchgBool(&g_fInstantiated, false);
    903 
    904883    IOService::stop(pProvider);
    905 
    906884    return false;
    907885}
     
    915893    /* Do not use Log*() here (in IOService instance) because its instance
    916894     * already terminated in BSD's module unload callback! */
    917     PDEBUG("org_virtualbox_VBoxGuest::stop([%p], %p)\n", this, pProvider);
     895    Log(("org_virtualbox_VBoxGuest::stop([%p], %p)\n", this, pProvider));
    918896
    919897    AssertReturnVoid(ASMAtomicReadBool(&g_fInstantiated));
     
    921899    /* Low level termination should be performed only once */
    922900    if (!disableVmmDevInterrupts())
    923         PDEBUG("VBoxGuest: unable to unregister interrupt handler\n");
    924 
    925     VbgdDarwinCharDevRemove();
     901        printf("VBoxGuest: unable to unregister interrupt handler\n");
     902
     903    vgdrvDarwinCharDevRemove();
    926904    VGDrvCommonDeleteDevExt(&g_DevExt);
    927905
     
    936914    ASMAtomicWriteBool(&g_fInstantiated, false);
    937915
    938     PINFO("VBoxGuest: IOService stopped\n");
     916    printf("VBoxGuest: IOService stopped\n");
    939917}
    940918
     
    950928    /* Do not use Log*() here (in IOService instance) because its instance
    951929     * already terminated in BSD's module unload callback! */
     930#ifdef LOG_ENABLED
     931    printf("org_virtualbox_VBoxGuest::terminate: reference_count=%d g_cSessions=%d (fOptions=%#x)\n",
     932           KMOD_INFO_NAME.reference_count, ASMAtomicUoReadS32(&g_cSessions), fOptions);
     933#endif
    952934
    953935    bool fRc;
    954     PDEBUG("org_virtualbox_VBoxGuest::terminate: reference_count=%d g_cSessions=%d (fOptions=%#x)\n",
    955              KMOD_INFO_NAME.reference_count, ASMAtomicUoReadS32(&g_cSessions), fOptions);
    956936    if (    KMOD_INFO_NAME.reference_count != 0
    957937        ||  ASMAtomicUoReadS32(&g_cSessions))
     
    959939    else
    960940        fRc = IOService::terminate(fOptions);
    961     PDEBUG("org_virtualbox_SupDrv::terminate: returns %d\n", fRc);
     941
     942#ifdef LOG_ENABLED
     943    printf("org_virtualbox_SupDrv::terminate: returns %d\n", fRc);
     944#endif
    962945    return fRc;
    963946}
     
    10811064     *
    10821065     * Note! Only one session per process. (Both start() and
    1083      * VbgdDarwinOpen makes sure this is so.)
     1066     * vgdrvDarwinOpen makes sure this is so.)
    10841067     */
    10851068    const unsigned  iHash = SESSION_HASH(Process);
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c

    r58053 r58113  
    2121 * applied to the other. */
    2222
     23
     24/*********************************************************************************************************************************
     25*   Header Files                                                                                                                 *
     26*********************************************************************************************************************************/
    2327#include <sys/param.h>
     28#undef PVM
     29#include <sys/types.h>
     30#include <sys/module.h>
    2431#include <sys/systm.h>
     32#include <sys/errno.h>
     33#include <sys/kernel.h>
     34#include <sys/fcntl.h>
    2535#include <sys/conf.h>
    26 #include <sys/kernel.h>
    27 #include <sys/module.h>
     36#include <sys/uio.h>
    2837#include <sys/bus.h>
    2938#include <sys/poll.h>
     
    3241#include <sys/lock.h>
    3342#include <sys/lockmgr.h>
    34 #include <sys/types.h>
    35 #include <sys/conf.h>
    3643#include <sys/malloc.h>
    37 #include <sys/uio.h>
    3844#include <sys/file.h>
    3945#include <sys/rman.h>
     
    4349#include <dev/pci/pcireg.h>
    4450
    45 #ifdef PVM
    46 #  undef PVM
    47 #endif
    4851#include "VBoxGuestInternal.h"
     52#include <VBox/version.h>
    4953#include <VBox/log.h>
    5054#include <iprt/assert.h>
     
    5458#include <iprt/asm.h>
    5559
     60
     61/*********************************************************************************************************************************
     62*   Defined Constants And Macros                                                                                                 *
     63*********************************************************************************************************************************/
    5664/** The module name. */
    57 #define DEVICE_NAME    "vboxguest"
    58 
     65#define DEVICE_NAME  "vboxguest"
     66
     67
     68/*********************************************************************************************************************************
     69*   Structures and Typedefs                                                                                                      *
     70*********************************************************************************************************************************/
    5971struct VBoxGuestDeviceState
    6072{
     
    8597};
    8698
    87 static MALLOC_DEFINE(M_VBOXDEV, "vboxdev_pci", "VirtualBox Guest driver PCI");
    88 
     99
     100/*********************************************************************************************************************************
     101*   Internal Functions                                                                                                           *
     102*********************************************************************************************************************************/
    89103/*
    90104 * Character device file handlers.
    91105 */
    92 static d_fdopen_t VBoxGuestFreeBSDOpen;
    93 static d_close_t  VBoxGuestFreeBSDClose;
    94 static d_ioctl_t  VBoxGuestFreeBSDIOCtl;
    95 static d_write_t  VBoxGuestFreeBSDWrite;
    96 static d_read_t   VBoxGuestFreeBSDRead;
    97 static d_poll_t   VBoxGuestFreeBSDPoll;
     106static d_fdopen_t vgdrvFreeBSDOpen;
     107static d_close_t  vgdrvFreeBSDClose;
     108static d_ioctl_t  vgdrvFreeBSDIOCtl;
     109static d_write_t  vgdrvFreeBSDWrite;
     110static d_read_t   vgdrvFreeBSDRead;
     111static d_poll_t   vgdrvFreeBSDPoll;
    98112
    99113/*
    100114 * IRQ related functions.
    101115 */
    102 static void VBoxGuestFreeBSDRemoveIRQ(device_t pDevice, void *pvState);
    103 static int  VBoxGuestFreeBSDAddIRQ(device_t pDevice, void *pvState);
    104 static int  VBoxGuestFreeBSDISR(void *pvState);
    105 
    106 /*
    107  * Available functions for kernel drivers.
    108  */
    109 DECLVBGL(int)    VBoxGuestFreeBSDServiceCall(void *pvSession, unsigned uCmd, void *pvData, size_t cbData, size_t *pcbDataReturned);
    110 DECLVBGL(void *) VBoxGuestFreeBSDServiceOpen(uint32_t *pu32Version);
    111 DECLVBGL(int)    VBoxGuestFreeBSDServiceClose(void *pvSession);
     116static void vgdrvFreeBSDRemoveIRQ(device_t pDevice, void *pvState);
     117static int  vgdrvFreeBSDAddIRQ(device_t pDevice, void *pvState);
     118static int  vgdrvFreeBSDISR(void *pvState);
     119
     120
     121/*********************************************************************************************************************************
     122*   Global Variables                                                                                                             *
     123*********************************************************************************************************************************/
     124static MALLOC_DEFINE(M_VBOXGUEST, "vboxguest", "VirtualBox Guest Device Driver");
    112125
    113126#ifndef D_NEEDMINOR
     
    116129
    117130/*
    118  * Device node entry points.
    119  */
    120 static struct cdevsw    g_VBoxGuestFreeBSDChrDevSW =
     131 * The /dev/vboxguest character device entry points.
     132 */
     133static struct cdevsw    g_vgdrvFreeBSDChrDevSW =
    121134{
    122135    .d_version =        D_VERSION,
    123136    .d_flags =          D_TRACKCLOSE | D_NEEDMINOR,
    124     .d_fdopen =         VBoxGuestFreeBSDOpen,
    125     .d_close =          VBoxGuestFreeBSDClose,
    126     .d_ioctl =          VBoxGuestFreeBSDIOCtl,
    127     .d_read =           VBoxGuestFreeBSDRead,
    128     .d_write =          VBoxGuestFreeBSDWrite,
    129     .d_poll =           VBoxGuestFreeBSDPoll,
    130     .d_name =           DEVICE_NAME
     137    .d_fdopen =         vgdrvFreeBSDOpen,
     138    .d_close =          vgdrvFreeBSDClose,
     139    .d_ioctl =          vgdrvFreeBSDIOCtl,
     140    .d_read =           vgdrvFreeBSDRead,
     141    .d_write =          vgdrvFreeBSDWrite,
     142    .d_poll =           vgdrvFreeBSDPoll,
     143    .d_name =           "vboxguest"
    131144};
    132145
    133146/** Device extention & session data association structure. */
    134147static VBOXGUESTDEVEXT      g_DevExt;
     148
    135149/** List of cloned device. Managed by the kernel. */
    136 static struct clonedevs    *g_pVBoxGuestFreeBSDClones;
     150static struct clonedevs    *g_pvgdrvFreeBSDClones;
    137151/** The dev_clone event handler tag. */
    138 static eventhandler_tag     g_VBoxGuestFreeBSDEHTag;
     152static eventhandler_tag     g_vgdrvFreeBSDEHTag;
    139153/** Reference counter */
    140154static volatile uint32_t    cUsers;
     
    145159 * DEVFS event handler.
    146160 */
    147 static void VBoxGuestFreeBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)
     161static void vgdrvFreeBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)
    148162{
    149163    int iUnit;
    150164    int rc;
    151165
    152     Log(("VBoxGuestFreeBSDClone: pszName=%s ppDev=%p\n", pszName, ppDev));
     166    Log(("vgdrvFreeBSDClone: pszName=%s ppDev=%p\n", pszName, ppDev));
    153167
    154168    /*
     
    164178    if (iUnit >= 256)
    165179    {
    166         Log(("VBoxGuestFreeBSDClone: iUnit=%d >= 256 - rejected\n", iUnit));
     180        Log(("vgdrvFreeBSDClone: iUnit=%d >= 256 - rejected\n", iUnit));
    167181        return;
    168182    }
    169183
    170     Log(("VBoxGuestFreeBSDClone: pszName=%s iUnit=%d\n", pszName, iUnit));
    171 
    172     rc = clone_create(&g_pVBoxGuestFreeBSDClones, &g_VBoxGuestFreeBSDChrDevSW, &iUnit, ppDev, 0);
    173     Log(("VBoxGuestFreeBSDClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));
     184    Log(("vgdrvFreeBSDClone: pszName=%s iUnit=%d\n", pszName, iUnit));
     185
     186    rc = clone_create(&g_pvgdrvFreeBSDClones, &g_vgdrvFreeBSDChrDevSW, &iUnit, ppDev, 0);
     187    Log(("vgdrvFreeBSDClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));
    174188    if (rc)
    175189    {
    176         *ppDev = make_dev(&g_VBoxGuestFreeBSDChrDevSW,
     190        *ppDev = make_dev(&g_vgdrvFreeBSDChrDevSW,
    177191                          iUnit,
    178192                          UID_ROOT,
     
    184198            dev_ref(*ppDev);
    185199            (*ppDev)->si_flags |= SI_CHEAPCLONE;
    186             Log(("VBoxGuestFreeBSDClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
     200            Log(("vgdrvFreeBSDClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
    187201                     *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
    188202            (*ppDev)->si_drv1 = (*ppDev)->si_drv2 = NULL;
    189203        }
    190204        else
    191             Log(("VBoxGuestFreeBSDClone: make_dev iUnit=%d failed\n", iUnit));
     205            Log(("vgdrvFreeBSDClone: make_dev iUnit=%d failed\n", iUnit));
    192206    }
    193207    else
    194         Log(("VBoxGuestFreeBSDClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
     208        Log(("vgdrvFreeBSDClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
    195209             *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
    196210}
     
    201215 */
    202216#if __FreeBSD_version >= 700000
    203 static int VBoxGuestFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd, struct file *pFd)
     217static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd, struct file *pFd)
    204218#else
    205 static int VBoxGuestFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd)
     219static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd)
    206220#endif
    207221{
     
    209223    PVBOXGUESTSESSION   pSession;
    210224
    211     LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDOpen\n"));
     225    LogFlow(("vgdrvFreeBSDOpen:\n"));
    212226
    213227    /*
     
    225239        if (ASMAtomicCmpXchgPtr(&pDev->si_drv1, pSession, (void *)0x42))
    226240        {
    227             Log((DEVICE_NAME ":VBoxGuestFreeBSDOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
     241            Log(("vgdrvFreeBSDOpen: success - g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
    228242            ASMAtomicIncU32(&cUsers);
    229243            return 0;
     
    233247    }
    234248
    235     LogRel((DEVICE_NAME ":VBoxGuestFreeBSDOpen: failed. rc=%d\n", rc));
     249    LogRel(("vgdrvFreeBSDOpen: failed. rc=%d\n", rc));
    236250    return RTErrConvertToErrno(rc);
    237251}
     
    241255 *
    242256 */
    243 static int VBoxGuestFreeBSDClose(struct cdev *pDev, int fFile, int DevType, struct thread *pTd)
     257static int vgdrvFreeBSDClose(struct cdev *pDev, int fFile, int DevType, struct thread *pTd)
    244258{
    245259    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
    246     Log(("VBoxGuestFreeBSDClose: fFile=%#x pSession=%p\n", fFile, pSession));
     260    Log(("vgdrvFreeBSDClose: fFile=%#x pSession=%p\n", fFile, pSession));
    247261
    248262    /*
     
    253267        VGDrvCommonCloseSession(&g_DevExt, pSession);
    254268        if (!ASMAtomicCmpXchgPtr(&pDev->si_drv1, NULL, pSession))
    255             Log(("VBoxGuestFreeBSDClose: si_drv1=%p expected %p!\n", pDev->si_drv1, pSession));
     269            Log(("vgdrvFreeBSDClose: si_drv1=%p expected %p!\n", pDev->si_drv1, pSession));
    256270        ASMAtomicDecU32(&cUsers);
    257271        /* Don't use destroy_dev here because it may sleep resulting in a hanging user process. */
     
    259273    }
    260274    else
    261         Log(("VBoxGuestFreeBSDClose: si_drv1=%p!\n", pSession));
     275        Log(("vgdrvFreeBSDClose: si_drv1=%p!\n", pSession));
    262276    return 0;
    263277}
     
    267281 *
    268282 */
    269 static int VBoxGuestFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
    270 {
    271     LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl\n"));
     283static int vgdrvFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
     284{
     285    LogFlow(("vgdrvFreeBSDIOCtl\n"));
    272286
    273287    int rc = 0;
     
    285299    if (IOCPARM_LEN(ulCmd) != sizeof(VBGLBIGREQ))
    286300    {
    287         Log((DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ)));
     301        Log(("vgdrvFreeBSDIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ)));
    288302        return ENOTTY;
    289303    }
     
    292306    if (ReqWrap->u32Magic != VBGLBIGREQ_MAGIC)
    293307    {
    294         Log((DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad magic %#x; pArg=%p Cmd=%lu.\n", ReqWrap->u32Magic, pvData, ulCmd));
     308        Log(("vgdrvFreeBSDIOCtl: bad magic %#x; pArg=%p Cmd=%lu.\n", ReqWrap->u32Magic, pvData, ulCmd));
    295309        return EINVAL;
    296310    }
     
    298312                    || ReqWrap->cbData > _1M*16))
    299313    {
    300         printf(DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", ReqWrap->cbData, pvData, ulCmd);
     314        printf("vgdrvFreeBSDIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", ReqWrap->cbData, pvData, ulCmd);
    301315        return EINVAL;
    302316    }
     
    308322    if (RT_UNLIKELY(!pvBuf))
    309323    {
    310         Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap->cbData));
     324        Log(("vgdrvFreeBSDIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap->cbData));
    311325        return ENOMEM;
    312326    }
     
    316330    {
    317331        RTMemTmpFree(pvBuf);
    318         Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: copyin failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
     332        Log(("vgdrvFreeBSDIOCtl: copyin failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
    319333        return EFAULT;
    320334    }
     
    323337    {
    324338        RTMemTmpFree(pvBuf);
    325         Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: pvBuf invalid pointer %p\n", pvBuf));
     339        Log(("vgdrvFreeBSDIOCtl: pvBuf invalid pointer %p\n", pvBuf));
    326340        return EINVAL;
    327341    }
    328     Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));
     342    Log(("vgdrvFreeBSDIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));
    329343
    330344    /*
     
    338352        if (RT_UNLIKELY(cbDataReturned > ReqWrap->cbData))
    339353        {
    340             Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap->cbData));
     354            Log(("vgdrvFreeBSDIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap->cbData));
    341355            cbDataReturned = ReqWrap->cbData;
    342356        }
     
    346360            if (RT_UNLIKELY(rc))
    347361            {
    348                 Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: copyout failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
     362                Log(("vgdrvFreeBSDIOCtl: copyout failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
    349363                rc = EFAULT;
    350364            }
     
    353367    else
    354368    {
    355         Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: VbgdCommonIoCtl failed. rc=%d\n", rc));
     369        Log(("vgdrvFreeBSDIOCtl: VGDrvCommonIoCtl failed. rc=%d\n", rc));
    356370        rc = EFAULT;
    357371    }
     
    360374}
    361375
    362 static int VBoxGuestFreeBSDPoll (struct cdev *pDev, int fEvents, struct thread *td)
     376static int vgdrvFreeBSDPoll(struct cdev *pDev, int fEvents, struct thread *td)
    363377{
    364378    int fEventsProcessed;
    365379
    366     LogFlow((DEVICE_NAME "::Poll: fEvents=%d\n", fEvents));
     380    LogFlow(("vgdrvFreeBSDPoll: fEvents=%d\n", fEvents));
    367381
    368382    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
    369383    if (RT_UNLIKELY(!VALID_PTR(pSession))) {
    370         Log((DEVICE_NAME "::Poll: no state data for %s\n", devtoname(pDev)));
     384        Log(("vgdrvFreeBSDPoll: no state data for %s\n", devtoname(pDev)));
    371385        return (fEvents & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM));
    372386    }
     
    388402}
    389403
    390 static int VBoxGuestFreeBSDWrite (struct cdev *pDev, struct uio *pUio, int fIo)
     404static int vgdrvFreeBSDWrite(struct cdev *pDev, struct uio *pUio, int fIo)
    391405{
    392406    return 0;
    393407}
    394408
    395 static int VBoxGuestFreeBSDRead (struct cdev *pDev, struct uio *pUio, int fIo)
     409static int vgdrvFreeBSDRead(struct cdev *pDev, struct uio *pUio, int fIo)
    396410{
    397411    return 0;
    398412}
    399413
    400 static int VBoxGuestFreeBSDDetach(device_t pDevice)
     414static int vgdrvFreeBSDDetach(device_t pDevice)
    401415{
    402416    struct VBoxGuestDeviceState *pState = device_get_softc(pDevice);
     
    406420
    407421    /*
    408      * Reverse what we did in VBoxGuestFreeBSDAttach.
    409      */
    410     if (g_VBoxGuestFreeBSDEHTag != NULL)
    411         EVENTHANDLER_DEREGISTER(dev_clone, g_VBoxGuestFreeBSDEHTag);
    412 
    413     clone_cleanup(&g_pVBoxGuestFreeBSDClones);
    414 
    415     VBoxGuestFreeBSDRemoveIRQ(pDevice, pState);
     422     * Reverse what we did in vgdrvFreeBSDAttach.
     423     */
     424    if (g_vgdrvFreeBSDEHTag != NULL)
     425        EVENTHANDLER_DEREGISTER(dev_clone, g_vgdrvFreeBSDEHTag);
     426
     427    clone_cleanup(&g_pvgdrvFreeBSDClones);
     428
     429    vgdrvFreeBSDRemoveIRQ(pDevice, pState);
    416430
    417431    if (pState->pVMMDevMemRes)
     
    433447 * @param   pvState Opaque pointer to the device state.
    434448 */
    435 static int VBoxGuestFreeBSDISR(void *pvState)
    436 {
    437     LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDISR pvState=%p\n", pvState));
     449static int vgdrvFreeBSDISR(void *pvState)
     450{
     451    LogFlow(("vgdrvFreeBSDISR: pvState=%p\n", pvState));
    438452
    439453    bool fOurIRQ = VGDrvCommonISR(&g_DevExt);
     
    444458void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
    445459{
    446     LogFlow((DEVICE_NAME ":VGDrvNativeISRMousePollEvent:\n"));
     460    LogFlow(("VGDrvNativeISRMousePollEvent:\n"));
    447461
    448462    /*
     
    459473 * @param   pvState  Pointer to the state info structure.
    460474 */
    461 static int VBoxGuestFreeBSDAddIRQ(device_t pDevice, void *pvState)
     475static int vgdrvFreeBSDAddIRQ(device_t pDevice, void *pvState)
    462476{
    463477    int iResId = 0;
     
    468482
    469483#if __FreeBSD_version >= 700000
    470     rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *)VBoxGuestFreeBSDISR, pState,
     484    rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *)vgdrvFreeBSDISR, pState,
    471485                        &pState->pfnIrqHandler);
    472486#else
    473     rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO, (driver_intr_t *)VBoxGuestFreeBSDISR, pState, &pState->pfnIrqHandler);
     487    rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO, (driver_intr_t *)vgdrvFreeBSDISR, pState, &pState->pfnIrqHandler);
    474488#endif
    475489
     
    491505 * @param   pvState  Opaque pointer to the state info structure.
    492506 */
    493 static void VBoxGuestFreeBSDRemoveIRQ(device_t pDevice, void *pvState)
     507static void vgdrvFreeBSDRemoveIRQ(device_t pDevice, void *pvState)
    494508{
    495509    struct VBoxGuestDeviceState *pState = (struct VBoxGuestDeviceState *)pvState;
     
    502516}
    503517
    504 static int VBoxGuestFreeBSDAttach(device_t pDevice)
    505 {
    506     int rc = VINF_SUCCESS;
    507     int iResId = 0;
    508     struct VBoxGuestDeviceState *pState = NULL;
     518static int vgdrvFreeBSDAttach(device_t pDevice)
     519{
     520    int rc;
     521    int iResId;
     522    struct VBoxGuestDeviceState *pState;
    509523
    510524    cUsers = 0;
     
    539553        pState->VMMDevMemSize    = rman_get_size(pState->pVMMDevMemRes);
    540554
    541         pState->pMMIOBase       = rman_get_virtual(pState->pVMMDevMemRes);
    542         pState->iVMMDevMemResId = iResId;
     555        pState->pMMIOBase        = rman_get_virtual(pState->pVMMDevMemRes);
     556        pState->iVMMDevMemResId  = iResId;
    543557        if (pState->pMMIOBase)
    544558        {
     
    559573                 * Add IRQ of VMMDev.
    560574                 */
    561                 rc = VBoxGuestFreeBSDAddIRQ(pDevice, pState);
     575                rc = vgdrvFreeBSDAddIRQ(pDevice, pState);
    562576                if (RT_SUCCESS(rc))
    563577                {
     
    565579                     * Configure device cloning.
    566580                     */
    567                     clone_setup(&g_pVBoxGuestFreeBSDClones);
    568                     g_VBoxGuestFreeBSDEHTag = EVENTHANDLER_REGISTER(dev_clone, VBoxGuestFreeBSDClone, 0, 1000);
    569                     if (g_VBoxGuestFreeBSDEHTag)
     581                    clone_setup(&g_pvgdrvFreeBSDClones);
     582                    g_vgdrvFreeBSDEHTag = EVENTHANDLER_REGISTER(dev_clone, vgdrvFreeBSDClone, 0, 1000);
     583                    if (g_vgdrvFreeBSDEHTag)
    570584                    {
    571585                        printf(DEVICE_NAME ": loaded successfully\n");
     
    574588
    575589                    printf(DEVICE_NAME ": EVENTHANDLER_REGISTER(dev_clone,,,) failed\n");
    576                     clone_cleanup(&g_pVBoxGuestFreeBSDClones);
    577                     VBoxGuestFreeBSDRemoveIRQ(pDevice, pState);
     590                    clone_cleanup(&g_pvgdrvFreeBSDClones);
     591                    vgdrvFreeBSDRemoveIRQ(pDevice, pState);
    578592                }
    579593                else
    580                     printf((DEVICE_NAME ":VbgdCommonInitDevExt failed.\n"));
     594                    printf((DEVICE_NAME ": VGDrvCommonInitDevExt failed.\n"));
    581595                VGDrvCommonDeleteDevExt(&g_DevExt);
    582596            }
    583597            else
    584                 printf((DEVICE_NAME ":VBoxGuestFreeBSDAddIRQ failed.\n"));
     598                printf((DEVICE_NAME ": vgdrvFreeBSDAddIRQ failed.\n"));
    585599        }
    586600        else
    587             printf((DEVICE_NAME ":MMIO region setup failed.\n"));
     601            printf((DEVICE_NAME ": MMIO region setup failed.\n"));
    588602    }
    589603    else
    590         printf((DEVICE_NAME ":IOport setup failed.\n"));
     604        printf((DEVICE_NAME ": IOport setup failed.\n"));
    591605
    592606    RTR0Term();
     
    594608}
    595609
    596 static int VBoxGuestFreeBSDProbe(device_t pDevice)
     610static int vgdrvFreeBSDProbe(device_t pDevice)
    597611{
    598612    if ((pci_get_vendor(pDevice) == VMMDEV_VENDORID) && (pci_get_device(pDevice) == VMMDEV_DEVICEID))
     
    602616}
    603617
    604 static device_method_t VBoxGuestFreeBSDMethods[] =
     618static device_method_t vgdrvFreeBSDMethods[] =
    605619{
    606620    /* Device interface. */
    607     DEVMETHOD(device_probe,  VBoxGuestFreeBSDProbe),
    608     DEVMETHOD(device_attach, VBoxGuestFreeBSDAttach),
    609     DEVMETHOD(device_detach, VBoxGuestFreeBSDDetach),
     621    DEVMETHOD(device_probe,  vgdrvFreeBSDProbe),
     622    DEVMETHOD(device_attach, vgdrvFreeBSDAttach),
     623    DEVMETHOD(device_detach, vgdrvFreeBSDDetach),
    610624    {0,0}
    611625};
    612626
    613 static driver_t VBoxGuestFreeBSDDriver =
     627static driver_t vgdrvFreeBSDDriver =
    614628{
    615629    DEVICE_NAME,
    616     VBoxGuestFreeBSDMethods,
     630    vgdrvFreeBSDMethods,
    617631    sizeof(struct VBoxGuestDeviceState),
    618632};
    619633
    620 static devclass_t VBoxGuestFreeBSDClass;
    621 
    622 DRIVER_MODULE(vboxguest, pci, VBoxGuestFreeBSDDriver, VBoxGuestFreeBSDClass, 0, 0);
     634static devclass_t vgdrvFreeBSDClass;
     635
     636DRIVER_MODULE(vboxguest, pci, vgdrvFreeBSDDriver, vgdrvFreeBSDClass, 0, 0);
    623637MODULE_VERSION(vboxguest, 1);
    624638
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-haiku.c

    r58053 r58113  
    7070#include <iprt/heap.h>
    7171
     72
     73/*********************************************************************************************************************************
     74*   Defined Constants And Macros                                                                                                 *
     75*********************************************************************************************************************************/
    7276#define MODULE_NAME VBOXGUEST_MODULE_NAME
    7377
     78
     79/*********************************************************************************************************************************
     80*   Internal Functions                                                                                                           *
     81*********************************************************************************************************************************/
    7482/*
    7583 * IRQ related functions.
    7684 */
    77 static void  VBoxGuestHaikuRemoveIRQ(void *pvState);
    78 static int   VBoxGuestHaikuAddIRQ(void *pvState);
    79 static int32 VBoxGuestHaikuISR(void *pvState);
    80 
    81 /*
    82  * Available functions for kernel drivers.
    83  */
    84 DECLVBGL(int)    VBoxGuestHaikuServiceCall(void *pvSession, unsigned uCmd, void *pvData, size_t cbData, size_t *pcbDataReturned);
    85 DECLVBGL(void *) VBoxGuestHaikuServiceOpen(uint32_t *pu32Version);
    86 DECLVBGL(int)    VBoxGuestHaikuServiceClose(void *pvSession);
    87 DECLVBGL(void *) VBoxGuestIDCOpen(uint32_t *pu32Version);
    88 DECLVBGL(int)    VBoxGuestIDCClose(void *pvSession);
    89 DECLVBGL(int)    VBoxGuestIDCCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned);
    90 
     85static void  vgdrvHaikuRemoveIRQ(void *pvState);
     86static int   vgdrvHaikuAddIRQ(void *pvState);
     87static int32 vgdrvHaikuISR(void *pvState);
     88
     89
     90/*********************************************************************************************************************************
     91*   Global Variables                                                                                                             *
     92*********************************************************************************************************************************/
    9193static status_t std_ops(int32 op, ...);
    9294
     
    9698
    9799/** List of cloned device. Managed by the kernel. */
    98 //static struct clonedevs    *g_pVBoxGuestHaikuClones;
     100//static struct clonedevs    *g_pvgdrvHaikuClones;
    99101/** The dev_clone event handler tag. */
    100 //static eventhandler_tag     g_VBoxGuestHaikuEHTag;
     102//static eventhandler_tag     g_vgdrvHaikuEHTag;
    101103/** selinfo structure used for polling. */
    102104//static struct selinfo       g_SelInfo;
     
    213215 * DEVFS event handler.
    214216 */
    215 static void VBoxGuestHaikuClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)
     217static void vgdrvHaikuClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)
    216218{
    217219    int iUnit;
    218220    int rc;
    219221
    220     Log(("VBoxGuestHaikuClone: pszName=%s ppDev=%p\n", pszName, ppDev));
     222    Log(("vgdrvHaikuClone: pszName=%s ppDev=%p\n", pszName, ppDev));
    221223
    222224    /*
     
    232234    if (iUnit >= 256)
    233235    {
    234         Log(("VBoxGuestHaikuClone: iUnit=%d >= 256 - rejected\n", iUnit));
     236        Log(("vgdrvHaikuClone: iUnit=%d >= 256 - rejected\n", iUnit));
    235237        return;
    236238    }
    237239
    238     Log(("VBoxGuestHaikuClone: pszName=%s iUnit=%d\n", pszName, iUnit));
    239 
    240     rc = clone_create(&g_pVBoxGuestHaikuClones, &g_VBoxGuestHaikuDeviceHooks, &iUnit, ppDev, 0);
    241     Log(("VBoxGuestHaikuClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));
     240    Log(("vgdrvHaikuClone: pszName=%s iUnit=%d\n", pszName, iUnit));
     241
     242    rc = clone_create(&g_pvgdrvHaikuClones, &g_vgdrvHaikuDeviceHooks, &iUnit, ppDev, 0);
     243    Log(("vgdrvHaikuClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));
    242244    if (rc)
    243245    {
    244         *ppDev = make_dev(&g_VBoxGuestHaikuDeviceHooks,
     246        *ppDev = make_dev(&g_vgdrvHaikuDeviceHooks,
    245247                          iUnit,
    246248                          UID_ROOT,
     
    252254            dev_ref(*ppDev);
    253255            (*ppDev)->si_flags |= SI_CHEAPCLONE;
    254             Log(("VBoxGuestHaikuClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
     256            Log(("vgdrvHaikuClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
    255257                 *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
    256258            (*ppDev)->si_drv1 = (*ppDev)->si_drv2 = NULL;
    257259        }
    258260        else
    259         Log(("VBoxGuestHaikuClone: make_dev iUnit=%d failed\n", iUnit));
     261        Log(("vgdrvHaikuClone: make_dev iUnit=%d failed\n", iUnit));
    260262    }
    261263    else
    262     Log(("VBoxGuestHaikuClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
     264    Log(("vgdrvHaikuClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
    263265         *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
    264266}
     
    266268
    267269
    268 static status_t VBoxGuestHaikuDetach(void)
     270static status_t vgdrvHaikuDetach(void)
    269271{
    270272    struct VBoxGuestDeviceState *pState = &sState;
     
    274276
    275277    /*
    276      * Reverse what we did in VBoxGuestHaikuAttach.
     278     * Reverse what we did in vgdrvHaikuAttach.
    277279     */
    278     VBoxGuestHaikuRemoveIRQ(pState);
     280    vgdrvHaikuRemoveIRQ(pState);
    279281
    280282    if (pState->iVMMDevMemAreaId)
     
    303305 * @param   pvState Opaque pointer to the device state.
    304306 */
    305 static int32 VBoxGuestHaikuISR(void *pvState)
    306 {
    307     LogFlow((MODULE_NAME ":VBoxGuestHaikuISR pvState=%p\n", pvState));
     307static int32 vgdrvHaikuISR(void *pvState)
     308{
     309    LogFlow((MODULE_NAME ":vgdrvHaikuISR pvState=%p\n", pvState));
    308310
    309311    bool fOurIRQ = VGDrvCommonISR(&g_DevExt);
     
    316318void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
    317319{
    318     LogFlow((MODULE_NAME ":VGDrvNativeISRMousePollEvent:\n"));
     320    LogFlow(("VGDrvNativeISRMousePollEvent:\n"));
    319321
    320322    status_t err = B_OK;
     
    349351 * @param   pvState  Pointer to the state info structure.
    350352 */
    351 static int VBoxGuestHaikuAddIRQ(void *pvState)
     353static int vgdrvHaikuAddIRQ(void *pvState)
    352354{
    353355    status_t err;
     
    356358    AssertReturn(pState, VERR_INVALID_PARAMETER);
    357359
    358     err = install_io_interrupt_handler(pState->iIrqResId, VBoxGuestHaikuISR, pState,  0);
     360    err = install_io_interrupt_handler(pState->iIrqResId, vgdrvHaikuISR, pState,  0);
    359361    if (err == B_OK)
    360362        return VINF_SUCCESS;
     
    368370 * @param   pvState  Opaque pointer to the state info structure.
    369371 */
    370 static void VBoxGuestHaikuRemoveIRQ(void *pvState)
     372static void vgdrvHaikuRemoveIRQ(void *pvState)
    371373{
    372374    struct VBoxGuestDeviceState *pState = (struct VBoxGuestDeviceState *)pvState;
    373375    AssertPtr(pState);
    374376
    375     remove_io_interrupt_handler(pState->iIrqResId, VBoxGuestHaikuISR, pState);
    376 }
    377 
    378 
    379 static status_t VBoxGuestHaikuAttach(const pci_info *pDevice)
     377    remove_io_interrupt_handler(pState->iIrqResId, vgdrvHaikuISR, pState);
     378}
     379
     380
     381static status_t vgdrvHaikuAttach(const pci_info *pDevice)
    380382{
    381383    status_t status;
    382     int rc = VINF_SUCCESS;
    383     int iResId = 0;
     384    int rc;
     385    int iResId;
    384386    struct VBoxGuestDeviceState *pState = &sState;
    385387    static const char *const     s_apszGroups[] = VBOX_LOGGROUP_NAMES;
     
    396398    if (RT_FAILURE(rc))
    397399    {
    398         /** @todo r=ramshankar: use dprintf here. */
    399         LogFunc(("RTR0Init failed.\n"));
     400        dprintf(MODULE_NAME ": RTR0Init failed: %d\n", rc);
    400401        return ENXIO;
    401402    }
    402403
    403     rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestHaiku");
     404    rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "vgdrvHaiku");
    404405    if (RT_FAILURE(rc))
    405406    {
    406         LogRel(("VBoxGuestHaikuAttach: RTSpinlock create failed. rc=%Rrc\n", rc));
     407        LogRel(("vgdrvHaikuAttach: RTSpinlock create failed. rc=%Rrc\n", rc));
    407408        return ENXIO;
    408409    }
     
    462463                 */
    463464                pState->iIrqResId = pDevice->u.h0.interrupt_line;
    464                 rc = VBoxGuestHaikuAddIRQ(pState);
     465                rc = vgdrvHaikuAddIRQ(pState);
    465466                if (RT_SUCCESS(rc))
    466467                {
     
    469470                }
    470471
    471                 LogRel((MODULE_NAME ":VbgdCommonInitDevExt failed.\n"));
     472                LogRel((MODULE_NAME ": VGDrvCommonInitDevExt failed.\n"));
    472473                VGDrvCommonDeleteDevExt(&g_DevExt);
    473474            }
    474475            else
    475                 LogRel((MODULE_NAME ":VBoxGuestHaikuAddIRQ failed.\n"));
     476                LogRel((MODULE_NAME ": vgdrvHaikuAddIRQ failed.\n"));
    476477        }
    477478        else
    478             LogRel((MODULE_NAME ":MMIO region setup failed.\n"));
     479            LogRel((MODULE_NAME ": MMIO region setup failed.\n"));
    479480    }
    480481    else
    481         LogRel((MODULE_NAME ":IOport setup failed.\n"));
     482        LogRel((MODULE_NAME ": IOport setup failed.\n"));
    482483
    483484    RTR0Term();
     
    486487
    487488
    488 static status_t VBoxGuestHaikuProbe(pci_info *pDevice)
    489 {
    490     if ((pDevice->vendor_id == VMMDEV_VENDORID) && (pDevice->device_id == VMMDEV_DEVICEID))
     489static status_t vgdrvHaikuProbe(pci_info *pDevice)
     490{
     491    if (   pDevice->vendor_id == VMMDEV_VENDORID
     492        && pDevice->device_id == VMMDEV_DEVICEID)
    491493        return B_OK;
    492494
     
    507509    while ((*gPCI->get_nth_pci_info)(ix++, &info) == B_OK)
    508510    {
    509         if (VBoxGuestHaikuProbe(&info) == 0)
     511        if (vgdrvHaikuProbe(&info) == 0)
    510512        {
    511513            /* We found it */
    512             err = VBoxGuestHaikuAttach(&info);
     514            err = vgdrvHaikuAttach(&info);
    513515            return err;
    514516        }
     
    521523void uninit_module(void)
    522524{
    523     VBoxGuestHaikuDetach();
     525    vgdrvHaikuDetach();
    524526    put_module(B_PCI_MODULE_NAME);
    525527}
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-haiku.h

    r58053 r58113  
    224224#endif
    225225
    226 #endif /* ___VBoxGuest_haiku_h */
    227 
     226#endif /* !___VBoxGuest_haiku_h */
     227
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c

    r58089 r58113  
    7272*   Internal Functions                                                                                                           *
    7373*********************************************************************************************************************************/
    74 static void vboxguestLinuxTermPci(struct pci_dev *pPciDev);
    75 static int  vboxguestLinuxModInit(void);
    76 static void vboxguestLinuxModExit(void);
    77 static int  vboxguestLinuxOpen(struct inode *pInode, struct file *pFilp);
    78 static int  vboxguestLinuxRelease(struct inode *pInode, struct file *pFilp);
     74static void vgdrvLinuxTermPci(struct pci_dev *pPciDev);
     75static int  vgdrvLinuxProbePci(struct pci_dev *pPciDev, const struct pci_device_id *id);
     76static int  vgdrvLinuxModInit(void);
     77static void vgdrvLinuxModExit(void);
     78static int  vgdrvLinuxOpen(struct inode *pInode, struct file *pFilp);
     79static int  vgdrvLinuxRelease(struct inode *pInode, struct file *pFilp);
    7980#ifdef HAVE_UNLOCKED_IOCTL
    80 static long vboxguestLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg);
     81static long vgdrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg);
    8182#else
    82 static int  vboxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg);
    83 #endif
    84 static int  vboxguestFAsync(int fd, struct file *pFile, int fOn);
    85 static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt);
    86 static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff);
     83static int  vgdrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg);
     84#endif
     85static int  vgdrvLinuxFAsync(int fd, struct file *pFile, int fOn);
     86static unsigned int vgdrvLinuxPoll(struct file *pFile, poll_table *pPt);
     87static ssize_t vgdrvLinuxRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff);
    8788
    8889
     
    141142{
    142143    owner:          THIS_MODULE,
    143     open:           vboxguestLinuxOpen,
    144     release:        vboxguestLinuxRelease,
     144    open:           vgdrvLinuxOpen,
     145    release:        vgdrvLinuxRelease,
    145146#ifdef HAVE_UNLOCKED_IOCTL
    146     unlocked_ioctl: vboxguestLinuxIOCtl,
     147    unlocked_ioctl: vgdrvLinuxIOCtl,
    147148#else
    148     ioctl:          vboxguestLinuxIOCtl,
    149 #endif
    150     fasync:         vboxguestFAsync,
    151     read:           vboxguestRead,
    152     poll:           vboxguestPoll,
     149    ioctl:          vgdrvLinuxIOCtl,
     150#endif
     151    fasync:         vgdrvLinuxFAsync,
     152    read:           vgdrvLinuxRead,
     153    poll:           vgdrvLinuxPoll,
    153154    llseek:         no_llseek,
    154155};
     
    168169{
    169170    owner:          THIS_MODULE,
    170     open:           vboxguestLinuxOpen,
    171     release:        vboxguestLinuxRelease,
     171    open:           vgdrvLinuxOpen,
     172    release:        vgdrvLinuxRelease,
    172173#ifdef HAVE_UNLOCKED_IOCTL
    173     unlocked_ioctl: vboxguestLinuxIOCtl,
     174    unlocked_ioctl: vgdrvLinuxIOCtl,
    174175#else
    175     ioctl:          vboxguestLinuxIOCtl,
     176    ioctl:          vgdrvLinuxIOCtl,
    176177#endif
    177178};
     
    201202    }
    202203};
     204
    203205MODULE_DEVICE_TABLE(pci, g_VBoxGuestPciId);
    204206
     207/** Structure for registering the PCI driver. */
     208static struct pci_driver  g_PciDriver =
     209{
     210    name:           DRIVER_NAME,
     211    id_table:       g_VBoxGuestPciId,
     212    probe:          vgdrvLinuxProbePci,
     213    remove:         vgdrvLinuxTermPci
     214};
     215
    205216static PVBOXGUESTSESSION        g_pKernelSession = NULL;
     217
     218
    206219
    207220/**
     
    211224 * @param   rc  supdrv error code (SUPDRV_ERR_* defines).
    212225 */
    213 static int vboxguestLinuxConvertToNegErrno(int rc)
     226static int vgdrvLinuxConvertToNegErrno(int rc)
    214227{
    215228    if (   rc > -1000
     
    234247
    235248
    236 
    237249/**
    238250 * Does the PCI detection and init of the device.
     
    240252 * @returns 0 on success, negated errno on failure.
    241253 */
    242 static int vboxguestLinuxProbePci(struct pci_dev *pPciDev,
    243                                   const struct pci_device_id *id)
    244 {
    245     int             rc;
     254static int vgdrvLinuxProbePci(struct pci_dev *pPciDev, const struct pci_device_id *id)
     255{
     256    int rc;
    246257
    247258    NOREF(id);
     
    299310 * Clean up the usage of the PCI device.
    300311 */
    301 static void vboxguestLinuxTermPci(struct pci_dev *pPciDev)
     312static void vgdrvLinuxTermPci(struct pci_dev *pPciDev)
    302313{
    303314    g_pPciDev = NULL;
     
    316327
    317328
    318 /** Structure for registering the PCI driver. */
    319 static struct pci_driver  g_PciDriver =
    320 {
    321     name:           DRIVER_NAME,
    322     id_table:       g_VBoxGuestPciId,
    323     probe:          vboxguestLinuxProbePci,
    324     remove:         vboxguestLinuxTermPci
    325 };
    326 
    327 
    328329/**
    329330 * Interrupt service routine.
     
    337338 */
    338339#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !defined(DOXYGEN_RUNNING)
    339 static irqreturn_t vboxguestLinuxISR(int iIrq, void *pvDevId)
     340static irqreturn_t vgdrvLinuxISR(int iIrq, void *pvDevId)
    340341#else
    341 static irqreturn_t vboxguestLinuxISR(int iIrq, void *pvDevId, struct pt_regs *pRegs)
     342static irqreturn_t vgdrvLinuxISR(int iIrq, void *pvDevId, struct pt_regs *pRegs)
    342343#endif
    343344{
     
    350351 * Registers the ISR and initializes the poll wait queue.
    351352 */
    352 static int __init vboxguestLinuxInitISR(void)
     353static int __init vgdrvLinuxInitISR(void)
    353354{
    354355    int rc;
     
    356357    init_waitqueue_head(&g_PollEventQueue);
    357358    rc = request_irq(g_pPciDev->irq,
    358                      vboxguestLinuxISR,
     359                     vgdrvLinuxISR,
    359360#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
    360361                     IRQF_SHARED,
     
    376377 * Deregisters the ISR.
    377378 */
    378 static void vboxguestLinuxTermISR(void)
     379static void vgdrvLinuxTermISR(void)
    379380{
    380381    free_irq(g_pPciDev->irq, &g_DevExt);
     
    383384
    384385#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    385 /** Calls the kernel IOCtl to report mouse status to the host on behalf of
    386  * our kernel session. */
    387 static int vboxguestLinuxSetMouseStatus(uint32_t fStatus)
     386
     387/**
     388 * Reports the mouse integration status to the host.
     389 *
     390 * Calls the kernel IOCtl to report mouse status to the host on behalf of
     391 * our kernel session.
     392 *
     393 * @param   fStatus     The mouse status to report.
     394 */
     395static int vgdrvLinuxSetMouseStatus(uint32_t fStatus)
    388396{
    389397    return VGDrvCommonIoCtl(VBOXGUEST_IOCTL_SET_MOUSE_STATUS, &g_DevExt, g_pKernelSession, &fStatus, sizeof(fStatus), NULL);
     
    391399
    392400
    393 /** Called when the input device is first opened.  Sets up absolute reporting.
     401/**
     402 * Called when the input device is first opened.
     403 *
     404 * Sets up absolute mouse reporting.
    394405 */
    395406static int vboxguestOpenInputDevice(struct input_dev *pDev)
    396407{
    397     int rc= vboxguestLinuxSetMouseStatus(VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_NEW_PROTOCOL);
     408    int rc = vgdrvLinuxSetMouseStatus(VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_NEW_PROTOCOL);
    398409    if (RT_FAILURE(rc))
    399410        return ENODEV;
     
    403414
    404415
    405 /** Called if all open handles to the device are closed, disables absolute
    406  * reporting. */
     416/**
     417 * Called if all open handles to the input device are closed.
     418 *
     419 * Disables absolute reporting.
     420 */
    407421static void vboxguestCloseInputDevice(struct input_dev *pDev)
    408422{
    409423    NOREF(pDev);
    410     vboxguestLinuxSetMouseStatus(0);
     424    vgdrvLinuxSetMouseStatus(0);
    411425}
    412426
     
    415429 * Creates the kernel input device.
    416430 */
    417 static int __init vboxguestLinuxCreateInputDevice(void)
    418 {
    419     int rc;
    420 
    421     rc = VbglGRAlloc((VMMDevRequestHeader **)&g_pMouseStatusReq,
    422                      sizeof(*g_pMouseStatusReq),
    423                      VMMDevReq_GetMouseStatus);
    424     if (RT_FAILURE(rc))
    425         return -ENOMEM;
    426     g_pInputDevice = input_allocate_device();
    427     if (!g_pInputDevice)
    428     {
     431static int __init vgdrvLinuxCreateInputDevice(void)
     432{
     433    int rc = VbglGRAlloc((VMMDevRequestHeader **)&g_pMouseStatusReq, sizeof(*g_pMouseStatusReq), VMMDevReq_GetMouseStatus);
     434    if (RT_SUCCESS(rc))
     435    {
     436        g_pInputDevice = input_allocate_device();
     437        if (g_pInputDevice)
     438        {
     439            g_pInputDevice->id.bustype = BUS_PCI;
     440            g_pInputDevice->id.vendor  = VMMDEV_VENDORID;
     441            g_pInputDevice->id.product = VMMDEV_DEVICEID;
     442            g_pInputDevice->id.version = VBOX_SHORT_VERSION;
     443            g_pInputDevice->open       = vboxguestOpenInputDevice;
     444            g_pInputDevice->close      = vboxguestCloseInputDevice;
     445# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
     446            g_pInputDevice->cdev.dev   = &g_pPciDev->dev;
     447# else
     448            g_pInputDevice->dev.parent = &g_pPciDev->dev;
     449# endif
     450            rc = input_register_device(g_pInputDevice);
     451            if (rc == 0)
     452            {
     453                /* Do what one of our competitors apparently does as that works. */
     454                ASMBitSet(g_pInputDevice->evbit, EV_ABS);
     455                ASMBitSet(g_pInputDevice->evbit, EV_KEY);
     456# ifdef EV_SYN
     457                ASMBitSet(g_pInputDevice->evbit, EV_SYN);
     458# endif
     459                input_set_abs_params(g_pInputDevice, ABS_X, VMMDEV_MOUSE_RANGE_MIN, VMMDEV_MOUSE_RANGE_MAX, 0, 0);
     460                input_set_abs_params(g_pInputDevice, ABS_Y, VMMDEV_MOUSE_RANGE_MIN, VMMDEV_MOUSE_RANGE_MAX, 0, 0);
     461                ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE);
     462                /** @todo this string should be in a header file somewhere. */
     463                g_pInputDevice->name = "VirtualBox mouse integration";
     464                return 0;
     465            }
     466
     467            input_free_device(g_pInputDevice);
     468        }
     469        else
     470            rc = -ENOMEM;
    429471        VbglGRFree(&g_pMouseStatusReq->header);
    430         return -ENOMEM;
    431     }
    432     g_pInputDevice->id.bustype = BUS_PCI;
    433     g_pInputDevice->id.vendor  = VMMDEV_VENDORID;
    434     g_pInputDevice->id.product = VMMDEV_DEVICEID;
    435     g_pInputDevice->id.version = VBOX_SHORT_VERSION;
    436     g_pInputDevice->open       = vboxguestOpenInputDevice;
    437     g_pInputDevice->close      = vboxguestCloseInputDevice;
    438 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
    439     g_pInputDevice->cdev.dev   = &g_pPciDev->dev;
    440 # else
    441     g_pInputDevice->dev.parent = &g_pPciDev->dev;
    442 # endif
    443     {
    444         int rc = input_register_device(g_pInputDevice);
    445         if (rc)
    446         {
    447             VbglGRFree(&g_pMouseStatusReq->header);
    448             input_free_device(g_pInputDevice);
    449             return rc;
    450         }
    451     }
    452     /* Do what one of our competitors apparently does as that works. */
    453     ASMBitSet(g_pInputDevice->evbit, EV_ABS);
    454     ASMBitSet(g_pInputDevice->evbit, EV_KEY);
    455 # ifdef EV_SYN
    456     ASMBitSet(g_pInputDevice->evbit, EV_SYN);
    457 # endif
    458     input_set_abs_params(g_pInputDevice, ABS_X, VMMDEV_MOUSE_RANGE_MIN,
    459                          VMMDEV_MOUSE_RANGE_MAX, 0, 0);
    460     input_set_abs_params(g_pInputDevice, ABS_Y, VMMDEV_MOUSE_RANGE_MIN,
    461                          VMMDEV_MOUSE_RANGE_MAX, 0, 0);
    462     ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE);
    463     /** @todo this string should be in a header file somewhere. */
    464     g_pInputDevice->name = "VirtualBox mouse integration";
    465     return 0;
     472        g_pMouseStatusReq = NULL;
     473    }
     474    else
     475        rc = -ENOMEM;
     476    return rc;
    466477}
    467478
     
    470481 * Terminates the kernel input device.
    471482 */
    472 static void vboxguestLinuxTermInputDevice(void)
     483static void vgdrvLinuxTermInputDevice(void)
    473484{
    474485    VbglGRFree(&g_pMouseStatusReq->header);
     486    g_pMouseStatusReq = NULL;
     487
    475488    /* See documentation of input_register_device(): input_free_device()
    476489     * should not be called after a device has been registered. */
    477490    input_unregister_device(g_pInputDevice);
    478491}
     492
    479493#endif /* VBOXGUEST_WITH_INPUT_DRIVER */
    480494
     
    485499 * @returns 0 on success, negated errno on failure.
    486500 */
    487 static int __init vboxguestLinuxInitDeviceNodes(void)
    488 {
    489     int rc;
    490 
     501static int __init vgdrvLinuxInitDeviceNodes(void)
     502{
    491503    /*
    492504     * The full feature device node.
    493505     */
    494     rc = misc_register(&g_MiscDevice);
    495     if (rc)
    496     {
    497         LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME, rc));
    498         return rc;
    499     }
    500 
    501     /*
    502      * The device node intended to be accessible by all users.
    503      */
    504     rc = misc_register(&g_MiscDeviceUser);
    505     if (rc)
    506     {
     506    int rc = misc_register(&g_MiscDevice);
     507    if (!rc)
     508    {
     509        /*
     510         * The device node intended to be accessible by all users.
     511         */
     512        rc = misc_register(&g_MiscDeviceUser);
     513        if (!rc)
     514            return 0;
    507515        LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME_USER, rc));
    508516        misc_deregister(&g_MiscDevice);
    509         return rc;
    510     }
    511 
    512     return 0;
     517    }
     518    else
     519        LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME, rc));
     520    return rc;
    513521}
    514522
     
    517525 * Deregisters the device nodes.
    518526 */
    519 static void vboxguestLinuxTermDeviceNodes(void)
     527static void vgdrvLinuxTermDeviceNodes(void)
    520528{
    521529    misc_deregister(&g_MiscDevice);
     
    529537 * @returns appropriate status code.
    530538 */
    531 static int __init vboxguestLinuxModInit(void)
     539static int __init vgdrvLinuxModInit(void)
    532540{
    533541    static const char * const   s_apszGroups[] = VBOX_LOGGROUP_NAMES;
     
    575583         * Register the interrupt service routine for it.
    576584         */
    577         rc = vboxguestLinuxInitISR();
     585        rc = vgdrvLinuxInitISR();
    578586        if (rc >= 0)
    579587        {
     
    611619                     */
    612620#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    613                     rc = vboxguestLinuxCreateInputDevice();
     621                    rc = vgdrvLinuxCreateInputDevice();
    614622                    if (rc >= 0)
    615623                    {
     
    618626                         * Finally, create the device nodes.
    619627                         */
    620                         rc = vboxguestLinuxInitDeviceNodes();
     628                        rc = vgdrvLinuxInitDeviceNodes();
    621629                        if (rc >= 0)
    622630                        {
     
    631639                        /* bail out */
    632640#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    633                         vboxguestLinuxTermInputDevice();
     641                        vgdrvLinuxTermInputDevice();
    634642                    }
    635643                    else
     
    645653            else
    646654            {
    647                 LogRel((DEVICE_NAME ": VbgdCommonInitDevExt failed with rc=%Rrc\n", rc));
     655                LogRel((DEVICE_NAME ": VGDrvCommonInitDevExt failed with rc=%Rrc\n", rc));
    648656                rc = RTErrConvertFromErrno(rc);
    649657            }
    650             vboxguestLinuxTermISR();
     658            vgdrvLinuxTermISR();
    651659        }
    652660    }
     
    667675 * Unload the module.
    668676 */
    669 static void __exit vboxguestLinuxModExit(void)
     677static void __exit vgdrvLinuxModExit(void)
    670678{
    671679    /*
    672680     * Inverse order of init.
    673681     */
    674     vboxguestLinuxTermDeviceNodes();
     682    vgdrvLinuxTermDeviceNodes();
    675683#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    676     vboxguestLinuxTermInputDevice();
     684    vgdrvLinuxTermInputDevice();
    677685#endif
    678686    VGDrvCommonCloseSession(&g_DevExt, g_pKernelSession);
    679687    VGDrvCommonDeleteDevExt(&g_DevExt);
    680     vboxguestLinuxTermISR();
     688    vgdrvLinuxTermISR();
    681689    pci_unregister_driver(&g_PciDriver);
    682690    RTLogDestroy(RTLogRelSetDefaultInstance(NULL));
     
    692700 * @param   pFilp       Associated file pointer.
    693701 */
    694 static int vboxguestLinuxOpen(struct inode *pInode, struct file *pFilp)
     702static int vgdrvLinuxOpen(struct inode *pInode, struct file *pFilp)
    695703{
    696704    int                 rc;
     
    710718    }
    711719
    712     Log(("vboxguestLinuxOpen: g_DevExt=%p pSession=%p rc=%d/%d (pid=%d/%d %s)\n",
    713          &g_DevExt, pSession, rc, vboxguestLinuxConvertToNegErrno(rc),
    714          RTProcSelf(), current->pid, current->comm));
    715     return vboxguestLinuxConvertToNegErrno(rc);
     720    Log(("vgdrvLinuxOpen: g_DevExt=%p pSession=%p rc=%d/%d (pid=%d/%d %s)\n",
     721         &g_DevExt, pSession, rc, vgdrvLinuxConvertToNegErrno(rc), RTProcSelf(), current->pid, current->comm));
     722    return vgdrvLinuxConvertToNegErrno(rc);
    716723}
    717724
     
    723730 * @param   pFilp       Associated file pointer.
    724731 */
    725 static int vboxguestLinuxRelease(struct inode *pInode, struct file *pFilp)
    726 {
    727     Log(("vboxguestLinuxRelease: pFilp=%p pSession=%p pid=%d/%d %s\n",
     732static int vgdrvLinuxRelease(struct inode *pInode, struct file *pFilp)
     733{
     734    Log(("vgdrvLinuxRelease: pFilp=%p pSession=%p pid=%d/%d %s\n",
    728735         pFilp, pFilp->private_data, RTProcSelf(), current->pid, current->comm));
    729736
     
    731738    /* This housekeeping was needed in older kernel versions to ensure that
    732739     * the file pointer didn't get left on the polling queue. */
    733     vboxguestFAsync(-1, pFilp, 0);
     740    vgdrvLinuxFAsync(-1, pFilp, 0);
    734741#endif
    735742    VGDrvCommonCloseSession(&g_DevExt, (PVBOXGUESTSESSION)pFilp->private_data);
     
    748755 */
    749756#ifdef HAVE_UNLOCKED_IOCTL
    750 static long vboxguestLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg)
     757static long vgdrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg)
    751758#else
    752 static int vboxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg)
     759static int vgdrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg)
    753760#endif
    754761{
     
    760767    uint64_t            au64Buf[32/sizeof(uint64_t)];
    761768
    762     Log6(("vboxguestLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p pid=%d/%d\n", pFilp, uCmd, (void *)ulArg, RTProcSelf(), current->pid));
     769    Log6(("vgdrvLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p pid=%d/%d\n", pFilp, uCmd, (void *)ulArg, RTProcSelf(), current->pid));
    763770
    764771    /*
     
    810817        else
    811818        {
    812             Log(("vboxguestLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p failed, rc=%d\n", pFilp, uCmd, (void *)ulArg, rc));
     819            Log(("vgdrvLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p failed, rc=%d\n", pFilp, uCmd, (void *)ulArg, rc));
    813820            rc = -rc; Assert(rc > 0); /* Positive returns == negated VBox error status codes. */
    814821        }
     
    822829        RTMemFree(pvBufFree);
    823830
    824     Log6(("vboxguestLinuxIOCtl: returns %d (pid=%d/%d)\n", rc, RTProcSelf(), current->pid));
     831    Log6(("vgdrvLinuxIOCtl: returns %d (pid=%d/%d)\n", rc, RTProcSelf(), current->pid));
    825832    return rc;
    826833}
     
    836843 * @param   fOn         On/off indicator.
    837844 */
    838 static int vboxguestFAsync(int fd, struct file *pFile, int fOn)
     845static int vgdrvLinuxFAsync(int fd, struct file *pFile, int fOn)
    839846{
    840847    return fasync_helper(fd, pFile, fOn, &g_pFAsyncQueue);
     
    856863 *          interface instead.
    857864 */
    858 static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt)
     865static unsigned int vgdrvLinuxPoll(struct file *pFile, poll_table *pPt)
    859866{
    860867    PVBOXGUESTSESSION   pSession  = (PVBOXGUESTSESSION)pFile->private_data;
     
    880887 * @remarks This is probably not really used as X11 lets the driver do its own
    881888 *          event reading. The poll condition is therefore also cleared when we
    882  *          see VMMDevReq_GetMouseStatus in VbgdCommonIoCtl_VMMRequest.
    883  */
    884 static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff)
     889 *          see VMMDevReq_GetMouseStatus in vgdrvIoCtl_VMMRequest.
     890 */
     891static ssize_t vgdrvLinuxRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff)
    885892{
    886893    PVBOXGUESTSESSION   pSession  = (PVBOXGUESTSESSION)pFile->private_data;
     
    951958
    952959/** log and dbg_log parameter setter. */
    953 static int vboxguestLinuxParamLogGrpSet(const char *pszValue, struct kernel_param *pParam)
     960static int vgdrvLinuxParamLogGrpSet(const char *pszValue, struct kernel_param *pParam)
    954961{
    955962    if (g_fLoggerCreated)
     
    966973
    967974/** log and dbg_log parameter getter. */
    968 static int vboxguestLinuxParamLogGrpGet(char *pszBuf, struct kernel_param *pParam)
     975static int vgdrvLinuxParamLogGrpGet(char *pszBuf, struct kernel_param *pParam)
    969976{
    970977    PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance();
     
    977984
    978985/** log and dbg_log_flags parameter setter. */
    979 static int vboxguestLinuxParamLogFlagsSet(const char *pszValue, struct kernel_param *pParam)
     986static int vgdrvLinuxParamLogFlagsSet(const char *pszValue, struct kernel_param *pParam)
    980987{
    981988    if (g_fLoggerCreated)
     
    991998
    992999/** log and dbg_log_flags parameter getter. */
    993 static int vboxguestLinuxParamLogFlagsGet(char *pszBuf, struct kernel_param *pParam)
     1000static int vgdrvLinuxParamLogFlagsGet(char *pszBuf, struct kernel_param *pParam)
    9941001{
    9951002    PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance();
     
    10021009
    10031010/** log and dbg_log_dest parameter setter. */
    1004 static int vboxguestLinuxParamLogDstSet(const char *pszValue, struct kernel_param *pParam)
     1011static int vgdrvLinuxParamLogDstSet(const char *pszValue, struct kernel_param *pParam)
    10051012{
    10061013    if (g_fLoggerCreated)
     
    10161023
    10171024/** log and dbg_log_dest parameter getter. */
    1018 static int vboxguestLinuxParamLogDstGet(char *pszBuf, struct kernel_param *pParam)
     1025static int vgdrvLinuxParamLogDstGet(char *pszBuf, struct kernel_param *pParam)
    10191026{
    10201027    PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance();
     
    10271034
    10281035/** r3_log_to_host parameter setter. */
    1029 static int vboxguestLinuxParamR3LogToHostSet(const char *pszValue, struct kernel_param *pParam)
     1036static int vgdrvLinuxParamR3LogToHostSet(const char *pszValue, struct kernel_param *pParam)
    10301037{
    10311038    if (    pszValue == NULL
     
    10451052
    10461053/** r3_log_to_host parameter getter. */
    1047 static int vboxguestLinuxParamR3LogToHostGet(char *pszBuf, struct kernel_param *pParam)
     1054static int vgdrvLinuxParamR3LogToHostGet(char *pszBuf, struct kernel_param *pParam)
    10481055{
    10491056    strcpy(pszBuf, g_DevExt.fLoggingEnabled ? "enabled" : "disabled");
     
    10551062 * Define module parameters.
    10561063 */
    1057 module_param_call(log,            vboxguestLinuxParamLogGrpSet,   vboxguestLinuxParamLogGrpGet,   NULL, 0664);
    1058 module_param_call(log_flags,      vboxguestLinuxParamLogFlagsSet, vboxguestLinuxParamLogFlagsGet, NULL, 0664);
    1059 module_param_call(log_dest,       vboxguestLinuxParamLogDstSet,   vboxguestLinuxParamLogDstGet,   NULL, 0664);
     1064module_param_call(log,            vgdrvLinuxParamLogGrpSet,   vgdrvLinuxParamLogGrpGet,   NULL, 0664);
     1065module_param_call(log_flags,      vgdrvLinuxParamLogFlagsSet, vgdrvLinuxParamLogFlagsGet, NULL, 0664);
     1066module_param_call(log_dest,       vgdrvLinuxParamLogDstSet,   vgdrvLinuxParamLogDstGet,   NULL, 0664);
    10601067# ifdef LOG_ENABLED
    1061 module_param_call(dbg_log,        vboxguestLinuxParamLogGrpSet,   vboxguestLinuxParamLogGrpGet,   NULL, 0664);
    1062 module_param_call(dbg_log_flags,  vboxguestLinuxParamLogFlagsSet, vboxguestLinuxParamLogFlagsGet, NULL, 0664);
    1063 module_param_call(dbg_log_dest,   vboxguestLinuxParamLogDstSet,   vboxguestLinuxParamLogDstGet,   NULL, 0664);
     1068module_param_call(dbg_log,        vgdrvLinuxParamLogGrpSet,   vgdrvLinuxParamLogGrpGet,   NULL, 0664);
     1069module_param_call(dbg_log_flags,  vgdrvLinuxParamLogFlagsSet, vgdrvLinuxParamLogFlagsGet, NULL, 0664);
     1070module_param_call(dbg_log_dest,   vgdrvLinuxParamLogDstSet,   vgdrvLinuxParamLogDstGet,   NULL, 0664);
    10641071# endif
    1065 module_param_call(r3_log_to_host, vboxguestLinuxParamR3LogToHostSet, vboxguestLinuxParamR3LogToHostGet, NULL, 0664);
     1072module_param_call(r3_log_to_host, vgdrvLinuxParamR3LogToHostSet, vgdrvLinuxParamR3LogToHostGet, NULL, 0664);
    10661073
    10671074#endif /* 2.6.0 and later */
    10681075
    10691076
    1070 module_init(vboxguestLinuxModInit);
    1071 module_exit(vboxguestLinuxModExit);
     1077module_init(vgdrvLinuxModInit);
     1078module_exit(vgdrvLinuxModExit);
    10721079
    10731080MODULE_AUTHOR(VBOX_VENDOR);
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-os2.cpp

    r58089 r58113  
    109109*   Internal Functions                                                                                                           *
    110110*********************************************************************************************************************************/
    111 static int vboxGuestOS2MapMemory(void);
    112 static VBOXOSTYPE vboxGuestOS2DetectVersion(void);
     111static int vgdrvOS2MapMemory(void);
     112static VBOXOSTYPE vgdrvOS2DetectVersion(void);
    113113
    114114/* in VBoxGuestA-os2.asm */
    115 DECLASM(int) VBoxGuestOS2SetIRQ(uint8_t bIRQ);
     115DECLASM(int) vgdrvOS2DevHlpSetIRQ(uint8_t bIRQ);
    116116
    117117
     
    124124 * @param   pszArgs     Pointer to the device arguments.
    125125 */
    126 DECLASM(int) VBoxGuestOS2Init(const char *pszArgs)
    127 {
    128     Log(("VBoxGuestOS2Init: pszArgs='%s' MMIO=0x%RX32 IOPort=0x%RX16 Int=%#x Bus=%#x Dev=%#x Fun=%d\n",
     126DECLASM(int) vgdrvOS2Init(const char *pszArgs)
     127{
     128    Log(("vgdrvOS2Init: pszArgs='%s' MMIO=0x%RX32 IOPort=0x%RX16 Int=%#x Bus=%#x Dev=%#x Fun=%d\n",
    129129         pszArgs, g_PhysMMIOBase, g_IOPortBase, g_bInterruptLine, g_bPciBusNo, g_bPciDevFunNo >> 3, g_bPciDevFunNo & 7));
    130130
     
    143143         * Map the MMIO memory if found.
    144144         */
    145         rc = vboxGuestOS2MapMemory();
     145        rc = vgdrvOS2MapMemory();
    146146        if (RT_SUCCESS(rc))
    147147        {
     
    153153                                           RTR0MemObjAddress(g_MemMapMMIO),
    154154                                           RTR0MemObjSize(g_MemMapMMIO),
    155                                            vboxGuestOS2DetectVersion(),
     155                                           vgdrvOS2DetectVersion(),
    156156                                           0);
    157157            else
    158                 rc = VGDrvCommonInitDevExt(&g_DevExt, g_IOPortBase, NULL, 0, vboxGuestOS2DetectVersion(), 0);
     158                rc = VGDrvCommonInitDevExt(&g_DevExt, g_IOPortBase, NULL, 0, vgdrvOS2DetectVersion(), 0);
    159159            if (RT_SUCCESS(rc))
    160160            {
     
    170170                    if (g_bInterruptLine)
    171171                    {
    172                         rc = VBoxGuestOS2SetIRQ(g_bInterruptLine);
     172                        rc = vgdrvOS2DevHlpSetIRQ(g_bInterruptLine);
    173173                        if (rc)
    174174                        {
    175                             Log(("VBoxGuestOS2SetIRQ(%d) -> %d\n", g_bInterruptLine, rc));
     175                            Log(("vgdrvOS2DevHlpSetIRQ(%d) -> %d\n", g_bInterruptLine, rc));
    176176                            rc = RTErrConvertFromOS2(rc);
    177177                        }
     
    190190                            g_cchInitText = strlen(&g_szInitText[0]);
    191191                        }
    192                         Log(("VBoxGuestOS2Init: Successfully loaded\n%s", g_szInitText));
     192                        Log(("vgdrvOS2Init: Successfully loaded\n%s", g_szInitText));
    193193                        return VINF_SUCCESS;
    194194                    }
     
    202202            }
    203203            else
    204                 g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxGuest.sys: VBoxGuestOS2InitDevExt failed, rc=%Rrc\n", rc);
     204                g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxGuest.sys: vgdrvOS2InitDevExt failed, rc=%Rrc\n", rc);
    205205
    206206            int rc2 = RTR0MemObjFree(g_MemObjMMIO, true /* fFreeMappings */); AssertRC(rc2);
     
    214214        g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxGuest.sys: RTR0Init failed, rc=%Rrc\n", rc);
    215215
    216     RTLogBackdoorPrintf("VBoxGuestOS2Init: failed rc=%Rrc - %s", rc, &g_szInitText[0]);
     216    RTLogBackdoorPrintf("vgdrvOS2Init: failed rc=%Rrc - %s", rc, &g_szInitText[0]);
    217217    return rc;
    218218}
     
    225225 * @retval  VERR_VERSION_MISMATCH       The VMMDev memory didn't meet our expectations.
    226226 */
    227 static int vboxGuestOS2MapMemory(void)
     227static int vgdrvOS2MapMemory(void)
    228228{
    229229    const RTCCPHYS PhysMMIOBase = g_PhysMMIOBase;
     
    254254    if (RT_FAILURE(rc))
    255255    {
    256         Log(("vboxGuestOS2MapMemory: RTR0MemObjEnterPhys(,%RCp,%zx) -> %Rrc\n",
    257              PhysMMIOBase, cb, rc));
     256        Log(("vgdrvOS2MapMemory: RTR0MemObjEnterPhys(,%RCp,%zx) -> %Rrc\n", PhysMMIOBase, cb, rc));
    258257        return rc;
    259258    }
     
    267266     * anyway for normal RAM.
    268267     */
    269     rc = RTR0MemObjMapKernel(&g_MemMapMMIO, g_MemObjMMIO, (void *)-1, 0,
    270                              RTMEM_PROT_READ | RTMEM_PROT_WRITE);
     268    rc = RTR0MemObjMapKernel(&g_MemMapMMIO, g_MemObjMMIO, (void *)-1, 0, RTMEM_PROT_READ | RTMEM_PROT_WRITE);
    271269    if (RT_SUCCESS(rc))
    272270    {
     
    286284                return VINF_SUCCESS;
    287285
    288             Log(("vboxGuestOS2MapMemory: Actual size %#RX32 (tried %#zx)\n", pVMMDev->u32Size, cb));
     286            Log(("vgdrvOS2MapMemory: Actual size %#RX32 (tried %#zx)\n", pVMMDev->u32Size, cb));
    289287            cb = RT_ALIGN_32(pVMMDev->u32Size, PAGE_SIZE);
    290288
     
    295293            if (RT_SUCCESS(rc))
    296294            {
    297                 rc = RTR0MemObjMapKernel(&g_MemMapMMIO, g_MemObjMMIO, (void *)-1, 0,
    298                                          RTMEM_PROT_READ | RTMEM_PROT_WRITE);
     295                rc = RTR0MemObjMapKernel(&g_MemMapMMIO, g_MemObjMMIO, (void *)-1, 0, RTMEM_PROT_READ | RTMEM_PROT_WRITE);
    299296                if (RT_SUCCESS(rc))
    300297                    return VINF_SUCCESS;
    301298
    302                 Log(("vboxGuestOS2MapMemory: RTR0MemObjMapKernel [%RCp,%zx] -> %Rrc (2nd)\n",
    303                      PhysMMIOBase, cb, rc));
     299                Log(("vgdrvOS2MapMemory: RTR0MemObjMapKernel [%RCp,%zx] -> %Rrc (2nd)\n", PhysMMIOBase, cb, rc));
    304300            }
    305301            else
    306                 Log(("vboxGuestOS2MapMemory: RTR0MemObjEnterPhys(,%RCp,%zx) -> %Rrc (2nd)\n",
    307                      PhysMMIOBase, cb, rc));
     302                Log(("vgdrvOS2MapMemory: RTR0MemObjEnterPhys(,%RCp,%zx) -> %Rrc (2nd)\n", PhysMMIOBase, cb, rc));
    308303        }
    309304        else
    310305        {
    311306            rc = VERR_VERSION_MISMATCH;
    312             LogRel(("vboxGuestOS2MapMemory: Bogus VMMDev memory; u32Version=%RX32 (expected %RX32) u32Size=%RX32\n",
     307            LogRel(("vgdrvOS2MapMemory: Bogus VMMDev memory; u32Version=%RX32 (expected %RX32) u32Size=%RX32\n",
    313308                    pVMMDev->u32Version, VMMDEV_MEMORY_VERSION, pVMMDev->u32Size));
    314309        }
    315310    }
    316311    else
    317         Log(("vboxGuestOS2MapMemory: RTR0MemObjMapKernel [%RCp,%zx] -> %Rrc\n",
    318              PhysMMIOBase, cb, rc));
     312        Log(("vgdrvOS2MapMemory: RTR0MemObjMapKernel [%RCp,%zx] -> %Rrc\n", PhysMMIOBase, cb, rc));
    319313
    320314    int rc2 = RTR0MemObjFree(g_MemObjMMIO, true /* fFreeMappings */); AssertRC(rc2);
     
    325319
    326320/**
    327  * Called fromn VBoxGuestOS2Init to determine which OS/2 version this is.
     321 * Called fromn vgdrvOS2Init to determine which OS/2 version this is.
    328322 *
    329323 * @returns VBox OS/2 type.
    330324 */
    331 static VBOXOSTYPE vboxGuestOS2DetectVersion(void)
     325static VBOXOSTYPE vgdrvOS2DetectVersion(void)
    332326{
    333327    VBOXOSTYPE enmOSType = VBOXOSTYPE_OS2;
     
    349343
    350344
    351 DECLASM(int) VBoxGuestOS2Open(uint16_t sfn)
     345DECLASM(int) vgdrvOS2Open(uint16_t sfn)
    352346{
    353347    int                 rc;
     
    372366    }
    373367
    374     Log(("VBoxGuestOS2Open: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
     368    Log(("vgdrvOS2Open: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
    375369    return rc;
    376370}
    377371
    378372
    379 DECLASM(int) VBoxGuestOS2Close(uint16_t sfn)
    380 {
    381     Log(("VBoxGuestOS2Close: pid=%d sfn=%d\n", (int)RTProcSelf(), sfn));
     373DECLASM(int) vgdrvOS2Close(uint16_t sfn)
     374{
     375    Log(("vgdrvOS2Close: pid=%d sfn=%d\n", (int)RTProcSelf(), sfn));
    382376
    383377    /*
     
    433427
    434428
    435 DECLASM(int) VBoxGuestOS2IOCtlFast(uint16_t sfn, uint8_t iFunction, int32_t *prc)
     429DECLASM(int) vgdrvOS2IOCtlFast(uint16_t sfn, uint8_t iFunction, int32_t *prc)
    436430{
    437431    /*
     
    482476 * @remark  This is called from the 16-bit thunker as well as directly from the 32-bit clients.
    483477 */
    484 DECLASM(int) VBoxGuestOS2IDCService(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned)
     478DECLASM(int) VGDrvOS2IDCService(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned)
    485479{
    486480    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)u32Session;
     
    511505 * @returns Pointer to the session.
    512506 */
    513 DECLASM(PVBOXGUESTSESSION) VBoxGuestOS2IDCConnect(void)
     507DECLASM(PVBOXGUESTSESSION) vgdrvOS2IDCConnect(void)
    514508{
    515509    PVBOXGUESTSESSION pSession;
     
    524518
    525519
    526 DECLASM(int) VBoxGuestOS2IOCtl(uint16_t sfn, uint8_t iCat, uint8_t iFunction, void *pvParm, void *pvData, uint16_t *pcbParm, uint16_t *pcbData)
     520DECLASM(int) vgdrvOS2IOCtl(uint16_t sfn, uint8_t iCat, uint8_t iFunction, void *pvParm, void *pvData,
     521                           uint16_t *pcbParm, uint16_t *pcbData)
    527522{
    528523    /*
     
    560555    if (RT_LIKELY(iCat == VBOXGUEST_IOCTL_CATEGORY))
    561556    {
    562         Log(("VBoxGuestOS2IOCtl: pSession=%p iFunction=%#x pvParm=%p pvData=%p *pcbParm=%d *pcbData=%d\n", pSession, iFunction, pvParm, pvData, *pcbParm, *pcbData));
     557        Log(("vgdrvOS2IOCtl: pSession=%p iFunction=%#x pvParm=%p pvData=%p *pcbParm=%d *pcbData=%d\n", pSession, iFunction, pvParm, pvData, *pcbParm, *pcbData));
    563558        Assert(pvParm || !*pcbData);
    564559        Assert(pvData);
     
    619614#endif
    620615
    621         Log2(("VBoxGuestOS2IOCtl: returns VINF_SUCCESS / %d\n", rc));
     616        Log2(("vgdrvOS2IOCtl: returns VINF_SUCCESS / %d\n", rc));
    622617        return VINF_SUCCESS;
    623618    }
     
    631626 * @returns true if it's our interrupt, false it isn't.
    632627 */
    633 DECLASM(bool) VBoxGuestOS2ISR(void)
    634 {
    635     Log(("VBoxGuestOS2ISR\n"));
     628DECLASM(bool) vgdrvOS2ISR(void)
     629{
     630    Log(("vgdrvOS2ISR\n"));
    636631
    637632    return VGDrvCommonISR(&g_DevExt);
     
    656651 * @param   cbChars     Number of bytes in the character array pointed to by pachChars.
    657652 */
    658 static DECLCALLBACK(size_t) vboxGuestNativeLogOutput(void *pvArg, const char *pachChars, size_t cbChars)
     653static DECLCALLBACK(size_t) vgdrvOS2LogOutput(void *pvArg, const char *pachChars, size_t cbChars)
    659654{
    660655    size_t cchWritten = 0;
     
    684679
    685680    va_start(va, pszFormat);
    686     int cch = RTLogFormatV(vboxGuestNativeLogOutput, NULL, pszFormat, va);
     681    int cch = RTLogFormatV(vgdrvOS2LogOutput, NULL, pszFormat, va);
    687682    va_end(va);
    688683
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c

    r58053 r58113  
    6565*   Internal Functions                                                                                                           *
    6666*********************************************************************************************************************************/
    67 static int VBoxGuestSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred);
    68 static int VBoxGuestSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred);
    69 static int VBoxGuestSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred);
    70 static int VBoxGuestSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred);
    71 static int VBoxGuestSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal);
    72 static int VBoxGuestSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead);
    73 
    74 static int VBoxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult);
    75 static int VBoxGuestSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd);
    76 static int VBoxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd);
    77 static int VBoxGuestSolarisQuiesce(dev_info_t *pDip);
    78 
    79 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip);
    80 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip);
    81 static uint_t VBoxGuestSolarisISR(caddr_t Arg);
     67static int vgdrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred);
     68static int vgdrvSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred);
     69static int vgdrvSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred);
     70static int vgdrvSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred);
     71static int vgdrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal);
     72static int vgdrvSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead);
     73
     74static int vgdrvSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult);
     75static int vgdrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd);
     76static int vgdrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd);
     77static int vgdrvSolarisQuiesce(dev_info_t *pDip);
     78
     79static int vgdrvSolarisAddIRQ(dev_info_t *pDip);
     80static void vgdrvSolarisRemoveIRQ(dev_info_t *pDip);
     81static uint_t vgdrvSolarisISR(caddr_t Arg);
    8282
    8383
     
    8888 * cb_ops: for drivers that support char/block entry points
    8989 */
    90 static struct cb_ops g_VBoxGuestSolarisCbOps =
    91 {
    92     VBoxGuestSolarisOpen,
    93     VBoxGuestSolarisClose,
     90static struct cb_ops g_vgdrvSolarisCbOps =
     91{
     92    vgdrvSolarisOpen,
     93    vgdrvSolarisClose,
    9494    nodev,                  /* b strategy */
    9595    nodev,                  /* b dump */
    9696    nodev,                  /* b print */
    97     VBoxGuestSolarisRead,
    98     VBoxGuestSolarisWrite,
    99     VBoxGuestSolarisIOCtl,
     97    vgdrvSolarisRead,
     98    vgdrvSolarisWrite,
     99    vgdrvSolarisIOCtl,
    100100    nodev,                  /* c devmap */
    101101    nodev,                  /* c mmap */
    102102    nodev,                  /* c segmap */
    103     VBoxGuestSolarisPoll,
     103    vgdrvSolarisPoll,
    104104    ddi_prop_op,            /* property ops */
    105105    NULL,                   /* streamtab  */
     
    111111 * dev_ops: for driver device operations
    112112 */
    113 static struct dev_ops g_VBoxGuestSolarisDevOps =
     113static struct dev_ops g_vgdrvSolarisDevOps =
    114114{
    115115    DEVO_REV,               /* driver build revision */
    116116    0,                      /* ref count */
    117     VBoxGuestSolarisGetInfo,
     117    vgdrvSolarisGetInfo,
    118118    nulldev,                /* identify */
    119119    nulldev,                /* probe */
    120     VBoxGuestSolarisAttach,
    121     VBoxGuestSolarisDetach,
     120    vgdrvSolarisAttach,
     121    vgdrvSolarisDetach,
    122122    nodev,                  /* reset */
    123     &g_VBoxGuestSolarisCbOps,
     123    &g_vgdrvSolarisCbOps,
    124124    (struct bus_ops *)0,
    125125    nodev,                  /* power */
    126     VBoxGuestSolarisQuiesce
     126    vgdrvSolarisQuiesce
    127127};
    128128
     
    130130 * modldrv: export driver specifics to the kernel
    131131 */
    132 static struct modldrv g_VBoxGuestSolarisModule =
     132static struct modldrv g_vgdrvSolarisModule =
    133133{
    134134    &mod_driverops,         /* extern from kernel */
    135135    DEVICE_DESC " " VBOX_VERSION_STRING "r" RT_XSTR(VBOX_SVN_REV),
    136     &g_VBoxGuestSolarisDevOps
     136    &g_vgdrvSolarisDevOps
    137137};
    138138
     
    140140 * modlinkage: export install/remove/info to the kernel
    141141 */
    142 static struct modlinkage g_VBoxGuestSolarisModLinkage =
     142static struct modlinkage g_vgdrvSolarisModLinkage =
    143143{
    144144    MODREV_1,               /* loadable module system revision */
    145     &g_VBoxGuestSolarisModule,
     145    &g_vgdrvSolarisModule,
    146146    NULL                    /* terminate array of linkage structures */
    147147};
     
    165165static dev_info_t          *g_pDip = NULL;
    166166/** Opaque pointer to file-descriptor states */
    167 static void                *g_pVBoxGuestSolarisState = NULL;
     167static void                *g_pvgdrvSolarisState = NULL;
    168168/** Device extention & session data association structure. */
    169169static VBOXGUESTDEVEXT      g_DevExt;
     
    219219         * Prevent module autounloading.
    220220         */
    221         modctl_t *pModCtl = mod_getctl(&g_VBoxGuestSolarisModLinkage);
     221        modctl_t *pModCtl = mod_getctl(&g_vgdrvSolarisModLinkage);
    222222        if (pModCtl)
    223223            pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD;
    224224        else
    225             LogRel((DEVICE_NAME ":failed to disable autounloading!\n"));
    226 
    227         rc = ddi_soft_state_init(&g_pVBoxGuestSolarisState, sizeof(vboxguest_state_t), 1);
     225            LogRel((DEVICE_NAME ": failed to disable autounloading!\n"));
     226
     227        rc = ddi_soft_state_init(&g_pvgdrvSolarisState, sizeof(vboxguest_state_t), 1);
    228228        if (!rc)
    229229        {
    230             rc = mod_install(&g_VBoxGuestSolarisModLinkage);
     230            rc = mod_install(&g_vgdrvSolarisModLinkage);
    231231            if (rc)
    232                 ddi_soft_state_fini(&g_pVBoxGuestSolarisState);
     232                ddi_soft_state_fini(&g_pvgdrvSolarisState);
    233233        }
    234234    }
     
    246246{
    247247    LogFlow((DEVICE_NAME ":_fini\n"));
    248     int rc = mod_remove(&g_VBoxGuestSolarisModLinkage);
     248    int rc = mod_remove(&g_vgdrvSolarisModLinkage);
    249249    if (!rc)
    250         ddi_soft_state_fini(&g_pVBoxGuestSolarisState);
     250        ddi_soft_state_fini(&g_pvgdrvSolarisState);
    251251
    252252    RTLogDestroy(RTLogRelSetDefaultInstance(NULL));
     
    265265{
    266266    LogFlow((DEVICE_NAME ":_info\n"));
    267     return mod_info(&g_VBoxGuestSolarisModLinkage, pModInfo);
     267    return mod_info(&g_vgdrvSolarisModLinkage, pModInfo);
    268268}
    269269
     
    277277 * @return  corresponding solaris error code.
    278278 */
    279 static int VBoxGuestSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd)
    280 {
    281     LogFlow((DEVICE_NAME "::Attach\n"));
     279static int vgdrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd)
     280{
     281    LogFlow(("vgdrvSolarisAttach:\n"));
    282282    switch (enmCmd)
    283283    {
     
    286286            if (g_pDip)
    287287            {
    288                 LogRel((DEVICE_NAME "::Attach: Only one instance supported.\n"));
     288                LogRel(("vgdrvSolarisAttach: Only one instance supported.\n"));
    289289                return DDI_FAILURE;
    290290            }
     
    325325                             * Add IRQ of VMMDev.
    326326                             */
    327                             rc = VBoxGuestSolarisAddIRQ(pDip);
     327                            rc = vgdrvSolarisAddIRQ(pDip);
    328328                            if (rc == DDI_SUCCESS)
    329329                            {
     
    352352                                }
    353353                                else
    354                                     LogRel((DEVICE_NAME "::Attach: VbgdCommonInitDevExt failed.\n"));
    355                                 VBoxGuestSolarisRemoveIRQ(pDip);
     354                                    LogRel((DEVICE_NAME "::Attach: VGDrvCommonInitDevExt failed.\n"));
     355                                vgdrvSolarisRemoveIRQ(pDip);
    356356                            }
    357357                            else
    358                                 LogRel((DEVICE_NAME "::Attach: VBoxGuestSolarisAddIRQ failed.\n"));
     358                                LogRel((DEVICE_NAME "::Attach: vgdrvSolarisAddIRQ failed.\n"));
    359359                            ddi_regs_map_free(&g_PciMMIOHandle);
    360360                        }
     
    395395 * @return  corresponding solaris error code.
    396396 */
    397 static int VBoxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)
    398 {
    399     LogFlow((DEVICE_NAME "::Detach\n"));
     397static int vgdrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)
     398{
     399    LogFlow(("vgdrvSolarisDetach:\n"));
    400400    switch (enmCmd)
    401401    {
    402402        case DDI_DETACH:
    403403        {
    404             VBoxGuestSolarisRemoveIRQ(pDip);
     404            vgdrvSolarisRemoveIRQ(pDip);
    405405            ddi_regs_map_free(&g_PciIOHandle);
    406406            ddi_regs_map_free(&g_PciMMIOHandle);
     
    431431 * @return  corresponding solaris error code.
    432432 */
    433 static int VBoxGuestSolarisQuiesce(dev_info_t *pDip)
     433static int vgdrvSolarisQuiesce(dev_info_t *pDip)
    434434{
    435435    for (int i = 0; i < g_cIntrAllocated; i++)
     
    456456 * @return  corresponding solaris error code.
    457457 */
    458 static int VBoxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult)
    459 {
    460     LogFlow((DEVICE_NAME "::GetInfo\n"));
     458static int vgdrvSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult)
     459{
     460    LogFlow(("vgdrvSolarisGetInfo:\n"));
    461461
    462462    int rc = DDI_SUCCESS;
     
    484484 * User context entry points
    485485 */
    486 static int VBoxGuestSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred)
     486static int vgdrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred)
    487487{
    488488    int                 rc;
    489489    PVBOXGUESTSESSION   pSession = NULL;
    490490
    491     LogFlow((DEVICE_NAME "::Open\n"));
     491    LogFlow(("vgdrvSolarisOpen:\n"));
    492492
    493493    /*
     
    501501    for (iOpenInstance = 0; iOpenInstance < 4096; iOpenInstance++)
    502502    {
    503         if (    !ddi_get_soft_state(g_pVBoxGuestSolarisState, iOpenInstance) /* faster */
    504             &&  ddi_soft_state_zalloc(g_pVBoxGuestSolarisState, iOpenInstance) == DDI_SUCCESS)
    505         {
    506             pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, iOpenInstance);
     503        if (    !ddi_get_soft_state(g_pvgdrvSolarisState, iOpenInstance) /* faster */
     504            &&  ddi_soft_state_zalloc(g_pvgdrvSolarisState, iOpenInstance) == DDI_SUCCESS)
     505        {
     506            pState = ddi_get_soft_state(g_pvgdrvSolarisState, iOpenInstance);
    507507            break;
    508508        }
     
    510510    if (!pState)
    511511    {
    512         Log((DEVICE_NAME "::Open: too many open instances."));
     512        Log(("vgdrvSolarisOpen: too many open instances."));
    513513        return ENXIO;
    514514    }
     
    523523        pState->pSession = pSession;
    524524        *pDev = makedevice(getmajor(*pDev), iOpenInstance);
    525         Log((DEVICE_NAME "::Open: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf()));
     525        Log(("vgdrvSolarisOpen: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf()));
    526526        return 0;
    527527    }
    528528
    529529    /* Failed, clean up. */
    530     ddi_soft_state_free(g_pVBoxGuestSolarisState, iOpenInstance);
    531 
    532     LogRel((DEVICE_NAME "::Open: VbgdCommonCreateUserSession failed. rc=%d\n", rc));
     530    ddi_soft_state_free(g_pvgdrvSolarisState, iOpenInstance);
     531
     532    LogRel((DEVICE_NAME "::Open: VGDrvCommonCreateUserSession failed. rc=%d\n", rc));
    533533    return EFAULT;
    534534}
    535535
    536536
    537 static int VBoxGuestSolarisClose(dev_t Dev, int flag, int fType, cred_t *pCred)
    538 {
    539     LogFlow((DEVICE_NAME "::Close pid=%d\n", (int)RTProcSelf()));
     537static int vgdrvSolarisClose(dev_t Dev, int flag, int fType, cred_t *pCred)
     538{
     539    LogFlow(("vgdrvSolarisClose: pid=%d\n", (int)RTProcSelf()));
    540540
    541541    PVBOXGUESTSESSION pSession = NULL;
    542     vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev));
     542    vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev));
    543543    if (!pState)
    544544    {
    545         Log((DEVICE_NAME "::Close: failed to get pState.\n"));
     545        Log(("vgdrvSolarisClose: failed to get pState.\n"));
    546546        return EFAULT;
    547547    }
     
    550550    pSession = pState->pSession;
    551551    pState->pSession = NULL;
    552     Log((DEVICE_NAME "::Close: pSession=%p pState=%p\n", pSession, pState));
    553     ddi_soft_state_free(g_pVBoxGuestSolarisState, getminor(Dev));
     552    Log(("vgdrvSolarisClose: pSession=%p pState=%p\n", pSession, pState));
     553    ddi_soft_state_free(g_pvgdrvSolarisState, getminor(Dev));
    554554    if (!pSession)
    555555    {
    556         Log((DEVICE_NAME "::Close: failed to get pSession.\n"));
     556        Log(("vgdrvSolarisClose: failed to get pSession.\n"));
    557557        return EFAULT;
    558558    }
     
    566566
    567567
    568 static int VBoxGuestSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred)
     568static int vgdrvSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred)
    569569{
    570570    LogFlow((DEVICE_NAME "::Read\n"));
    571571
    572     vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev));
     572    vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev));
    573573    if (!pState)
    574574    {
     
    586586
    587587
    588 static int VBoxGuestSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred)
    589 {
    590     LogFlow((DEVICE_NAME "::Write\n"));
     588static int vgdrvSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred)
     589{
     590    LogFlow(("vgdrvSolarisWrite:\n"));
    591591    return 0;
    592592}
     
    614614 * @return  corresponding solaris error code.
    615615 */
    616 static int VBoxGuestSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal)
    617 {
    618     LogFlow((DEVICE_NAME ":VBoxGuestSolarisIOCtl\n"));
     616static int vgdrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal)
     617{
     618    LogFlow(("vgdrvSolarisIOCtl: iCmd=%#x\n", Cmd));
    619619
    620620    /*
    621621     * Get the session from the soft state item.
    622622     */
    623     vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev));
     623    vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev));
    624624    if (!pState)
    625625    {
     
    690690        }
    691691    }
    692     Log((DEVICE_NAME "::IOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));
     692    Log(("vgdrvSolarisIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));
    693693
    694694    /*
     
    723723         * which are not really failures that require logging.
    724724         */
    725         Log((DEVICE_NAME "::IOCtl: VbgdCommonIoCtl failed. Cmd=%#x rc=%d\n", Cmd, rc));
     725        Log(("vgdrvSolarisIOCtl: VGDrvCommonIoCtl failed. Cmd=%#x rc=%d\n", Cmd, rc));
    726726        if (rc == VERR_PERMISSION_DENIED)   /* RTErrConvertToErrno() below will ring-0 debug assert if we don't do this. */
    727727            rc = VERR_ACCESS_DENIED;
     
    735735
    736736
    737 static int VBoxGuestSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead)
    738 {
    739     LogFlow((DEVICE_NAME "::Poll: fEvents=%d fAnyYet=%d\n", fEvents, fAnyYet));
    740 
    741     vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev));
     737static int vgdrvSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead)
     738{
     739    LogFlow(("vgdrvSolarisPoll: fEvents=%d fAnyYet=%d\n", fEvents, fAnyYet));
     740
     741    vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev));
    742742    if (RT_LIKELY(pState))
    743743    {
     
    760760    else
    761761    {
    762         Log((DEVICE_NAME "::Poll: no state data for %d\n", getminor(Dev)));
     762        Log(("vgdrvSolarisPoll: no state data for %d\n", getminor(Dev)));
    763763        return EINVAL;
    764764    }
     
    772772 * @param   pDip     Pointer to the device info structure.
    773773 */
    774 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip)
    775 {
    776     LogFlow((DEVICE_NAME "::AddIRQ: pDip=%p\n", pDip));
     774static int vgdrvSolarisAddIRQ(dev_info_t *pDip)
     775{
     776    LogFlow(("vgdrvSolarisAddIRQ: pDip=%p\n", pDip));
    777777
    778778    int IntrType = 0;
     
    813813                                for (int i = 0; i < IntrAllocated; i++)
    814814                                {
    815                                     rc = ddi_intr_add_handler(g_pIntr[i], (ddi_intr_handler_t *)VBoxGuestSolarisISR,
     815                                    rc = ddi_intr_add_handler(g_pIntr[i], (ddi_intr_handler_t *)vgdrvSolarisISR,
    816816                                                              NULL /* pvArg1 */, NULL /* pvArg2 */);
    817817                                    if (rc == DDI_SUCCESS)
     
    867867 * @param   pDip     Pointer to the device info structure.
    868868 */
    869 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip)
    870 {
    871     LogFlow((DEVICE_NAME "::RemoveIRQ:\n"));
     869static void vgdrvSolarisRemoveIRQ(dev_info_t *pDip)
     870{
     871    LogFlow(("vgdrvSolarisRemoveIRQ:\n"));
    872872
    873873    for (int i = 0; i < g_cIntrAllocated; i++)
     
    893893 * @returns DDI_INTR_CLAIMED if it's our interrupt, DDI_INTR_UNCLAIMED if it isn't.
    894894 */
    895 static uint_t VBoxGuestSolarisISR(caddr_t Arg)
    896 {
    897     LogFlow((DEVICE_NAME "::ISR:\n"));
     895static uint_t vgdrvSolarisISR(caddr_t Arg)
     896{
     897    LogFlow(("vgdrvSolarisISR:\n"));
    898898
    899899    mutex_enter(&g_IrqMtx);
     
    907907void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
    908908{
    909     LogFlow((DEVICE_NAME "::VGDrvNativeISRMousePollEvent:\n"));
     909    LogFlow(("VGDrvNativeISRMousePollEvent:\n"));
    910910
    911911    /*
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win-legacy.cpp

    r57358 r58113  
    4141*********************************************************************************************************************************/
    4242RT_C_DECLS_BEGIN
    43 static NTSTATUS vbgdNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber);
     43static NTSTATUS vgdrvNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber);
    4444RT_C_DECLS_END
    4545
    4646#ifdef ALLOC_PRAGMA
    47 # pragma alloc_text(INIT, vbgdNt4CreateDevice)
    48 # pragma alloc_text(INIT, vbgdNt4FindPciDevice)
     47# pragma alloc_text(INIT, vgdrvNt4CreateDevice)
     48# pragma alloc_text(INIT, vgdrvNt4FindPciDevice)
    4949#endif
    5050
     
    5959 * @param   pRegPath        The driver registry path.
    6060 */
    61 NTSTATUS vbgdNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)
     61NTSTATUS vgdrvNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)
    6262{
    63     Log(("VBoxGuest::vbgdNt4CreateDevice: pDrvObj=%p, pDevObj=%p, pRegPath=%p\n", pDrvObj, pDevObj, pRegPath));
     63    Log(("vgdrvNt4CreateDevice: pDrvObj=%p, pDevObj=%p, pRegPath=%p\n", pDrvObj, pDevObj, pRegPath));
    6464
    6565    /*
     
    6868    ULONG uBusNumber;
    6969    PCI_SLOT_NUMBER SlotNumber;
    70     NTSTATUS rc = vbgdNt4FindPciDevice(&uBusNumber, &SlotNumber);
     70    NTSTATUS rc = vgdrvNt4FindPciDevice(&uBusNumber, &SlotNumber);
    7171    if (NT_ERROR(rc))
    7272    {
    73         Log(("VBoxGuest::vbgdNt4CreateDevice: Device not found!\n"));
     73        Log(("vgdrvNt4CreateDevice: Device not found!\n"));
    7474        return rc;
    7575    }
     
    8484    if (NT_SUCCESS(rc))
    8585    {
    86         Log(("VBoxGuest::vbgdNt4CreateDevice: Device created\n"));
     86        Log(("vgdrvNt4CreateDevice: Device created\n"));
    8787
    8888        UNICODE_STRING DosName;
     
    9191        if (NT_SUCCESS(rc))
    9292        {
    93             Log(("VBoxGuest::vbgdNt4CreateDevice: Symlink created\n"));
     93            Log(("vgdrvNt4CreateDevice: Symlink created\n"));
    9494
    9595            /*
    9696             * Setup the device extension.
    9797             */
    98             Log(("VBoxGuest::vbgdNt4CreateDevice: Setting up device extension ...\n"));
     98            Log(("vgdrvNt4CreateDevice: Setting up device extension ...\n"));
    9999
    100100            PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDeviceObject->DeviceExtension;
    101101            RT_ZERO(*pDevExt);
    102102
    103             Log(("VBoxGuest::vbgdNt4CreateDevice: Device extension created\n"));
     103            Log(("vgdrvNt4CreateDevice: Device extension created\n"));
    104104
    105105            /* Store a reference to ourself. */
     
    117117            if (NT_SUCCESS(rc))
    118118            {
    119                 rc = vbgdNtInit(pDrvObj, pDeviceObject, pRegPath);
     119                rc = vgdrvNtInit(pDrvObj, pDeviceObject, pRegPath);
    120120                if (NT_SUCCESS(rc))
    121121                {
    122                     Log(("VBoxGuest::vbgdNt4CreateDevice: Returning rc = 0x%x (succcess)\n", rc));
     122                    Log(("vgdrvNt4CreateDevice: Returning rc = 0x%x (succcess)\n", rc));
    123123                    return rc;
    124124                }
     
    129129        }
    130130        else
    131             Log(("VBoxGuest::vbgdNt4CreateDevice: IoCreateSymbolicLink failed with rc = %#x\n", rc));
     131            Log(("vgdrvNt4CreateDevice: IoCreateSymbolicLink failed with rc = %#x\n", rc));
    132132        IoDeleteDevice(pDeviceObject);
    133133    }
    134134    else
    135         Log(("VBoxGuest::vbgdNt4CreateDevice: IoCreateDevice failed with rc = %#x\n", rc));
    136     Log(("VBoxGuest::vbgdNt4CreateDevice: Returning rc = 0x%x\n", rc));
     135        Log(("vgdrvNt4CreateDevice: IoCreateDevice failed with rc = %#x\n", rc));
     136    Log(("vgdrvNt4CreateDevice: Returning rc = 0x%x\n", rc));
    137137    return rc;
    138138}
     
    147147 * @param   pSlotNumber     Where to return the slot number on success.
    148148 */
    149 static NTSTATUS vbgdNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber)
     149static NTSTATUS vgdrvNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber)
    150150{
    151     Log(("VBoxGuest::vbgdNt4FindPciDevice\n"));
     151    Log(("vgdrvNt4FindPciDevice\n"));
    152152
    153153    PCI_SLOT_NUMBER SlotNumber;
     
    186186
    187187                /* Hooray, we've found it! */
    188                 Log(("VBoxGuest::vbgdNt4FindPciDevice: Device found!\n"));
     188                Log(("vgdrvNt4FindPciDevice: Device found!\n"));
    189189
    190190                *pulBusNumber = ulBusNumber;
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win-pnp.cpp

    r58053 r58113  
    3232*********************************************************************************************************************************/
    3333RT_C_DECLS_BEGIN
    34 static NTSTATUS vbgdNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict);
    35 static NTSTATUS vbgdNtPnPIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);
    36 static VOID     vbgdNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList);
     34static NTSTATUS vgdrvNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict);
     35static NTSTATUS vgdrvNtPnPIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);
     36static VOID     vgdrvNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList);
    3737RT_C_DECLS_END
    3838
    3939#ifdef ALLOC_PRAGMA
    40 # pragma alloc_text(PAGE, vbgdNtPnP)
    41 # pragma alloc_text(PAGE, vbgdNtPower)
    42 # pragma alloc_text(PAGE, vbgdNtSendIrpSynchronously)
    43 # pragma alloc_text(PAGE, vbgdNtShowDeviceResources)
     40# pragma alloc_text(PAGE, vgdrvNtPnP)
     41# pragma alloc_text(PAGE, vgdrvNtPower)
     42# pragma alloc_text(PAGE, vgdrvNtSendIrpSynchronously)
     43# pragma alloc_text(PAGE, vgdrvNtShowDeviceResources)
    4444#endif
    4545
     
    4848 * Irp completion routine for PnP Irps we send.
    4949 *
     50 * @returns NT status code.
    5051 * @param   pDevObj   Device object.
    5152 * @param   pIrp      Request packet.
    5253 * @param   pEvent    Semaphore.
    53  * @return   NT status code
    54  */
    55 static NTSTATUS vbgdNtPnpIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent)
     54 */
     55static NTSTATUS vgdrvNtPnpIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent)
    5656{
    5757    KeSetEvent(pEvent, 0, FALSE);
     
    6363 * Helper to send a PnP IRP and wait until it's done.
    6464 *
     65 * @returns NT status code.
    6566 * @param    pDevObj    Device object.
    6667 * @param    pIrp       Request packet.
    6768 * @param    fStrict    When set, returns an error if the IRP gives an error.
    68  * @return   NT status code
    69  */
    70 static NTSTATUS vbgdNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict)
     69 */
     70static NTSTATUS vgdrvNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict)
    7171{
    7272    KEVENT Event;
     
    7575
    7676    IoCopyCurrentIrpStackLocationToNext(pIrp);
    77     IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE)vbgdNtPnpIrpComplete,
    78                            &Event, TRUE, TRUE, TRUE);
     77    IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE)vgdrvNtPnpIrpComplete, &Event, TRUE, TRUE, TRUE);
    7978
    8079    NTSTATUS rc = IoCallDriver(pDevObj, pIrp);
     
    8685    }
    8786
    88     if (!fStrict
     87    if (   !fStrict
    8988        && (rc == STATUS_NOT_SUPPORTED || rc == STATUS_INVALID_DEVICE_REQUEST))
    9089    {
     
    9291    }
    9392
    94     Log(("VBoxGuest::vbgdNtSendIrpSynchronously: Returning 0x%x\n", rc));
     93    Log(("vgdrvNtSendIrpSynchronously: Returning 0x%x\n", rc));
    9594    return rc;
    9695}
     
    103102 * @param  pIrp       Request packet.
    104103 */
    105 NTSTATUS vbgdNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     104NTSTATUS vgdrvNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    106105{
    107106    PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
     
    136135        "IRP_MN_SURPRISE_REMOVAL",
    137136    };
    138     Log(("VBoxGuest::vbgdNtGuestPnp: MinorFunction: %s\n",
     137    Log(("vgdrvNtPnP: MinorFunction: %s\n",
    139138         pStack->MinorFunction < RT_ELEMENTS(s_apszFnctName) ? s_apszFnctName[pStack->MinorFunction] : "Unknown"));
    140139#endif
     
    145144        case IRP_MN_START_DEVICE:
    146145        {
    147             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE\n"));
     146            Log(("vgdrvNtPnP: START_DEVICE\n"));
    148147
    149148            /* This must be handled first by the lower driver. */
    150             rc = vbgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
     149            rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
    151150
    152151            if (   NT_SUCCESS(rc)
    153152                && NT_SUCCESS(pIrp->IoStatus.Status))
    154153            {
    155                 Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE: pStack->Parameters.StartDevice.AllocatedResources = %p\n",
     154                Log(("vgdrvNtPnP: START_DEVICE: pStack->Parameters.StartDevice.AllocatedResources = %p\n",
    156155                     pStack->Parameters.StartDevice.AllocatedResources));
    157156
    158                 if (!pStack->Parameters.StartDevice.AllocatedResources)
     157                if (pStack->Parameters.StartDevice.AllocatedResources)
     158                    rc = vgdrvNtInit(pDevObj, pIrp);
     159                else
    159160                {
    160                     Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE: No resources, pDevExt = %p, nextLowerDriver = %p!\n",
     161                    Log(("vgdrvNtPnP: START_DEVICE: No resources, pDevExt = %p, nextLowerDriver = %p!\n",
    161162                         pDevExt, pDevExt ? pDevExt->pNextLowerDriver : NULL));
    162163                    rc = STATUS_UNSUCCESSFUL;
    163164                }
    164                 else
    165                 {
    166                     rc = vbgdNtInit(pDevObj, pIrp);
    167                 }
    168165            }
    169166
    170167            if (NT_ERROR(rc))
    171168            {
    172                 Log(("VBoxGuest::vbgdNtGuestPnp: START_DEVICE: Error: rc = 0x%x\n", rc));
     169                Log(("vgdrvNtPnP: START_DEVICE: Error: rc = 0x%x\n", rc));
    173170
    174171                /* Need to unmap memory in case of errors ... */
    175                 vbgdNtUnmapVMMDevMemory(pDevExt);
     172/** @todo r=bird: vgdrvNtInit maps it and is responsible for cleaning up its own friggin mess...
     173 * Fix it instead of kind of working around things there!! */
     174                vgdrvNtUnmapVMMDevMemory(pDevExt);
    176175            }
    177176            break;
     
    180179        case IRP_MN_CANCEL_REMOVE_DEVICE:
    181180        {
    182             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: CANCEL_REMOVE_DEVICE\n"));
     181            Log(("vgdrvNtPnP: CANCEL_REMOVE_DEVICE\n"));
    183182
    184183            /* This must be handled first by the lower driver. */
    185             rc = vbgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
    186 
    187             if (NT_SUCCESS(rc) && pDevExt->devState == PENDINGREMOVE)
     184            rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
     185
     186            if (NT_SUCCESS(rc) && pDevExt->enmDevState == VGDRVNTDEVSTATE_PENDINGREMOVE)
    188187            {
    189188                /* Return to the state prior to receiving the IRP_MN_QUERY_REMOVE_DEVICE request. */
    190                 pDevExt->devState = pDevExt->prevDevState;
     189                pDevExt->enmDevState = pDevExt->enmPrevDevState;
    191190            }
    192191
     
    197196        case IRP_MN_SURPRISE_REMOVAL:
    198197        {
    199             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: IRP_MN_SURPRISE_REMOVAL\n"));
    200 
    201             VBOXGUEST_UPDATE_DEVSTATE(pDevExt, SURPRISEREMOVED);
     198            Log(("vgdrvNtPnP: IRP_MN_SURPRISE_REMOVAL\n"));
     199
     200            VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_SURPRISEREMOVED);
    202201
    203202            /* Do nothing here actually. Cleanup is done in IRP_MN_REMOVE_DEVICE.
     
    219218        case IRP_MN_QUERY_REMOVE_DEVICE:
    220219        {
    221             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: QUERY_REMOVE_DEVICE\n"));
     220            Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE\n"));
    222221
    223222#ifdef VBOX_REBOOT_ON_UNINSTALL
    224             Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_REMOVE_DEVICE: Device cannot be removed without a reboot.\n"));
     223            Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE: Device cannot be removed without a reboot.\n"));
    225224            rc = STATUS_UNSUCCESSFUL;
    226225#endif
     
    228227            if (NT_SUCCESS(rc))
    229228            {
    230                 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, PENDINGREMOVE);
     229                VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_PENDINGREMOVE);
    231230
    232231                /* This IRP passed down to lower driver. */
     
    236235
    237236                rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
    238                 Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
     237                Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
    239238
    240239                /* we must not do anything the IRP after doing IoSkip & CallDriver
     
    250249        case IRP_MN_REMOVE_DEVICE:
    251250        {
    252             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: REMOVE_DEVICE\n"));
    253 
    254             VBOXGUEST_UPDATE_DEVSTATE(pDevExt, REMOVED);
     251            Log(("vgdrvNtPnP: REMOVE_DEVICE\n"));
     252
     253            VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_REMOVED);
    255254
    256255            /* Free hardware resources. */
    257256            /** @todo this should actually free I/O ports, interrupts, etc.
    258              * Update/bird: vbgdNtCleanup actually does that... So, what's there to do?  */
    259             rc = vbgdNtCleanup(pDevObj);
    260             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: vbgdNtCleanup rc = 0x%08X\n", rc));
     257             * Update/bird: vgdrvNtCleanup actually does that... So, what's there to do?  */
     258            rc = vgdrvNtCleanup(pDevObj);
     259            Log(("vgdrvNtPnP: REMOVE_DEVICE: vgdrvNtCleanup rc = 0x%08X\n", rc));
    261260
    262261            /*
     
    270269
    271270            rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
    272             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
     271            Log(("vgdrvNtPnP: REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
    273272
    274273            IoDetachDevice(pDevExt->pNextLowerDriver);
    275274
    276             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Removing device ...\n"));
     275            Log(("vgdrvNtPnP: REMOVE_DEVICE: Removing device ...\n"));
    277276
    278277            /* Destroy device extension and clean up everything else. */
     
    284283            IoDeleteSymbolicLink(&win32Name);
    285284
    286             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Deleting device ...\n"));
     285            Log(("vgdrvNtPnP: REMOVE_DEVICE: Deleting device ...\n"));
    287286
    288287            /* Last action: Delete our device! pDevObj is *not* failed
     
    290289            IoDeleteDevice(pDevObj);
    291290
    292             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Device removed!\n"));
     291            Log(("vgdrvNtPnP: REMOVE_DEVICE: Device removed!\n"));
    293292
    294293            /* Propagating rc from IoCallDriver. */
     
    298297        case IRP_MN_CANCEL_STOP_DEVICE:
    299298        {
    300             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: CANCEL_STOP_DEVICE\n"));
     299            Log(("vgdrvNtPnP: CANCEL_STOP_DEVICE\n"));
    301300
    302301            /* This must be handled first by the lower driver. */
    303             rc = vbgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
    304 
    305             if (NT_SUCCESS(rc) && pDevExt->devState == PENDINGSTOP)
     302            rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
     303
     304            if (NT_SUCCESS(rc) && pDevExt->enmDevState == VGDRVNTDEVSTATE_PENDINGSTOP)
    306305            {
    307306                /* Return to the state prior to receiving the IRP_MN_QUERY_STOP_DEVICE request. */
    308                 pDevExt->devState = pDevExt->prevDevState;
     307                pDevExt->enmDevState = pDevExt->enmPrevDevState;
    309308            }
    310309
     
    315314        case IRP_MN_QUERY_STOP_DEVICE:
    316315        {
    317             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: QUERY_STOP_DEVICE\n"));
     316            Log(("vgdrvNtPnP: QUERY_STOP_DEVICE\n"));
    318317
    319318#ifdef VBOX_REBOOT_ON_UNINSTALL
    320             Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_STOP_DEVICE: Device cannot be stopped without a reboot!\n"));
     319            Log(("vgdrvNtPnP: QUERY_STOP_DEVICE: Device cannot be stopped without a reboot!\n"));
    321320            pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
    322321#endif
     
    324323            if (NT_SUCCESS(rc))
    325324            {
    326                 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, PENDINGSTOP);
     325                VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_PENDINGSTOP);
    327326
    328327                /* This IRP passed down to lower driver. */
     
    332331
    333332                rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
    334                 Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
     333                Log(("vgdrvNtPnP: QUERY_STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
    335334
    336335                /* we must not do anything with the IRP after doing IoSkip & CallDriver
     
    346345        case IRP_MN_STOP_DEVICE:
    347346        {
    348             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: STOP_DEVICE\n"));
    349 
    350             VBOXGUEST_UPDATE_DEVSTATE(pDevExt, STOPPED);
     347            Log(("vgdrvNtPnP: STOP_DEVICE\n"));
     348
     349            VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_STOPPED);
    351350
    352351            /* Free hardware resources. */
    353352            /** @todo this should actually free I/O ports, interrupts, etc.
    354              * Update/bird: vbgdNtCleanup actually does that... So, what's there to do?  */
    355             rc = vbgdNtCleanup(pDevObj);
    356             Log(("VBoxGuest::vbgdNtGuestPnp: STOP_DEVICE: cleaning up, rc = 0x%x\n", rc));
     353             * Update/bird: vgdrvNtCleanup actually does that... So, what's there to do?  */
     354            rc = vgdrvNtCleanup(pDevObj);
     355            Log(("vgdrvNtPnP: STOP_DEVICE: cleaning up, rc = 0x%x\n", rc));
    357356
    358357            /* Pass to the lower driver. */
     
    362361
    363362            rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
    364             Log(("VBoxGuest::vbgdNtGuestPnp: STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
     363            Log(("vgdrvNtPnP: STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
    365364
    366365            return rc;
     
    378377    IoCompleteRequest(pIrp, IO_NO_INCREMENT);
    379378
    380     Log(("VBoxGuest::vbgdNtGuestPnp: Returning with rc = 0x%x\n", rc));
     379    Log(("vgdrvNtPnP: Returning with rc = 0x%x\n", rc));
    381380    return rc;
    382381}
     
    391390 * @param pContext  Context value passed to IoSetCompletionRoutine in VBoxGuestPower.
    392391 */
    393 static NTSTATUS vbgdNtPowerComplete(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN PVOID pContext)
     392static NTSTATUS vgdrvNtPowerComplete(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN PVOID pContext)
    394393{
    395394#ifdef VBOX_STRICT
     
    407406            {
    408407                case IRP_MN_SET_POWER:
    409 
    410408                    switch (pIrpSp->Parameters.Power.Type)
    411409                    {
     
    435433 * @param     pIrp      IRP
    436434 */
    437 NTSTATUS vbgdNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     435NTSTATUS vgdrvNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    438436{
    439437    PIO_STACK_LOCATION  pStack   = IoGetCurrentIrpStackLocation(pIrp);
     
    443441    POWER_ACTION        enmPowerAction = pStack->Parameters.Power.ShutdownType;
    444442
    445     Log(("VBoxGuest::vbgdNtGuestPower\n"));
     443    Log(("vgdrvNtPower:\n"));
    446444
    447445    switch (pStack->MinorFunction)
     
    449447        case IRP_MN_SET_POWER:
    450448        {
    451             Log(("VBoxGuest::vbgdNtGuestPower: IRP_MN_SET_POWER, type= %d\n", enmPowerType));
     449            Log(("vgdrvNtPower: IRP_MN_SET_POWER, type= %d\n", enmPowerType));
    452450            switch (enmPowerType)
    453451            {
    454452                case SystemPowerState:
    455453                {
    456                     Log(("VBoxGuest::vbgdNtGuestPower: SystemPowerState, action = %d, state = %d/%d\n",
     454                    Log(("vgdrvNtPower: SystemPowerState, action = %d, state = %d/%d\n",
    457455                         enmPowerAction, PowerState.SystemState, PowerState.DeviceState));
    458456
     
    467465                                    && pDevExt->LastSystemPowerAction == PowerActionHibernate)
    468466                                {
    469                                     Log(("VBoxGuest::vbgdNtGuestPower: Returning from hibernation!\n"));
     467                                    Log(("vgdrvNtPower: Returning from hibernation!\n"));
    470468                                    int rc = VGDrvCommonReinitDevExtAfterHibernation(&pDevExt->Core,
    471                                                                                      vbgdNtVersionToOSType(g_enmVbgdNtVer));
     469                                                                                     vgdrvNtVersionToOSType(g_enmVGDrvNtVer));
    472470                                    if (RT_FAILURE(rc))
    473                                         Log(("VBoxGuest::vbgdNtGuestPower: Cannot re-init VMMDev chain, rc = %d!\n", rc));
     471                                        Log(("vgdrvNtPower: Cannot re-init VMMDev chain, rc = %d!\n", rc));
    474472                                }
    475473                            }
     
    478476                        case PowerActionShutdownReset:
    479477                        {
    480                             Log(("VBoxGuest::vbgdNtGuestPower: Power action reset!\n"));
     478                            Log(("vgdrvNtPower: Power action reset!\n"));
    481479
    482480                            /* Tell the VMM that we no longer support mouse pointer integration. */
     
    493491                                if (RT_FAILURE(vrc))
    494492                                {
    495                                     Log(("VBoxGuest::PowerStateRequest: error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));
     493                                    Log(("vgdrvNtPower: error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));
    496494                                }
    497495
     
    507505                        case PowerActionShutdownOff:
    508506                        {
    509                             Log(("VBoxGuest::vbgdNtGuestPower: Power action shutdown!\n"));
     507                            Log(("vgdrvNtPower: Power action shutdown!\n"));
    510508                            if (PowerState.SystemState >= PowerSystemShutdown)
    511509                            {
    512                                 Log(("VBoxGuest::vbgdNtGuestPower: Telling the VMMDev to close the VM ...\n"));
     510                                Log(("vgdrvNtPower: Telling the VMMDev to close the VM ...\n"));
    513511
    514512                                VMMDevPowerStateRequest *pReq = pDevExt->pPowerStateRequest;
     
    522520                                }
    523521                                if (RT_FAILURE(vrc))
    524                                     Log(("VBoxGuest::PowerStateRequest: Error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));
     522                                    Log(("vgdrvNtPower: Error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));
    525523
    526524                                /* No need to do cleanup here; at this point we should've been
     
    532530                        case PowerActionHibernate:
    533531
    534                             Log(("VBoxGuest::vbgdNtGuestPower: Power action hibernate!\n"));
     532                            Log(("vgdrvNtPower: Power action hibernate!\n"));
    535533                            break;
    536534                    }
     
    566564    IoCopyCurrentIrpStackLocationToNext(pIrp);
    567565    IoSetCompletionRoutine(pIrp,
    568                            vbgdNtPowerComplete,
     566                           vgdrvNtPowerComplete,
    569567                           (PVOID)pDevExt,
    570568                           TRUE,
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp

    r58089 r58113  
    4545*********************************************************************************************************************************/
    4646RT_C_DECLS_BEGIN
    47 static NTSTATUS vbgdNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj);
    48 static void     vbgdNtUnload(PDRIVER_OBJECT pDrvObj);
    49 static NTSTATUS vbgdNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    50 static NTSTATUS vbgdNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    51 static NTSTATUS vbgdNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    52 static NTSTATUS vbgdNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    53 static NTSTATUS vbgdNtRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue);
    54 static NTSTATUS vbgdNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    55 static NTSTATUS vbgdNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    56 static NTSTATUS vbgdNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    57 #ifdef DEBUG
    58 static void     vbgdNtDoTests(void);
    59 #endif
     47static NTSTATUS vgdrvNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj);
     48static void     vgdrvNtUnload(PDRIVER_OBJECT pDrvObj);
     49static NTSTATUS vgdrvNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     50static NTSTATUS vgdrvNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     51static NTSTATUS vgdrvNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     52static NTSTATUS vgdrvNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     53static NTSTATUS vgdrvNtRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue);
     54static NTSTATUS vgdrvNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     55static NTSTATUS vgdrvNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     56static NTSTATUS vgdrvNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     57#ifdef VBOX_STRICT
     58static void     vgdrvNtDoTests(void);
     59#endif
     60static VOID     vgdrvNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext);
     61static BOOLEAN  vgdrvNtIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
     62static NTSTATUS vgdrvNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt);
     63static NTSTATUS vgdrvNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap,
     64                                       void **ppvMMIOBase, uint32_t *pcbMMIO);
    6065RT_C_DECLS_END
    6166
     
    7075#ifdef ALLOC_PRAGMA
    7176# pragma alloc_text(INIT, DriverEntry)
    72 # pragma alloc_text(PAGE, vbgdNtAddDevice)
    73 # pragma alloc_text(PAGE, vbgdNtUnload)
    74 # pragma alloc_text(PAGE, vbgdNtCreate)
    75 # pragma alloc_text(PAGE, vbgdNtClose)
    76 # pragma alloc_text(PAGE, vbgdNtShutdown)
    77 # pragma alloc_text(PAGE, vbgdNtNotSupportedStub)
    78 # pragma alloc_text(PAGE, vbgdNtScanPCIResourceList)
     77# pragma alloc_text(PAGE, vgdrvNtAddDevice)
     78# pragma alloc_text(PAGE, vgdrvNtUnload)
     79# pragma alloc_text(PAGE, vgdrvNtCreate)
     80# pragma alloc_text(PAGE, vgdrvNtClose)
     81# pragma alloc_text(PAGE, vgdrvNtShutdown)
     82# pragma alloc_text(PAGE, vgdrvNtNotSupportedStub)
     83# pragma alloc_text(PAGE, vgdrvNtScanPCIResourceList)
    7984#endif
    8085
     
    8489*********************************************************************************************************************************/
    8590/** The detected NT (windows) version. */
    86 VBGDNTVER g_enmVbgdNtVer = VBGDNTVER_INVALID;
     91VGDRVNTVER g_enmVGDrvNtVer = VGDRVNTVER_INVALID;
    8792
    8893
     
    103108    /*
    104109     * Check if the the NT version is supported and initializing
    105      * g_enmVbgdNtVer in the process.
     110     * g_enmVGDrvNtVer in the process.
    106111     */
    107112    ULONG ulMajorVer;
     
    115120        RTLogBackdoorPrintf("VBoxGuest: Windows checked build\n");
    116121
    117 #ifdef DEBUG
    118     vbgdNtDoTests();
     122#ifdef VBOX_STRICT
     123    vgdrvNtDoTests();
    119124#endif
    120125    switch (ulMajorVer)
     
    127132                default:
    128133                    /* Also everything newer. */
    129                     g_enmVbgdNtVer = VBGDNTVER_WIN10;
     134                    g_enmVGDrvNtVer = VGDRVNTVER_WIN10;
    130135                    break;
    131136            }
     
    135140            {
    136141                case 0: /* Note: Also could be Windows 2008 Server! */
    137                     g_enmVbgdNtVer = VBGDNTVER_WINVISTA;
     142                    g_enmVGDrvNtVer = VGDRVNTVER_WINVISTA;
    138143                    break;
    139144                case 1: /* Note: Also could be Windows 2008 Server R2! */
    140                     g_enmVbgdNtVer = VBGDNTVER_WIN7;
     145                    g_enmVGDrvNtVer = VGDRVNTVER_WIN7;
    141146                    break;
    142147                case 2:
    143                     g_enmVbgdNtVer = VBGDNTVER_WIN8;
     148                    g_enmVGDrvNtVer = VGDRVNTVER_WIN8;
    144149                    break;
    145150                case 3:
    146                     g_enmVbgdNtVer = VBGDNTVER_WIN81;
     151                    g_enmVGDrvNtVer = VGDRVNTVER_WIN81;
    147152                    break;
    148153                case 4:
     
    150155                default:
    151156                    /* Also everything newer. */
    152                     g_enmVbgdNtVer = VBGDNTVER_WIN10;
     157                    g_enmVGDrvNtVer = VGDRVNTVER_WIN10;
    153158                    break;
    154159            }
     
    159164                default:
    160165                case 2:
    161                     g_enmVbgdNtVer = VBGDNTVER_WIN2K3;
     166                    g_enmVGDrvNtVer = VGDRVNTVER_WIN2K3;
    162167                    break;
    163168                case 1:
    164                     g_enmVbgdNtVer = VBGDNTVER_WINXP;
     169                    g_enmVGDrvNtVer = VGDRVNTVER_WINXP;
    165170                    break;
    166171                case 0:
    167                     g_enmVbgdNtVer = VBGDNTVER_WIN2K;
     172                    g_enmVGDrvNtVer = VGDRVNTVER_WIN2K;
    168173                    break;
    169174            }
    170175            break;
    171176        case 4:
    172             g_enmVbgdNtVer = VBGDNTVER_WINNT4;
     177            g_enmVGDrvNtVer = VGDRVNTVER_WINNT4;
    173178            break;
    174179        default:
     
    176181            {
    177182                /* "Windows 10 mode" for Windows 8.1+. */
    178                 g_enmVbgdNtVer = VBGDNTVER_WIN10;
     183                g_enmVGDrvNtVer = VGDRVNTVER_WIN10;
    179184            }
    180185            else
     
    194199         * Setup the driver entry points in pDrvObj.
    195200         */
    196         pDrvObj->DriverUnload                                  = vbgdNtUnload;
    197         pDrvObj->MajorFunction[IRP_MJ_CREATE]                  = vbgdNtCreate;
    198         pDrvObj->MajorFunction[IRP_MJ_CLOSE]                   = vbgdNtClose;
    199         pDrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL]          = vbgdNtIOCtl;
    200         pDrvObj->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = vbgdNtInternalIOCtl;
    201         pDrvObj->MajorFunction[IRP_MJ_SHUTDOWN]                = vbgdNtShutdown;
    202         pDrvObj->MajorFunction[IRP_MJ_READ]                    = vbgdNtNotSupportedStub;
    203         pDrvObj->MajorFunction[IRP_MJ_WRITE]                   = vbgdNtNotSupportedStub;
     201        pDrvObj->DriverUnload                                  = vgdrvNtUnload;
     202        pDrvObj->MajorFunction[IRP_MJ_CREATE]                  = vgdrvNtCreate;
     203        pDrvObj->MajorFunction[IRP_MJ_CLOSE]                   = vgdrvNtClose;
     204        pDrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL]          = vgdrvNtIOCtl;
     205        pDrvObj->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = vgdrvNtInternalIOCtl;
     206        pDrvObj->MajorFunction[IRP_MJ_SHUTDOWN]                = vgdrvNtShutdown;
     207        pDrvObj->MajorFunction[IRP_MJ_READ]                    = vgdrvNtNotSupportedStub;
     208        pDrvObj->MajorFunction[IRP_MJ_WRITE]                   = vgdrvNtNotSupportedStub;
    204209#ifdef TARGET_NT4
    205         rc = vbgdNt4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath);
     210        rc = vgdrvNt4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath);
    206211#else
    207         pDrvObj->MajorFunction[IRP_MJ_PNP]                     = vbgdNtPnP;
    208         pDrvObj->MajorFunction[IRP_MJ_POWER]                   = vbgdNtPower;
    209         pDrvObj->MajorFunction[IRP_MJ_SYSTEM_CONTROL]          = vbgdNtSystemControl;
    210         pDrvObj->DriverExtension->AddDevice                    = (PDRIVER_ADD_DEVICE)vbgdNtAddDevice;
     212        pDrvObj->MajorFunction[IRP_MJ_PNP]                     = vgdrvNtPnP;
     213        pDrvObj->MajorFunction[IRP_MJ_POWER]                   = vgdrvNtPower;
     214        pDrvObj->MajorFunction[IRP_MJ_SYSTEM_CONTROL]          = vgdrvNtSystemControl;
     215        pDrvObj->DriverExtension->AddDevice                    = (PDRIVER_ADD_DEVICE)vgdrvNtAddDevice;
    211216#endif
    212217    }
     
    222227 *
    223228 * @returns NT status code
    224  * @param  pDrvObj   Driver object
    225  * @param  pDevObj   Device object
    226  */
    227 static NTSTATUS vbgdNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj)
     229 * @param   pDrvObj   Driver object
     230 * @param   pDevObj   Device object
     231 *
     232 * @remarks Parts of this is duplicated in VBoxGuest-win-legacy.cpp.
     233 */
     234static NTSTATUS vgdrvNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj)
    228235{
    229236    NTSTATUS rc;
     
    255262            KeInitializeSpinLock(&pDevExt->MouseEventAccessLock);
    256263
    257             pDevExt->pDeviceObject = pDeviceObject;
    258             pDevExt->prevDevState = STOPPED;
    259             pDevExt->devState = STOPPED;
     264            pDevExt->pDeviceObject   = pDeviceObject;
     265            pDevExt->enmPrevDevState = VGDRVNTDEVSTATE_STOPPED;
     266            pDevExt->enmDevState     = VGDRVNTDEVSTATE_STOPPED;
    260267
    261268            pDevExt->pNextLowerDriver = IoAttachDeviceToDeviceStack(pDeviceObject, pDevObj);
     
    267274                 */
    268275#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    269                 vbgdNtBugCheckCallback(pDevExt); /* Ignore failure! */
     276                vgdrvNtBugCheckCallback(pDevExt); /* Ignore failure! */
    270277#endif
    271278                if (NT_SUCCESS(rc))
     
    276283                    /* Driver is ready now. */
    277284                    pDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    278                     LogFlowFunc(("Returning with rc=0x%x (success)\n", rc));
     285                    LogFlowFunc(("Returning with rc=%#x (success)\n", rc));
    279286                    return rc;
    280287                }
     
    298305        LogFunc(("IoCreateDevice failed with rc=%#x!\n", rc));
    299306
    300     LogFunc(("Returning with rc=0x%x\n", rc));
     307    LogFunc(("Returning with rc=%#x\n", rc));
    301308    return rc;
    302309}
    303 #endif
    304 
    305 
     310#endif /* TARGET_NT4 */
     311
     312
     313#ifdef LOG_ENABLED
    306314/**
    307315 * Debug helper to dump a device resource list.
     
    309317 * @param pResourceList  list of device resources.
    310318 */
    311 static void vbgdNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList)
    312 {
    313 #ifdef LOG_ENABLED
     319static void vgdrvNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList)
     320{
    314321    PCM_PARTIAL_RESOURCE_DESCRIPTOR pResource = pResourceList->PartialDescriptors;
    315322    ULONG cResources = pResourceList->Count;
     
    339346            case CmResourceTypeMemory:
    340347                LogFunc(("Start %8X%8.8lX, length=%X\n",
    341                          pResource->u.Port.Start.HighPart, pResource->u.Port.Start.LowPart,
    342                          pResource->u.Port.Length));
     348                         pResource->u.Port.Start.HighPart, pResource->u.Port.Start.LowPart, pResource->u.Port.Length));
    343349                break;
    344350
    345351            case CmResourceTypeInterrupt:
    346352                LogFunc(("Level=%X, vector=%X, affinity=%X\n",
    347                          pResource->u.Interrupt.Level, pResource->u.Interrupt.Vector,
    348                          pResource->u.Interrupt.Affinity));
     353                         pResource->u.Interrupt.Level, pResource->u.Interrupt.Vector, pResource->u.Interrupt.Affinity));
    349354                break;
    350355
    351356            case CmResourceTypeDma:
    352                 LogFunc(("Channel %d, Port %X\n",
    353                          pResource->u.Dma.Channel, pResource->u.Dma.Port));
     357                LogFunc(("Channel %d, Port %X\n", pResource->u.Dma.Channel, pResource->u.Dma.Port));
    354358                break;
    355359
     
    359363        }
    360364    }
    361 #endif
    362 }
     365}
     366#endif /* LOG_ENABLED */
    363367
    364368
     
    370374 */
    371375#ifndef TARGET_NT4
    372 NTSTATUS vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     376NTSTATUS vgdrvNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    373377#else
    374 NTSTATUS vbgdNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)
     378NTSTATUS vgdrvNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)
    375379#endif
    376380{
     
    382386    LogFlowFuncEnter();
    383387
    384     int rc = STATUS_SUCCESS; /** @todo r=bird: s/rc/rcNt/ and s/int/NTSTATUS/. gee. */
     388    NTSTATUS rcNt;
    385389#ifdef TARGET_NT4
    386390    /*
     
    393397    UNICODE_STRING classNameString;
    394398    RtlInitUnicodeString(&classNameString, L"VBoxGuestAdapter");
    395     rc = HalAssignSlotResources(pRegPath, &classNameString,
    396                                 pDrvObj, pDevObj,
    397                                 PCIBus, pDevExt->busNumber, pDevExt->slotNumber,
    398                                 &pResourceList);
     399    rcNt = HalAssignSlotResources(pRegPath, &classNameString, pDrvObj, pDevObj,
     400                                  PCIBus, pDevExt->busNumber, pDevExt->slotNumber, &pResourceList);
     401# ifdef LOG_ENABLED
    399402    if (pResourceList && pResourceList->Count > 0)
    400         vbgdNtShowDeviceResources(&pResourceList->List[0].PartialResourceList);
    401     if (NT_SUCCESS(rc))
    402         rc = vbgdNtScanPCIResourceList(pResourceList, pDevExt);
     403        vgdrvNtShowDeviceResources(&pResourceList->List[0].PartialResourceList);
     404# endif
     405    if (NT_SUCCESS(rcNt))
     406        rcNt = vgdrvNtScanPCIResourceList(pResourceList, pDevExt);
    403407#else
     408# ifdef LOG_ENABLED
    404409    if (pStack->Parameters.StartDevice.AllocatedResources->Count > 0)
    405         vbgdNtShowDeviceResources(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList);
    406     if (NT_SUCCESS(rc))
    407         rc = vbgdNtScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated, pDevExt);
    408 #endif
    409     if (NT_SUCCESS(rc))
     410        vgdrvNtShowDeviceResources(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList);
     411# endif
     412    rcNt = vgdrvNtScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated, pDevExt);
     413#endif
     414    if (NT_SUCCESS(rcNt))
    410415    {
    411416        /*
     
    415420        void *pvMMIOBase = NULL;
    416421        uint32_t cbMMIO = 0;
    417         rc = vbgdNtMapVMMDevMemory(pDevExt,
    418                                    pDevExt->vmmDevPhysMemoryAddress,
    419                                    pDevExt->vmmDevPhysMemoryLength,
    420                                    &pvMMIOBase,
    421                                    &cbMMIO);
    422         if (NT_SUCCESS(rc))
     422        rcNt = vgdrvNtMapVMMDevMemory(pDevExt,
     423                                      pDevExt->vmmDevPhysMemoryAddress,
     424                                      pDevExt->vmmDevPhysMemoryLength,
     425                                      &pvMMIOBase,
     426                                      &cbMMIO);
     427        if (NT_SUCCESS(rcNt))
    423428        {
    424429            pDevExt->Core.pVMMDevMemory = (VMMDevMemory *)pvMMIOBase;
     
    430435                                            pDevExt->Core.IOPortBase,
    431436                                            pvMMIOBase, cbMMIO,
    432                                             vbgdNtVersionToOSType(g_enmVbgdNtVer),
     437                                            vgdrvNtVersionToOSType(g_enmVGDrvNtVer),
    433438                                            VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
    434439            if (RT_FAILURE(vrc))
    435440            {
    436                 LogFunc(("Could not init device extension, rc=%Rrc\n", vrc));
    437                 rc = STATUS_DEVICE_CONFIGURATION_ERROR;
     441                LogFunc(("Could not init device extension, vrc=%Rrc\n", vrc));
     442                rcNt = STATUS_DEVICE_CONFIGURATION_ERROR;
    438443            }
    439444        }
    440445        else
    441             LogFunc(("Could not map physical address of VMMDev, rc=0x%x\n", rc));
    442     }
    443 
    444     if (NT_SUCCESS(rc))
     446            LogFunc(("Could not map physical address of VMMDev, rcNt=%#x\n", rcNt));
     447    }
     448
     449    if (NT_SUCCESS(rcNt))
    445450    {
    446451        int vrc = VbglGRAlloc((VMMDevRequestHeader **)&pDevExt->pPowerStateRequest,
     
    448453        if (RT_FAILURE(vrc))
    449454        {
    450             LogFunc(("Alloc for pPowerStateRequest failed, rc=%Rrc\n", vrc));
    451             rc = STATUS_UNSUCCESSFUL;
     455            LogFunc(("Alloc for pPowerStateRequest failed, vrc=%Rrc\n", vrc));
     456            rcNt = STATUS_UNSUCCESSFUL;
    452457        }
    453458    }
    454459
    455     if (NT_SUCCESS(rc))
     460    if (NT_SUCCESS(rcNt))
    456461    {
    457462        /*
     
    460465        LogFlowFunc(("Initializing DPC/ISR ...\n"));
    461466
    462         IoInitializeDpcRequest(pDevExt->pDeviceObject, vbgdNtDpcHandler);
     467        IoInitializeDpcRequest(pDevExt->pDeviceObject, vgdrvNtDpcHandler);
    463468#ifdef TARGET_NT4
    464469        ULONG uInterruptVector;
     
    489494            LogFlowFunc(("Connecting interrupt ...\n"));
    490495
    491             rc = IoConnectInterrupt(&pDevExt->pInterruptObject,                 /* Out: interrupt object. */
    492                                     (PKSERVICE_ROUTINE)vbgdNtIsrHandler,        /* Our ISR handler. */
    493                                     pDevExt,                                    /* Device context. */
    494                                     NULL,                                       /* Optional spinlock. */
     496            rcNt = IoConnectInterrupt(&pDevExt->pInterruptObject,                 /* Out: interrupt object. */
     497                                      (PKSERVICE_ROUTINE)vgdrvNtIsrHandler,        /* Our ISR handler. */
     498                                      pDevExt,                                    /* Device context. */
     499                                      NULL,                                       /* Optional spinlock. */
    495500#ifdef TARGET_NT4
    496                                     uInterruptVector,                           /* Interrupt vector. */
    497                                     irqLevel,                                   /* Interrupt level. */
    498                                     irqLevel,                                   /* Interrupt level. */
     501                                      uInterruptVector,                           /* Interrupt vector. */
     502                                      irqLevel,                                   /* Interrupt level. */
     503                                      irqLevel,                                   /* Interrupt level. */
    499504#else
    500                                     pDevExt->interruptVector,                   /* Interrupt vector. */
    501                                     (KIRQL)pDevExt->interruptLevel,             /* Interrupt level. */
    502                                     (KIRQL)pDevExt->interruptLevel,             /* Interrupt level. */
    503 #endif
    504                                     pDevExt->interruptMode,                     /* LevelSensitive or Latched. */
    505                                     TRUE,                                       /* Shareable interrupt. */
    506                                     pDevExt->interruptAffinity,                 /* CPU affinity. */
    507                                     FALSE);                                     /* Don't save FPU stack. */
    508             if (NT_ERROR(rc))
    509                 LogFunc(("Could not connect interrupt, rc=0x%x\n", rc));
     505                                      pDevExt->interruptVector,                   /* Interrupt vector. */
     506                                      (KIRQL)pDevExt->interruptLevel,             /* Interrupt level. */
     507                                      (KIRQL)pDevExt->interruptLevel,             /* Interrupt level. */
     508#endif
     509                                      pDevExt->interruptMode,                     /* LevelSensitive or Latched. */
     510                                      TRUE,                                       /* Shareable interrupt. */
     511                                      pDevExt->interruptAffinity,                 /* CPU affinity. */
     512                                      FALSE);                                     /* Don't save FPU stack. */
     513            if (NT_ERROR(rcNt))
     514                LogFunc(("Could not connect interrupt, rcNt=%#x\n", rcNt));
    510515        }
    511516        else
     
    519524    if (RT_FAILURE(vrc))
    520525    {
    521         LogFunc(("Failed to allocated kernel session data, rc=%Rrc\n", rc));
    522         rc = STATUS_UNSUCCESSFUL;
    523     }
    524 #endif
    525 
    526     if (RT_SUCCESS(rc))
    527     {
    528         ULONG ulValue = 0;
    529         NTSTATUS rcNt = vbgdNtRegistryReadDWORD(RTL_REGISTRY_SERVICES,
    530                                                 L"VBoxGuest", L"LoggingEnabled", &ulValue);
    531         if (NT_SUCCESS(rcNt))
     526        LogFunc(("Failed to allocated kernel session data, vrc=%Rrc\n", vrc));
     527        rcNt = STATUS_UNSUCCESSFUL;
     528    }
     529#endif
     530
     531    if (RT_SUCCESS(rcNt))
     532    {
     533        ULONG uValue = 0;
     534        NTSTATUS rcNt2 = vgdrvNtRegistryReadDWORD(RTL_REGISTRY_SERVICES, L"VBoxGuest", L"LoggingEnabled", &uValue);
     535        if (NT_SUCCESS(rcNt2))
    532536        {
    533             pDevExt->Core.fLoggingEnabled = ulValue >= 0xFF;
     537            pDevExt->Core.fLoggingEnabled = uValue >= 0xFF;
    534538            if (pDevExt->Core.fLoggingEnabled)
    535                 LogRelFunc(("Logging to host log enabled (0x%x)", ulValue));
     539                LogRelFunc(("Logging to host log enabled (%#x)", uValue));
    536540        }
    537541
    538542        /* Ready to rumble! */
    539543        LogRelFunc(("Device is ready!\n"));
    540         VBOXGUEST_UPDATE_DEVSTATE(pDevExt, WORKING);
     544        VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_WORKING);
    541545    }
    542546    else
     
    546550     *        whole bunch of things... */
    547551
    548     LogFunc(("Returned with rc=0x%x\n", rc));
    549     return rc;
     552    LogFunc(("Returned with rcNt=%#x\n", rcNt));
     553    return rcNt;
    550554}
    551555
     
    557561 * @param   pDevObj     Device object.
    558562 */
    559 NTSTATUS vbgdNtCleanup(PDEVICE_OBJECT pDevObj)
     563NTSTATUS vgdrvNtCleanup(PDEVICE_OBJECT pDevObj)
    560564{
    561565    LogFlowFuncEnter();
     
    565569    {
    566570
    567 #if 0 /* @todo: test & enable cleaning global session data */
     571#if 0 /** @todo test & enable cleaning global session data */
    568572#ifdef VBOX_WITH_HGCM
    569573        if (pDevExt->pKernelSession)
    570574        {
    571             VbgdCommonCloseSession(pDevExt, pDevExt->pKernelSession);
     575            VGDrvCommonCloseSession(pDevExt, pDevExt->pKernelSession);
    572576            pDevExt->pKernelSession = NULL;
    573577        }
     
    581585        }
    582586
    583         /** @todo: cleanup the rest stuff */
     587        /** @todo cleanup the rest stuff */
    584588
    585589
     
    588592#endif
    589593        /* According to MSDN we have to unmap previously mapped memory. */
    590         vbgdNtUnmapVMMDevMemory(pDevExt);
     594        vgdrvNtUnmapVMMDevMemory(pDevExt);
    591595    }
    592596
     
    600604 * @param   pDrvObj     Driver object.
    601605 */
    602 static void vbgdNtUnload(PDRIVER_OBJECT pDrvObj)
     606static void vgdrvNtUnload(PDRIVER_OBJECT pDrvObj)
    603607{
    604608    LogFlowFuncEnter();
    605609
    606610#ifdef TARGET_NT4
    607     vbgdNtCleanup(pDrvObj->DeviceObject);
     611    vgdrvNtCleanup(pDrvObj->DeviceObject);
    608612
    609613    /* Destroy device extension and clean up everything else. */
     
    636640 * @param   pIrp        Request packet.
    637641 */
    638 static NTSTATUS vbgdNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     642static NTSTATUS vgdrvNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    639643{
    640644    /** @todo AssertPtrReturn(pIrp); */
     
    645649    NTSTATUS            rc       = STATUS_SUCCESS;
    646650
    647     if (pDevExt->devState != WORKING)
    648     {
    649         LogFunc(("Device is not working currently, state=%d\n", pDevExt->devState));
     651    if (pDevExt->enmDevState != VGDRVNTDEVSTATE_WORKING)
     652    {
     653        LogFunc(("Device is not working currently, state=%d\n", pDevExt->enmDevState));
    650654        rc = STATUS_UNSUCCESSFUL;
    651655    }
     
    692696    IoCompleteRequest(pIrp, IO_NO_INCREMENT);
    693697
    694     LogFlowFunc(("Returning rc=0x%x\n", rc));
     698    LogFlowFunc(("Returning rc=%#x\n", rc));
    695699    return rc;
    696700}
     
    703707 * @param   pIrp        Request packet.
    704708 */
    705 static NTSTATUS vbgdNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     709static NTSTATUS vgdrvNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    706710{
    707711    PVBOXGUESTDEVEXTWIN pDevExt  = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
     
    709713    PFILE_OBJECT        pFileObj = pStack->FileObject;
    710714
    711     LogFlowFunc(("pDevExt=0x%p, pFileObj=0x%p, FsContext=0x%p\n",
    712                  pDevExt, pFileObj, pFileObj->FsContext));
     715    LogFlowFunc(("pDevExt=0x%p, pFileObj=0x%p, FsContext=0x%p\n", pDevExt, pFileObj, pFileObj->FsContext));
    713716
    714717#ifdef VBOX_WITH_HGCM
     
    734737 * @param   pIrp        Request packet.
    735738 */
    736 static NTSTATUS vbgdNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     739static NTSTATUS vgdrvNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    737740{
    738741    NTSTATUS            Status   = STATUS_SUCCESS;
     
    751754        pSession = (PVBOXGUESTSESSION)pFileObj->FsContext;
    752755
    753     LogFlowFunc(("uCmd=%u, pDevExt=0x%p, pSession=0x%p\n",
    754                  uCmd, pDevExt, pSession));
     756    LogFlowFunc(("uCmd=%u, pDevExt=0x%p, pSession=0x%p\n", uCmd, pDevExt, pSession));
    755757
    756758    /* We don't have a session associated with the file object? So this seems
     
    823825 * @param   pIrp        Request packet.
    824826 */
    825 static NTSTATUS vbgdNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     827static NTSTATUS vgdrvNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    826828{
    827829    NTSTATUS            Status      = STATUS_SUCCESS;
     
    877879     * No override, go to common code.
    878880     */
    879     return vbgdNtIOCtl(pDevObj, pIrp);
     881    return vgdrvNtIOCtl(pDevObj, pIrp);
    880882}
    881883
     
    888890 * @param   pIrp        IRP.
    889891 */
    890 NTSTATUS vbgdNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     892static NTSTATUS vgdrvNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    891893{
    892894    PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
     
    908910 * @param pIrp       IRP.
    909911 */
    910 NTSTATUS vbgdNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     912static NTSTATUS vgdrvNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    911913{
    912914    PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
     
    936938 * @param   pIrp        IRP.
    937939 */
    938 NTSTATUS vbgdNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     940static NTSTATUS vgdrvNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    939941{
    940942    LogFlowFuncEnter();
     
    956958 * @param   pContext    Context specific pointer.
    957959 */
    958 void vbgdNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext)
     960static void vgdrvNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext)
    959961{
    960962    PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
     
    976978
    977979    /* Process the wake-up list we were asked by the scheduling a DPC
    978      * in vbgdNtIsrHandler(). */
     980     * in vgdrvNtIsrHandler(). */
    979981    VGDrvCommonWaitDoWakeUps(&pDevExt->Core);
    980982}
     
    988990 * @param   pServiceContext Context specific pointer.
    989991 */
    990 BOOLEAN vbgdNtIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext)
     992static BOOLEAN vgdrvNtIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext)
    991993{
    992994    PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pServiceContext;
     
    10401042 *                      registry value if found.
    10411043 */
    1042 NTSTATUS vbgdNtRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue)
     1044static NTSTATUS vgdrvNtRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue)
    10431045{
    10441046    if (!pwszPath || !pwszName || !puValue)
     
    10711073 * @param pDevExt   Device extension
    10721074 */
    1073 NTSTATUS vbgdNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt)
     1075static NTSTATUS vgdrvNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt)
    10741076{
    10751077    /* Enumerate the resource list. */
     
    12031205 * @param pcbMMIO           Length of mapped I/O base.
    12041206 */
    1205 NTSTATUS vbgdNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap,
    1206                                void **ppvMMIOBase, uint32_t *pcbMMIO)
     1207static NTSTATUS vgdrvNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap,
     1208                                       void **ppvMMIOBase, uint32_t *pcbMMIO)
    12071209{
    12081210    AssertPtrReturn(pDevExt, VERR_INVALID_POINTER);
     
    12141216    {
    12151217         VMMDevMemory *pVMMDevMemory = (VMMDevMemory *)MmMapIoSpace(PhysAddr, cbToMap, MmNonCached);
    1216          LogFlowFunc(("pVMMDevMemory = 0x%x\n", pVMMDevMemory));
     1218         LogFlowFunc(("pVMMDevMemory = %#x\n", pVMMDevMemory));
    12171219         if (pVMMDevMemory)
    12181220         {
    1219              LogFunc(("VMMDevMemory: Version = 0x%x, Size = %d\n", pVMMDevMemory->u32Version, pVMMDevMemory->u32Size));
     1221             LogFunc(("VMMDevMemory: Version = %#x, Size = %d\n", pVMMDevMemory->u32Version, pVMMDevMemory->u32Size));
    12201222
    12211223             /* Check version of the structure; do we have the right memory version? */
     
    12341236                 LogFunc(("Wrong version (%u), refusing operation!\n", pVMMDevMemory->u32Version));
    12351237
    1236                  vbgdNtUnmapVMMDevMemory(pDevExt);
     1238                 vgdrvNtUnmapVMMDevMemory(pDevExt);
    12371239                 rc = STATUS_UNSUCCESSFUL;
    12381240             }
     
    12501252 * @param   pDevExt     The device extension.
    12511253 */
    1252 void vbgdNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt)
    1253 {
    1254     LogFlowFunc(("pVMMDevMemory = 0x%x\n", pDevExt->Core.pVMMDevMemory));
     1254void vgdrvNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt)
     1255{
     1256    LogFlowFunc(("pVMMDevMemory = %#x\n", pDevExt->Core.pVMMDevMemory));
    12551257    if (pDevExt->Core.pVMMDevMemory)
    12561258    {
     
    12641266
    12651267
    1266 VBOXOSTYPE vbgdNtVersionToOSType(VBGDNTVER enmNtVer)
     1268/**
     1269 * Translates NT version to VBox OS.
     1270 *
     1271 * @returns VBox OS type.
     1272 * @param   enmNtVer            The NT version.
     1273 */
     1274VBOXOSTYPE vgdrvNtVersionToOSType(VGDRVNTVER enmNtVer)
    12671275{
    12681276    VBOXOSTYPE enmOsType;
    12691277    switch (enmNtVer)
    12701278    {
    1271         case VBGDNTVER_WINNT4:
     1279        case VGDRVNTVER_WINNT4:
    12721280            enmOsType = VBOXOSTYPE_WinNT4;
    12731281            break;
    12741282
    1275         case VBGDNTVER_WIN2K:
     1283        case VGDRVNTVER_WIN2K:
    12761284            enmOsType = VBOXOSTYPE_Win2k;
    12771285            break;
    12781286
    1279         case VBGDNTVER_WINXP:
     1287        case VGDRVNTVER_WINXP:
    12801288#if ARCH_BITS == 64
    12811289            enmOsType = VBOXOSTYPE_WinXP_x64;
     
    12851293            break;
    12861294
    1287         case VBGDNTVER_WIN2K3:
     1295        case VGDRVNTVER_WIN2K3:
    12881296#if ARCH_BITS == 64
    12891297            enmOsType = VBOXOSTYPE_Win2k3_x64;
     
    12931301            break;
    12941302
    1295         case VBGDNTVER_WINVISTA:
     1303        case VGDRVNTVER_WINVISTA:
    12961304#if ARCH_BITS == 64
    12971305            enmOsType = VBOXOSTYPE_WinVista_x64;
     
    13011309            break;
    13021310
    1303         case VBGDNTVER_WIN7:
     1311        case VGDRVNTVER_WIN7:
    13041312#if ARCH_BITS == 64
    13051313            enmOsType = VBOXOSTYPE_Win7_x64;
     
    13091317            break;
    13101318
    1311         case VBGDNTVER_WIN8:
     1319        case VGDRVNTVER_WIN8:
    13121320#if ARCH_BITS == 64
    13131321            enmOsType = VBOXOSTYPE_Win8_x64;
     
    13171325            break;
    13181326
    1319         case VBGDNTVER_WIN81:
     1327        case VGDRVNTVER_WIN81:
    13201328#if ARCH_BITS == 64
    13211329            enmOsType = VBOXOSTYPE_Win81_x64;
     
    13251333            break;
    13261334
    1327         case VBGDNTVER_WIN10:
     1335        case VGDRVNTVER_WIN10:
    13281336#if ARCH_BITS == 64
    13291337            enmOsType = VBOXOSTYPE_Win10_x64;
     
    13411349}
    13421350
    1343 #ifdef DEBUG
     1351#ifdef VBOX_STRICT
    13441352
    13451353/**
    13461354 * A quick implementation of AtomicTestAndClear for uint32_t and multiple bits.
    13471355 */
    1348 static uint32_t vboxugestwinAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask)
     1356static uint32_t vgdrvNtAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask)
    13491357{
    13501358    AssertPtrReturn(pu32Bits, 0);
    1351     LogFlowFunc(("*pu32Bits=0x%x, u32Mask=0x%x\n", *(uint32_t *)pu32Bits, u32Mask));
     1359    LogFlowFunc(("*pu32Bits=%#x, u32Mask=%#x\n", *(uint32_t *)pu32Bits, u32Mask));
    13521360    uint32_t u32Result = 0;
    13531361    uint32_t u32WorkingMask = u32Mask;
     
    13621370        iBitOffset = ASMBitFirstSetU32 (u32WorkingMask);
    13631371    }
    1364     LogFlowFunc(("Returning 0x%x\n", u32Result));
     1372    LogFlowFunc(("Returning %#x\n", u32Result));
    13651373    return u32Result;
    13661374}
    13671375
    13681376
    1369 static void vbgdNtTestAtomicTestAndClearBitsU32(uint32_t u32Mask, uint32_t u32Bits, uint32_t u32Exp)
     1377static void vgdrvNtTestAtomicTestAndClearBitsU32(uint32_t u32Mask, uint32_t u32Bits, uint32_t u32Exp)
    13701378{
    13711379    ULONG u32Bits2 = u32Bits;
    1372     uint32_t u32Result = vboxugestwinAtomicBitsTestAndClear(&u32Bits2, u32Mask);
     1380    uint32_t u32Result = vgdrvNtAtomicBitsTestAndClear(&u32Bits2, u32Mask);
    13731381    if (   u32Result != u32Exp
    13741382        || (u32Bits2 & u32Mask)
     
    13761384        || ((u32Bits2 | u32Result) != u32Bits)
    13771385       )
    1378         AssertLogRelMsgFailed(("%s: TEST FAILED: u32Mask=0x%x, u32Bits (before)=0x%x, u32Bits (after)=0x%x, u32Result=0x%x, u32Exp=ox%x\n",
    1379                                __PRETTY_FUNCTION__, u32Mask, u32Bits, u32Bits2,
    1380                                u32Result));
    1381 }
    1382 
    1383 
    1384 static void vbgdNtDoTests(void)
    1385 {
    1386     vbgdNtTestAtomicTestAndClearBitsU32(0x00, 0x23, 0);
    1387     vbgdNtTestAtomicTestAndClearBitsU32(0x11, 0, 0);
    1388     vbgdNtTestAtomicTestAndClearBitsU32(0x11, 0x22, 0);
    1389     vbgdNtTestAtomicTestAndClearBitsU32(0x11, 0x23, 0x1);
    1390     vbgdNtTestAtomicTestAndClearBitsU32(0x11, 0x32, 0x10);
    1391     vbgdNtTestAtomicTestAndClearBitsU32(0x22, 0x23, 0x22);
    1392 }
    1393 
    1394 #endif /* DEBUG */
     1386        AssertLogRelMsgFailed(("TEST FAILED: u32Mask=%#x, u32Bits (before)=%#x, u32Bits (after)=%#x, u32Result=%#x, u32Exp=%#x\n",
     1387                               u32Mask, u32Bits, u32Bits2, u32Result));
     1388}
     1389
     1390
     1391static void vgdrvNtDoTests(void)
     1392{
     1393    vgdrvNtTestAtomicTestAndClearBitsU32(0x00, 0x23, 0);
     1394    vgdrvNtTestAtomicTestAndClearBitsU32(0x11, 0, 0);
     1395    vgdrvNtTestAtomicTestAndClearBitsU32(0x11, 0x22, 0);
     1396    vgdrvNtTestAtomicTestAndClearBitsU32(0x11, 0x23, 0x1);
     1397    vgdrvNtTestAtomicTestAndClearBitsU32(0x11, 0x32, 0x10);
     1398    vgdrvNtTestAtomicTestAndClearBitsU32(0x22, 0x23, 0x22);
     1399}
     1400
     1401#endif /* VBOX_STRICT */
    13951402
    13961403#ifdef VBOX_WITH_DPC_LATENCY_CHECKER
     
    14511458 * @param   SystemArgument2     System use, ignored.
    14521459 */
    1453 static VOID vbgdNtDpcLatencyCallback(PKDPC pDpc, PVOID pvDeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
     1460static VOID vgdrvNtDpcLatencyCallback(PKDPC pDpc, PVOID pvDeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
    14541461{
    14551462    DPCDATA *pData = (DPCDATA *)pvDeferredContext;
     
    14961503     * Initialize the data.
    14971504     */
    1498     KeInitializeDpc(&pData->Dpc, vbgdNtDpcLatencyCallback, pData);
     1505    KeInitializeDpc(&pData->Dpc, vgdrvNtDpcLatencyCallback, pData);
    14991506    KeInitializeTimer(&pData->Timer);
    15001507    KeInitializeSpinLock(&pData->SpinLock);
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.h

    r54608 r58113  
    4242
    4343/** Possible device states for our state machine. */
    44 enum DEVSTATE
     44typedef enum VGDRVNTDEVSTATE
    4545{
    46     STOPPED,
    47     WORKING,
    48     PENDINGSTOP,
    49     PENDINGREMOVE,
    50     SURPRISEREMOVED,
    51     REMOVED
    52 };
     46    VGDRVNTDEVSTATE_STOPPED,
     47    VGDRVNTDEVSTATE_WORKING,
     48    VGDRVNTDEVSTATE_PENDINGSTOP,
     49    VGDRVNTDEVSTATE_PENDINGREMOVE,
     50    VGDRVNTDEVSTATE_SURPRISEREMOVED,
     51    VGDRVNTDEVSTATE_REMOVED
     52} VGDRVNTDEVSTATE;
    5353
    5454typedef struct VBOXGUESTWINBASEADDRESS
     
    105105
    106106    /** Device state. */
    107     DEVSTATE devState;
    108     DEVSTATE prevDevState;
     107    VGDRVNTDEVSTATE enmDevState;
     108    /** The previous device state.   */
     109    VGDRVNTDEVSTATE enmPrevDevState;
    109110
    110111    /** Last system power action set (see VBoxGuestPower). */
     
    126127
    127128/** NT (windows) version identifier. */
    128 typedef enum VBGDNTVER
     129typedef enum VGDRVNTVER
    129130{
    130     VBGDNTVER_INVALID = 0,
    131     VBGDNTVER_WINNT4,
    132     VBGDNTVER_WIN2K,
    133     VBGDNTVER_WINXP,
    134     VBGDNTVER_WIN2K3,
    135     VBGDNTVER_WINVISTA,
    136     VBGDNTVER_WIN7,
    137     VBGDNTVER_WIN8,
    138     VBGDNTVER_WIN81,
    139     VBGDNTVER_WIN10
    140 } VBGDNTVER;
    141 extern VBGDNTVER g_enmVbgdNtVer;
     131    VGDRVNTVER_INVALID = 0,
     132    VGDRVNTVER_WINNT4,
     133    VGDRVNTVER_WIN2K,
     134    VGDRVNTVER_WINXP,
     135    VGDRVNTVER_WIN2K3,
     136    VGDRVNTVER_WINVISTA,
     137    VGDRVNTVER_WIN7,
     138    VGDRVNTVER_WIN8,
     139    VGDRVNTVER_WIN81,
     140    VGDRVNTVER_WIN10
     141} VGDRVNTVER;
     142extern VGDRVNTVER g_enmVGDrvNtVer;
    142143
    143144
    144 #define VBOXGUEST_UPDATE_DEVSTATE(a_pDevExt, a_newDevState) \
     145#define VBOXGUEST_UPDATE_DEVSTATE(a_pDevExt, a_enmNewDevState) \
    145146    do { \
    146         (a_pDevExt)->prevDevState = (a_pDevExt)->devState; \
    147         (a_pDevExt)->devState     = (a_newDevState); \
     147        (a_pDevExt)->enmPrevDevState = (a_pDevExt)->enmDevState; \
     148        (a_pDevExt)->enmDevState     = (a_enmNewDevState); \
    148149    } while (0)
    149150
     
    155156
    156157#ifdef TARGET_NT4
    157 NTSTATUS   vbgdNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
     158NTSTATUS   vgdrvNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
    158159#else
    159 NTSTATUS   vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    160 NTSTATUS   vbgdNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    161 NTSTATUS   vbgdNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     160NTSTATUS   vgdrvNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     161NTSTATUS   vgdrvNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    162162#endif
    163163
     
    166166 */
    167167#ifdef TARGET_NT4
    168 NTSTATUS   vbgdNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
     168NTSTATUS   vgdrvNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
    169169#else
    170 NTSTATUS   vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     170NTSTATUS   vgdrvNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    171171#endif
    172 NTSTATUS   vbgdNtCleanup(PDEVICE_OBJECT pDevObj);
    173 VOID       vbgdNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext);
    174 BOOLEAN    vbgdNtIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
    175 NTSTATUS   vbgdNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt);
    176 NTSTATUS   vbgdNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap,
    177                                  void **ppvMMIOBase, uint32_t *pcbMMIO);
    178 void       vbgdNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt);
    179 VBOXOSTYPE vbgdNtVersionToOSType(VBGDNTVER enmNtVer);
     172NTSTATUS   vgdrvNtCleanup(PDEVICE_OBJECT pDevObj);
     173void       vgdrvNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt); /**< @todo make static once buggy vgdrvNtInit is fixed. */
     174VBOXOSTYPE vgdrvNtVersionToOSType(VGDRVNTVER enmNtVer);
    180175/** @}  */
    181176
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestA-os2.asm

    r54608 r58113  
    221221extern KernThunkStackTo16
    222222
    223 extern NAME(VBoxGuestOS2Init)
    224 extern NAME(VBoxGuestOS2Open)
    225 extern NAME(VBoxGuestOS2Close)
    226 extern NAME(VBoxGuestOS2IOCtl)
    227 extern NAME(VBoxGuestOS2IOCtlFast)
    228 extern NAME(VBoxGuestOS2IDCConnect)
    229 extern NAME(VBoxGuestOS2IDCService)
    230 extern NAME(VBoxGuestOS2ISR)
     223extern NAME(vgdrvOS2Init)
     224extern NAME(vgdrvOS2Open)
     225extern NAME(vgdrvOS2Close)
     226extern NAME(vgdrvOS2IOCtl)
     227extern NAME(vgdrvOS2IOCtlFast)
     228extern NAME(vgdrvOS2IDCConnect)
     229extern NAME(VGDrvOS2IDCService)
     230extern NAME(vgdrvOS2ISR)
    231231
    232232
     
    240240    dw  DATA16                                      ; NextHeader.sel
    241241    dw  DEVLEV_3 | DEV_30 | DEV_CHAR_DEV | DEV_IOCTL; SDevAtt
    242     dw  NAME(VBoxGuestOS2EP) wrt CODE16             ; StrategyEP
    243     dw  NAME(VBoxGuestOS2IDC) wrt CODE16            ; IDCEP
     242    dw  NAME(VGDrvOS2Entrypoint) wrt CODE16         ; StrategyEP
     243    dw  NAME(VGDrvOS2IDC) wrt CODE16                ; IDCEP
    244244    db  'vboxgst$'                                  ; DevName
    245245    dw  0                                           ; SDevProtCS
     
    253253    dd  0ffffffffh                                  ; NextHeader (NIL)
    254254    dw  DEVLEV_3 | DEV_30 | DEV_CHAR_DEV            ; SDevAtt
    255     dw  NAME(VBoxGuestOS2InitEP) wrt CODE16         ; StrategyEP
     255    dw  NAME(vgdrvOS2InitEntrypoint) wrt CODE16     ; StrategyEP
    256256    dw  0                                           ; IDCEP
    257257    db  'vboxgs1$'                                  ; DevName
     
    276276
    277277
    278 ;; VBoxGuestFindAdapter Output
     278;; vgdrvFindAdapter Output
    279279; @{
    280280
     
    381381; Can clobber any registers it likes except SP.
    382382;
    383 BEGINPROC VBoxGuestOS2EP
     383BEGINPROC VGDrvOS2Entrypoint
    384384    push    ebp
    385385    mov     ebp, esp
     
    392392    ;
    393393    cmp     byte [es:bx + PKTHDR.cmd], 10h          ; Generic IOCtl
    394     jne near VBoxGuestOS2EP_NotGenIOCtl
     394    jne near vgdrvOS2EP_NotGenIOCtl
    395395
    396396
     
    398398    ; Generic I/O Control Request.
    399399    ;
    400 VBoxGuestOS2EP_GenIOCtl:
     400vgdrvOS2EP_GenIOCtl:
    401401
    402402    ; Fast IOCtl?
    403403    cmp     byte [es:bx + PKTIOCTL.cat], VBOXGUEST_IOCTL_CATEGORY_FAST
    404     jne     VBoxGuestOS2EP_GenIOCtl_Other
     404    jne     vgdrvOS2EP_GenIOCtl_Other
    405405
    406406    ;
    407407    ; Fast IOCtl.
    408     ;   DECLASM(int) VBoxGuestOS2IOCtlFast(uint16_t sfn, uint8_t iFunction, uint16_t *pcbParm)
    409     ;
    410 VBoxGuestOS2EP_GenIOCtl_Fast:
     408    ;   DECLASM(int) vgdrvOS2IOCtlFast(uint16_t sfn, uint8_t iFunction, uint16_t *pcbParm)
     409    ;
     410vgdrvOS2EP_GenIOCtl_Fast:
    411411    mov     ax, [es:bx + PKTIOCTL.pData + 2]        ; LDT selector to flat address.
    412412    shr     ax, 3
     
    423423    push    eax                                     ; 00h
    424424
    425     JMP16TO32 VBoxGuestOS2EP_GenIOCtl_Fast_32
     425    JMP16TO32 vgdrvOS2EP_GenIOCtl_Fast_32
    426426segment TEXT32
    427 GLOBALNAME VBoxGuestOS2EP_GenIOCtl_Fast_32
     427GLOBALNAME vgdrvOS2EP_GenIOCtl_Fast_32
    428428
    429429    ; switch stack to 32-bit.
     
    434434
    435435    ; call the C code (don't cleanup the stack).
    436     call    NAME(VBoxGuestOS2IOCtlFast)
     436    call    NAME(vgdrvOS2IOCtlFast)
    437437
    438438    ; switch back the stack.
     
    441441    pop     eax
    442442
    443     JMP32TO16 VBoxGuestOS2EP_GenIOCtl_Fast_32
     443    JMP32TO16 vgdrvOS2EP_GenIOCtl_Fast_32
    444444segment CODE16
    445 GLOBALNAME VBoxGuestOS2EP_GenIOCtl_Fast_16
     445GLOBALNAME vgdrvOS2EP_GenIOCtl_Fast_16
    446446
    447447    les     bx, [bp - 4]                            ; Reload the packet pointer.
    448448    or      eax, eax
    449     jnz near VBoxGuestOS2EP_GeneralFailure
     449    jnz near vgdrvOS2EP_GeneralFailure
    450450
    451451    ; setup output stuff.
     
    462462    ; Other IOCtl (slow)
    463463    ;
    464 VBoxGuestOS2EP_GenIOCtl_Other:
     464vgdrvOS2EP_GenIOCtl_Other:
    465465    mov     eax, [es:bx +  PKTIOCTL.cbParm]         ; Load cbParm and cbData
    466466    push    eax                                     ; 1eh - in/out data size.
     
    476476    mov     dl, DevHlp_VirtToLin
    477477    call far [NAME(g_fpfnDevHlp)]
    478     jc near VBoxGuestOS2EP_GeneralFailure
     478    jc near vgdrvOS2EP_GeneralFailure
    479479    jmp     .finish_data
    480480.no_data:
     
    490490    mov     dl, DevHlp_VirtToLin
    491491    call far [NAME(g_fpfnDevHlp)]
    492     jc near VBoxGuestOS2EP_GeneralFailure
     492    jc near vgdrvOS2EP_GeneralFailure
    493493    jmp     .finish_parm
    494494.no_parm:
     
    509509    push    eax                                     ; 00h
    510510
    511     JMP16TO32 VBoxGuestOS2EP_GenIOCtl_Other_32
     511    JMP16TO32 vgdrvOS2EP_GenIOCtl_Other_32
    512512segment TEXT32
    513 GLOBALNAME VBoxGuestOS2EP_GenIOCtl_Other_32
     513GLOBALNAME vgdrvOS2EP_GenIOCtl_Other_32
    514514
    515515    ; switch stack to 32-bit.
     
    526526
    527527    ; call the C code (don't cleanup the stack).
    528     call    NAME(VBoxGuestOS2IOCtl)
     528    call    NAME(vgdrvOS2IOCtl)
    529529
    530530    ; switch back the stack.
     
    533533    pop     eax
    534534
    535     JMP32TO16 VBoxGuestOS2EP_GenIOCtl_Other_16
     535    JMP32TO16 vgdrvOS2EP_GenIOCtl_Other_16
    536536segment CODE16
    537 GLOBALNAME VBoxGuestOS2EP_GenIOCtl_Other_16
     537GLOBALNAME vgdrvOS2EP_GenIOCtl_Other_16
    538538
    539539    les     bx, [bp - 4]                            ; Reload the packet pointer.
    540540    or      eax, eax
    541     jnz near VBoxGuestOS2EP_GeneralFailure
     541    jnz near vgdrvOS2EP_GeneralFailure
    542542
    543543    ; setup output stuff.
     
    555555    ; Less Performance Critical Requests.
    556556    ;
    557 VBoxGuestOS2EP_NotGenIOCtl:
     557vgdrvOS2EP_NotGenIOCtl:
    558558    cmp     byte [es:bx + PKTHDR.cmd], 0dh          ; Open
    559     je      VBoxGuestOS2EP_Open
     559    je      vgdrvOS2EP_Open
    560560    cmp     byte [es:bx + PKTHDR.cmd], 0eh          ; Close
    561     je      VBoxGuestOS2EP_Close
     561    je      vgdrvOS2EP_Close
    562562    cmp     byte [es:bx + PKTHDR.cmd], 00h          ; Init
    563     je      VBoxGuestOS2EP_Init
     563    je      vgdrvOS2EP_Init
    564564%ifdef DEBUG_READ
    565565    cmp     byte [es:bx + PKTHDR.cmd], 04h          ; Read
    566     je near VBoxGuestOS2EP_Read
     566    je near vgdrvOS2EP_Read
    567567%endif
    568     jmp near VBoxGuestOS2EP_NotSupported
     568    jmp near vgdrvOS2EP_NotSupported
    569569
    570570
     
    572572    ; Open Request. w/ ring-0 init.
    573573    ;
    574 VBoxGuestOS2EP_Open:
     574vgdrvOS2EP_Open:
    575575    cmp     byte [NAME(g_fInitialized)], 1
    576     jne     VBoxGuestOS2EP_OpenOther
     576    jne     vgdrvOS2EP_OpenOther
    577577
    578578    ; First argument, the system file number.
     
    580580    push    eax
    581581
    582     JMP16TO32 VBoxGuestOS2EP_Open_32
     582    JMP16TO32 vgdrvOS2EP_Open_32
    583583segment TEXT32
    584 GLOBALNAME VBoxGuestOS2EP_Open_32
     584GLOBALNAME vgdrvOS2EP_Open_32
    585585
    586586    ; switch stack to 32-bit.
     
    591591
    592592    ; call the C code.
    593     call    NAME(VBoxGuestOS2Open)
     593    call    NAME(vgdrvOS2Open)
    594594
    595595    ; switch back the stack.
     
    598598    pop     eax
    599599
    600     JMP32TO16 VBoxGuestOS2EP_Open_16
     600    JMP32TO16 vgdrvOS2EP_Open_16
    601601segment CODE16
    602 GLOBALNAME VBoxGuestOS2EP_Open_16
     602GLOBALNAME vgdrvOS2EP_Open_16
    603603
    604604    les     bx, [bp - 4]                            ; Reload the packet pointer.
    605605    or      eax, eax
    606     jnz near VBoxGuestOS2EP_GeneralFailure
     606    jnz near vgdrvOS2EP_GeneralFailure
    607607    mov     word [es:bx + PKTHDR.status], 00100h    ; done, ok.
    608     jmp near VBoxGuestOS2EP_Done
     608    jmp near vgdrvOS2EP_Done
    609609
    610610    ; Initializing or failed init?
    611 VBoxGuestOS2EP_OpenOther:
     611vgdrvOS2EP_OpenOther:
    612612    cmp     byte [NAME(g_fInitialized)], 0
    613     jne     VBoxGuestOS2EP_OpenFailed
     613    jne     vgdrvOS2EP_OpenFailed
    614614
    615615    mov     byte [NAME(g_fInitialized)], -1
    616     call    NAME(VBoxGuestRing0Init)
     616    call    NAME(vgdrvRing0Init)
    617617    cmp     byte [NAME(g_fInitialized)], 1
    618     je      VBoxGuestOS2EP_Open
    619 
    620 VBoxGuestOS2EP_OpenFailed:
     618    je      vgdrvOS2EP_Open
     619
     620vgdrvOS2EP_OpenFailed:
    621621    mov     word [es:bx + PKTHDR.status], 0810fh    ; error, done, init failed.
    622     jmp near VBoxGuestOS2EP_Done
     622    jmp near vgdrvOS2EP_Done
    623623
    624624
     
    626626    ; Close Request.
    627627    ;
    628 VBoxGuestOS2EP_Close:
     628vgdrvOS2EP_Close:
    629629    ; First argument, the system file number.
    630630    movzx   eax, word [es:bx + PKTOPEN.sfn]
    631631    push    eax
    632632
    633     JMP16TO32 VBoxGuestOS2EP_Close_32
     633    JMP16TO32 vgdrvOS2EP_Close_32
    634634segment TEXT32
    635 GLOBALNAME VBoxGuestOS2EP_Close_32
     635GLOBALNAME vgdrvOS2EP_Close_32
    636636
    637637    ; switch stack to 32-bit.
     
    642642
    643643    ; call the C code.
    644     call    NAME(VBoxGuestOS2Close)
     644    call    NAME(vgdrvOS2Close)
    645645
    646646    ; switch back the stack.
     
    649649    pop     eax
    650650
    651     JMP32TO16 VBoxGuestOS2EP_Close_16
     651    JMP32TO16 vgdrvOS2EP_Close_16
    652652segment CODE16
    653 GLOBALNAME VBoxGuestOS2EP_Close_16
     653GLOBALNAME vgdrvOS2EP_Close_16
    654654
    655655    les     bx, [bp - 4]                            ; Reload the packet pointer.
    656656    or      eax, eax
    657     jnz near VBoxGuestOS2EP_GeneralFailure
     657    jnz near vgdrvOS2EP_GeneralFailure
    658658    mov     word [es:bx + PKTHDR.status], 00100h    ; done, ok.
    659     jmp near VBoxGuestOS2EP_Done
     659    jmp near vgdrvOS2EP_Done
    660660
    661661
     
    664664    ; Find the VMMDev adapter so we can unload the driver (and avoid trouble) if not found.
    665665    ;
    666 VBoxGuestOS2EP_Init:
    667     call    NAME(VBoxGuestFindAdapter)
     666vgdrvOS2EP_Init:
     667    call    NAME(vgdrvFindAdapter)
    668668    test    ax, ax
    669669    jz      .ok
    670670    mov     word [es:bx + PKTHDR.status], 0810fh    ; error, done, init failed.
    671     call    NAME(VBoxGuestOS2InitFlushText)
     671    call    NAME(vgdrvOS2InitFlushText)
    672672    jmp     .next
    673673.ok:
     
    678678    mov     word [es:bx + PKTINITOUT.cbData16], NAME(g_InitDataStart) wrt DATA16
    679679    mov     dword [es:bx + PKTINITOUT.fpaBPBs], 0
    680     jmp near VBoxGuestOS2EP_Done
     680    jmp near vgdrvOS2EP_Done
    681681
    682682
     
    686686    ; Return log data.
    687687    ;
    688 VBoxGuestOS2EP_Read:
     688vgdrvOS2EP_Read:
    689689    ; Any log data available?
    690690    xor     dx, dx
     
    735735    mov     word [es:bx + PKTRW.cbTrans], dx
    736736    mov     word [es:bx + PKTHDR.status], 00100h    ; done, ok.
    737     jmp near VBoxGuestOS2EP_Done
     737    jmp near vgdrvOS2EP_Done
    738738
    739739.log_phystovirt_failed:
    740740    les     bx, [bp - 4]                            ; Reload the packet pointer.
    741     jmp     VBoxGuestOS2EP_GeneralFailure
     741    jmp     vgdrvOS2EP_GeneralFailure
    742742%endif ; DEBUG_READ
    743743
     
    746746    ; Return 'unknown command' error.
    747747    ;
    748 VBoxGuestOS2EP_NotSupported:
     748vgdrvOS2EP_NotSupported:
    749749    mov     word [es:bx + PKTHDR.status], 08103h    ; error, done, unknown command.
    750     jmp     VBoxGuestOS2EP_Done
     750    jmp     vgdrvOS2EP_Done
    751751
    752752    ;
    753753    ; Return 'general failure' error.
    754754    ;
    755 VBoxGuestOS2EP_GeneralFailure:
     755vgdrvOS2EP_GeneralFailure:
    756756    mov     word [es:bx + PKTHDR.status], 0810ch    ; error, done, general failure.
    757     jmp     VBoxGuestOS2EP_Done
     757    jmp     vgdrvOS2EP_Done
    758758
    759759    ;
    760760    ; Non-optimized return path.
    761761    ;
    762 VBoxGuestOS2EP_Done:
     762vgdrvOS2EP_Done:
    763763    mov     sp, bp
    764764    pop     ebp
    765765    retf
    766 ENDPROC VBoxGuestOS2EP
     766ENDPROC VGDrvOS2Entrypoint
    767767
    768768
     
    773773; do ring-3 init and report failures.
    774774;
    775 GLOBALNAME VBoxGuestOS2InitEP
     775GLOBALNAME vgdrvOS2InitEntryPoint
    776776    ; The only request we're servicing is the 'init' one.
    777777    cmp     word [es:bx + PKTHDR.cmd], 0
    778     je near NAME(VBoxGuestOS2InitEPServiceInitReq)
     778    je near NAME(vgdrvOS2InitEntryPointServiceInitReq)
    779779
    780780    ; Ok, it's not the init request, just fail it.
     
    789789; will provide the entry points that we'll be using.
    790790;
    791 ; @cproto  void far __cdecl VBoxGuestOS2IDC(VBOXGUESTOS2IDCCONNECT far *fpConnectInfo);
     791; @cproto  void far __cdecl VGDrvOS2IDC(VBOXGUESTOS2IDCCONNECT far *fpConnectInfo);
    792792;
    793793; @param   fpConnectInfo   [bp + 8]     Pointer to an VBOXGUESTOS2IDCCONNECT structure.
    794794;
    795 GLOBALNAME VBoxGuestOS2IDC
     795GLOBALNAME VGDrvOS2IDC
    796796    push    ebp                         ; bp -  0h
    797797    mov     ebp, esp                   
     
    805805    and     sp, 0fffch
    806806
    807     JMP16TO32 VBoxGuestOS2IDC_32
     807    JMP16TO32 VGDrvOS2IDC_32
    808808segment TEXT32
    809 GLOBALNAME VBoxGuestOS2IDC_32
     809GLOBALNAME VGDrvOS2IDC_32
    810810
    811811    ; switch stack to 32-bit.
     
    816816
    817817    ; call the C code.
    818     call    NAME(VBoxGuestOS2IDCConnect)
     818    call    NAME(vgdrvOS2IDCConnect)
    819819
    820820    ;
     
    828828    mov     dword [ebx + VBGOS2IDC.u32Version       ], VMMDEV_VERSION
    829829    mov     dword [ebx + VBGOS2IDC.u32Session       ], eax
    830     mov     dword [ebx + VBGOS2IDC.pfnServiceEP     ], NAME(VBoxGuestOS2IDCService)
    831     mov     word  [ebx + VBGOS2IDC.fpfnServiceEP    ], NAME(VBoxGuestOs2IDCService16) wrt CODE16
     830    mov     dword [ebx + VBGOS2IDC.pfnServiceEP     ], NAME(VGDrvOS2IDCService)
     831    mov     word  [ebx + VBGOS2IDC.fpfnServiceEP    ], NAME(VGDrvOS2IDCService16) wrt CODE16
    832832    mov     word  [ebx + VBGOS2IDC.fpfnServiceEP + 2], CODE16
    833     mov     word  [ebx + VBGOS2IDC.fpfnServiceAsmEP ], NAME(VBoxGuestOs2IDCService16Asm) wrt CODE16
     833    mov     word  [ebx + VBGOS2IDC.fpfnServiceAsmEP ], NAME(VGDrvOS2IDCService16Asm) wrt CODE16
    834834    mov     word  [ebx + VBGOS2IDC.fpfnServiceAsmEP+2],CODE16
    835835
     
    840840    call    KernThunkStackTo16
    841841
    842     JMP32TO16 VBoxGuestOS2IDC_16
     842    JMP32TO16 VGDrvOS2IDC_16
    843843segment CODE16
    844 GLOBALNAME VBoxGuestOS2IDC_16
     844GLOBALNAME VGDrvOS2IDC_16
    845845
    846846    ; restore.
     
    854854    pop     ebp
    855855    retf
    856 ENDPROC VBoxGuestOS2IDC
     856ENDPROC VGDrvOS2IDC
    857857
    858858
     
    875875;                                         This can be NULL if pvData is NULL.
    876876;
    877 ; @cproto long far __cdecl VBoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction, void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned);
    878 ;
    879 GLOBALNAME VBoxGuestOs2IDCService16
     877; @cproto long far __cdecl VGDrvOS2IDCService16(uint32_t u32Session, uint16_t iFunction, void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned);
     878;
     879GLOBALNAME VGDrvOS2IDCService16
    880880    push    ebp                         ; bp -  0h
    881881    mov     ebp, esp                   
     
    908908    mov     dl, DevHlp_VirtToLin
    909909    call far [NAME(g_fpfnDevHlp)]
    910     jc near VBoxGuestOs2IDCService16_InvalidPointer
     910    jc near VGDrvOS2IDCService16_InvalidPointer
    911911    jmp     .finish_data
    912912.no_data:
     
    919919    push    ecx                         ; esp + 00h:    u32Session
    920920
    921     JMP16TO32 VBoxGuestOs2IDCService16_32
     921    JMP16TO32 VGDrvOS2IDCService16_32
    922922segment TEXT32
    923 GLOBALNAME VBoxGuestOs2IDCService16_32
     923GLOBALNAME VGDrvOS2IDCService16_32
    924924
    925925    ; switch stack to 32-bit.
     
    934934
    935935    ; call the C code (don't cleanup the stack).
    936     call    NAME(VBoxGuestOS2IDCService)
     936    call    NAME(VGDrvOS2IDCService)
    937937
    938938    ; switch back the stack.
     
    941941    pop     eax
    942942
    943     JMP32TO16 VBoxGuestOs2IDCService16_16
     943    JMP32TO16 VGDrvOS2IDCService16_16
    944944segment CODE16
    945 GLOBALNAME VBoxGuestOs2IDCService16_16
     945GLOBALNAME VGDrvOS2IDCService16_16
    946946
    947947    ; Set *pcbDataReturned.
     
    955955.no_pcbDataReturned:
    956956
    957 VBoxGuestOs2IDCService16_Done:
     957VGDrvOS2IDCService16_Done:
    958958    lea     sp, [bp - 10h]
    959959    pop     esi
     
    965965    retf
    966966
    967 VBoxGuestOs2IDCService16_InvalidPointer:
     967VGDrvOS2IDCService16_InvalidPointer:
    968968    mov     ax, VERR_INVALID_POINTER
    969     jmp     VBoxGuestOs2IDCService16_Done
    970 ENDPROC VBoxGuestOs2IDCService16
     969    jmp     VGDrvOS2IDCService16_Done
     970ENDPROC VGDrvOS2IDCService16
    971971
    972972
     
    974974; The 16-bit IDC entry point, register based.
    975975;
    976 ; This is just a wrapper around VBoxGuestOs2IDCService16 to simplify
     976; This is just a wrapper around VGDrvOS2IDCService16 to simplify
    977977; calls from 16-bit assembly code.
    978978;
     
    984984; @param   cbData              cx    - The size of the data buffer.
    985985;
    986 GLOBALNAME VBoxGuestOs2IDCService16Asm
     986GLOBALNAME VGDrvOS2IDCService16Asm
    987987    push    ebp                         ; bp - 0h
    988988    mov     ebp, esp
     
    10051005    mov     [bp - 18h], eax             ; bp - 18h (dd): u32Session
    10061006
    1007     call    NAME(VBoxGuestOs2IDCService16)
     1007    call    NAME(VGDrvOS2IDCService16)
    10081008
    10091009    mov     cx, [bp - 08h]              ; cbDataReturned.
     
    10131013    pop     ebp
    10141014    retf
    1015 ENDPROC VBoxGuestOs2IDCService16Asm
     1015ENDPROC VGDrvOS2IDCService16Asm
    10161016
    10171017
     
    10271027;
    10281028;
    1029 GLOBALNAME VBoxGuestOS2ISR16
     1029GLOBALNAME vgdrvOS2ISR16
    10301030    push    ebp
    10311031    mov     ebp, esp
     
    10431043    and     sp, 0fff0h                  ; align the stack (16-bytes make GCC extremely happy).
    10441044
    1045     JMP16TO32 VBoxGuestOS2ISR16_32
     1045    JMP16TO32 vgdrvOS2ISR16_32
    10461046segment TEXT32
    1047 GLOBALNAME VBoxGuestOS2ISR16_32
     1047GLOBALNAME vgdrvOS2ISR16_32
    10481048
    10491049    mov     ax, DATA32 wrt FLAT
     
    10531053    call    KernThunkStackTo32
    10541054
    1055     call    NAME(VBoxGuestOS2ISR)
     1055    call    NAME(vgdrvOS2ISR)
    10561056    mov     ebx, eax
    10571057
    10581058    call    KernThunkStackTo16
    10591059
    1060     JMP32TO16 VBoxGuestOS2ISR16_16
     1060    JMP32TO16 vgdrvOS2ISR16_16
    10611061segment CODE16
    1062 GLOBALNAME VBoxGuestOS2ISR16_16
     1062GLOBALNAME vgdrvOS2ISR16_16
    10631063
    10641064    lea     sp, [bp - 1eh]
     
    10931093    clc
    10941094    retf
    1095 ENDPROC VBoxGuestOS2ISR16
     1095ENDPROC vgdrvOS2ISR16
    10961096
    10971097
     
    11101110; @param    bIrq        [ebp + 8]       The IRQ number. (uint8_t)
    11111111;
    1112 GLOBALNAME VBoxGuestOS2SetIRQ
     1112GLOBALNAME vgdrvOS2DevHlpSetIRQ
    11131113    push    ebp
    11141114    mov     ebp, esp
     
    11201120    movzx   ebx, byte [ebp + 8]         ; load bIrq into BX.
    11211121
    1122     JMP32TO16 VBoxGuestOS2SetIRQ_16
     1122    JMP32TO16 vgdrvOS2DevHlpSetIRQ_16
    11231123segment CODE16
    1124 GLOBALNAME VBoxGuestOS2SetIRQ_16
     1124GLOBALNAME vgdrvOS2DevHlpSetIRQ_16
    11251125
    11261126    mov     ax, DATA16                  ; for g_fpfnDevHlp.
    11271127    mov     ds, ax
    1128     mov     ax, NAME(VBoxGuestOS2ISR16) ; The devhlp assume it's relative to DS.
     1128    mov     ax, NAME(vgdrvOS2ISR16)    ; The devhlp assume it's relative to DS.
    11291129    mov     dh, 1                       ; 1 = shared
    11301130    mov     dl, DevHlp_SetIRQ
     
    11401140
    11411141.go_back:
    1142     JMP16TO32 VBoxGuestOS2SetIRQ_32
     1142    JMP16TO32 vgdrvOS2DevHlpSetIRQ_32
    11431143segment TEXT32
    1144 GLOBALNAME VBoxGuestOS2SetIRQ_32
     1144GLOBALNAME vgdrvOS2DevHlpSetIRQ_32
    11451145
    11461146    pop     ds                          ; KernThunkStackTo32 ASSUMES flat DS and ES.
     
    11531153    pop     ebp
    11541154    ret
    1155 ENDPROC VBoxGuestOS2SetIRQ
     1155ENDPROC vgdrvOS2DevHlpSetIRQ
    11561156
    11571157
     
    11791179; The Ring-3 init code.
    11801180;
    1181 BEGINPROC VBoxGuestOS2InitEPServiceInitReq
     1181BEGINPROC vgdrvOS2InitEntryPointServiceInitReq
    11821182    push    ebp
    11831183    mov     ebp, esp
     
    12271227
    12281228    push    ax                                      ; Quickly flush any text.
    1229     call    NAME(VBoxGuestOS2InitFlushText)
     1229    call    NAME(vgdrvOS2InitFlushText)
    12301230    pop     ax
    12311231
     
    12751275    pop     ebp
    12761276    retf
    1277 ENDPROC VBoxGuestOS2InitEPServiceInitReq
     1277ENDPROC vgdrvOS2InitEntryPointServiceInitReq
    12781278
    12791279
     
    12811281; The Ring-0 init code.
    12821282;
    1283 BEGINPROC VBoxGuestRing0Init
     1283BEGINPROC vgdrvRing0Init
    12841284    push    es
    12851285    push    esi
     
    12951295    mov     dl, DevHlp_VirtToLin
    12961296    call far [NAME(g_fpfnDevHlp)]
    1297     jc near VBoxGuestRing0Init_done                 ; eax is non-zero on failure (can't happen)
    1298     push    eax                                     ; 00h - pszArgs (for VBoxGuestOS2Init).
     1297    jc near vgdrvRing0Init_done                     ; eax is non-zero on failure (can't happen)
     1298    push    eax                                     ; 00h - pszArgs (for vgdrvOS2Init).
    12991299
    13001300    ;
     
    13061306    ; Do 32-bit init
    13071307    ;
    1308     JMP16TO32 VBoxGuestRing0Init_32
     1308    JMP16TO32 vgdrvRing0Init_32
    13091309segment TEXT32
    1310 GLOBALNAME VBoxGuestRing0Init_32
     1310GLOBALNAME vgdrvRing0Init_32
    13111311
    13121312    ; switch stack to 32-bit.
     
    13171317
    13181318    ; call the C code.
    1319     call    NAME(VBoxGuestOS2Init)
     1319    call    NAME(vgdrvOS2Init)
    13201320
    13211321    ; switch back the stack and reload ds.
     
    13271327    mov     ds, dx
    13281328
    1329     JMP32TO16 VBoxGuestRing0Init_16
     1329    JMP32TO16 vgdrvRing0Init_16
    13301330segment CODE16_INIT
    1331 GLOBALNAME VBoxGuestRing0Init_16
     1331GLOBALNAME vgdrvRing0Init_16
    13321332
    13331333    ; check the result and set g_fInitialized on success.
    13341334    or      eax, eax
    1335     jnz     VBoxGuestRing0Init_done
     1335    jnz     vgdrvRing0Init_done
    13361336    mov     byte [NAME(g_fInitialized)], 1
    13371337
    1338 VBoxGuestRing0Init_done:
     1338vgdrvRing0Init_done:
    13391339    mov     sp, bp
    13401340    pop     ebp
     
    13421342    pop     es
    13431343    ret
    1344 ENDPROC VBoxGuestRing0Init
     1344ENDPROC vgdrvRing0Init
    13451345
    13461346
     
    13481348; Flush any text in the text buffer.
    13491349;
    1350 BEGINPROC VBoxGuestOS2InitFlushText
     1350BEGINPROC vgdrvOS2InitFlushText
    13511351    push    bp
    13521352    mov     bp, sp
     
    14071407    pop     bp
    14081408    ret
    1409 ENDPROC VBoxGuestOS2InitFlushText
     1409ENDPROC vgdrvOS2InitFlushText
    14101410
    14111411
     
    14271427; @uses     nothing.
    14281428;
    1429 BEGINPROC VBoxGuestFindAdapter
     1429BEGINPROC vgdrvFindAdapter
    14301430    push    ebx
    14311431    push    ecx
     
    16011601
    16021602    ;
    1603     ; Return to VBoxGuestOS2EP_Init.
     1603    ; Return to vgdrvOS2EP_Init.
    16041604    ;
    16051605.done:
     
    16471647    ;
    16481648    ; Nested function which reads a PCI config register.
    1649     ; (This operates on the VBoxGuestFindAdapter stack frame.)
     1649    ; (This operates on the vgdrvFindAdapter stack frame.)
    16501650    ;
    16511651    ; Input:
     
    16791679    ret
    16801680
    1681 ENDPROC VBoxGuestFindAdapter
     1681ENDPROC vgdrvFindAdapter
    16821682
    16831683
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestIDC-unix.c.h

    r58089 r58113  
    8989#endif
    9090
    91     LogRel(("VBoxGuestIDCOpen: VbgdCommonCreateKernelSession failed. rc=%d\n", rc));
     91    LogRel(("VBoxGuestIDCOpen: VGDrvCommonCreateKernelSession failed. rc=%d\n", rc));
    9292    return NULL;
    9393}
     
    103103{
    104104    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
    105     LogFlow(("VBoxGuestIDCClose:\n"));
     105    LogFlow(("VBoxGuestIDCClose: pvSession=%p\n", pvSession));
    106106
    107107    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    141141
    142142    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
    143     AssertMsgReturn(pSession->pDevExt == &g_DevExt,
    144                     ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE);
     143    AssertMsgReturn(pSession->pDevExt == &g_DevExt, ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE);
    145144
    146145    return VGDrvCommonIoCtl(iCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned);
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h

    r58089 r58113  
    11/* $Id$ */
    22/** @file
    3  * VBoxGuest - Guest Additions Driver.
     3 * VBoxGuest - Guest Additions Driver, Internal Header.
    44 */
    55
     
    6565    uint32_t volatile           fResEvents;
    6666#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
    67     /** Set by VbgdCommonWaitDoWakeUps before leaving the spinlock to call
     67    /** Set by VGDrvCommonWaitDoWakeUps before leaving the spinlock to call
    6868     *  RTSemEventMultiSignal. */
    6969    bool volatile               fPendingWakeUp;
    7070    /** Set by the requestor thread if it got the spinlock before the
    71      * signaller.  Deals with the race in VbgdCommonWaitDoWakeUps. */
     71     * signaller.  Deals with the race in VGDrvCommonWaitDoWakeUps. */
    7272    bool volatile               fFreeMe;
    7373#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