1/* SPDX-License-Identifier: LGPL-2.1-only */
2/******************************************************************************
3 * DSDT for Xen with Qemu device model
4 *
5 * Copyright (c) 2004, Intel Corporation.
6 */
7
8DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
9{
10    Name (\PMBS, 0x0C00)
11    Name (\PMLN, 0x08)
12    Name (\IOB1, 0x00)
13    Name (\IOL1, 0x00)
14    Name (\APCB, 0xFEC00000)
15    Name (\APCL, 0x00010000)
16    Name (\PUID, 0x00)
17
18
19    Scope (\_SB)
20    {
21
22        /* Fix HCT test for 0x400 pci memory:
23         * - need to report low 640 MB mem as motherboard resource
24         */
25       Device(MEM0)
26       {
27           Name(_HID, EISAID("PNP0C02"))
28           Name(_CRS, ResourceTemplate() {
29               QWordMemory(
30                    ResourceConsumer, PosDecode, MinFixed,
31                    MaxFixed, Cacheable, ReadWrite,
32                    0x00000000,
33                    0x00000000,
34                    0x0009ffff,
35                    0x00000000,
36                    0x000a0000)
37           })
38       }
39
40       Device (PCI0)
41       {
42           Name (_HID, EisaId ("PNP0A03"))
43           Name (_UID, 0x00)
44           Name (_ADR, 0x00)
45           Name (_BBN, 0x00)
46
47           /* Make cirrues VGA S3 suspend/resume work in Windows XP/2003 */
48           Device (VGA)
49           {
50               Name (_ADR, 0x00020000)
51
52               Method (_S1D, 0, NotSerialized)
53               {
54                   Return (0x00)
55               }
56               Method (_S2D, 0, NotSerialized)
57               {
58                   Return (0x00)
59               }
60               Method (_S3D, 0, NotSerialized)
61               {
62                   Return (0x00)
63               }
64           }
65
66           Method (_CRS, 0, NotSerialized)
67           {
68               Store (ResourceTemplate ()
69               {
70                   /* bus number is from 0 - 255*/
71                   WordBusNumber(
72                        ResourceProducer, MinFixed, MaxFixed, SubDecode,
73                        0x0000,
74                        0x0000,
75                        0x00FF,
76                        0x0000,
77                        0x0100)
78                    IO (Decode16, 0x0CF8, 0x0CF8, 0x01, 0x08)
79                    WordIO(
80                        ResourceProducer, MinFixed, MaxFixed, PosDecode,
81                        EntireRange,
82                        0x0000,
83                        0x0000,
84                        0x0CF7,
85                        0x0000,
86                        0x0CF8)
87                    WordIO(
88                        ResourceProducer, MinFixed, MaxFixed, PosDecode,
89                        EntireRange,
90                        0x0000,
91                        0x0D00,
92                        0xFFFF,
93                        0x0000,
94                        0xF300)
95
96                    /* reserve memory for pci devices */
97                    DWordMemory(
98                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
99                        WriteCombining, ReadWrite,
100                        0x00000000,
101                        0x000A0000,
102                        0x000BFFFF,
103                        0x00000000,
104                        0x00020000)
105
106                    DWordMemory(
107                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
108                        NonCacheable, ReadWrite,
109                        0x00000000,
110                        0xF0000000,
111                        0xF4FFFFFF,
112                        0x00000000,
113                        0x05000000,
114                        ,, _Y01)
115
116                    QWordMemory (
117                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
118                        NonCacheable, ReadWrite,
119                        0x0000000000000000,
120                        0x0000000FFFFFFFF0,
121                        0x0000000FFFFFFFFF,
122                        0x0000000000000000,
123                        0x0000000000000010,
124                        ,, _Y02)
125
126                }, Local1)
127
128                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._MIN, MMIN)
129                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._MAX, MMAX)
130                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._LEN, MLEN)
131
132                Store(\_SB.PMIN, MMIN)
133                Store(\_SB.PLEN, MLEN)
134                Add(MMIN, MLEN, MMAX)
135                Subtract(MMAX, One, MMAX)
136
137                /*
138                 * WinXP / Win2K3 blue-screen for operations on 64-bit values.
139                 * Therefore we need to split the 64-bit calculations needed
140                 * here, but different iasl versions evaluate name references
141                 * to integers differently:
142                 * Year (approximate)          2006    2008    2012
143                 * \_SB.PCI0._CRS._Y02         zero   valid   valid
144                 * \_SB.PCI0._CRS._Y02._MIN   valid   valid    huge
145                 */
146                If(LEqual(Zero, \_SB.PCI0._CRS._Y02)) {
147                    Subtract(\_SB.PCI0._CRS._Y02._MIN, 14, Local0)
148                } Else {
149                    Store(\_SB.PCI0._CRS._Y02, Local0)
150                }
151                CreateDWordField(Local1, Add(Local0, 14), MINL)
152                CreateDWordField(Local1, Add(Local0, 18), MINH)
153                CreateDWordField(Local1, Add(Local0, 22), MAXL)
154                CreateDWordField(Local1, Add(Local0, 26), MAXH)
155                CreateDWordField(Local1, Add(Local0, 38), LENL)
156                CreateDWordField(Local1, Add(Local0, 42), LENH)
157
158                Store(\_SB.LMIN, MINL)
159                Store(\_SB.HMIN, MINH)
160                Store(\_SB.LLEN, LENL)
161                Store(\_SB.HLEN, LENH)
162                Add(MINL, LENL, MAXL)
163                Add(MINH, LENH, MAXH)
164                If(LLess(MAXL, MINL)) {
165                    Add(MAXH, One, MAXH)
166                }
167                If(LOr(MINH, LENL)) {
168                    If(LEqual(MAXL, 0)) {
169                        Subtract(MAXH, One, MAXH)
170                    }
171                    Subtract(MAXL, One, MAXL)
172                }
173
174                Return (Local1)
175            }
176
177            Device(HPET) {
178                Name(_HID,  EISAID("PNP0103"))
179                Name(_UID, 0)
180                Method (_STA, 0, NotSerialized) {
181                    If(LEqual(\_SB.HPET, 0)) {
182                        Return(0x00)
183                    } Else {
184                        Return(0x0F)
185                    }
186                }
187                Name(_CRS, ResourceTemplate() {
188                    DWordMemory(
189                        ResourceConsumer, PosDecode, MinFixed, MaxFixed,
190                        NonCacheable, ReadWrite,
191                        0x00000000,
192                        0xFED00000,
193                        0xFED003FF,
194                        0x00000000,
195                        0x00000400 /* 1K memory: FED00000 - FED003FF */
196                    )
197                })
198            }
199
200            Device (ISA)
201            {
202                Name (_ADR, 0x00010000) /* device 1, fn 0 */
203
204                OperationRegion(PIRQ, PCI_Config, 0x60, 0x4)
205                Scope(\) {
206                    Field (\_SB.PCI0.ISA.PIRQ, ByteAcc, NoLock, Preserve) {
207                        PIRA, 8,
208                        PIRB, 8,
209                        PIRC, 8,
210                        PIRD, 8
211                    }
212                }
213                Device (SYSR)
214                {
215                    Name (_HID, EisaId ("PNP0C02"))
216                    Name (_UID, 0x01)
217                    Name (CRS, ResourceTemplate ()
218                    {
219                        /* TODO: list hidden resources */
220                        IO (Decode16, 0x0010, 0x0010, 0x00, 0x10)
221                        IO (Decode16, 0x0022, 0x0022, 0x00, 0x0C)
222                        IO (Decode16, 0x0030, 0x0030, 0x00, 0x10)
223                        IO (Decode16, 0x0044, 0x0044, 0x00, 0x1C)
224                        IO (Decode16, 0x0062, 0x0062, 0x00, 0x02)
225                        IO (Decode16, 0x0065, 0x0065, 0x00, 0x0B)
226                        IO (Decode16, 0x0072, 0x0072, 0x00, 0x0E)
227                        IO (Decode16, 0x0080, 0x0080, 0x00, 0x01)
228                        IO (Decode16, 0x0084, 0x0084, 0x00, 0x03)
229                        IO (Decode16, 0x0088, 0x0088, 0x00, 0x01)
230                        IO (Decode16, 0x008C, 0x008C, 0x00, 0x03)
231                        IO (Decode16, 0x0090, 0x0090, 0x00, 0x10)
232                        IO (Decode16, 0x00A2, 0x00A2, 0x00, 0x1C)
233                        IO (Decode16, 0x00E0, 0x00E0, 0x00, 0x10)
234                        IO (Decode16, 0x08A0, 0x08A0, 0x00, 0x04)
235                        IO (Decode16, 0x0CC0, 0x0CC0, 0x00, 0x10)
236                        IO (Decode16, 0x04D0, 0x04D0, 0x00, 0x02)
237                    })
238                    Method (_CRS, 0, NotSerialized)
239                    {
240                        Return (CRS)
241                    }
242                }
243
244                Device (PIC)
245                {
246                    Name (_HID, EisaId ("PNP0000"))
247                    Name (_CRS, ResourceTemplate ()
248                    {
249                        IO (Decode16, 0x0020, 0x0020, 0x01, 0x02)
250                        IO (Decode16, 0x00A0, 0x00A0, 0x01, 0x02)
251                        IRQNoFlags () {2}
252                    })
253                }
254
255                Device (DMA0)
256                {
257                    Name (_HID, EisaId ("PNP0200"))
258                    Name (_CRS, ResourceTemplate ()
259                    {
260                        DMA (Compatibility, BusMaster, Transfer8) {4}
261                        IO (Decode16, 0x0000, 0x0000, 0x00, 0x10)
262                        IO (Decode16, 0x0081, 0x0081, 0x00, 0x03)
263                        IO (Decode16, 0x0087, 0x0087, 0x00, 0x01)
264                        IO (Decode16, 0x0089, 0x0089, 0x00, 0x03)
265                        IO (Decode16, 0x008F, 0x008F, 0x00, 0x01)
266                        IO (Decode16, 0x00C0, 0x00C0, 0x00, 0x20)
267                        IO (Decode16, 0x0480, 0x0480, 0x00, 0x10)
268                    })
269                }
270
271                Device (TMR)
272                {
273                    Name (_HID, EisaId ("PNP0100"))
274                    Name (_CRS, ResourceTemplate ()
275                    {
276                        IO (Decode16, 0x0040, 0x0040, 0x00, 0x04)
277                        IRQNoFlags () {0}
278                    })
279                }
280
281                Device (RTC)
282                {
283                    Name (_HID, EisaId ("PNP0B00"))
284                    Name (_CRS, ResourceTemplate ()
285                    {
286                        IO (Decode16, 0x0070, 0x0070, 0x00, 0x02)
287                        IRQNoFlags () {8}
288                    })
289                }
290
291                Device (SPKR)
292                {
293                    Name (_HID, EisaId ("PNP0800"))
294                    Name (_CRS, ResourceTemplate ()
295                    {
296                        IO (Decode16, 0x0061, 0x0061, 0x00, 0x01)
297                    })
298                }
299
300                Device (PS2M)
301                {
302                    Name (_HID, EisaId ("PNP0F13"))
303                    Name (_CID, 0x130FD041)
304                    Method (_STA, 0, NotSerialized)
305                    {
306                        Return (0x0F)
307                    }
308
309                    Name (_CRS, ResourceTemplate ()
310                    {
311                        IRQNoFlags () {12}
312                    })
313                }
314
315                Device (PS2K)
316                {
317                    Name (_HID, EisaId ("PNP0303"))
318                    Name (_CID, 0x0B03D041)
319                    Method (_STA, 0, NotSerialized)
320                    {
321                        Return (0x0F)
322                    }
323
324                    Name (_CRS, ResourceTemplate ()
325                    {
326                        IO (Decode16, 0x0060, 0x0060, 0x00, 0x01)
327                        IO (Decode16, 0x0064, 0x0064, 0x00, 0x01)
328                        IRQNoFlags () {1}
329                    })
330                }
331
332                Device (FDC0)
333                {
334                    Name (_HID, EisaId ("PNP0700"))
335                    Method (_STA, 0, NotSerialized)
336                    {
337                          Return (0x0F)
338                    }
339
340                    Name (_CRS, ResourceTemplate ()
341                    {
342                        IO (Decode16, 0x03F0, 0x03F0, 0x01, 0x06)
343                        IO (Decode16, 0x03F7, 0x03F7, 0x01, 0x01)
344                        IRQNoFlags () {6}
345                        DMA (Compatibility, NotBusMaster, Transfer8) {2}
346                    })
347                }
348
349                Device (UAR1)
350                {
351                    Name (_HID, EisaId ("PNP0501"))
352                    Name (_UID, 0x01)
353                    Method (_STA, 0, NotSerialized)
354                    {
355                        If(LEqual(\_SB.UAR1, 0)) {
356                            Return(0x00)
357                        } Else {
358                            Return(0x0F)
359                        }
360                    }
361
362                    Name (_CRS, ResourceTemplate()
363                    {
364                        IO (Decode16, 0x03F8, 0x03F8, 8, 8)
365                        IRQNoFlags () {4}
366                    })
367                }
368
369                Device (UAR2)
370                {
371                    Name (_HID, EisaId ("PNP0501"))
372                    Name (_UID, 0x02)
373                    Method (_STA, 0, NotSerialized)
374                    {
375                        If(LEqual(\_SB.UAR2, 0)) {
376                            Return(0x00)
377                        } Else {
378                            Return(0x0F)
379                        }
380                    }
381
382                    Name (_CRS, ResourceTemplate()
383                    {
384                        IO (Decode16, 0x02F8, 0x02F8, 8, 8)
385                        IRQNoFlags () {3}
386                    })
387                }
388
389                Device (LTP1)
390                {
391                    Name (_HID, EisaId ("PNP0400"))
392                    Name (_UID, 0x02)
393                    Method (_STA, 0, NotSerialized)
394                    {
395                        If(LEqual(\_SB.LTP1, 0)) {
396                            Return(0x00)
397                        } Else {
398                            Return(0x0F)
399                        }
400                    }
401
402                    Name (_CRS, ResourceTemplate()
403                    {
404                        IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
405                        IRQNoFlags () {7}
406                    })
407                }
408
409                Device(VGID) {
410                    Name(_HID, EisaId ("XEN0000"))
411                    Name(_UID, 0x00)
412                    Name(_CID, "VM_Gen_Counter")
413                    Name(_DDN, "VM_Gen_Counter")
414                    Method(_STA, 0, NotSerialized)
415                    {
416                        If(LEqual(\_SB.VGIA, 0x00000000)) {
417                            Return(0x00)
418                        } Else {
419                            Return(0x0F)
420                        }
421                    }
422                    Name(PKG, Package ()
423                    {
424                        0x00000000,
425                        0x00000000
426                    })
427                    Method(ADDR, 0, NotSerialized)
428                    {
429                        Store(\_SB.VGIA, Index(PKG, 0))
430                        Return(PKG)
431                    }
432                }
433            }
434        }
435    }
436    /* _S3 and _S4 are in separate SSDTs */
437    Name (\_S5, Package (0x04) {
438        0x00,  /* PM1a_CNT.SLP_TYP */
439        0x00,  /* PM1b_CNT.SLP_TYP */
440        0x00,  /* reserved */
441        0x00   /* reserved */
442    })
443    Name(PICD, 0)
444    Method(_PIC, 1) {
445        Store(Arg0, PICD)
446    }
447}
448