VirtualBox

Changeset 25928 in vbox


Ignore:
Timestamp:
Jan 20, 2010 11:58:14 AM (15 years ago)
Author:
vboxsync
Message:

ACPI: HPET work

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

Legend:

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

    r25855 r25928  
    466466AssertCompileSize(ACPITBLIOAPIC, 12);
    467467
     468
     469
     470/* HPET Descriptor Structure */
     471struct ACPITBLHPET
     472{
     473    ACPITBLHEADER aHeader;
     474    uint32_t      u32Id;
     475    ACPIGENADDR   HpetAddr;
     476    uint8_t       u32Number;
     477    uint16_t      u32MinTick;
     478    uint8_t       u8Attributes;
     479};
     480
    468481# ifdef IN_RING3 /** @todo r=bird: Move this down to where it's used. */
    469482
     
    872885}
    873886
     887
     888/** High Performance Event Timer (HPET) descriptor */
     889static void acpiSetupHPET(ACPIState *s, RTGCPHYS32 addr)
     890{
     891    ACPITBLHPET hpet;
     892
     893    memset(&hpet, 0, sizeof(hpet));
     894
     895    acpiPrepareHeader(&hpet.aHeader, "HPET", sizeof(hpet), 1);
     896    /* Keep base address consistent with appropriate DSDT entry  (vbox.dsl) */
     897    acpiWriteGenericAddr(&hpet.HpetAddr,
     898                         0  /* Memory address space */,
     899                         64 /* Register bit width */,
     900                         0  /* Bit offset */,
     901                         0, /* Register access size, is it correct? */
     902                         0xfed00000 /* Address */);
     903
     904    hpet.u32Id        = 0x8086a201; /* must match what HPET ID returns, is it correct ? */
     905    hpet.u32Number    = 0;
     906    hpet.u32MinTick   = 4096;
     907    hpet.u8Attributes = 0;
     908
     909    hpet.aHeader.u8Checksum = acpiChecksum((uint8_t *)&hpet, sizeof(hpet));
     910
     911    acpiPhyscpy(s, addr, (const uint8_t *)&hpet, sizeof(hpet));
     912}
     913
    874914/* SCI IRQ */
    875915DECLINLINE(void) acpiSetIrq(ACPIState *s, int level)
     
    19231963{
    19241964    int        rc;
    1925     RTGCPHYS32 rsdt_addr, xsdt_addr, fadt_acpi1_addr, fadt_acpi2_addr, facs_addr, dsdt_addr, last_addr, apic_addr = 0;
     1965    RTGCPHYS32 cur_addr, rsdt_addr, xsdt_addr, fadt_acpi1_addr, fadt_acpi2_addr, facs_addr, dsdt_addr, hpet_addr, apic_addr = 0;
    19261966    uint32_t   addend = 0;
    19271967    RTGCPHYS32 rsdt_addrs[4];
    19281968    RTGCPHYS32 xsdt_addrs[4];
    1929     uint32_t   cAddr;
     1969    uint32_t   cAddr, madt_index, hpet_index;
    19301970    size_t     rsdt_tbl_len = sizeof(ACPITBLHEADER);
    19311971    size_t     xsdt_tbl_len = sizeof(ACPITBLHEADER);
     
    19331973    cAddr = 1;           /* FADT */
    19341974    if (s->u8UseIOApic)
    1935         cAddr++;         /* MADT */
     1975        madt_index = cAddr++;         /* MADT */
     1976
     1977
     1978    if (s->fUseHpet)
     1979        hpet_index = cAddr++;         /* HPET */
    19361980
    19371981    rsdt_tbl_len += cAddr*4;  /* each entry: 32 bits phys. address. */
     
    19642008    s->cbRamLow = (uint32_t)cbRamLow;
    19652009
    1966     rsdt_addr = 0;
    1967     xsdt_addr = RT_ALIGN_32(rsdt_addr + rsdt_tbl_len, 16);
    1968     fadt_acpi1_addr = RT_ALIGN_32(xsdt_addr       + xsdt_tbl_len, 16);
    1969     fadt_acpi2_addr = RT_ALIGN_32(fadt_acpi1_addr + ACPITBLFADT_VERSION1_SIZE, 16);
     2010    cur_addr = 0;
     2011
     2012    rsdt_addr = cur_addr;
     2013    cur_addr = RT_ALIGN_32(cur_addr + rsdt_tbl_len, 16);
     2014
     2015    xsdt_addr = cur_addr;
     2016    cur_addr = RT_ALIGN_32(cur_addr       + xsdt_tbl_len, 16);
     2017
     2018    fadt_acpi1_addr = cur_addr;
     2019    cur_addr = RT_ALIGN_32(cur_addr + ACPITBLFADT_VERSION1_SIZE, 16);
     2020
     2021    fadt_acpi2_addr = cur_addr;
    19702022    /** @todo ACPI 3.0 doc says it needs to be aligned on a 64 byte boundary. */
    1971     facs_addr = RT_ALIGN_32(fadt_acpi2_addr + sizeof(ACPITBLFADT), 16);
     2023    cur_addr = RT_ALIGN_32(cur_addr + sizeof(ACPITBLFADT), 16);
     2024
     2025
     2026    facs_addr = cur_addr;
     2027    cur_addr = RT_ALIGN_32(cur_addr + sizeof(ACPITBLFACS), 16);
     2028
    19722029    if (s->u8UseIOApic)
    19732030    {
    1974         apic_addr = RT_ALIGN_32(facs_addr + sizeof(ACPITBLFACS), 16);
    1975         /**
    1976          * @todo nike: maybe some refactoring needed to compute tables layout,
    1977          * but as this code is executed only once it doesn't make sense to optimize much
    1978          */
    1979         dsdt_addr = RT_ALIGN_32(apic_addr + AcpiTableMADT::sizeFor(s), 16);
    1980     }
    1981     else
    1982     {
    1983         dsdt_addr = RT_ALIGN_32(facs_addr + sizeof(ACPITBLFACS), 16);
     2031        apic_addr = cur_addr;
     2032        cur_addr = RT_ALIGN_32(cur_addr + AcpiTableMADT::sizeFor(s), 16);
     2033    }
     2034    if (s->fUseHpet)
     2035    {
     2036        hpet_addr = cur_addr;
     2037        cur_addr = RT_ALIGN_32(cur_addr + sizeof(ACPITBLHPET), 16);
    19842038    }
    19852039
     
    19902044        return rc;
    19912045
    1992     last_addr = RT_ALIGN_32(dsdt_addr + uDsdtSize, 16);
    1993     if (last_addr > 0x10000)
     2046    dsdt_addr = cur_addr;
     2047    cur_addr = RT_ALIGN_32(cur_addr + uDsdtSize, 16);
     2048
     2049    if (cur_addr > 0x10000)
    19942050        return PDMDEV_SET_ERROR(s->pDevIns, VERR_TOO_MUCH_DATA,
    19952051                                N_("Error: ACPI tables > 64KB"));
     
    20002056    Log(("FACS 0x%08X FADT (1.0) 0x%08X, FADT (2+) 0x%08X\n", facs_addr + addend, fadt_acpi1_addr + addend, fadt_acpi2_addr + addend));
    20012057    Log(("DSDT 0x%08X\n", dsdt_addr + addend));
     2058    if (s->fUseHpet)
     2059    {
     2060        Log(("HPET 0x%08X\n", hpet_addr + addend));
     2061    }
    20022062    acpiSetupRSDP((ACPITBLRSDP*)s->au8RSDPPage, rsdt_addr + addend, xsdt_addr + addend);
    20032063    acpiSetupDSDT(s, dsdt_addr + addend, pDsdtCode, uDsdtSize);
     
    20112071    {
    20122072        acpiSetupMADT(s, apic_addr + addend);
    2013         rsdt_addrs[1] = apic_addr + addend;
    2014         xsdt_addrs[1] = apic_addr + addend;
     2073        rsdt_addrs[madt_index] = apic_addr + addend;
     2074        xsdt_addrs[madt_index] = apic_addr + addend;
     2075    }
     2076    if (s->fUseHpet)
     2077    {
     2078        acpiSetupHPET(s, hpet_addr + addend);
     2079        rsdt_addrs[hpet_index] = hpet_addr + addend;
     2080        xsdt_addrs[hpet_index] = hpet_addr + addend;
    20152081    }
    20162082
  • trunk/src/VBox/Devices/PC/vbox.dsl

    r25895 r25928  
    891891                // High Precision Event Timer
    892892                Device(HPET) {
    893                 Name(_HID,  EISAID("PNP0103"))
    894                 Name (_CID, 0x010CD041)
     893                Name (_HID,  EISAID("PNP0103"))
     894                Name (_CID, EISAID("PNP0C01"))
    895895                Name(_UID, 0)
    896896                Method (_STA, 0, NotSerialized) {
    897897                    Return(UHPT)
    898898                }
    899                 Name(_CRS, ResourceTemplate() {
     899                Name(CRS, ResourceTemplate() {
    900900                 IRQNoFlags ()
    901901                            {0}
     
    904904                 Memory32Fixed (ReadWrite,
    905905                            0xFED00000,         // Address Base
    906                             0x00000400,         // Address Length
    907                             _Y16)
     906                            0x00000400         // Address Length
     907                            )
    908908                  })
     909               
     910                }
     911                Method (_CRS, 0, NotSerialized)
     912                {
     913                     Return (CRS)
    909914                }
    910915
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