dbfileio.c (114237) | dbfileio.c (117521) |
---|---|
1/******************************************************************************* 2 * 3 * Module Name: dbfileio - Debugger file I/O commands. These can't usually 4 * be used when running the debugger in Ring 0 (Kernel mode) | 1/******************************************************************************* 2 * 3 * Module Name: dbfileio - Debugger file I/O commands. These can't usually 4 * be used when running the debugger in Ring 0 (Kernel mode) |
5 * $Revision: 72 $ | 5 * $Revision: 74 $ |
6 * 7 ******************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. --- 187 unchanged lines hidden (view full) --- 201 } 202 203#endif 204} 205#endif 206 207 208#ifdef ACPI_APPLICATION | 6 * 7 ******************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. --- 187 unchanged lines hidden (view full) --- 201 } 202 203#endif 204} 205#endif 206 207 208#ifdef ACPI_APPLICATION |
209 |
|
209/******************************************************************************* 210 * | 210/******************************************************************************* 211 * |
212 * FUNCTION: AcpiDbCheckTextModeCorruption 213 * 214 * PARAMETERS: Table - Table buffer 215 * TableLength - Length of table from the table header 216 * FileLength - Length of the file that contains the table 217 * 218 * RETURN: Status 219 * 220 * DESCRIPTION: Check table for text mode file corruption where all linefeed 221 * characters (LF) have been replaced by carriage return linefeed 222 * pairs (CR/LF). 223 * 224 ******************************************************************************/ 225 226static ACPI_STATUS 227AcpiDbCheckTextModeCorruption ( 228 UINT8 *Table, 229 UINT32 TableLength, 230 UINT32 FileLength) 231{ 232 UINT32 i; 233 UINT32 Pairs = 0; 234 235 236 if (TableLength != FileLength) 237 { 238 ACPI_REPORT_WARNING (("File length (0x%X) is not the same as the table length (0x%X)\n", 239 FileLength, TableLength)); 240 } 241 242 /* Scan entire table to determine if each LF has been prefixed with a CR */ 243 244 for (i = 1; i < FileLength; i++) 245 { 246 if (Table[i] == 0x0A) 247 { 248 if (Table[i - 1] != 0x0D) 249 { 250 /* the LF does not have a preceeding CR, table is not corrupted */ 251 252 return (AE_OK); 253 } 254 else 255 { 256 /* Found a CR/LF pair */ 257 258 Pairs++; 259 } 260 i++; 261 } 262 } 263 264 /* 265 * Entire table scanned, each CR is part of a CR/LF pair -- 266 * meaning that the table was treated as a text file somewhere. 267 * 268 * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the 269 * original table are left untouched by the text conversion process -- 270 * meaning that we cannot simply replace CR/LF pairs with LFs. 271 */ 272 AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); 273 AcpiOsPrintf ("All LFs (%d) were changed to CR/LF pairs\n", Pairs); 274 AcpiOsPrintf ("Table cannot be repaired!\n"); 275 return (AE_BAD_VALUE); 276} 277 278 279/******************************************************************************* 280 * |
|
211 * FUNCTION: AcpiDbReadTable 212 * 213 * PARAMETERS: fp - File that contains table 214 * Table - Return value, buffer with table 215 * TableLength - Return value, length of table 216 * 217 * RETURN: Status 218 * 219 * DESCRIPTION: Load the DSDT from the file pointer 220 * 221 ******************************************************************************/ 222 223static ACPI_STATUS 224AcpiDbReadTable ( 225 FILE *fp, 226 ACPI_TABLE_HEADER **Table, 227 UINT32 *TableLength) 228{ 229 ACPI_TABLE_HEADER TableHeader; | 281 * FUNCTION: AcpiDbReadTable 282 * 283 * PARAMETERS: fp - File that contains table 284 * Table - Return value, buffer with table 285 * TableLength - Return value, length of table 286 * 287 * RETURN: Status 288 * 289 * DESCRIPTION: Load the DSDT from the file pointer 290 * 291 ******************************************************************************/ 292 293static ACPI_STATUS 294AcpiDbReadTable ( 295 FILE *fp, 296 ACPI_TABLE_HEADER **Table, 297 UINT32 *TableLength) 298{ 299 ACPI_TABLE_HEADER TableHeader; |
230 UINT8 *AmlStart; 231 UINT32 AmlLength; | |
232 UINT32 Actual; 233 ACPI_STATUS Status; | 300 UINT32 Actual; 301 ACPI_STATUS Status; |
302 UINT32 FileSize; |
|
234 235 | 303 304 |
305 fseek (fp, 0, SEEK_END); 306 FileSize = ftell (fp); 307 fseek (fp, 0, SEEK_SET); 308 |
|
236 /* Read the table header */ 237 238 if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (ACPI_TABLE_HEADER)) 239 { 240 AcpiOsPrintf ("Couldn't read the table header\n"); 241 return (AE_BAD_SIGNATURE); 242 } 243 --- 16 unchanged lines hidden (view full) --- 260 AcpiOsPrintf ("Table signature is invalid\n"); 261 ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); 262 return (AE_ERROR); 263 } 264 265 /* Allocate a buffer for the table */ 266 267 *TableLength = TableHeader.Length; | 309 /* Read the table header */ 310 311 if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (ACPI_TABLE_HEADER)) 312 { 313 AcpiOsPrintf ("Couldn't read the table header\n"); 314 return (AE_BAD_SIGNATURE); 315 } 316 --- 16 unchanged lines hidden (view full) --- 333 AcpiOsPrintf ("Table signature is invalid\n"); 334 ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); 335 return (AE_ERROR); 336 } 337 338 /* Allocate a buffer for the table */ 339 340 *TableLength = TableHeader.Length; |
268 *Table = AcpiOsAllocate ((size_t) *TableLength); | 341 *Table = AcpiOsAllocate ((size_t) (FileSize)); |
269 if (!*Table) 270 { 271 AcpiOsPrintf ("Could not allocate memory for ACPI table %4.4s (size=%X)\n", 272 TableHeader.Signature, TableHeader.Length); 273 return (AE_NO_MEMORY); 274 } 275 | 342 if (!*Table) 343 { 344 AcpiOsPrintf ("Could not allocate memory for ACPI table %4.4s (size=%X)\n", 345 TableHeader.Signature, TableHeader.Length); 346 return (AE_NO_MEMORY); 347 } 348 |
276 AmlStart = (UINT8 *) *Table + sizeof (TableHeader); 277 AmlLength = *TableLength - sizeof (TableHeader); 278 279 /* Copy the header to the buffer */ 280 281 ACPI_MEMCPY (*Table, &TableHeader, sizeof (TableHeader)); 282 | |
283 /* Get the rest of the table */ 284 | 349 /* Get the rest of the table */ 350 |
285 Actual = fread (AmlStart, 1, (size_t) AmlLength, fp); 286 if (Actual == AmlLength) | 351 fseek (fp, 0, SEEK_SET); 352 Actual = fread (*Table, 1, (size_t) FileSize, fp); 353 if (Actual == FileSize) |
287 { 288 /* Now validate the checksum */ 289 290 Status = AcpiTbVerifyTableChecksum (*Table); | 354 { 355 /* Now validate the checksum */ 356 357 Status = AcpiTbVerifyTableChecksum (*Table); |
358 359 if (Status == AE_BAD_CHECKSUM) 360 { 361 Status = AcpiDbCheckTextModeCorruption ((UINT8 *) *Table, 362 FileSize, (*Table)->Length); 363 return (Status); 364 } |
|
291 return (AE_OK); 292 } 293 294 if (Actual > 0) 295 { | 365 return (AE_OK); 366 } 367 368 if (Actual > 0) 369 { |
296 AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", AmlLength, Actual); | 370 AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", 371 FileSize, Actual); |
297 return (AE_OK); 298 } 299 300 AcpiOsPrintf ("Error - could not read the table file\n"); 301 AcpiOsFree (*Table); 302 *Table = NULL; 303 *TableLength = 0; 304 --- 54 unchanged lines hidden (view full) --- 359 360#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) 361 362 Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); 363 if (ACPI_FAILURE (Status)) 364 { 365 /* Uninstall table and free the buffer */ 366 | 372 return (AE_OK); 373 } 374 375 AcpiOsPrintf ("Error - could not read the table file\n"); 376 AcpiOsFree (*Table); 377 *Table = NULL; 378 *TableLength = 0; 379 --- 54 unchanged lines hidden (view full) --- 434 435#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) 436 437 Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); 438 if (ACPI_FAILURE (Status)) 439 { 440 /* Uninstall table and free the buffer */ 441 |
367 AcpiTbDeleteAcpiTable (ACPI_TABLE_DSDT); | 442 AcpiTbDeleteTablesByType (ACPI_TABLE_DSDT); |
368 return_ACPI_STATUS (Status); 369 } 370#endif 371 372 return_ACPI_STATUS (Status); 373} 374 375 --- 114 unchanged lines hidden --- | 443 return_ACPI_STATUS (Status); 444 } 445#endif 446 447 return_ACPI_STATUS (Status); 448} 449 450 --- 114 unchanged lines hidden --- |