1 | Index: OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c
|
---|
2 | ===================================================================
|
---|
3 | --- OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c (revision 8827)
|
---|
4 | +++ OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c (working copy)
|
---|
5 | @@ -17,10 +17,23 @@
|
---|
6 | #include <Library/BaseLib.h>
|
---|
7 | #include <Library/IoLib.h>
|
---|
8 | #include <Library/PciLib.h>
|
---|
9 | +#include <Library/DebugLib.h>
|
---|
10 |
|
---|
11 | #define ACPI_TIMER_FREQUENCY 3579545
|
---|
12 | #define ACPI_TIMER_COUNT_SIZE 0x01000000
|
---|
13 |
|
---|
14 | +struct DeviceProbe
|
---|
15 | +{
|
---|
16 | + UINT8 Device;
|
---|
17 | + UINT16 VendorID;
|
---|
18 | + UINT16 DeviceID;
|
---|
19 | +};
|
---|
20 | +
|
---|
21 | +struct DeviceProbe DeviceProber[] =
|
---|
22 | +{
|
---|
23 | + {1, 0xabad, 0xbabe }, /*qemu, todo fill right values */
|
---|
24 | + {7, 0x8086, 0x7113 }, /*vbox*/
|
---|
25 | +};
|
---|
26 | /**
|
---|
27 | The constructor function enables ACPI IO space.
|
---|
28 |
|
---|
29 | @@ -36,17 +49,30 @@
|
---|
30 | VOID
|
---|
31 | )
|
---|
32 | {
|
---|
33 | - UINT8 Device;
|
---|
34 | + UINT8 Device = (UINT8)~0;
|
---|
35 | + UINT16 DeviceID;
|
---|
36 | + UINT16 VendorID;
|
---|
37 | + UINTN i;
|
---|
38 | + for (i = 0; i < 2; ++i)
|
---|
39 | + {
|
---|
40 | + VendorID = PciRead16(PCI_LIB_ADDRESS(0, DeviceProber[i].Device, 0, 0));
|
---|
41 | + DeviceID = PciRead16(PCI_LIB_ADDRESS(0, DeviceProber[i].Device, 0, 2));
|
---|
42 | + DEBUG((DEBUG_INFO, "TM(%d)(VendorID:%x, DeviceID(%x))\n", DeviceProber[i].Device, VendorID, DeviceID));
|
---|
43 | + if (VendorID == DeviceProber[i].VendorID
|
---|
44 | + && DeviceID == DeviceProber[i].DeviceID)
|
---|
45 | + {
|
---|
46 | + Device = DeviceProber[i].Device;
|
---|
47 | + break;
|
---|
48 | + }
|
---|
49 | + }
|
---|
50 | + ASSERT(Device != (UINT8)~0);
|
---|
51 |
|
---|
52 | - Device = 1;
|
---|
53 | - // Device = 7;
|
---|
54 | -
|
---|
55 | //
|
---|
56 | - // ACPI Timer enable is in Bus 0, Device ?, Function 3
|
---|
57 | + // ACPI Timer enable is in Bus 0, Device ?, Function 0
|
---|
58 | //
|
---|
59 | - PciOr8 (PCI_LIB_ADDRESS (0,Device,3,0x04), 0x01);
|
---|
60 | - PciAndThenOr32 (PCI_LIB_ADDRESS (0,Device,3,0x40), (UINT32) ~0xfc0, 0x400);
|
---|
61 | - PciOr8 (PCI_LIB_ADDRESS (0,Device,3,0x80), 0x01); return RETURN_SUCCESS;
|
---|
62 | + PciOr8 (PCI_LIB_ADDRESS (0,Device,0,0x04), 0x01);
|
---|
63 | + PciAndThenOr32 (PCI_LIB_ADDRESS (0,Device,0,0x40), (UINT32) ~0xfc0, 0x400);
|
---|
64 | + PciOr8 (PCI_LIB_ADDRESS (0,Device,0,0x80), 0x01); return RETURN_SUCCESS;
|
---|
65 | }
|
---|
66 |
|
---|
67 | /**
|
---|