Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2009 Rudolf Marek <r.marek@assembler.cz> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
Uwe Hermann | c70e9fc | 2010-02-15 23:10:19 +0000 | [diff] [blame] | 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 9 | * |
| 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. |
| 14 | * |
| 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 |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 20 | /* How much nesting do we support? */ |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 21 | #define ACPIGEN_LENSTACK_SIZE 10 |
| 22 | |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 23 | /* |
| 24 | * If you need to change this, change acpigen_write_f and |
| 25 | * acpigen_patch_len |
| 26 | */ |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 27 | |
| 28 | #define ACPIGEN_MAXLEN 0xfff |
| 29 | |
| 30 | #include <string.h> |
| 31 | #include <arch/acpigen.h> |
| 32 | #include <console/console.h> |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 33 | #include <device/device.h> |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 34 | |
| 35 | static char *gencurrent; |
| 36 | |
| 37 | char *len_stack[ACPIGEN_LENSTACK_SIZE]; |
| 38 | int ltop = 0; |
| 39 | |
Stefan Reinauer | 5b73d4d | 2012-04-27 21:55:05 +0200 | [diff] [blame] | 40 | int acpigen_write_len_f(void) |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 41 | { |
| 42 | ASSERT(ltop < (ACPIGEN_LENSTACK_SIZE - 1)) |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 43 | len_stack[ltop++] = gencurrent; |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 44 | acpigen_emit_byte(0); |
| 45 | acpigen_emit_byte(0); |
| 46 | return 2; |
| 47 | } |
| 48 | |
| 49 | void acpigen_patch_len(int len) |
| 50 | { |
| 51 | ASSERT(len <= ACPIGEN_MAXLEN) |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 52 | ASSERT(ltop > 0) |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 53 | char *p = len_stack[--ltop]; |
| 54 | /* generate store length for 0xfff max */ |
| 55 | p[0] = (0x40 | (len & 0xf)); |
| 56 | p[1] = (len >> 4 & 0xff); |
| 57 | |
| 58 | } |
| 59 | |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 60 | void acpigen_set_current(char *curr) |
| 61 | { |
| 62 | gencurrent = curr; |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 65 | char *acpigen_get_current(void) |
| 66 | { |
| 67 | return gencurrent; |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | int acpigen_emit_byte(unsigned char b) |
| 71 | { |
| 72 | (*gencurrent++) = b; |
| 73 | return 1; |
| 74 | } |
| 75 | |
| 76 | int acpigen_write_package(int nr_el) |
| 77 | { |
| 78 | int len; |
| 79 | /* package op */ |
| 80 | acpigen_emit_byte(0x12); |
| 81 | len = acpigen_write_len_f(); |
| 82 | acpigen_emit_byte(nr_el); |
| 83 | return len + 2; |
| 84 | } |
| 85 | |
| 86 | int acpigen_write_byte(unsigned int data) |
| 87 | { |
| 88 | /* byte op */ |
| 89 | acpigen_emit_byte(0xa); |
| 90 | acpigen_emit_byte(data & 0xff); |
| 91 | return 2; |
| 92 | } |
| 93 | |
| 94 | int acpigen_write_dword(unsigned int data) |
| 95 | { |
| 96 | /* dword op */ |
| 97 | acpigen_emit_byte(0xc); |
| 98 | acpigen_emit_byte(data & 0xff); |
| 99 | acpigen_emit_byte((data >> 8) & 0xff); |
| 100 | acpigen_emit_byte((data >> 16) & 0xff); |
| 101 | acpigen_emit_byte((data >> 24) & 0xff); |
| 102 | return 5; |
| 103 | } |
| 104 | |
Carl-Daniel Hailfinger | d58671c | 2009-02-17 21:38:51 +0000 | [diff] [blame] | 105 | int acpigen_write_qword(uint64_t data) |
| 106 | { |
| 107 | /* qword op */ |
| 108 | acpigen_emit_byte(0xe); |
| 109 | acpigen_emit_byte(data & 0xff); |
| 110 | acpigen_emit_byte((data >> 8) & 0xff); |
| 111 | acpigen_emit_byte((data >> 16) & 0xff); |
| 112 | acpigen_emit_byte((data >> 24) & 0xff); |
| 113 | acpigen_emit_byte((data >> 32) & 0xff); |
| 114 | acpigen_emit_byte((data >> 40) & 0xff); |
| 115 | acpigen_emit_byte((data >> 48) & 0xff); |
| 116 | acpigen_emit_byte((data >> 56) & 0xff); |
| 117 | return 9; |
| 118 | } |
| 119 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 120 | int acpigen_write_name_byte(const char *name, uint8_t val) |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 121 | { |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 122 | int len; |
| 123 | len = acpigen_write_name(name); |
| 124 | len += acpigen_write_byte(val); |
| 125 | return len; |
| 126 | } |
| 127 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 128 | int acpigen_write_name_dword(const char *name, uint32_t val) |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 129 | { |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 130 | int len; |
| 131 | len = acpigen_write_name(name); |
| 132 | len += acpigen_write_dword(val); |
| 133 | return len; |
| 134 | } |
| 135 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 136 | int acpigen_write_name_qword(const char *name, uint64_t val) |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 137 | { |
Carl-Daniel Hailfinger | d58671c | 2009-02-17 21:38:51 +0000 | [diff] [blame] | 138 | int len; |
| 139 | len = acpigen_write_name(name); |
| 140 | len += acpigen_write_qword(val); |
| 141 | return len; |
| 142 | } |
| 143 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 144 | int acpigen_emit_stream(const char *data, int size) |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 145 | { |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 146 | int i; |
| 147 | for (i = 0; i < size; i++) { |
| 148 | acpigen_emit_byte(data[i]); |
| 149 | } |
| 150 | return size; |
| 151 | } |
| 152 | |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 153 | /* |
| 154 | * The naming conventions for ACPI namespace names are a bit tricky as |
| 155 | * each element has to be 4 chars wide (»All names are a fixed 32 bits.«) |
| 156 | * and »By convention, when an ASL compiler pads a name shorter than 4 |
| 157 | * characters, it is done so with trailing underscores (‘_’).«. |
| 158 | * |
| 159 | * Check sections 5.3, 18.2.2 and 18.4 of ACPI spec 3.0 for details. |
| 160 | */ |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 161 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 162 | static int acpigen_emit_simple_namestring(const char *name) { |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 163 | int i, len = 0; |
| 164 | char ud[] = "____"; |
| 165 | for (i = 0; i < 4; i++) { |
| 166 | if ((name[i] == '\0') || (name[i] == '.')) { |
| 167 | len += acpigen_emit_stream(ud, 4 - i); |
| 168 | break; |
| 169 | } else { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 170 | len += acpigen_emit_byte(name[i]); |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 171 | } |
| 172 | } |
| 173 | return len; |
| 174 | } |
| 175 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 176 | static int acpigen_emit_double_namestring(const char *name, int dotpos) { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 177 | int len = 0; |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 178 | /* mark dual name prefix */ |
| 179 | len += acpigen_emit_byte(0x2e); |
| 180 | len += acpigen_emit_simple_namestring(name); |
| 181 | len += acpigen_emit_simple_namestring(&name[dotpos + 1]); |
| 182 | return len; |
| 183 | } |
| 184 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 185 | static int acpigen_emit_multi_namestring(const char *name) { |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 186 | int len = 0, count = 0; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 187 | unsigned char *pathlen; |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 188 | /* mark multi name prefix */ |
| 189 | len += acpigen_emit_byte(0x2f); |
| 190 | len += acpigen_emit_byte(0x0); |
| 191 | pathlen = ((unsigned char *) acpigen_get_current()) - 1; |
| 192 | |
| 193 | while (name[0] != '\0') { |
| 194 | len += acpigen_emit_simple_namestring(name); |
| 195 | /* find end or next entity */ |
| 196 | while ((name[0] != '.') && (name[0] != '\0')) |
| 197 | name++; |
| 198 | /* forward to next */ |
| 199 | if (name[0] == '.') |
| 200 | name++; |
| 201 | count++; |
| 202 | } |
| 203 | |
| 204 | pathlen[0] = count; |
| 205 | return len; |
| 206 | } |
| 207 | |
| 208 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 209 | int acpigen_emit_namestring(const char *namepath) { |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 210 | int dotcount = 0, i; |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 211 | int dotpos = 0; |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 212 | int len = 0; |
| 213 | |
Ronald G. Minnich | be738eb | 2013-03-07 11:05:28 -0600 | [diff] [blame] | 214 | /* We can start with a '\'. */ |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 215 | if (namepath[0] == '\\') { |
| 216 | len += acpigen_emit_byte('\\'); |
| 217 | namepath++; |
| 218 | } |
| 219 | |
Ronald G. Minnich | be738eb | 2013-03-07 11:05:28 -0600 | [diff] [blame] | 220 | /* And there can be any number of '^' */ |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 221 | while (namepath[0] == '^') { |
| 222 | len += acpigen_emit_byte('^'); |
| 223 | namepath++; |
| 224 | } |
| 225 | |
Vladimir Serbinenko | d942ed9 | 2014-08-30 20:44:37 +0200 | [diff] [blame^] | 226 | /* If we have only \\ or only ^...^. Then we need to put a null |
| 227 | name (0x00). */ |
| 228 | if(namepath[0] == '\0') { |
| 229 | len += acpigen_emit_byte(0x00); |
| 230 | return len; |
| 231 | } |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 232 | |
| 233 | i = 0; |
| 234 | while (namepath[i] != '\0') { |
| 235 | if (namepath[i] == '.') { |
| 236 | dotcount++; |
| 237 | dotpos = i; |
| 238 | } |
| 239 | i++; |
| 240 | } |
| 241 | |
| 242 | if (dotcount == 0) { |
| 243 | len += acpigen_emit_simple_namestring(namepath); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 244 | } else if (dotcount == 1) { |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 245 | len += acpigen_emit_double_namestring(namepath, dotpos); |
| 246 | } else { |
| 247 | len += acpigen_emit_multi_namestring(namepath); |
| 248 | } |
| 249 | return len; |
| 250 | } |
| 251 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 252 | int acpigen_write_name(const char *name) |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 253 | { |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 254 | int len; |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 255 | /* name op */ |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 256 | len = acpigen_emit_byte(0x8); |
| 257 | return len + acpigen_emit_namestring(name); |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 258 | } |
| 259 | |
Myles Watson | 3fe6b70 | 2009-10-09 20:13:43 +0000 | [diff] [blame] | 260 | int acpigen_write_scope(const char *name) |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 261 | { |
| 262 | int len; |
| 263 | /* scope op */ |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 264 | len = acpigen_emit_byte(0x10); |
| 265 | len += acpigen_write_len_f(); |
| 266 | return len + acpigen_emit_namestring(name); |
Rudolf Marek | 293b5f5 | 2009-02-01 18:35:15 +0000 | [diff] [blame] | 267 | } |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 268 | |
| 269 | int acpigen_write_processor(u8 cpuindex, u32 pblock_addr, u8 pblock_len) |
| 270 | { |
| 271 | /* |
| 272 | Processor (\_PR.CPUcpuindex, cpuindex, pblock_addr, pblock_len) |
| 273 | { |
| 274 | */ |
| 275 | char pscope[16]; |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 276 | int len; |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 277 | /* processor op */ |
| 278 | acpigen_emit_byte(0x5b); |
| 279 | acpigen_emit_byte(0x83); |
| 280 | len = acpigen_write_len_f(); |
| 281 | |
Vladimir Serbinenko | a37383d | 2013-11-26 02:41:26 +0100 | [diff] [blame] | 282 | snprintf(pscope, sizeof (pscope), |
| 283 | "\\_PR.CPU%x", (unsigned int) cpuindex); |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 284 | len += acpigen_emit_namestring(pscope); |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 285 | acpigen_emit_byte(cpuindex); |
| 286 | acpigen_emit_byte(pblock_addr & 0xff); |
| 287 | acpigen_emit_byte((pblock_addr >> 8) & 0xff); |
| 288 | acpigen_emit_byte((pblock_addr >> 16) & 0xff); |
| 289 | acpigen_emit_byte((pblock_addr >> 24) & 0xff); |
| 290 | acpigen_emit_byte(pblock_len); |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 291 | return 6 + 2 + len; |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | int acpigen_write_empty_PCT(void) |
| 295 | { |
| 296 | /* |
| 297 | Name (_PCT, Package (0x02) |
| 298 | { |
| 299 | ResourceTemplate () |
| 300 | { |
| 301 | Register (FFixedHW, |
| 302 | 0x00, // Bit Width |
| 303 | 0x00, // Bit Offset |
| 304 | 0x0000000000000000, // Address |
| 305 | ,) |
| 306 | }, |
| 307 | |
| 308 | ResourceTemplate () |
| 309 | { |
| 310 | Register (FFixedHW, |
| 311 | 0x00, // Bit Width |
| 312 | 0x00, // Bit Offset |
| 313 | 0x0000000000000000, // Address |
| 314 | ,) |
| 315 | } |
| 316 | }) |
| 317 | */ |
| 318 | static char stream[] = { |
| 319 | 0x08, 0x5F, 0x50, 0x43, 0x54, 0x12, 0x2C, /* 00000030 "0._PCT.," */ |
| 320 | 0x02, 0x11, 0x14, 0x0A, 0x11, 0x82, 0x0C, 0x00, /* 00000038 "........" */ |
| 321 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000040 "........" */ |
| 322 | 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x11, 0x14, /* 00000048 "....y..." */ |
| 323 | 0x0A, 0x11, 0x82, 0x0C, 0x00, 0x7F, 0x00, 0x00, /* 00000050 "........" */ |
| 324 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000058 "........" */ |
| 325 | 0x00, 0x79, 0x00 |
| 326 | }; |
| 327 | return acpigen_emit_stream(stream, ARRAY_SIZE(stream)); |
| 328 | } |
| 329 | |
Stefan Reinauer | 39205c6 | 2012-04-27 21:49:28 +0200 | [diff] [blame] | 330 | int acpigen_write_empty_PTC(void) |
| 331 | { |
| 332 | /* |
| 333 | Name (_PTC, Package (0x02) |
| 334 | { |
| 335 | ResourceTemplate () |
| 336 | { |
| 337 | Register (FFixedHW, |
| 338 | 0x00, // Bit Width |
| 339 | 0x00, // Bit Offset |
| 340 | 0x0000000000000000, // Address |
| 341 | ,) |
| 342 | }, |
| 343 | |
| 344 | ResourceTemplate () |
| 345 | { |
| 346 | Register (FFixedHW, |
| 347 | 0x00, // Bit Width |
| 348 | 0x00, // Bit Offset |
| 349 | 0x0000000000000000, // Address |
| 350 | ,) |
| 351 | } |
| 352 | }) |
| 353 | */ |
| 354 | int len, nlen, rlen; |
| 355 | acpi_addr_t addr = { |
| 356 | .space_id = ACPI_ADDRESS_SPACE_FIXED, |
| 357 | .bit_width = 0, |
| 358 | .bit_offset = 0, |
zbao | ee8a9f6c | 2012-05-29 14:59:38 +0800 | [diff] [blame] | 359 | { |
| 360 | .resv = 0 |
| 361 | }, |
Stefan Reinauer | 39205c6 | 2012-04-27 21:49:28 +0200 | [diff] [blame] | 362 | .addrl = 0, |
| 363 | .addrh = 0, |
| 364 | }; |
| 365 | |
| 366 | nlen = acpigen_write_name("_PTC"); |
| 367 | len = acpigen_write_package(2); |
| 368 | |
| 369 | /* ControlRegister */ |
| 370 | rlen = acpigen_write_resourcetemplate_header(); |
| 371 | rlen += acpigen_write_register(&addr); |
| 372 | len += acpigen_write_resourcetemplate_footer(rlen); |
| 373 | len += rlen; |
| 374 | |
| 375 | /* StatusRegister */ |
| 376 | rlen = acpigen_write_resourcetemplate_header(); |
| 377 | rlen += acpigen_write_register(&addr); |
| 378 | len += acpigen_write_resourcetemplate_footer(rlen); |
| 379 | len += rlen; |
| 380 | |
| 381 | acpigen_patch_len(len - 1); |
| 382 | return len + nlen; |
| 383 | } |
| 384 | |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 385 | /* |
| 386 | * Generates a func with max supported P-states. |
| 387 | */ |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 388 | int acpigen_write_PPC(u8 nr) |
| 389 | { |
| 390 | /* |
| 391 | Method (_PPC, 0, NotSerialized) |
| 392 | { |
| 393 | Return (nr) |
| 394 | } |
| 395 | */ |
| 396 | int len; |
| 397 | /* method op */ |
| 398 | acpigen_emit_byte(0x14); |
| 399 | len = acpigen_write_len_f(); |
Rudolf Marek | 3310d75 | 2009-06-21 20:26:13 +0000 | [diff] [blame] | 400 | len += acpigen_emit_namestring("_PPC"); |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 401 | /* no fnarg */ |
| 402 | acpigen_emit_byte(0x00); |
| 403 | /* return */ |
| 404 | acpigen_emit_byte(0xa4); |
| 405 | /* arg */ |
| 406 | len += acpigen_write_byte(nr); |
Rudolf Marek | 6b2e760 | 2009-03-02 22:45:31 +0000 | [diff] [blame] | 407 | /* add all single bytes */ |
| 408 | len += 3; |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 409 | acpigen_patch_len(len - 1); |
Rudolf Marek | 6b2e760 | 2009-03-02 22:45:31 +0000 | [diff] [blame] | 410 | return len; |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 411 | } |
| 412 | |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 413 | /* |
| 414 | * Generates a func with max supported P-states saved |
| 415 | * in the variable PPCM. |
| 416 | */ |
Duncan Laurie | 0eefa00 | 2012-07-16 12:11:53 -0700 | [diff] [blame] | 417 | int acpigen_write_PPC_NVS(void) |
| 418 | { |
| 419 | /* |
| 420 | Method (_PPC, 0, NotSerialized) |
| 421 | { |
| 422 | Return (PPCM) |
| 423 | } |
| 424 | */ |
| 425 | int len; |
| 426 | /* method op */ |
| 427 | acpigen_emit_byte(0x14); |
| 428 | len = acpigen_write_len_f(); |
| 429 | len += acpigen_emit_namestring("_PPC"); |
| 430 | /* no fnarg */ |
| 431 | acpigen_emit_byte(0x00); |
| 432 | /* return */ |
| 433 | acpigen_emit_byte(0xa4); |
| 434 | /* arg */ |
| 435 | len += acpigen_emit_namestring("PPCM"); |
| 436 | /* add all single bytes */ |
| 437 | len += 3; |
| 438 | acpigen_patch_len(len - 1); |
| 439 | return len; |
| 440 | } |
| 441 | |
Stefan Reinauer | 39205c6 | 2012-04-27 21:49:28 +0200 | [diff] [blame] | 442 | int acpigen_write_TPC(const char *gnvs_tpc_limit) |
| 443 | { |
| 444 | /* |
| 445 | // Sample _TPC method |
| 446 | Method (_TPC, 0, NotSerialized) |
| 447 | { |
| 448 | Return (\TLVL) |
| 449 | } |
| 450 | */ |
| 451 | int len; |
| 452 | |
| 453 | len = acpigen_emit_byte(0x14); /* MethodOp */ |
| 454 | len += acpigen_write_len_f(); /* PkgLength */ |
| 455 | len += acpigen_emit_namestring("_TPC"); |
| 456 | len += acpigen_emit_byte(0x00); /* No Arguments */ |
| 457 | len += acpigen_emit_byte(0xa4); /* ReturnOp */ |
| 458 | len += acpigen_emit_namestring(gnvs_tpc_limit); |
| 459 | acpigen_patch_len(len - 1); |
| 460 | return len; |
| 461 | } |
| 462 | |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 463 | int acpigen_write_PSS_package(u32 coreFreq, u32 power, u32 transLat, |
| 464 | u32 busmLat, u32 control, u32 status) |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 465 | { |
| 466 | int len; |
| 467 | len = acpigen_write_package(6); |
| 468 | len += acpigen_write_dword(coreFreq); |
| 469 | len += acpigen_write_dword(power); |
| 470 | len += acpigen_write_dword(transLat); |
| 471 | len += acpigen_write_dword(busmLat); |
| 472 | len += acpigen_write_dword(control); |
| 473 | len += acpigen_write_dword(status); |
Stefan Reinauer | d4bacf9 | 2012-05-02 16:38:47 -0700 | [diff] [blame] | 474 | // pkglen without the len opcode |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 475 | acpigen_patch_len(len - 1); |
Stefan Reinauer | d4bacf9 | 2012-05-02 16:38:47 -0700 | [diff] [blame] | 476 | |
| 477 | printk(BIOS_DEBUG, "PSS: %uMHz power %u control 0x%x status 0x%x\n", |
| 478 | coreFreq, power, control, status); |
| 479 | |
Rudolf Marek | f997b55 | 2009-02-14 15:40:23 +0000 | [diff] [blame] | 480 | return len; |
| 481 | } |
Patrick Georgi | df444bf | 2009-04-21 20:34:36 +0000 | [diff] [blame] | 482 | |
| 483 | int acpigen_write_PSD_package(u32 domain, u32 numprocs, PSD_coord coordtype) |
| 484 | { |
| 485 | int len, lenh, lenp; |
| 486 | lenh = acpigen_write_name("_PSD"); |
| 487 | lenp = acpigen_write_package(1); |
| 488 | len = acpigen_write_package(5); |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 489 | len += acpigen_write_byte(5); // 5 values |
| 490 | len += acpigen_write_byte(0); // revision 0 |
Patrick Georgi | df444bf | 2009-04-21 20:34:36 +0000 | [diff] [blame] | 491 | len += acpigen_write_dword(domain); |
| 492 | len += acpigen_write_dword(coordtype); |
| 493 | len += acpigen_write_dword(numprocs); |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 494 | acpigen_patch_len(len - 1); |
Patrick Georgi | df444bf | 2009-04-21 20:34:36 +0000 | [diff] [blame] | 495 | len += lenp; |
Stefan Reinauer | f96c2d9 | 2009-04-22 16:23:47 +0000 | [diff] [blame] | 496 | acpigen_patch_len(len - 1); |
Patrick Georgi | df444bf | 2009-04-21 20:34:36 +0000 | [diff] [blame] | 497 | return len + lenh; |
| 498 | } |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 499 | |
Stefan Reinauer | f69b468 | 2012-04-27 23:12:08 +0200 | [diff] [blame] | 500 | int acpigen_write_CST_package_entry(acpi_cstate_t *cstate) |
Sven Schnelle | 0b86c76 | 2011-10-21 21:46:47 +0200 | [diff] [blame] | 501 | { |
| 502 | int len, len0; |
| 503 | char *start, *end; |
| 504 | |
| 505 | len0 = acpigen_write_package(4); |
| 506 | len = acpigen_write_resourcetemplate_header(); |
| 507 | start = acpigen_get_current(); |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 508 | acpigen_write_register(&cstate->resource); |
Sven Schnelle | 0b86c76 | 2011-10-21 21:46:47 +0200 | [diff] [blame] | 509 | end = acpigen_get_current(); |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 510 | len += end - start; |
Sven Schnelle | 0b86c76 | 2011-10-21 21:46:47 +0200 | [diff] [blame] | 511 | len += acpigen_write_resourcetemplate_footer(len); |
| 512 | len += len0; |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 513 | len += acpigen_write_dword(cstate->ctype); |
| 514 | len += acpigen_write_dword(cstate->latency); |
| 515 | len += acpigen_write_dword(cstate->power); |
Sven Schnelle | 0b86c76 | 2011-10-21 21:46:47 +0200 | [diff] [blame] | 516 | acpigen_patch_len(len - 1); |
| 517 | return len; |
| 518 | } |
| 519 | |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 520 | int acpigen_write_CST_package(acpi_cstate_t *cstate, int nentries) |
Sven Schnelle | 0b86c76 | 2011-10-21 21:46:47 +0200 | [diff] [blame] | 521 | { |
| 522 | int len, lenh, lenp, i; |
| 523 | lenh = acpigen_write_name("_CST"); |
| 524 | lenp = acpigen_write_package(nentries+1); |
| 525 | len = acpigen_write_dword(nentries); |
| 526 | |
| 527 | for (i = 0; i < nentries; i++) |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 528 | len += acpigen_write_CST_package_entry(cstate + i); |
Sven Schnelle | 0b86c76 | 2011-10-21 21:46:47 +0200 | [diff] [blame] | 529 | |
| 530 | len += lenp; |
| 531 | acpigen_patch_len(len - 1); |
| 532 | return len + lenh; |
| 533 | } |
| 534 | |
Stefan Reinauer | 39205c6 | 2012-04-27 21:49:28 +0200 | [diff] [blame] | 535 | int acpigen_write_TSS_package(int entries, acpi_tstate_t *tstate_list) |
| 536 | { |
| 537 | /* |
| 538 | Sample _TSS package with 100% and 50% duty cycles |
| 539 | Name (_TSS, Package (0x02) |
| 540 | { |
| 541 | Package(){100, 1000, 0, 0x00, 0) |
| 542 | Package(){50, 520, 0, 0x18, 0) |
| 543 | }) |
| 544 | */ |
| 545 | int i, len, plen, nlen; |
| 546 | acpi_tstate_t *tstate = tstate_list; |
| 547 | |
| 548 | nlen = acpigen_write_name("_TSS"); |
| 549 | plen = acpigen_write_package(entries); |
| 550 | |
| 551 | for (i = 0; i < entries; i++) { |
| 552 | len = acpigen_write_package(5); |
| 553 | len += acpigen_write_dword(tstate->percent); |
| 554 | len += acpigen_write_dword(tstate->power); |
| 555 | len += acpigen_write_dword(tstate->latency); |
| 556 | len += acpigen_write_dword(tstate->control); |
| 557 | len += acpigen_write_dword(tstate->status); |
| 558 | acpigen_patch_len(len - 1); |
| 559 | tstate++; |
| 560 | plen += len; |
| 561 | } |
| 562 | |
| 563 | acpigen_patch_len(plen - 1); |
| 564 | return plen + nlen; |
| 565 | } |
| 566 | |
| 567 | int acpigen_write_TSD_package(u32 domain, u32 numprocs, PSD_coord coordtype) |
| 568 | { |
| 569 | int len, lenh, lenp; |
| 570 | lenh = acpigen_write_name("_TSD"); |
| 571 | lenp = acpigen_write_package(1); |
| 572 | len = acpigen_write_package(5); |
| 573 | len += acpigen_write_byte(5); // 5 values |
| 574 | len += acpigen_write_byte(0); // revision 0 |
| 575 | len += acpigen_write_dword(domain); |
| 576 | len += acpigen_write_dword(coordtype); |
| 577 | len += acpigen_write_dword(numprocs); |
| 578 | acpigen_patch_len(len - 1); |
| 579 | len += lenp; |
| 580 | acpigen_patch_len(len - 1); |
| 581 | return len + lenh; |
| 582 | } |
| 583 | |
| 584 | |
| 585 | |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 586 | int acpigen_write_mem32fixed(int readwrite, u32 base, u32 size) |
| 587 | { |
| 588 | /* |
| 589 | * acpi 4.0 section 6.4.3.4: 32-Bit Fixed Memory Range Descriptor |
| 590 | * Byte 0: |
| 591 | * Bit7 : 1 => big item |
| 592 | * Bit6-0: 0000110 (0x6) => 32-bit fixed memory |
| 593 | */ |
| 594 | acpigen_emit_byte(0x86); |
| 595 | /* Byte 1+2: length (0x0009) */ |
| 596 | acpigen_emit_byte(0x09); |
| 597 | acpigen_emit_byte(0x00); |
| 598 | /* bit1-7 are ignored */ |
| 599 | acpigen_emit_byte(readwrite ? 0x01 : 0x00); |
| 600 | acpigen_emit_byte(base & 0xff); |
| 601 | acpigen_emit_byte((base >> 8) & 0xff); |
| 602 | acpigen_emit_byte((base >> 16) & 0xff); |
| 603 | acpigen_emit_byte((base >> 24) & 0xff); |
| 604 | acpigen_emit_byte(size & 0xff); |
| 605 | acpigen_emit_byte((size >> 8) & 0xff); |
| 606 | acpigen_emit_byte((size >> 16) & 0xff); |
| 607 | acpigen_emit_byte((size >> 24) & 0xff); |
| 608 | return 12; |
| 609 | } |
| 610 | |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 611 | int acpigen_write_register(acpi_addr_t *addr) |
Sven Schnelle | 0b86c76 | 2011-10-21 21:46:47 +0200 | [diff] [blame] | 612 | { |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 613 | acpigen_emit_byte(0x82); /* Register Descriptor */ |
| 614 | acpigen_emit_byte(0x0c); /* Register Length 7:0 */ |
| 615 | acpigen_emit_byte(0x00); /* Register Length 15:8 */ |
| 616 | acpigen_emit_byte(addr->space_id); /* Address Space ID */ |
| 617 | acpigen_emit_byte(addr->bit_width); /* Register Bit Width */ |
| 618 | acpigen_emit_byte(addr->bit_offset); /* Register Bit Offset */ |
| 619 | acpigen_emit_byte(addr->resv); /* Register Access Size */ |
| 620 | acpigen_emit_byte(addr->addrl & 0xff); /* Register Address Low */ |
| 621 | acpigen_emit_byte((addr->addrl >> 8) & 0xff); |
| 622 | acpigen_emit_byte((addr->addrl >> 16) & 0xff); |
| 623 | acpigen_emit_byte((addr->addrl >> 24) & 0xff); |
| 624 | acpigen_emit_byte(addr->addrh & 0xff); /* Register Address High */ |
| 625 | acpigen_emit_byte((addr->addrh >> 8) & 0xff); |
| 626 | acpigen_emit_byte((addr->addrh >> 16) & 0xff); |
| 627 | acpigen_emit_byte((addr->addrh >> 24) & 0xff); |
Sven Schnelle | 0b86c76 | 2011-10-21 21:46:47 +0200 | [diff] [blame] | 628 | return 15; |
| 629 | } |
| 630 | |
Vladimir Serbinenko | 20ea040 | 2014-02-15 18:57:17 +0100 | [diff] [blame] | 631 | int acpigen_write_irq(u16 mask) |
| 632 | { |
| 633 | /* |
| 634 | * acpi 3.0b section 6.4.2.1: IRQ Descriptor |
| 635 | * Byte 0: |
| 636 | * Bit7 : 0 => small item |
| 637 | * Bit6-3: 0100 (0x4) => IRQ port descriptor |
| 638 | * Bit2-0: 010 (0x2) => 2 Bytes long |
| 639 | */ |
| 640 | acpigen_emit_byte(0x22); |
| 641 | acpigen_emit_byte(mask & 0xff); |
| 642 | acpigen_emit_byte((mask >> 8) & 0xff); |
| 643 | return 3; |
| 644 | } |
| 645 | |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 646 | int acpigen_write_io16(u16 min, u16 max, u8 align, u8 len, u8 decode16) |
| 647 | { |
| 648 | /* |
| 649 | * acpi 4.0 section 6.4.2.6: I/O Port Descriptor |
| 650 | * Byte 0: |
| 651 | * Bit7 : 0 => small item |
| 652 | * Bit6-3: 1000 (0x8) => I/O port descriptor |
| 653 | * Bit2-0: 111 (0x7) => 7 Bytes long |
| 654 | */ |
| 655 | acpigen_emit_byte(0x47); |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 656 | /* Does the device decode all 16 or just 10 bits? */ |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 657 | /* bit1-7 are ignored */ |
| 658 | acpigen_emit_byte(decode16 ? 0x01 : 0x00); |
| 659 | /* minimum base address the device may be configured for */ |
| 660 | acpigen_emit_byte(min & 0xff); |
| 661 | acpigen_emit_byte((min >> 8) & 0xff); |
| 662 | /* maximum base address the device may be configured for */ |
| 663 | acpigen_emit_byte(max & 0xff); |
| 664 | acpigen_emit_byte((max >> 8) & 0xff); |
| 665 | /* alignment for min base */ |
| 666 | acpigen_emit_byte(align & 0xff); |
| 667 | acpigen_emit_byte(len & 0xff); |
| 668 | return 8; |
| 669 | } |
| 670 | |
| 671 | int acpigen_write_resourcetemplate_header(void) |
| 672 | { |
| 673 | int len; |
| 674 | /* |
| 675 | * A ResourceTemplate() is a Buffer() with a |
| 676 | * (Byte|Word|DWord) containing the length, followed by one or more |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 677 | * resource items, terminated by the end tag. |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 678 | * (small item 0xf, len 1) |
| 679 | */ |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 680 | len = acpigen_emit_byte(0x11); /* Buffer opcode */ |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 681 | len += acpigen_write_len_f(); |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 682 | len += acpigen_emit_byte(0x0b); /* Word opcode */ |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 683 | len_stack[ltop++] = acpigen_get_current(); |
| 684 | len += acpigen_emit_byte(0x00); |
| 685 | len += acpigen_emit_byte(0x00); |
| 686 | return len; |
| 687 | } |
| 688 | |
| 689 | int acpigen_write_resourcetemplate_footer(int len) |
| 690 | { |
| 691 | char *p = len_stack[--ltop]; |
| 692 | /* |
| 693 | * end tag (acpi 4.0 Section 6.4.2.8) |
| 694 | * 0x79 <checksum> |
| 695 | * 0x00 is treated as a good checksum according to the spec |
| 696 | * and is what iasl generates. |
| 697 | */ |
| 698 | len += acpigen_emit_byte(0x79); |
| 699 | len += acpigen_emit_byte(0x00); |
| 700 | /* patch len word */ |
| 701 | p[0] = (len-6) & 0xff; |
| 702 | p[1] = ((len-6) >> 8) & 0xff; |
| 703 | /* patch len field */ |
| 704 | acpigen_patch_len(len-1); |
| 705 | return 2; |
| 706 | } |
| 707 | |
| 708 | static void acpigen_add_mainboard_rsvd_mem32(void *gp, struct device *dev, |
| 709 | struct resource *res) |
| 710 | { |
| 711 | acpigen_write_mem32fixed(0, res->base, res->size); |
| 712 | } |
| 713 | |
| 714 | static void acpigen_add_mainboard_rsvd_io(void *gp, struct device *dev, |
| 715 | struct resource *res) |
| 716 | { |
| 717 | resource_t base = res->base; |
| 718 | resource_t size = res->size; |
| 719 | while (size > 0) { |
| 720 | resource_t sz = size > 255 ? 255 : size; |
| 721 | acpigen_write_io16(base, base, 0, sz, 1); |
| 722 | size -= sz; |
| 723 | base += sz; |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | int acpigen_write_mainboard_resource_template(void) |
| 728 | { |
| 729 | int len; |
| 730 | char *start; |
| 731 | char *end; |
| 732 | len = acpigen_write_resourcetemplate_header(); |
| 733 | start = acpigen_get_current(); |
| 734 | |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 735 | /* Add reserved memory ranges. */ |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 736 | search_global_resources( |
| 737 | IORESOURCE_MEM | IORESOURCE_RESERVE, |
| 738 | IORESOURCE_MEM | IORESOURCE_RESERVE, |
| 739 | acpigen_add_mainboard_rsvd_mem32, 0); |
| 740 | |
Paul Menzel | 0f4c0e2 | 2013-02-22 12:33:08 +0100 | [diff] [blame] | 741 | /* Add reserved io ranges. */ |
Tobias Diedrich | 0fe6e9a | 2010-11-17 16:27:06 +0000 | [diff] [blame] | 742 | search_global_resources( |
| 743 | IORESOURCE_IO | IORESOURCE_RESERVE, |
| 744 | IORESOURCE_IO | IORESOURCE_RESERVE, |
| 745 | acpigen_add_mainboard_rsvd_io, 0); |
| 746 | |
| 747 | end = acpigen_get_current(); |
| 748 | len += end-start; |
| 749 | len += acpigen_write_resourcetemplate_footer(len); |
| 750 | return len; |
| 751 | } |
| 752 | |
| 753 | int acpigen_write_mainboard_resources(const char *scope, const char *name) |
| 754 | { |
| 755 | int len; |
| 756 | len = acpigen_write_scope(scope); |
| 757 | len += acpigen_write_name(name); |
| 758 | len += acpigen_write_mainboard_resource_template(); |
| 759 | acpigen_patch_len(len - 1); |
| 760 | return len; |
| 761 | } |
Vladimir Serbinenko | 8ecdc9e | 2014-02-15 18:59:40 +0100 | [diff] [blame] | 762 | |
| 763 | static int hex2bin(const char c) |
| 764 | { |
| 765 | if (c >= 'A' && c <= 'F') |
| 766 | return c - 'A' + 10; |
| 767 | if (c >= 'a' && c <= 'f') |
| 768 | return c - 'a' + 10; |
| 769 | return c - '0'; |
| 770 | } |
| 771 | |
| 772 | int acpigen_emit_eisaid(const char *eisaid) |
| 773 | { |
| 774 | u32 compact = 0; |
| 775 | |
| 776 | /* Clamping individual values would be better but |
| 777 | there is a disagreement over what is a valid |
| 778 | EISA id, so accept anything and don't clamp, |
| 779 | parent code should create a valid EISAid. |
| 780 | */ |
| 781 | compact |= (eisaid[0] - 'A' + 1) << 26; |
| 782 | compact |= (eisaid[1] - 'A' + 1) << 21; |
| 783 | compact |= (eisaid[2] - 'A' + 1) << 16; |
| 784 | compact |= hex2bin(eisaid[3]) << 12; |
| 785 | compact |= hex2bin(eisaid[4]) << 8; |
| 786 | compact |= hex2bin(eisaid[5]) << 4; |
| 787 | compact |= hex2bin(eisaid[6]); |
| 788 | |
| 789 | acpigen_emit_byte(0xc); |
| 790 | acpigen_emit_byte((compact >> 24) & 0xff); |
| 791 | acpigen_emit_byte((compact >> 16) & 0xff); |
| 792 | acpigen_emit_byte((compact >> 8) & 0xff); |
| 793 | acpigen_emit_byte(compact & 0xff); |
| 794 | return 5; |
| 795 | } |