VirtualBox

Changeset 25966 in vbox for trunk/src/VBox/Devices/PC


Ignore:
Timestamp:
Jan 22, 2010 11:15:43 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56818
Message:

PDMIBASE refactoring; use UUID as interface IDs.

Location:
trunk/src/VBox/Devices/PC
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r25928 r25966  
    3333# include <iprt/alloc.h>
    3434# include <iprt/string.h>
     35# include <iprt/uuid.h>
    3536#endif /* IN_RING3 */
    3637
     
    19351936
    19361937/**
    1937  * Queries an interface to the driver.
    1938  *
    1939  * @returns Pointer to interface.
    1940  * @returns NULL if the interface was not supported by the driver.
    1941  * @param   pInterface          Pointer to this interface structure.
    1942  * @param   enmInterface        The requested interface identification.
    1943  * @thread  Any thread.
     1938 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    19441939 */
    1945 static DECLCALLBACK(void *) acpiQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
    1946 {
    1947     ACPIState *pThis = (ACPIState*)((uintptr_t)pInterface - RT_OFFSETOF(ACPIState, IBase));
    1948     switch (enmInterface)
    1949     {
    1950         case PDMINTERFACE_BASE:
    1951             return &pThis->IBase;
    1952         case PDMINTERFACE_ACPI_PORT:
    1953             return &pThis->IACPIPort;
    1954         default:
    1955             return NULL;
    1956     }
     1940static DECLCALLBACK(void *) acpiQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     1941{
     1942    ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IBase);
     1943    if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
     1944        return &pThis->IBase;
     1945    if (RTUuidCompare2Strs(pszIID, PDMINTERFACE_ACPI_PORT) == 0)
     1946        return &pThis->IACPIPort;
     1947    return NULL;
    19571948}
    19581949
  • trunk/src/VBox/Devices/PC/DrvACPI.cpp

    r25893 r25966  
    3333#include <iprt/assert.h>
    3434#include <iprt/string.h>
     35#include <iprt/uuid.h>
    3536
    3637#ifdef RT_OS_LINUX
     
    6667/**
    6768 * ACPI driver instance data.
     69 *
     70 * @implements  PDMIACPICONNECTOR
    6871 */
    6972typedef struct DRVACPI
     
    7982
    8083/**
    81  * Queries an interface to the driver.
    82  *
    83  * @returns Pointer to interface.
    84  * @returns NULL if the interface was not supported by the driver.
    85  * @param   pInterface          Pointer to this interface structure.
    86  * @param   enmInterface        The requested interface identification.
    87  * @thread  Any thread.
     84 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    8885 */
    89 static DECLCALLBACK(void *) drvACPIQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
     86static DECLCALLBACK(void *) drvACPIQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    9087{
    9188    PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
    9289    PDRVACPI pThis = PDMINS_2_DATA(pDrvIns, PDRVACPI);
    93     switch (enmInterface)
    94     {
    95         case PDMINTERFACE_BASE:
    96             return &pDrvIns->IBase;
    97         case PDMINTERFACE_ACPI_CONNECTOR:
    98             return &pThis->IACPIConnector;
    99         default:
    100             return NULL;
    101     }
     90
     91    if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
     92        return &pDrvIns->IBase;
     93    if (RTUuidCompare2Strs(pszIID, PDMINTERFACE_ACPI_CONNECTOR) == 0)
     94        return &pThis->IACPIConnector;
     95    return NULL;
    10296}
    10397
     
    117111    {
    118112        /* running on battery? */
    119         if (    (powerStatus.ACLineStatus == 0)
    120              || (powerStatus.ACLineStatus == 255)
    121              && (powerStatus.BatteryFlag & 15))
     113        if (    powerStatus.ACLineStatus == 0   /* Offline */
     114             || powerStatus.ACLineStatus == 255 /* Unknown */
     115             && (powerStatus.BatteryFlag & 15)  /* high | low | critical | charging */
     116           ) /** @todo why is 'charging' included in the flag test?  Add parenthesis around the right bits so the code is clearer. */
    122117        {
    123118            *pPowerSource = PDM_ACPI_POWER_SOURCE_BATTERY;
  • trunk/src/VBox/Devices/PC/DrvAcpiCpu.cpp

    r25893 r25966  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2929#include <iprt/assert.h>
    3030#include <iprt/string.h>
     31#include <iprt/uuid.h>
    3132
    3233#include "Builtins.h"
    3334
     35
    3436/**
    35  * Queries an interface to the driver.
    36  *
    37  * @returns Pointer to interface.
    38  * @returns NULL if the interface was not supported by the driver.
    39  * @param   pInterface          Pointer to this interface structure.
    40  * @param   enmInterface        The requested interface identification.
    41  * @thread  Any thread.
     37 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    4238 */
    43 static DECLCALLBACK(void *) drvACPICpuQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
     39static DECLCALLBACK(void *) drvACPICpuQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    4440{
    4541    PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
    46 
    47     switch (enmInterface)
    48     {
    49         case PDMINTERFACE_BASE:
    50             return &pDrvIns->IBase;
    51         default:
    52             return NULL;
    53     }
     42    if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
     43        return &pDrvIns->IBase;
     44    return NULL;
    5445}
    5546
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette