Increase ROM_IMAGE_SIZE for the agami aruma to resolve overlapping
[coreboot.git] / src / mainboard / agami / aruma / dx / amdk8_util.asl
1 /*
2  * Copyright 2005 AMD
3  */
4
5 //AMD k8 util for BUSB and res range
6
7     Scope (\_SB)
8     {
9
10         Name (OSTB, Ones)
11         Method (OSTP, 0, NotSerialized)
12         {
13             If (LEqual (^OSTB, Ones))
14             {
15                 Store (0x00, ^OSTB)
16             }
17
18             Return (^OSTB)
19         }
20
21        Method (SEQL, 2, Serialized)
22         {
23             Store (SizeOf (Arg0), Local0)
24             Store (SizeOf (Arg1), Local1)
25             If (LNot (LEqual (Local0, Local1))) { Return (Zero) }
26
27             Name (BUF0, Buffer (Local0) {})
28             Store (Arg0, BUF0)
29             Name (BUF1, Buffer (Local0) {})
30             Store (Arg1, BUF1)
31             Store (Zero, Local2)
32             While (LLess (Local2, Local0))
33             {
34                 Store (DerefOf (Index (BUF0, Local2)), Local3)
35                 Store (DerefOf (Index (BUF1, Local2)), Local4)
36                 If (LNot (LEqual (Local3, Local4))) { Return (Zero) }
37
38                 Increment (Local2)
39             }
40
41             Return (One)
42         }
43
44
45         Method (DADD, 2, NotSerialized)
46         {
47                 Store( Arg1, Local0)
48                 Store( Arg0, Local1)
49                 Add( ShiftLeft(Local1,16), Local0, Local0)
50                 Return (Local0)
51         }
52
53
54         Method (GHCE, 1, NotSerialized) // check if the HC enabled
55         {
56                 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
57                 if(LEqual ( And(Local1, 0x01), 0x01)) { Return (0x0F) }
58                 Else { Return (0x00) }
59         }
60
61         Method (GHCN, 1, NotSerialized) // get the node num for the HC
62         {
63                 Store (0x00, Local0)
64                 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
65                 Store (ShiftRight( And (Local1, 0xf0), 0x04), Local0)
66                 Return (Local0)
67         }
68
69         Method (GHCL, 1, NotSerialized) // get the link num on node for the HC
70         {
71                 Store (0x00, Local0)
72                 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
73                 Store (ShiftRight( And (Local1, 0xf00), 0x08), Local0)
74                 Return (Local0)
75         }
76
77         Method (GHCD, 2, NotSerialized) // get the unit id base for the HT device in HC
78         {
79                 Store (0x00, Local0)
80                 Store (DerefOf (Index (\_SB.PCI0.HCDN, Arg0)), Local1)
81                 Store (Arg1, Local2) // Arg1 could be 3, 2, 1, 0
82                 Multiply (Local2, 0x08, Local2) // change to 24, 16, 8, 0
83                 Store (And (ShiftRight( Local1, Local2), 0xff), Local0)
84                 Return (Local0)
85         }
86
87         Method (GBUS, 2, NotSerialized)
88         {
89             Store (0x00, Local0)
90             While (LLess (Local0, 0x04))
91             {
92                 Store (DerefOf (Index (\_SB.PCI0.BUSN, Local0)), Local1)
93                 If (LEqual (And (Local1, 0x03), 0x03))
94                 {
95                     If (LEqual (Arg0, ShiftRight (And (Local1, 0x70), 0x04)))
96                     {
97                         If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x0300), 0x08))))
98                         {
99                             Return (ShiftRight (And (Local1, 0x00FF0000), 0x10))
100                         }
101                     }
102                 }
103
104                 Increment (Local0)
105             }
106
107             Return (0x00)
108         }
109
110         Method (GWBN, 2, NotSerialized)
111         {
112             Name (BUF0, ResourceTemplate ()
113             {
114                 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
115                     0x0000, // Address Space Granularity
116                     0x0000, // Address Range Minimum
117                     0x0000, // Address Range Maximum
118                     0x0000, // Address Translation Offset
119                     0x0000,,,)
120             })
121             CreateWordField (BUF0, 0x08, BMIN)
122             CreateWordField (BUF0, 0x0A, BMAX)
123             CreateWordField (BUF0, 0x0E, BLEN)
124             Store (0x00, Local0)
125             While (LLess (Local0, 0x04))
126             {
127                 Store (DerefOf (Index (\_SB.PCI0.BUSN, Local0)), Local1)
128                 If (LEqual (And (Local1, 0x03), 0x03))
129                 {
130                     If (LEqual (Arg0, ShiftRight (And (Local1, 0x70), 0x04)))
131                     {
132                         If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x0300), 0x08))))
133                         {
134                             Store (ShiftRight (And (Local1, 0x00FF0000), 0x10), BMIN)
135                             Store (ShiftRight (Local1, 0x18), BMAX)
136                             Subtract (BMAX, BMIN, BLEN)
137                             Increment (BLEN)
138                             Return (RTAG (BUF0))
139                         }
140                     }
141                 }
142
143                 Increment (Local0)
144             }
145
146             Return (RTAG (BUF0))
147         }
148
149         Method (GMEM, 2, NotSerialized)
150         {
151             Name (BUF0, ResourceTemplate ()
152             {
153                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
154                     0x00000000, // Address Space Granularity
155                     0x00000000, // Address Range Minimum
156                     0x00000000, // Address Range Maximum
157                     0x00000000, // Address Translation Offset
158                     0x00000000,,,
159                     , AddressRangeMemory, TypeStatic)
160             })
161             CreateDWordField (BUF0, 0x0A, MMIN)
162             CreateDWordField (BUF0, 0x0E, MMAX)
163             CreateDWordField (BUF0, 0x16, MLEN)
164             Store (0x00, Local0)
165             Store (0x00, Local4)
166             Store (0x00, Local3)
167             While (LLess (Local0, 0x10))
168             {
169                 Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local1)
170                 Increment (Local0)
171                 Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local2)
172                 If (LEqual (And (Local1, 0x03), 0x03))
173                 {
174                     If (LEqual (Arg0, And (Local2, 0x07)))
175                     {
176                         If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local2, 0x30), 0x04))))
177                         {
178                             Store (ShiftLeft (And (Local1, 0xFFFFFF00), 0x08), MMIN)
179                             Store (ShiftLeft (And (Local2, 0xFFFFFF00), 0x08), MMAX)
180                             Or (MMAX, 0xFFFF, MMAX)
181                             Subtract (MMAX, MMIN, MLEN)
182
183                             If (Local4)
184                             {
185                                 Concatenate (RTAG (BUF0), Local3, Local5)
186                                 Store (Local5, Local3)
187                             }
188                             Else
189                             {
190                                 If (LOr (LAnd (LEqual (Arg1, 0xFF), LEqual (Arg0, 0x00)), LEqual (Arg1, \_SB.PCI0.SBLK)))
191                                 {
192                                     Store (\_SB.PCI0.TOM1, MMIN)
193                                     Subtract (MMAX, MMIN, MLEN)
194                                     Increment (MLEN)
195                                 }
196
197                                 Store (RTAG (BUF0), Local3)
198                             }
199
200                             Increment (Local4)
201                         }
202                     }
203                 }
204
205                 Increment (Local0)
206             }
207
208             If (LNot (Local4))
209             {
210                 Store (BUF0, Local3)
211             }
212
213             Return (Local3)
214         }
215
216         Method (GIOR, 2, NotSerialized)
217         {
218             Name (BUF0, ResourceTemplate ()
219             {
220                 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
221                     0x00000000, // Address Space Granularity
222                     0x00000000, // Address Range Minimum
223                     0x00000000, // Address Range Maximum
224                     0x00000000, // Address Translation Offset
225                     0x00000000,,,
226                     , TypeStatic)
227             })
228             CreateDWordField (BUF0, 0x0A, PMIN)
229             CreateDWordField (BUF0, 0x0E, PMAX)
230             CreateDWordField (BUF0, 0x16, PLEN)
231             Store (0x00, Local0)
232             Store (0x00, Local4)
233             Store (0x00, Local3)
234             While (LLess (Local0, 0x08))
235             {
236                 Store (DerefOf (Index (\_SB.PCI0.PCIO, Local0)), Local1)
237                 Increment (Local0)
238                 Store (DerefOf (Index (\_SB.PCI0.PCIO, Local0)), Local2)
239                 If (LEqual (And (Local1, 0x03), 0x03))
240                 {
241                     If (LEqual (Arg0, And (Local2, 0x07)))
242                     {
243                         If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local2, 0x30), 0x04))))
244                         {
245                             Store (And (Local1, 0x01FFF000), PMIN)
246                             Store (And (Local2, 0x01FFF000), PMAX)
247                             Or (PMAX, 0x0FFF, PMAX)
248                             Subtract (PMAX, PMIN, PLEN)
249                             Increment (PLEN)
250
251                             If (Local4)
252                             {
253                                 Concatenate (RTAG (BUF0), Local3, Local5)
254                                 Store (Local5, Local3)
255                             }
256                             Else
257                             {
258                                 If (LGreater (PMAX, PMIN))
259                                 {
260                                     If (LOr (LAnd (LEqual (Arg1, 0xFF), LEqual (Arg0, 0x00)), LEqual (Arg1, \_SB.PCI0.SBLK)))
261                                     {
262                                         Store (0x0D00, PMIN)
263                                         Subtract (PMAX, PMIN, PLEN)
264                                         Increment (PLEN)
265                                     }
266
267                                     Store (RTAG (BUF0), Local3)
268                                     Increment (Local4)
269                                 }
270
271                                 If (And (Local1, 0x10))
272                                 {
273                                     Store (0x03B0, PMIN)
274                                     Store (0x03DF, PMAX)
275                                     Store (0x30, PLEN)
276                                     If (Local4)
277                                     {
278                                         Concatenate (RTAG (BUF0), Local3, Local5)
279                                         Store (Local5, Local3)
280                                     }
281                                     Else
282                                     {
283                                         Store (RTAG (BUF0), Local3)
284                                     }
285                                 }
286                             }
287
288                             Increment (Local4)
289                         }
290                     }
291                 }
292
293                 Increment (Local0)
294             }
295
296             If (LNot (Local4))
297             {
298                 Store (RTAG (BUF0), Local3)
299             }
300
301             Return (Local3)
302         }
303
304         Method (RTAG, 1, NotSerialized)
305         {
306             Store (Arg0, Local0)
307             Store (SizeOf (Local0), Local1)
308             Subtract (Local1, 0x02, Local1)
309             Multiply (Local1, 0x08, Local1)
310             CreateField (Local0, 0x00, Local1, RETB)
311             Store (RETB, Local2)
312             Return (Local2)
313         }
314     }
315