Skip to content

Commit

Permalink
Move all ASCII utilities to a common file
Browse files Browse the repository at this point in the history
New file is utascii.c
  • Loading branch information
acpibob committed Apr 19, 2016
1 parent 13c1892 commit ba60e45
Show file tree
Hide file tree
Showing 17 changed files with 273 additions and 267 deletions.
2 changes: 1 addition & 1 deletion source/common/acfileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ AcValidateTableHeader (

/* Validate the signature (limited ASCII chars) */

if (!AcpiIsValidSignature (TableHeader.Signature))
if (!AcpiUtValidNameseg (TableHeader.Signature))
{
fprintf (stderr, "Invalid table signature: 0x%8.8X\n",
*ACPI_CAST_PTR (UINT32, TableHeader.Signature));
Expand Down
56 changes: 4 additions & 52 deletions source/common/dmtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,6 @@ AcpiAhGetTableInfo (
char *Signature);


/* Local Prototypes */

static void
AcpiDmCheckAscii (
UINT8 *Target,
char *RepairedName,
UINT32 Count);


/* Common format strings for commented values */

#define UINT8_FORMAT "%2.2X [%s]\n"
Expand Down Expand Up @@ -1132,7 +1123,7 @@ AcpiDmDumpTable (

case ACPI_DMT_SIG:

AcpiDmCheckAscii (Target, RepairedName, 4);
AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
AcpiOsPrintf ("\"%.4s\" ", RepairedName);

TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
Expand All @@ -1148,19 +1139,19 @@ AcpiDmDumpTable (

case ACPI_DMT_NAME4:

AcpiDmCheckAscii (Target, RepairedName, 4);
AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
break;

case ACPI_DMT_NAME6:

AcpiDmCheckAscii (Target, RepairedName, 6);
AcpiUtCheckAndRepairAscii (Target, RepairedName, 6);
AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
break;

case ACPI_DMT_NAME8:

AcpiDmCheckAscii (Target, RepairedName, 8);
AcpiUtCheckAndRepairAscii (Target, RepairedName, 8);
AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
break;

Expand Down Expand Up @@ -1563,42 +1554,3 @@ AcpiDmDumpTable (

return (AE_OK);
}


/*******************************************************************************
*
* FUNCTION: AcpiDmCheckAscii
*
* PARAMETERS: Name - Ascii string
* Count - Number of characters to check
*
* RETURN: None
*
* DESCRIPTION: Ensure that the requested number of characters are printable
* Ascii characters. Sets non-printable and null chars to <space>.
*
******************************************************************************/

static void
AcpiDmCheckAscii (
UINT8 *Name,
char *RepairedName,
UINT32 Count)
{
UINT32 i;


for (i = 0; i < Count; i++)
{
RepairedName[i] = (char) Name[i];

if (!Name[i])
{
return;
}
if (!isprint (Name[i]))
{
RepairedName[i] = ' ';
}
}
}
2 changes: 1 addition & 1 deletion source/components/debugger/dbnames.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ AcpiDbIntegrityWalk (
return (AE_OK);
}

if (!AcpiUtValidAcpiName (Node->Name.Ascii))
if (!AcpiUtValidNameseg (Node->Name.Ascii))
{
AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
return (AE_OK);
Expand Down
2 changes: 1 addition & 1 deletion source/components/executer/exnames.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ AcpiExNameSegment (
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n"));

for (Index = 0;
(Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0));
(Index < ACPI_NAME_SIZE) && (AcpiUtValidNameChar (*AmlAddress, 0));
Index++)
{
CharBuf[Index] = *AmlAddress++;
Expand Down
2 changes: 1 addition & 1 deletion source/components/tables/tbdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ AcpiTbVerifyTempTable (
ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
"%4.4s 0x%8.8X%8.8X"
" Attempted table install failed",
AcpiUtValidAcpiName (TableDesc->Signature.Ascii) ?
AcpiUtValidNameseg (TableDesc->Signature.Ascii) ?
TableDesc->Signature.Ascii : "????",
ACPI_FORMAT_UINT64 (TableDesc->Address)));

Expand Down
2 changes: 1 addition & 1 deletion source/components/tables/tbfind.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ AcpiTbFindTable (

/* Validate the input table signature */

if (!AcpiIsValidSignature (Signature))
if (!AcpiUtValidNameseg (Signature))
{
return_ACPI_STATUS (AE_BAD_SIGNATURE);
}
Expand Down
2 changes: 1 addition & 1 deletion source/components/tables/tbinstal.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ AcpiTbInstallStandardTable (
ACPI_BIOS_ERROR ((AE_INFO,
"Table has invalid signature [%4.4s] (0x%8.8X), "
"must be SSDT or OEMx",
AcpiUtValidAcpiName (NewTableDesc.Signature.Ascii) ?
AcpiUtValidNameseg (NewTableDesc.Signature.Ascii) ?
NewTableDesc.Signature.Ascii : "????",
NewTableDesc.Signature.Integer));

Expand Down
33 changes: 0 additions & 33 deletions source/components/tables/tbutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,36 +483,3 @@ AcpiTbParseRootTable (
AcpiOsUnmapMemory (Table, Length);
return_ACPI_STATUS (AE_OK);
}


/*******************************************************************************
*
* FUNCTION: AcpiIsValidSignature
*
* PARAMETERS: Signature - Sig string to be validated
*
* RETURN: TRUE if signature is has 4 valid ACPI characters
*
* DESCRIPTION: Validate an ACPI table signature.
*
******************************************************************************/

BOOLEAN
AcpiIsValidSignature (
char *Signature)
{
UINT32 i;


/* Validate each character in the signature */

for (i = 0; i < ACPI_NAME_SIZE; i++)
{
if (!AcpiUtValidAcpiChar (Signature[i], i))
{
return (FALSE);
}
}

return (TRUE);
}
Loading

0 comments on commit ba60e45

Please sign in to comment.