acpi: EJ0 method name patching
[seabios.git] / src / ssdt-pcihp.dsl
1 ACPI_EXTRACT_ALL_CODE ssdp_pcihp_aml
2
3 DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
4 {
5
6 /****************************************************************
7  * PCI hotplug
8  ****************************************************************/
9
10     /* Objects supplied by DSDT */
11     External (\_SB.PCI0, DeviceObj)
12     External (\_SB.PCI0.PRMV, MethodObj)
13     External (\_SB.PCI0.PCEJ, MethodObj)
14
15     Scope(\_SB.PCI0) {
16
17 #define gen_pci_device(slot)                                    \
18         Device(SL##slot) {                                      \
19             Name (_ADR, 0x##slot##0000)                         \
20             Method (_RMV) { Return (PRMV(0x##slot)) }           \
21             Name (_SUN, 0x##slot)                               \
22         }
23
24         /* VGA (slot 1) and ISA bus (slot 2) defined in DSDT */
25         gen_pci_device(03)
26         gen_pci_device(04)
27         gen_pci_device(05)
28         gen_pci_device(06)
29         gen_pci_device(07)
30         gen_pci_device(08)
31         gen_pci_device(09)
32         gen_pci_device(0a)
33         gen_pci_device(0b)
34         gen_pci_device(0c)
35         gen_pci_device(0d)
36         gen_pci_device(0e)
37         gen_pci_device(0f)
38         gen_pci_device(10)
39         gen_pci_device(11)
40         gen_pci_device(12)
41         gen_pci_device(13)
42         gen_pci_device(14)
43         gen_pci_device(15)
44         gen_pci_device(16)
45         gen_pci_device(17)
46         gen_pci_device(18)
47         gen_pci_device(19)
48         gen_pci_device(1a)
49         gen_pci_device(1b)
50         gen_pci_device(1c)
51         gen_pci_device(1d)
52         gen_pci_device(1e)
53         gen_pci_device(1f)
54
55         /* Bulk generated PCI hotplug devices */
56         // Method _EJ0 can be patched by BIOS to EJ0_
57         // at runtime, if the slot is detected to not support hotplug.
58         // Extract the offset of the address dword and the
59         // _EJ0 name to allow this patching.
60 #define hotplug_slot(slot)                              \
61         Device (S##slot) {                              \
62            ACPI_EXTRACT_NAME_DWORD_CONST aml_adr_dword  \
63            Name (_ADR, 0x##slot##0000)                  \
64            ACPI_EXTRACT_METHOD_STRING aml_ej0_name      \
65            Method (_EJ0, 1) { Return(PCEJ(0x##slot)) }  \
66            Name (_SUN, 0x##slot)                        \
67         }
68
69         hotplug_slot(01)
70         hotplug_slot(02)
71         hotplug_slot(03)
72         hotplug_slot(04)
73         hotplug_slot(05)
74         hotplug_slot(06)
75         hotplug_slot(07)
76         hotplug_slot(08)
77         hotplug_slot(09)
78         hotplug_slot(0a)
79         hotplug_slot(0b)
80         hotplug_slot(0c)
81         hotplug_slot(0d)
82         hotplug_slot(0e)
83         hotplug_slot(0f)
84         hotplug_slot(10)
85         hotplug_slot(11)
86         hotplug_slot(12)
87         hotplug_slot(13)
88         hotplug_slot(14)
89         hotplug_slot(15)
90         hotplug_slot(16)
91         hotplug_slot(17)
92         hotplug_slot(18)
93         hotplug_slot(19)
94         hotplug_slot(1a)
95         hotplug_slot(1b)
96         hotplug_slot(1c)
97         hotplug_slot(1d)
98         hotplug_slot(1e)
99         hotplug_slot(1f)
100
101 #define gen_pci_hotplug(slot)   \
102             If (LEqual(Arg0, 0x##slot)) { Notify(S##slot, Arg1) }
103
104         Method(PCNT, 2) {
105             gen_pci_hotplug(01)
106             gen_pci_hotplug(02)
107             gen_pci_hotplug(03)
108             gen_pci_hotplug(04)
109             gen_pci_hotplug(05)
110             gen_pci_hotplug(06)
111             gen_pci_hotplug(07)
112             gen_pci_hotplug(08)
113             gen_pci_hotplug(09)
114             gen_pci_hotplug(0a)
115             gen_pci_hotplug(0b)
116             gen_pci_hotplug(0c)
117             gen_pci_hotplug(0d)
118             gen_pci_hotplug(0e)
119             gen_pci_hotplug(0f)
120             gen_pci_hotplug(10)
121             gen_pci_hotplug(11)
122             gen_pci_hotplug(12)
123             gen_pci_hotplug(13)
124             gen_pci_hotplug(14)
125             gen_pci_hotplug(15)
126             gen_pci_hotplug(16)
127             gen_pci_hotplug(17)
128             gen_pci_hotplug(18)
129             gen_pci_hotplug(19)
130             gen_pci_hotplug(1a)
131             gen_pci_hotplug(1b)
132             gen_pci_hotplug(1c)
133             gen_pci_hotplug(1d)
134             gen_pci_hotplug(1e)
135             gen_pci_hotplug(1f)
136         }
137     }
138 }