tbxfroot.c (77424) | tbxfroot.c (78986) |
---|---|
1/****************************************************************************** 2 * 3 * Module Name: tbxfroot - Find the root ACPI table (RSDT) | 1/****************************************************************************** 2 * 3 * Module Name: tbxfroot - Find the root ACPI table (RSDT) |
4 * $Revision: 37 $ | 4 * $Revision: 39 $ |
5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. --- 134 unchanged lines hidden (view full) --- 147 ACPI_STATUS Status; 148 149 150 FUNCTION_TRACE ("AcpiFindRootPointer"); 151 152 153 /* Get the RSDP */ 154 | 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. --- 134 unchanged lines hidden (view full) --- 147 ACPI_STATUS Status; 148 149 150 FUNCTION_TRACE ("AcpiFindRootPointer"); 151 152 153 /* Get the RSDP */ 154 |
155 Status = AcpiTbFindRsdp (&TableInfo); | 155 Status = AcpiTbFindRsdp (&TableInfo, ACPI_LOGICAL_ADDRESSING); |
156 if (ACPI_FAILURE (Status)) 157 { 158 DEBUG_PRINTP (ACPI_ERROR, ("RSDP structure not found\n")); 159 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 160 } 161 162 *RsdpPhysicalAddress = TableInfo.PhysicalAddress; 163 --- 49 unchanged lines hidden (view full) --- 213 return_PTR (NULL); 214} 215 216 217/******************************************************************************* 218 * 219 * FUNCTION: AcpiTbFindRsdp 220 * | 156 if (ACPI_FAILURE (Status)) 157 { 158 DEBUG_PRINTP (ACPI_ERROR, ("RSDP structure not found\n")); 159 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 160 } 161 162 *RsdpPhysicalAddress = TableInfo.PhysicalAddress; 163 --- 49 unchanged lines hidden (view full) --- 213 return_PTR (NULL); 214} 215 216 217/******************************************************************************* 218 * 219 * FUNCTION: AcpiTbFindRsdp 220 * |
221 * PARAMETERS: *BufferPtr - If == NULL, read data from buffer 222 * rather than searching memory 223 * *TableInfo - Where the table info is returned | 221 * PARAMETERS: *TableInfo - Where the table info is returned 222 * Flags - Current memory mode (logical vs. 223 * physical addressing) |
224 * 225 * RETURN: Status 226 * 227 * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor 228 * pointer structure. If it is found, set *RSDP to point to it. 229 * 230 * NOTE: The RSDP must be either in the first 1K of the Extended 231 * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section 232 * 5.2.2; assertion #421). 233 * 234 ******************************************************************************/ 235 236ACPI_STATUS 237AcpiTbFindRsdp ( | 224 * 225 * RETURN: Status 226 * 227 * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor 228 * pointer structure. If it is found, set *RSDP to point to it. 229 * 230 * NOTE: The RSDP must be either in the first 1K of the Extended 231 * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section 232 * 5.2.2; assertion #421). 233 * 234 ******************************************************************************/ 235 236ACPI_STATUS 237AcpiTbFindRsdp ( |
238 ACPI_TABLE_DESC *TableInfo) | 238 ACPI_TABLE_DESC *TableInfo, 239 UINT32 Flags) |
239{ 240 UINT8 *TablePtr; 241 UINT8 *MemRover; 242 UINT64 PhysAddr; 243 ACPI_STATUS Status = AE_OK; 244 245 246 FUNCTION_TRACE ("TbFindRsdp"); 247 248 | 240{ 241 UINT8 *TablePtr; 242 UINT8 *MemRover; 243 UINT64 PhysAddr; 244 ACPI_STATUS Status = AE_OK; 245 246 247 FUNCTION_TRACE ("TbFindRsdp"); 248 249 |
249 /* 250 * Search memory for RSDP. First map low physical memory. | 250 /* 251 * Scan supports either 1) Logical addressing or 2) Physical addressing |
251 */ | 252 */ |
253 if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) 254 { 255 /* 256 * 1) Search EBDA (low memory) paragraphs 257 */ 258 Status = AcpiOsMapMemory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE, 259 (void **) &TablePtr); 260 if (ACPI_FAILURE (Status)) 261 { 262 return_ACPI_STATUS (Status); 263 } |
|
252 | 264 |
253 Status = AcpiOsMapMemory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE, 254 (void **)&TablePtr); | 265 MemRover = AcpiTbScanMemoryForRsdp (TablePtr, LO_RSDP_WINDOW_SIZE); 266 AcpiOsUnmapMemory (TablePtr, LO_RSDP_WINDOW_SIZE); |
255 | 267 |
256 if (ACPI_FAILURE (Status)) 257 { 258 return_ACPI_STATUS (Status); | 268 if (MemRover) 269 { 270 /* Found it, return the physical address */ 271 272 PhysAddr = LO_RSDP_WINDOW_BASE; 273 PhysAddr += (MemRover - TablePtr); 274 275 TableInfo->PhysicalAddress = PhysAddr; 276 277 return_ACPI_STATUS (AE_OK); 278 } 279 280 /* 281 * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h 282 */ 283 Status = AcpiOsMapMemory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE, 284 (void **) &TablePtr); 285 if (ACPI_FAILURE (Status)) 286 { 287 return_ACPI_STATUS (Status); 288 } 289 290 MemRover = AcpiTbScanMemoryForRsdp (TablePtr, HI_RSDP_WINDOW_SIZE); 291 AcpiOsUnmapMemory (TablePtr, HI_RSDP_WINDOW_SIZE); 292 293 if (MemRover) 294 { 295 /* Found it, return the physical address */ 296 297 PhysAddr = HI_RSDP_WINDOW_BASE; 298 PhysAddr += (MemRover - TablePtr); 299 300 TableInfo->PhysicalAddress = PhysAddr; 301 302 return_ACPI_STATUS (AE_OK); 303 } |
259 } 260 | 304 } 305 |
306 |
|
261 /* | 307 /* |
262 * 1) Search EBDA (low memory) paragraphs | 308 * Physical addressing |
263 */ | 309 */ |
310 else 311 { 312 /* 313 * 1) Search EBDA (low memory) paragraphs 314 */ 315 MemRover = AcpiTbScanMemoryForRsdp ((UINT8 *) LO_RSDP_WINDOW_BASE, 316 LO_RSDP_WINDOW_SIZE); 317 if (MemRover) 318 { 319 /* Found it, return the physical address */ |
|
264 | 320 |
265 MemRover = AcpiTbScanMemoryForRsdp (TablePtr, LO_RSDP_WINDOW_SIZE); | 321 TableInfo->PhysicalAddress = (ACPI_TBLPTR) MemRover; 322 return_ACPI_STATUS (AE_OK); 323 } |
266 | 324 |
267 /* This mapping is no longer needed */ | 325 /* 326 * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h 327 */ 328 MemRover = AcpiTbScanMemoryForRsdp ((UINT8 *) HI_RSDP_WINDOW_BASE, 329 HI_RSDP_WINDOW_SIZE); 330 if (MemRover) 331 { 332 /* Found it, return the physical address */ |
268 | 333 |
269 AcpiOsUnmapMemory (TablePtr, LO_RSDP_WINDOW_SIZE); | 334 TableInfo->PhysicalAddress = (ACPI_TBLPTR) MemRover; 335 return_ACPI_STATUS (AE_OK); 336 } 337 } |
270 | 338 |
271 if (MemRover) 272 { 273 /* Found it, return the physical address */ | |
274 | 339 |
275 PhysAddr = LO_RSDP_WINDOW_BASE; 276 PhysAddr += (MemRover - TablePtr); | 340 /* RSDP signature was not found */ |
277 | 341 |
278 TableInfo->PhysicalAddress = PhysAddr; | 342 return_ACPI_STATUS (AE_NOT_FOUND); 343} |
279 | 344 |
280 return_ACPI_STATUS (AE_OK); 281 } | |
282 | 345 |
346/******************************************************************************* 347 * 348 * FUNCTION: AcpiGetFirmwareTable 349 * 350 * PARAMETERS: Signature - Any ACPI table signature 351 * Instance - the non zero instance of the table, allows 352 * support for multiple tables of the same type 353 * Flags - 0: Physical/Virtual support 354 * RetBuffer - pointer to a structure containing a buffer to 355 * receive the table 356 * 357 * RETURN: Status 358 * 359 * DESCRIPTION: This function is called to get an ACPI table. The caller 360 * supplies an OutBuffer large enough to contain the entire ACPI 361 * table. Upon completion 362 * the OutBuffer->Length field will indicate the number of bytes 363 * copied into the OutBuffer->BufPtr buffer. This table will be 364 * a complete table including the header. 365 * 366 ******************************************************************************/ |
|
283 | 367 |
368ACPI_STATUS 369AcpiGetFirmwareTable ( 370 ACPI_STRING Signature, 371 UINT32 Instance, 372 UINT32 Flags, 373 ACPI_TABLE_HEADER **TablePointer) 374{ 375 ACPI_PHYSICAL_ADDRESS PhysicalAddress; 376 ACPI_TABLE_DESC TableInfo; 377 ACPI_TABLE_HEADER *RsdtPtr; 378 ACPI_TABLE_HEADER *TablePtr; 379 ACPI_STATUS Status; 380 UINT32 RsdtSize; 381 UINT32 TableSize; 382 UINT32 TableCount; 383 UINT32 i; 384 UINT32 j; 385 386 387 FUNCTION_TRACE ("AcpiGetFirmwareTable"); 388 389 390 /* 391 * Ensure that at least the table manager is initialized. We don't 392 * require that the entire ACPI subsystem is up for this interface 393 */ 394 395 |
|
284 /* | 396 /* |
285 * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h | 397 * If we have a buffer, we must have a length too |
286 */ | 398 */ |
399 if ((Instance == 0) || 400 (!Signature) || 401 (!TablePointer)) 402 { 403 return_ACPI_STATUS (AE_BAD_PARAMETER); 404 } |
|
287 | 405 |
288 Status = AcpiOsMapMemory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE, 289 (void **)&TablePtr); | 406 /* Get the RSDP by scanning low memory */ |
290 | 407 |
408 Status = AcpiTbFindRsdp (&TableInfo, Flags); |
|
291 if (ACPI_FAILURE (Status)) 292 { | 409 if (ACPI_FAILURE (Status)) 410 { |
411 DEBUG_PRINTP (ACPI_ERROR, ("RSDP structure not found\n")); 412 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 413 } 414 415 AcpiGbl_RSDP = (RSDP_DESCRIPTOR *) TableInfo.Pointer; 416 417 418 /* Get the RSDT and validate it */ 419 420 PhysicalAddress = AcpiTbGetRsdtAddress (); 421 Status = AcpiTbGetTablePointer (PhysicalAddress, Flags, &RsdtSize, &RsdtPtr); 422 if (ACPI_FAILURE (Status)) 423 { |
|
293 return_ACPI_STATUS (Status); 294 } 295 | 424 return_ACPI_STATUS (Status); 425 } 426 |
296 MemRover = AcpiTbScanMemoryForRsdp (TablePtr, HI_RSDP_WINDOW_SIZE); | 427 Status = AcpiTbValidateRsdt (RsdtPtr); 428 if (ACPI_FAILURE (Status)) 429 { 430 goto Cleanup; 431 } |
297 | 432 |
298 /* This mapping is no longer needed */ | |
299 | 433 |
300 AcpiOsUnmapMemory (TablePtr, HI_RSDP_WINDOW_SIZE); | 434 /* Get the number of table pointers within the RSDT */ |
301 | 435 |
302 if (MemRover) | 436 TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtPtr); 437 438 439 /* 440 * Search the RSDT/XSDT for the correct instance of the 441 * requested table 442 */ 443 for (i = 0, j = 0; i < TableCount; i++) |
303 { | 444 { |
304 /* Found it, return the physical address */ | 445 /* Get the next table pointer */ |
305 | 446 |
306 PhysAddr = HI_RSDP_WINDOW_BASE; 307 PhysAddr += (MemRover - TablePtr); | 447 if (AcpiGbl_RSDP->Revision < 2) 448 { 449 PhysicalAddress = ((RSDT_DESCRIPTOR *) RsdtPtr)->TableOffsetEntry[i]; 450 } 451 else 452 { 453 PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) 454 ACPI_GET_ADDRESS (((XSDT_DESCRIPTOR *) RsdtPtr)->TableOffsetEntry[i]); 455 } |
308 | 456 |
309 TableInfo->PhysicalAddress = PhysAddr; | 457 /* Get addressibility if necessary */ |
310 | 458 |
311 return_ACPI_STATUS (AE_OK); | 459 Status = AcpiTbGetTablePointer (PhysicalAddress, Flags, &TableSize, &TablePtr); 460 if (ACPI_FAILURE (Status)) 461 { 462 goto Cleanup; 463 } 464 465 /* Compare table signatures and table instance */ 466 467 if (!STRNCMP ((char *) TablePtr, Signature, STRLEN (Signature))) 468 { 469 /* An instance of the table was found */ 470 471 j++; 472 if (j >= Instance) 473 { 474 /* Found the correct instance */ 475 476 *TablePointer = TablePtr; 477 goto Cleanup; 478 } 479 } 480 481 /* Delete table mapping if using virtual addressing */ 482 483 if (TableSize) 484 { 485 AcpiOsUnmapMemory (TablePtr, TableSize); 486 } |
312 } 313 | 487 } 488 |
489 /* Did not find the table */ |
|
314 | 490 |
315 /* RSDP signature was not found */ | 491 Status = AE_NOT_EXIST; |
316 | 492 |
317 return_ACPI_STATUS (AE_NOT_FOUND); | 493 494Cleanup: 495 if (RsdtSize) 496 { 497 AcpiOsUnmapMemory (RsdtPtr, RsdtSize); 498 } 499 return_ACPI_STATUS (Status); |
318} 319 320 | 500} 501 502 |