| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#include "aslcompiler.h" |
| 45 |
#include "dtparser.y.h" |
| 46 |
|
| 47 |
#define _COMPONENT DT_COMPILER |
| 48 |
ACPI_MODULE_NAME ("dtexpress") |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
static void |
| 54 |
DtInsertLabelField ( |
| 55 |
DT_FIELD *Field); |
| 56 |
|
| 57 |
static DT_FIELD * |
| 58 |
DtLookupLabel ( |
| 59 |
char *Name); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
DT_FIELD *AslGbl_CurrentField; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
ACPI_STATUS |
| 81 |
DtResolveIntegerExpression ( |
| 82 |
DT_FIELD *Field, |
| 83 |
UINT64 *ReturnValue) |
| 84 |
{ |
| 85 |
UINT64 Result; |
| 86 |
|
| 87 |
|
| 88 |
DbgPrint (ASL_DEBUG_OUTPUT, "Full Integer expression: %s\n", |
| 89 |
Field->Value); |
| 90 |
|
| 91 |
AslGbl_CurrentField = Field; |
| 92 |
|
| 93 |
Result = DtEvaluateExpression (Field->Value); |
| 94 |
*ReturnValue = Result; |
| 95 |
return (AE_OK); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
UINT64 |
| 114 |
DtDoOperator ( |
| 115 |
UINT64 LeftValue, |
| 116 |
UINT32 Operator, |
| 117 |
UINT64 RightValue) |
| 118 |
{ |
| 119 |
UINT64 Result; |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
switch (Operator) |
| 125 |
{ |
| 126 |
case OP_EXP_ONES_COMPLIMENT: |
| 127 |
|
| 128 |
Result = ~RightValue; |
| 129 |
break; |
| 130 |
|
| 131 |
case OP_EXP_LOGICAL_NOT: |
| 132 |
|
| 133 |
Result = !RightValue; |
| 134 |
break; |
| 135 |
|
| 136 |
case OP_EXP_MULTIPLY: |
| 137 |
|
| 138 |
Result = LeftValue * RightValue; |
| 139 |
break; |
| 140 |
|
| 141 |
case OP_EXP_DIVIDE: |
| 142 |
|
| 143 |
if (!RightValue) |
| 144 |
{ |
| 145 |
DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, |
| 146 |
AslGbl_CurrentField, NULL); |
| 147 |
return (0); |
| 148 |
} |
| 149 |
|
| 150 |
Result = LeftValue / RightValue; |
| 151 |
break; |
| 152 |
|
| 153 |
case OP_EXP_MODULO: |
| 154 |
|
| 155 |
if (!RightValue) |
| 156 |
{ |
| 157 |
DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, |
| 158 |
AslGbl_CurrentField, NULL); |
| 159 |
return (0); |
| 160 |
} |
| 161 |
|
| 162 |
Result = LeftValue % RightValue; |
| 163 |
break; |
| 164 |
|
| 165 |
case OP_EXP_ADD: |
| 166 |
Result = LeftValue + RightValue; |
| 167 |
break; |
| 168 |
|
| 169 |
case OP_EXP_SUBTRACT: |
| 170 |
|
| 171 |
Result = LeftValue - RightValue; |
| 172 |
break; |
| 173 |
|
| 174 |
case OP_EXP_SHIFT_RIGHT: |
| 175 |
|
| 176 |
Result = LeftValue >> RightValue; |
| 177 |
break; |
| 178 |
|
| 179 |
case OP_EXP_SHIFT_LEFT: |
| 180 |
|
| 181 |
Result = LeftValue << RightValue; |
| 182 |
break; |
| 183 |
|
| 184 |
case OP_EXP_LESS: |
| 185 |
|
| 186 |
Result = LeftValue < RightValue; |
| 187 |
break; |
| 188 |
|
| 189 |
case OP_EXP_GREATER: |
| 190 |
|
| 191 |
Result = LeftValue > RightValue; |
| 192 |
break; |
| 193 |
|
| 194 |
case OP_EXP_LESS_EQUAL: |
| 195 |
|
| 196 |
Result = LeftValue <= RightValue; |
| 197 |
break; |
| 198 |
|
| 199 |
case OP_EXP_GREATER_EQUAL: |
| 200 |
|
| 201 |
Result = LeftValue >= RightValue; |
| 202 |
break; |
| 203 |
|
| 204 |
case OP_EXP_EQUAL: |
| 205 |
|
| 206 |
Result = LeftValue == RightValue; |
| 207 |
break; |
| 208 |
|
| 209 |
case OP_EXP_NOT_EQUAL: |
| 210 |
|
| 211 |
Result = LeftValue != RightValue; |
| 212 |
break; |
| 213 |
|
| 214 |
case OP_EXP_AND: |
| 215 |
|
| 216 |
Result = LeftValue & RightValue; |
| 217 |
break; |
| 218 |
|
| 219 |
case OP_EXP_XOR: |
| 220 |
|
| 221 |
Result = LeftValue ^ RightValue; |
| 222 |
break; |
| 223 |
|
| 224 |
case OP_EXP_OR: |
| 225 |
|
| 226 |
Result = LeftValue | RightValue; |
| 227 |
break; |
| 228 |
|
| 229 |
case OP_EXP_LOGICAL_AND: |
| 230 |
|
| 231 |
Result = LeftValue && RightValue; |
| 232 |
break; |
| 233 |
|
| 234 |
case OP_EXP_LOGICAL_OR: |
| 235 |
|
| 236 |
Result = LeftValue || RightValue; |
| 237 |
break; |
| 238 |
|
| 239 |
default: |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
DtFatal (ASL_MSG_INVALID_EXPRESSION, |
| 244 |
AslGbl_CurrentField, NULL); |
| 245 |
return (0); |
| 246 |
} |
| 247 |
|
| 248 |
DbgPrint (ASL_DEBUG_OUTPUT, |
| 249 |
"IntegerEval: (%8.8X%8.8X %s %8.8X%8.8X) = %8.8X%8.8X\n", |
| 250 |
ACPI_FORMAT_UINT64 (LeftValue), |
| 251 |
DtGetOpName (Operator), |
| 252 |
ACPI_FORMAT_UINT64 (RightValue), |
| 253 |
ACPI_FORMAT_UINT64 (Result)); |
| 254 |
|
| 255 |
return (Result); |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
UINT64 |
| 272 |
DtResolveLabel ( |
| 273 |
char *LabelString) |
| 274 |
{ |
| 275 |
DT_FIELD *LabelField; |
| 276 |
|
| 277 |
|
| 278 |
DbgPrint (ASL_DEBUG_OUTPUT, "Resolve Label: %s\n", LabelString); |
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
if (*LabelString != '$') |
| 283 |
{ |
| 284 |
return (0); |
| 285 |
} |
| 286 |
|
| 287 |
LabelField = DtLookupLabel (LabelString); |
| 288 |
if (!LabelField) |
| 289 |
{ |
| 290 |
DtError (ASL_ERROR, ASL_MSG_UNKNOWN_LABEL, |
| 291 |
AslGbl_CurrentField, LabelString); |
| 292 |
return (0); |
| 293 |
} |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
DbgPrint (ASL_DEBUG_OUTPUT, "Resolved Label: 0x%8.8X\n", |
| 298 |
LabelField->TableOffset); |
| 299 |
|
| 300 |
return (LabelField->TableOffset); |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
void |
| 318 |
DtDetectAllLabels ( |
| 319 |
DT_FIELD *FieldList) |
| 320 |
{ |
| 321 |
ACPI_DMTABLE_INFO *Info; |
| 322 |
DT_FIELD *GenericField; |
| 323 |
UINT32 TableOffset; |
| 324 |
|
| 325 |
|
| 326 |
TableOffset = AslGbl_CurrentTableOffset; |
| 327 |
GenericField = FieldList; |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
while (GenericField) |
| 337 |
{ |
| 338 |
Info = DtGetGenericTableInfo (GenericField->Name); |
| 339 |
if (Info) |
| 340 |
{ |
| 341 |
|
| 342 |
|
| 343 |
GenericField->TableOffset = TableOffset; |
| 344 |
TableOffset += DtGetFieldLength (GenericField, Info); |
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
if (Info->Opcode == ACPI_DMT_LABEL) |
| 349 |
{ |
| 350 |
DtInsertLabelField (GenericField); |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
GenericField = GenericField->Next; |
| 355 |
} |
| 356 |
} |
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
static void |
| 372 |
DtInsertLabelField ( |
| 373 |
DT_FIELD *Field) |
| 374 |
{ |
| 375 |
ACPI_FUNCTION_NAME (DtInsertLabelField); |
| 376 |
|
| 377 |
DbgPrint (ASL_DEBUG_OUTPUT, |
| 378 |
"%s: Found Label : %s at output table offset %X\n", |
| 379 |
ACPI_GET_FUNCTION_NAME, Field->Value, Field->TableOffset); |
| 380 |
|
| 381 |
Field->NextLabel = AslGbl_LabelList; |
| 382 |
AslGbl_LabelList = Field; |
| 383 |
} |
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
static DT_FIELD * |
| 400 |
DtLookupLabel ( |
| 401 |
char *Name) |
| 402 |
{ |
| 403 |
DT_FIELD *LabelField; |
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
if (*Name == '$') |
| 409 |
{ |
| 410 |
Name++; |
| 411 |
} |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
LabelField = AslGbl_LabelList; |
| 416 |
while (LabelField) |
| 417 |
{ |
| 418 |
if (!strcmp (Name, LabelField->Value)) |
| 419 |
{ |
| 420 |
return (LabelField); |
| 421 |
} |
| 422 |
|
| 423 |
LabelField = LabelField->NextLabel; |
| 424 |
} |
| 425 |
|
| 426 |
return (NULL); |
| 427 |
} |