VirtualBox

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/fdc.c

    r22793 r25966  
    11#ifdef VBOX
     2/* $Id: $ */
    23/** @file
    3  *
    4  * VBox storage devices:
    5  * Floppy disk controller
     4 * VBox storage devices: Floppy disk controller
    65 */
    76
     
    5554#include <VBox/pdmdev.h>
    5655#include <iprt/assert.h>
     56#include <iprt/string.h>
    5757#include <iprt/uuid.h>
    58 #include <iprt/string.h>
    5958
    6059#include "Builtins.h"
     
    143142} fdisk_flags_t;
    144143
     144#ifdef VBOX
     145/**
     146 * The status for one drive.
     147 *
     148 * @implements  PDMIBASE
     149 * @implements  PDMIBLOCKPORT
     150 * @implements  PDMIMOUNTNOTIFY
     151 */
     152#endif
    145153typedef struct fdrive_t {
    146154#ifndef VBOX
     
    356364            /* @todo */ /** @todo r=bird: todo what exactly?!?!? */
    357365            {
    358                 uint64_t size = drv->pDrvBlock->pfnGetSize (drv->pDrvBlock);
    359                 nb_sectors = size / 512;
     366                uint64_t size2 = drv->pDrvBlock->pfnGetSize (drv->pDrvBlock);
     367                nb_sectors = size2 / 512;
    360368            }
    361369#endif /* VBOX */
     
    495503#define FD_FORMAT_CMD(state) ((state) & FD_STATE_FORMAT)
    496504
     505#ifdef VBOX
     506/**
     507 * Floppy controller state.
     508 *
     509 * @implements  PDMILEDPORTS
     510 */
     511#endif
    497512struct fdctrl_t {
    498513#ifndef VBOX
     
    540555    PPDMDEVINS pDevIns;
    541556
    542     /** Status Port - The base interface. */
     557    /** Status LUN: The base interface. */
    543558    PDMIBASE IBaseStatus;
    544     /** Status Port - The Leds interface. */
     559    /** Status LUN: The Leds interface. */
    545560    PDMILEDPORTS ILeds;
    546     /** Status Port - The Partner of ILeds. */
     561    /** Status LUN: The Partner of ILeds. */
    547562    PPDMILEDCONNECTORS pLedsConnector;
    548563#endif
     
    12431258            {
    12441259                uint32_t read;
    1245                 int rc = PDMDevHlpDMAWriteMemory(fdctrl->pDevIns, nchan,
    1246                                                  fdctrl->fifo + rel_pos,
    1247                                                  fdctrl->data_pos,
    1248                                                  len, &read);
     1260                int rc2 = PDMDevHlpDMAWriteMemory(fdctrl->pDevIns, nchan,
     1261                                                  fdctrl->fifo + rel_pos,
     1262                                                  fdctrl->data_pos,
     1263                                                  len, &read);
    12491264                dump (fdctrl->fifo + rel_pos, len);
    1250                 AssertMsgRC (rc, ("DMAWriteMemory -> %Rrc\n", rc));
     1265                AssertMsgRC (rc2, ("DMAWriteMemory -> %Rrc\n", rc2));
    12511266            }
    12521267#else
     
    12621277            {
    12631278                uint32_t written;
    1264                 int rc = PDMDevHlpDMAReadMemory(fdctrl->pDevIns, nchan,
    1265                                                 fdctrl->fifo + rel_pos,
    1266                                                 fdctrl->data_pos,
    1267                                                 len, &written);
    1268                 AssertMsgRC (rc, ("DMAReadMemory -> %Rrc\n", rc));
     1279                int rc2 = PDMDevHlpDMAReadMemory(fdctrl->pDevIns, nchan,
     1280                                                 fdctrl->fifo + rel_pos,
     1281                                                 fdctrl->data_pos,
     1282                                                 len, &written);
     1283                AssertMsgRC (rc2, ("DMAReadMemory -> %Rrc\n", rc2));
    12691284            }
    12701285#else
     
    13081323                int ret;
    13091324#ifdef VBOX
    1310                 int rc;
    13111325                uint32_t read;
    1312 
    1313                 rc = PDMDevHlpDMAReadMemory (fdctrl->pDevIns, nchan, tmpbuf,
    1314                                              fdctrl->data_pos, len, &read);
    1315                 AssertMsg (RT_SUCCESS (rc), ("DMAReadMemory -> %Rrc\n", rc));
     1326                int rc2 = PDMDevHlpDMAReadMemory (fdctrl->pDevIns, nchan, tmpbuf,
     1327                                                  fdctrl->data_pos, len, &read);
     1328                AssertMsg (RT_SUCCESS (rc2), ("DMAReadMemory -> %Rrc2\n", rc2));
    13161329#else
    13171330                DMA_read_memory (nchan, tmpbuf, fdctrl->data_pos, len);
     
    24852498
    24862499/**
    2487  * Queries an interface to the driver.
    2488  *
    2489  * @returns Pointer to interface.
    2490  * @returns NULL if the interface was not supported by the device.
    2491  * @param   pInterface          Pointer to IDEState::IBase.
    2492  * @param   enmInterface        The requested interface identification.
     2500 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    24932501 */
    2494 static DECLCALLBACK(void *) fdQueryInterface (PPDMIBASE pInterface,
    2495                                               PDMINTERFACE enmInterface)
    2496 {
    2497     fdrive_t *drv = PDMIBASE_2_FDRIVE(pInterface);
    2498     switch (enmInterface) {
    2499     case PDMINTERFACE_BASE:
    2500         return &drv->IBase;
    2501     case PDMINTERFACE_BLOCK_PORT:
    2502         return &drv->IPort;
    2503     case PDMINTERFACE_MOUNT_NOTIFY:
    2504         return &drv->IMountNotify;
    2505     default:
    2506         return NULL;
    2507     }
     2502static DECLCALLBACK(void *) fdQueryInterface (PPDMIBASE pInterface, const char *pszIID)
     2503{
     2504    fdrive_t *pDrive = PDMIBASE_2_FDRIVE(pInterface);
     2505    if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
     2506        return &pDrive->IBase;
     2507    if (RTUuidCompare2Strs(pszIID, PDMINTERFACE_BLOCK_PORT) == 0)
     2508        return &pDrive->IPort;
     2509    if (RTUuidCompare2Strs(pszIID, PDMINTERFACE_MOUNT_NOTIFY) == 0)
     2510        return &pDrive->IMountNotify;
     2511    return NULL;
    25082512}
    25092513
     
    25322536
    25332537/**
    2534  * Queries an interface to the status LUN.
    2535  *
    2536  * @returns Pointer to interface.
    2537  * @returns NULL if the interface was not supported by the device.
    2538  * @param   pInterface          Pointer to IDEState::IBase.
    2539  * @param   enmInterface        The requested interface identification.
     2538 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    25402539 */
    2541 static DECLCALLBACK(void *) fdcStatusQueryInterface (PPDMIBASE pInterface,
    2542                                                      PDMINTERFACE enmInterface)
    2543 {
    2544     fdctrl_t *fdctrl = (fdctrl_t *)
    2545         ((uintptr_t)pInterface - RT_OFFSETOF (fdctrl_t, IBaseStatus));
    2546     switch (enmInterface) {
    2547     case PDMINTERFACE_BASE:
    2548         return &fdctrl->IBaseStatus;
    2549     case PDMINTERFACE_LED_PORTS:
    2550         return &fdctrl->ILeds;
    2551     default:
    2552         return NULL;
    2553     }
     2540static DECLCALLBACK(void *) fdcStatusQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     2541{
     2542    fdctrl_t *pThis = RT_FROM_MEMBER (pInterface, fdctrl_t, IBaseStatus);
     2543
     2544    if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
     2545        return &pThis->IBaseStatus;
     2546    if (RTUuidCompare2Strs(pszIID, PDMINTERFACE_LED_PORTS) == 0)
     2547        return &pThis->ILeds;
     2548    return NULL;
    25542549}
    25552550
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