2 // This file is part of the LinuxBIOS project.
4 // Copyright (C) 2007 Advanced Micro Devices, Inc.
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; version 2 of the License.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 //AMD FAM10 util for BUSB and res range
26 Method (OSTP, 0, NotSerialized)
28 If (LEqual (^OSTB, Ones))
36 Method (SEQL, 2, Serialized)
38 Store (SizeOf (Arg0), Local0)
39 Store (SizeOf (Arg1), Local1)
40 If (LNot (LEqual (Local0, Local1))) { Return (Zero) }
42 Name (BUF0, Buffer (Local0) {})
44 Name (BUF1, Buffer (Local0) {})
47 While (LLess (Local2, Local0))
49 Store (DerefOf (Index (BUF0, Local2)), Local3)
50 Store (DerefOf (Index (BUF1, Local2)), Local4)
51 If (LNot (LEqual (Local3, Local4))) { Return (Zero) }
60 Method (DADD, 2, NotSerialized)
64 Add( ShiftLeft(Local1,16), Local0, Local0)
69 Method (GHCE, 1, NotSerialized) // check if the HC enabled
71 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
72 if(LEqual ( And(Local1, 0x01), 0x01)) { Return (0x0F) }
73 Else { Return (0x00) }
76 Method (GHCN, 1, NotSerialized) // get the node num for the HC
79 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
80 Store (ShiftRight( And (Local1, 0xfc), 0x02), Local0)
84 Method (GHCL, 1, NotSerialized) // get the link num on node for the HC
87 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
88 Store (ShiftRight( And (Local1, 0x700), 0x08), Local0)
92 Method (GHCD, 2, NotSerialized) // get the unit id base for the HT device in HC
95 Store (DerefOf (Index (\_SB.PCI0.HCDN, Arg0)), Local1)
96 Store (Arg1, Local2) // Arg1 could be 3, 2, 1, 0
97 Multiply (Local2, 0x08, Local2) // change to 24, 16, 8, 0
98 Store (And (ShiftRight( Local1, Local2), 0xff), Local0)
102 Method (GBUS, 2, NotSerialized)
105 While (LLess (Local0, 0x20)) // 32 ht links
107 Store (DerefOf (Index (\_SB.PCI0.BUSN, Local0)), Local1)
108 If (LEqual (And (Local1, 0x03), 0x03))
110 If (LEqual (Arg0, ShiftRight (And (Local1, 0xfc), 0x02)))
112 If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x0700), 0x08))))
114 Return (ShiftRight (And (Local1, 0x000FF000), 0x0c))
125 Method (GWBN, 2, NotSerialized)
127 Name (BUF0, ResourceTemplate ()
129 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
130 0x0000, // Address Space Granularity
131 0x0000, // Address Range Minimum
132 0x0000, // Address Range Maximum
133 0x0000, // Address Translation Offset
136 CreateWordField (BUF0, 0x08, BMIN)
137 CreateWordField (BUF0, 0x0A, BMAX)
138 CreateWordField (BUF0, 0x0E, BLEN)
140 While (LLess (Local0, 0x20))
142 Store (DerefOf (Index (\_SB.PCI0.BUSN, Local0)), Local1)
143 If (LEqual (And (Local1, 0x03), 0x03))
145 If (LEqual (Arg0, ShiftRight (And (Local1, 0xfc), 0x02)))
147 If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x0700), 0x08))))
149 Store (ShiftRight (And (Local1, 0x000FF000), 0x0c), BMIN)
150 Store (ShiftRight (Local1, 0x14), BMAX)
151 Subtract (BMAX, BMIN, BLEN)
164 Method (GMEM, 2, NotSerialized)
166 Name (BUF0, ResourceTemplate ()
168 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
169 0x00000000, // Address Space Granularity
170 0x00000000, // Address Range Minimum
171 0x00000000, // Address Range Maximum
172 0x00000000, // Address Translation Offset
174 , AddressRangeMemory, TypeStatic)
176 CreateDWordField (BUF0, 0x0A, MMIN)
177 CreateDWordField (BUF0, 0x0E, MMAX)
178 CreateDWordField (BUF0, 0x16, MLEN)
182 While (LLess (Local0, 0x80)) // 0x20 links * 2(mem, prefmem ) *2 ( base, limit )
184 Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local1)
186 Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local2)
187 If (LEqual (And (Local1, 0x03), 0x03))
189 If (LEqual (Arg0, And (Local2, 0x3f)))
191 If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x70), 0x04))))
193 Store (ShiftLeft (And (Local1, 0xFFFFFF00), 0x08), MMIN)
194 Store (ShiftLeft (And (Local2, 0xFFFFFF00), 0x08), MMAX)
195 Or (MMAX, 0xFFFF, MMAX)
196 Subtract (MMAX, MMIN, MLEN)
200 Concatenate (RTAG (BUF0), Local3, Local5)
201 Store (Local5, Local3)
205 If (LOr (LAnd (LEqual (Arg1, 0xFF), LEqual (Arg0, 0x00)), LEqual (Arg1, \_SB.PCI0.SBLK)))
207 Store (\_SB.PCI0.TOM1, MMIN)
208 Subtract (MMAX, MMIN, MLEN)
212 Store (RTAG (BUF0), Local3)
231 Method (GIOR, 2, NotSerialized)
233 Name (BUF0, ResourceTemplate ()
235 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
236 0x00000000, // Address Space Granularity
237 0x00000000, // Address Range Minimum
238 0x00000000, // Address Range Maximum
239 0x00000000, // Address Translation Offset
243 CreateDWordField (BUF0, 0x0A, PMIN)
244 CreateDWordField (BUF0, 0x0E, PMAX)
245 CreateDWordField (BUF0, 0x16, PLEN)
249 While (LLess (Local0, 0x40)) // 0x20 ht links * 2 ( base, limit)
251 Store (DerefOf (Index (\_SB.PCI0.PCIO, Local0)), Local1)
253 Store (DerefOf (Index (\_SB.PCI0.PCIO, Local0)), Local2)
254 If (LEqual (And (Local1, 0x03), 0x03))
256 If (LEqual (Arg0, And (Local2, 0x3f)))
258 If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x70), 0x04))))
260 Store (And (Local1, 0x01FFF000), PMIN)
261 Store (And (Local2, 0x01FFF000), PMAX)
262 Or (PMAX, 0x0FFF, PMAX)
263 Subtract (PMAX, PMIN, PLEN)
268 Concatenate (RTAG (BUF0), Local3, Local5)
269 Store (Local5, Local3)
273 If (LGreater (PMAX, PMIN))
275 If (LOr (LAnd (LEqual (Arg1, 0xFF), LEqual (Arg0, 0x00)), LEqual (Arg1, \_SB.PCI0.SBLK)))
278 Subtract (PMAX, PMIN, PLEN)
282 Store (RTAG (BUF0), Local3)
286 If (And (Local1, 0x10))
293 Concatenate (RTAG (BUF0), Local3, Local5)
294 Store (Local5, Local3)
298 Store (RTAG (BUF0), Local3)
313 Store (RTAG (BUF0), Local3)
319 Method (RTAG, 1, NotSerialized)
322 Store (SizeOf (Local0), Local1)
323 Subtract (Local1, 0x02, Local1)
324 Multiply (Local1, 0x08, Local1)
325 CreateField (Local0, 0x00, Local1, RETB)