Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 5 | * Copyright (C) 2010 Siemens AG, Inc. |
| 6 | * (Written by Josef Kellermann <joseph.kellermann@heitec.de> for Siemens AG, Inc.) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | Scope(\_SB) { |
| 24 | #include "globutil.asl" |
| 25 | } |
| 26 | */ |
| 27 | |
| 28 | /* string compare functions */ |
| 29 | Method(MIN, 2) |
| 30 | { |
| 31 | if (LLess(Arg0, Arg1)) { |
| 32 | Return(Arg0) |
| 33 | } else { |
| 34 | Return(Arg1) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | Method(SLEN, 1) |
| 39 | { |
| 40 | Store(Arg0, Local0) |
| 41 | Return(Sizeof(Local0)) |
| 42 | } |
| 43 | |
| 44 | Method(S2BF, 1) |
| 45 | { |
| 46 | Add(SLEN(Arg0), One, Local0) |
| 47 | Name(BUFF, Buffer(Local0) {}) |
| 48 | Store(Arg0, BUFF) |
| 49 | Return(BUFF) |
| 50 | } |
| 51 | |
| 52 | /* Strong string compare. Checks both length and content */ |
| 53 | Method(SCMP, 2) |
| 54 | { |
| 55 | Store(S2BF(Arg0), Local0) |
| 56 | Store(S2BF(Arg1), Local1) |
| 57 | Store(Zero, Local4) |
| 58 | Store(SLEN(Arg0), Local5) |
| 59 | Store(SLEN(Arg1), Local6) |
| 60 | Store(MIN(Local5, Local6), Local7) |
| 61 | |
| 62 | While(LLess(Local4, Local7)) { |
| 63 | Store(Derefof(Index(Local0, Local4)), Local2) |
| 64 | Store(Derefof(Index(Local1, Local4)), Local3) |
| 65 | if (LGreater(Local2, Local3)) { |
| 66 | Return(One) |
| 67 | } else { |
| 68 | if (LLess(Local2, Local3)) { |
| 69 | Return(Ones) |
| 70 | } |
| 71 | } |
| 72 | Increment(Local4) |
| 73 | } |
| 74 | if (LLess(Local4, Local5)) { |
| 75 | Return(One) |
| 76 | } else { |
| 77 | if (LLess(Local4, Local6)) { |
| 78 | Return(Ones) |
| 79 | } else { |
| 80 | Return(Zero) |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | /* Weak string compare. Checks to find Arg1 at beginning of Arg0. |
| 86 | * Fails if length(Arg0) < length(Arg1). Returns 0 on Fail, 1 on |
| 87 | * Pass. |
| 88 | */ |
| 89 | Method(WCMP, 2) |
| 90 | { |
| 91 | Store(S2BF(Arg0), Local0) |
| 92 | Store(S2BF(Arg1), Local1) |
| 93 | if (LLess(SLEN(Arg0), SLEN(Arg1))) { |
| 94 | Return(0) |
| 95 | } |
| 96 | Store(Zero, Local2) |
| 97 | Store(SLEN(Arg1), Local3) |
| 98 | |
| 99 | While(LLess(Local2, Local3)) { |
| 100 | if (LNotEqual(Derefof(Index(Local0, Local2)), |
| 101 | Derefof(Index(Local1, Local2)))) { |
| 102 | Return(0) |
| 103 | } |
| 104 | Increment(Local2) |
| 105 | } |
| 106 | Return(One) |
| 107 | } |
| 108 | |
| 109 | /* ARG0 = IRQ Number(0-15) |
| 110 | * Returns Bit Map |
| 111 | */ |
| 112 | Method(I2BM, 1) |
| 113 | { |
| 114 | Store(0, Local0) |
| 115 | if (LNotEqual(ARG0, 0)) { |
| 116 | Store(1, Local1) |
| 117 | ShiftLeft(Local1, ARG0, Local0) |
| 118 | } |
| 119 | Return(Local0) |
| 120 | } |
| 121 | Method (SEQL, 2, Serialized) |
| 122 | { |
| 123 | Store (SizeOf (Arg0), Local0) |
| 124 | Store (SizeOf (Arg1), Local1) |
| 125 | If (LNot (LEqual (Local0, Local1))) { Return (Zero) } |
| 126 | |
| 127 | Name (BUF0, Buffer (Local0) {}) |
| 128 | Store (Arg0, BUF0) |
| 129 | Name (BUF1, Buffer (Local0) {}) |
| 130 | Store (Arg1, BUF1) |
| 131 | Store (Zero, Local2) |
| 132 | While (LLess (Local2, Local0)) |
| 133 | { |
| 134 | Store (DerefOf (Index (BUF0, Local2)), Local3) |
| 135 | Store (DerefOf (Index (BUF1, Local2)), Local4) |
| 136 | If (LNot (LEqual (Local3, Local4))) { Return (Zero) } |
| 137 | |
| 138 | Increment (Local2) |
| 139 | } |
| 140 | |
| 141 | Return (One) |
| 142 | } |
| 143 | |
| 144 | /* GetMemoryResources(Node, Link) */ |
| 145 | Method (GMEM, 2, NotSerialized) |
| 146 | { |
| 147 | Name (BUF0, ResourceTemplate () |
| 148 | { |
| 149 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, |
| 150 | 0x00000000, // Address Space Granularity |
| 151 | 0x00000000, // Address Range Minimum |
| 152 | 0x00000000, // Address Range Maximum |
| 153 | 0x00000000, // Address Translation Offset |
| 154 | 0x00000001,,, |
| 155 | , AddressRangeMemory, TypeStatic) |
| 156 | }) |
| 157 | CreateDWordField (BUF0, 0x0A, MMIN) |
| 158 | CreateDWordField (BUF0, 0x0E, MMAX) |
| 159 | CreateDWordField (BUF0, 0x16, MLEN) |
| 160 | Store (0x00, Local0) |
| 161 | Store (0x00, Local4) |
| 162 | Store (0x00, Local3) |
| 163 | While (LLess (Local0, 0x10)) |
| 164 | { |
| 165 | /* Get value of the first register */ |
| 166 | Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local1) |
| 167 | Increment (Local0) |
| 168 | Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local2) |
| 169 | If (LEqual (And (Local1, 0x03), 0x03)) /* Pair enabled? */ |
| 170 | { |
| 171 | If (LEqual (Arg0, And (Local2, 0x07))) /* Node matches? */ |
| 172 | { |
| 173 | /* If Link Matches (or we got passed 0xFF) */ |
| 174 | If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local2, 0x30), 0x04)))) |
| 175 | { |
| 176 | /* Extract the Base and Limit values */ |
| 177 | Store (ShiftLeft (And (Local1, 0xFFFFFF00), 0x08), MMIN) |
| 178 | Store (ShiftLeft (And (Local2, 0xFFFFFF00), 0x08), MMAX) |
| 179 | Or (MMAX, 0xFFFF, MMAX) |
| 180 | Subtract (MMAX, MMIN, MLEN) |
| 181 | Increment (MLEN) |
| 182 | |
| 183 | If (Local4) /* I've already done this once */ |
| 184 | { |
| 185 | Concatenate (RTAG (BUF0), Local3, Local5) |
| 186 | Store (Local5, Local3) |
| 187 | } |
| 188 | Else |
| 189 | { |
| 190 | Store (RTAG (BUF0), Local3) |
| 191 | } |
| 192 | |
| 193 | Increment (Local4) |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | Increment (Local0) |
| 199 | } |
| 200 | |
| 201 | If (LNot (Local4)) /* No resources for this node and link. */ |
| 202 | { |
| 203 | Store (RTAG (BUF0), Local3) |
| 204 | } |
| 205 | |
| 206 | Return (Local3) |
| 207 | } |
| 208 | |
| 209 | Method (RTAG, 1, NotSerialized) |
| 210 | { |
| 211 | Store (Arg0, Local0) |
| 212 | Store (SizeOf (Local0), Local1) |
| 213 | Subtract (Local1, 0x02, Local1) |
| 214 | Multiply (Local1, 0x08, Local1) |
| 215 | CreateField (Local0, 0x00, Local1, RETB) |
| 216 | Store (RETB, Local2) |
| 217 | Return (Local2) |
| 218 | } |