Print this page
update to acpica-unix2-20140114
update to acpica-unix2-20131218
update to acpica-unix2-20130927
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/debugger/dbfileio.c
          +++ new/usr/src/common/acpica/components/debugger/dbfileio.c
   1    1  /*******************************************************************************
   2    2   *
   3    3   * Module Name: dbfileio - Debugger file I/O commands. These can't usually
   4    4   *              be used when running the debugger in Ring 0 (Kernel mode)
   5    5   *
   6    6   ******************************************************************************/
   7    7  
   8    8  /*
   9      - * Copyright (C) 2000 - 2011, Intel Corp.
        9 + * Copyright (C) 2000 - 2014, Intel Corp.
  10   10   * All rights reserved.
  11   11   *
  12   12   * Redistribution and use in source and binary forms, with or without
  13   13   * modification, are permitted provided that the following conditions
  14   14   * are met:
  15   15   * 1. Redistributions of source code must retain the above copyright
  16   16   *    notice, this list of conditions, and the following disclaimer,
  17   17   *    without modification.
  18   18   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  19   19   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 24 lines elided ↑ open up ↑
  44   44  
  45   45  
  46   46  #include "acpi.h"
  47   47  #include "accommon.h"
  48   48  #include "acdebug.h"
  49   49  
  50   50  #ifdef ACPI_APPLICATION
  51   51  #include "actables.h"
  52   52  #endif
  53   53  
       54 +#ifdef ACPI_ASL_COMPILER
       55 +#include "aslcompiler.h"
       56 +#endif
       57 +
  54   58  #if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER)
  55   59  
  56   60  #define _COMPONENT          ACPI_CA_DEBUGGER
  57   61          ACPI_MODULE_NAME    ("dbfileio")
  58   62  
  59      -/*
  60      - * NOTE: this is here for lack of a better place. It is used in all
  61      - * flavors of the debugger, need LCD file
  62      - */
  63      -#ifdef ACPI_APPLICATION
  64      -#include <stdio.h>
  65      -FILE                        *AcpiGbl_DebugFile = NULL;
  66      -#endif
  67      -
  68      -
  69   63  #ifdef ACPI_DEBUGGER
  70   64  
  71   65  /* Local prototypes */
  72   66  
  73   67  #ifdef ACPI_APPLICATION
  74   68  
  75   69  static ACPI_STATUS
  76   70  AcpiDbCheckTextModeCorruption (
  77   71      UINT8                   *Table,
  78   72      UINT32                  TableLength,
↓ open down ↓ 45 lines elided ↑ open up ↑
 124  118  
 125  119  void
 126  120  AcpiDbOpenDebugFile (
 127  121      char                    *Name)
 128  122  {
 129  123  
 130  124  #ifdef ACPI_APPLICATION
 131  125  
 132  126      AcpiDbCloseDebugFile ();
 133  127      AcpiGbl_DebugFile = fopen (Name, "w+");
 134      -    if (AcpiGbl_DebugFile)
      128 +    if (!AcpiGbl_DebugFile)
 135  129      {
 136      -        AcpiOsPrintf ("Debug output file %s opened\n", Name);
 137      -        ACPI_STRCPY (AcpiGbl_DbDebugFilename, Name);
 138      -        AcpiGbl_DbOutputToFile = TRUE;
 139      -    }
 140      -    else
 141      -    {
 142  130          AcpiOsPrintf ("Could not open debug file %s\n", Name);
      131 +        return;
 143  132      }
 144  133  
      134 +    AcpiOsPrintf ("Debug output file %s opened\n", Name);
      135 +    ACPI_STRNCPY (AcpiGbl_DbDebugFilename, Name,
      136 +        sizeof (AcpiGbl_DbDebugFilename));
      137 +    AcpiGbl_DbOutputToFile = TRUE;
      138 +
 145  139  #endif
 146  140  }
 147  141  #endif
 148  142  
 149  143  
 150  144  #ifdef ACPI_APPLICATION
 151  145  /*******************************************************************************
 152  146   *
 153  147   * FUNCTION:    AcpiDbCheckTextModeCorruption
 154  148   *
↓ open down ↓ 109 lines elided ↑ open up ↑
 264  258      /* Read the signature */
 265  259  
 266  260      if (fread (&TableHeader, 1, 4, fp) != 4)
 267  261      {
 268  262          AcpiOsPrintf ("Could not read the table signature\n");
 269  263          return (AE_BAD_HEADER);
 270  264      }
 271  265  
 272  266      fseek (fp, 0, SEEK_SET);
 273  267  
 274      -    /* The RSDT and FACS tables do not have standard ACPI headers */
      268 +    /* The RSDP table does not have standard ACPI header */
 275  269  
 276      -    if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD ") ||
 277      -        ACPI_COMPARE_NAME (TableHeader.Signature, "FACS"))
      270 +    if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD "))
 278  271      {
 279  272          *TableLength = FileSize;
 280  273          StandardHeader = FALSE;
 281  274      }
 282  275      else
 283  276      {
 284  277          /* Read the table header */
 285  278  
 286      -        if (fread (&TableHeader, 1, sizeof (TableHeader), fp) !=
      279 +        if (fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), fp) !=
 287  280                  sizeof (ACPI_TABLE_HEADER))
 288  281          {
 289  282              AcpiOsPrintf ("Could not read the table header\n");
 290  283              return (AE_BAD_HEADER);
 291  284          }
 292  285  
 293  286  #if 0
 294  287          /* Validate the table header/length */
 295  288  
 296  289          Status = AcpiTbValidateTableHeader (&TableHeader);
↓ open down ↓ 4 lines elided ↑ open up ↑
 301  294          }
 302  295  #endif
 303  296  
 304  297          /* File size must be at least as long as the Header-specified length */
 305  298  
 306  299          if (TableHeader.Length > FileSize)
 307  300          {
 308  301              AcpiOsPrintf (
 309  302                  "TableHeader length [0x%X] greater than the input file size [0x%X]\n",
 310  303                  TableHeader.Length, FileSize);
      304 +
      305 +#ifdef ACPI_ASL_COMPILER
      306 +            Status = FlCheckForAscii (fp, NULL, FALSE);
      307 +            if (ACPI_SUCCESS (Status))
      308 +            {
      309 +                AcpiOsPrintf ("File appears to be ASCII only, must be binary\n",
      310 +                    TableHeader.Length, FileSize);
      311 +            }
      312 +#endif
 311  313              return (AE_BAD_HEADER);
 312  314          }
 313  315  
 314  316  #ifdef ACPI_OBSOLETE_CODE
 315  317          /* We only support a limited number of table types */
 316  318  
 317      -        if (ACPI_STRNCMP ((char *) TableHeader.Signature, DSDT_SIG, 4) &&
 318      -            ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) &&
 319      -            ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4))
      319 +        if (!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_DSDT) &&
      320 +            !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_PSDT) &&
      321 +            !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_SSDT))
 320  322          {
 321  323              AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n",
 322  324                  (char *) TableHeader.Signature);
 323  325              ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER));
 324  326              return (AE_ERROR);
 325  327          }
 326  328  #endif
 327  329  
 328  330          *TableLength = TableHeader.Length;
 329  331      }
↓ open down ↓ 36 lines elided ↑ open up ↑
 366  368      {
 367  369          AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n",
 368  370              FileSize, Actual);
 369  371          return (AE_OK);
 370  372      }
 371  373  
 372  374      AcpiOsPrintf ("Error - could not read the table file\n");
 373  375      AcpiOsFree (*Table);
 374  376      *Table = NULL;
 375  377      *TableLength = 0;
 376      -
 377  378      return (AE_ERROR);
 378  379  }
 379  380  
 380  381  
 381  382  /*******************************************************************************
 382  383   *
 383  384   * FUNCTION:    AeLocalLoadTable
 384  385   *
 385  386   * PARAMETERS:  Table           - pointer to a buffer containing the entire
 386  387   *                                table to be loaded
↓ open down ↓ 77 lines elided ↑ open up ↑
 464  465   *
 465  466   * DESCRIPTION: Get an ACPI table from a file
 466  467   *
 467  468   ******************************************************************************/
 468  469  
 469  470  ACPI_STATUS
 470  471  AcpiDbReadTableFromFile (
 471  472      char                    *Filename,
 472  473      ACPI_TABLE_HEADER       **Table)
 473  474  {
 474      -    FILE                    *fp;
      475 +    FILE                    *File;
      476 +    UINT32                  FileSize;
 475  477      UINT32                  TableLength;
 476  478      ACPI_STATUS             Status;
 477  479  
 478  480  
 479  481      /* Open the file */
 480  482  
 481      -    fp = fopen (Filename, "rb");
 482      -    if (!fp)
      483 +    File = fopen (Filename, "rb");
      484 +    if (!File)
 483  485      {
 484      -        AcpiOsPrintf ("Could not open input file %s\n", Filename);
      486 +        perror ("Could not open input file");
 485  487          return (AE_ERROR);
 486  488      }
 487  489  
      490 +    /* Get the file size */
      491 +
      492 +    fseek (File, 0, SEEK_END);
      493 +    FileSize = (UINT32) ftell (File);
      494 +    fseek (File, 0, SEEK_SET);
      495 +
 488  496      /* Get the entire file */
 489  497  
 490      -    fprintf (stderr, "Loading Acpi table from file %s\n", Filename);
 491      -    Status = AcpiDbReadTable (fp, Table, &TableLength);
 492      -    fclose(fp);
      498 +    fprintf (stderr, "Loading Acpi table from file %10s - Length %.8u (%06X)\n",
      499 +        Filename, FileSize, FileSize);
 493  500  
      501 +    Status = AcpiDbReadTable (File, Table, &TableLength);
      502 +    fclose(File);
      503 +
 494  504      if (ACPI_FAILURE (Status))
 495  505      {
 496  506          AcpiOsPrintf ("Could not get table from the file\n");
 497  507          return (Status);
 498  508      }
 499  509  
 500  510      return (AE_OK);
 501  511   }
 502  512  #endif
 503  513  
↓ open down ↓ 63 lines elided ↑ open up ↑
 567  577      {
 568  578          *ReturnTable = Table;
 569  579      }
 570  580  
 571  581  
 572  582  #endif  /* ACPI_APPLICATION */
 573  583      return (AE_OK);
 574  584  }
 575  585  
 576  586  #endif  /* ACPI_DEBUGGER */
 577      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX