VirtualBox

Changeset 82214 in vbox for trunk/src


Ignore:
Timestamp:
Nov 26, 2019 2:51:43 AM (5 years ago)
Author:
vboxsync
Message:

DevEFI: Converted I/O port handler. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/DevEFI.cpp

    r81591 r82214  
    143143    /** The flash device containing the NVRAM. */
    144144    FLASHCORE               Flash;
     145    /** The 8 I/O ports at 0xEF10 (EFI_PORT_BASE). */
     146    IOMIOPORTHANDLE         hIoPorts;
    145147    /** The flash MMIO handle. */
    146148    IOMMMIOHANDLE           hMmioFlash;
     
    13381340        case EFI_IMAGE_EVT_CMD_COMPLETE:
    13391341        {
    1340 #ifdef IN_RING3
     1342# ifdef IN_RING3
    13411343            AssertBreak(EFI_IMAGE_EVT_GET_PAYLOAD(u32) == 0);
    13421344
     
    13861388            }
    13871389            return VINF_SUCCESS;
    1388 #else
     1390# else
    13891391            return VINF_IOM_R3_IOPORT_WRITE;
    1390 #endif
     1392# endif
    13911393        }
    13921394
     
    14311433
    14321434/**
    1433  * Port I/O Handler for IN operations.
    1434  *
    1435  * @returns VBox status code.
    1436  *
    1437  * @param   pDevIns     The device instance.
    1438  * @param   pvUser      User argument - ignored.
    1439  * @param   Port        Port number used for the IN operation.
    1440  * @param   pu32        Where to store the result.
    1441  * @param   cb          Number of bytes read.
    1442  */
    1443 static DECLCALLBACK(int) efiIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     1435 * @callback_method_impl{FNIOMIOPORTNEWIN}
     1436 *
     1437 * @note The @a offPort parameter is absolute!
     1438 */
     1439static DECLCALLBACK(VBOXSTRICTRC) efiR3IoPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
    14441440{
    14451441    RT_NOREF(pvUser);
    14461442    PDEVEFIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PDEVEFIR3);
    1447     Log4(("EFI in: %x %x\n", Port, cb));
    1448 
    1449     switch (Port)
     1443    Log4(("EFI in: %x %x\n", offPort, cb));
     1444
     1445    switch (offPort)
    14501446    {
    14511447        case EFI_INFO_PORT:
     
    14681464
    14691465        case EFI_PANIC_PORT:
    1470 #ifdef IN_RING3
     1466# ifdef IN_RING3
    14711467           LogRel(("EFI panic port read!\n"));
    14721468           /* Insert special code here on panic reads */
    14731469           return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "EFI Panic: panic port read!\n");
    1474 #else
     1470# else
    14751471           /* Reschedule to R3 */
    14761472           return VINF_IOM_R3_IOPORT_READ;
    1477 #endif
     1473# endif
    14781474
    14791475        case EFI_PORT_VARIABLE_OP:
     
    15171513
    15181514/**
    1519  * Port I/O Handler for OUT operations.
    1520  *
    1521  * @returns VBox status code.
    1522  *
    1523  * @param   pDevIns     The device instance.
    1524  * @param   pvUser      User argument - ignored.
    1525  * @param   Port        Port number used for the IN operation.
    1526  * @param   u32         The value to output.
    1527  * @param   cb          The value size in bytes.
    1528  */
    1529 static DECLCALLBACK(int) efiIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1515 * @callback_method_impl{FNIOMIOPORTNEWOUT}
     1516 *
     1517 * @note The @a offPort parameter is absolute!
     1518 */
     1519static DECLCALLBACK(VBOXSTRICTRC) efiR3IoPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    15301520{
    15311521    RT_NOREF(pvUser);
    15321522    PDEVEFIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PDEVEFIR3);
    1533     int     rc    = VINF_SUCCESS;
    1534     Log4(("efi: out %x %x %d\n", Port, u32, cb));
    1535 
    1536     switch (Port)
     1523    VBOXSTRICTRC rc   = VINF_SUCCESS;
     1524    Log4(("efi: out %x %x %d\n", offPort, u32, cb));
     1525
     1526    switch (offPort)
    15371527    {
    15381528        case EFI_INFO_PORT:
     
    16561646
    16571647        case EFI_PORT_DEBUG_POINT:
    1658 #ifdef IN_RING3
     1648# ifdef IN_RING3
    16591649            if (u32 > EFIDBGPOINT_INVALID && u32 < EFIDBGPOINT_END)
    16601650            {
     
    16661656                rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "Invalid debug point %#x\n", u32);
    16671657            break;
    1668 #else
     1658# else
    16691659            return VINF_IOM_R3_IOPORT_WRITE;
    1670 #endif
     1660# endif
    16711661
    16721662        case EFI_PORT_IMAGE_EVENT:
     
    16751665
    16761666        default:
    1677             Log(("EFI: Write to reserved port %RTiop: %#x (cb=%d)\n", Port, u32, cb));
     1667            Log(("EFI: Write to reserved port %RTiop: %#x (cb=%d)\n", offPort, u32, cb));
    16781668            break;
    16791669    }
     
    26402630     * Register our I/O ports.
    26412631     */
    2642     rc = PDMDevHlpIOPortRegister(pDevIns, EFI_PORT_BASE, EFI_PORT_COUNT, NULL,
    2643                                  efiIOPortWrite, efiIOPortRead,
    2644                                  NULL, NULL, "EFI communication ports");
    2645     if (RT_FAILURE(rc))
    2646         return rc;
     2632    rc = PDMDevHlpIoPortCreateFlagsAndMap(pDevIns, EFI_PORT_BASE, EFI_PORT_COUNT, IOM_IOPORT_F_ABS,
     2633                                          efiR3IoPortWrite, efiR3IoPortRead,
     2634                                          "EFI communication ports", NULL /*paExtDescs*/, &pThis->hIoPorts);
     2635    AssertRCReturn(rc, rc);
    26472636
    26482637    /*
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