Utilities: Fix local printf issue found for parsed format types.

The following commit has fixed local printf issue in width.prec:

  Commit: 6de9d1e3f1f9383dbe46e2454297873229b59234
  Subject: Utilities: Fix local printf issue.

But this commit only resets width/precision/quialifier to fix the reported
issue and doesn't fix other states issues. So now we still can see breakage
in format types and integer bases.

This patch resets format type/base states for local printf to fix this
issue. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Applications: Enable USE_NATIVE_ALLOCATE_ZEROED environment for all applications.

We now safe to enable USE_NATIVE_ALLOCATE_ZEROED for all applications as
there are implementations in oswinxf.c, osunixxf.c and osefixf.c. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Clib: Add porting layer for print APIs.

This patch:
1. Adds AcpiUtVprintf()/AcpiUtPrintf() support.
2. Adds default stdout for AcpiUtFileVprintf()/AcpiUtFilePrintf().
3. Adds wrapper layer for AcpiUtSnprintf()/AcpiUtVsnprintf(),
   AcpiUtFileVprintf()/AcpiUtFilePrintf() and
   AcpiUtVprintf()/AcpiUtPrintf() and converts their usages into the
   invocations of the wrapper layer.
Note that this patch doesn't enable the print APIs for OSPMs that do not
have ACPI_USE_SYSTEM_CLIBRARY defined before fulling testing the
implementations. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Applications: Fix a potential issue that help messages may be dumped to AcpiGbl_DebugFile.

There is an issue for usage macros, if an command line option changed
AcpiGbl_DebugFile, then the follow up usage may errornously dumped to the
debug file.
This is just a bug in theory, because currently AcpiGbl_DebugFile can only
be modified by acpibin and acpiexec. Currently this will not trigger such
issue because:
1. For acpibin, AcpiGbl_DebugFile will be modified by "-t" option and the
   program exit after processing this option without dumping help message
   or other error options.
2. For acpiexec, AcpiGbl_DebugFile will only be modified by the open
   command, which happens after parsing the command line options, so no
   help message will be dumped into the debug file.
But maintaining this logic is difficult, so this patch modifies
AcpiOsPrintf() into ACPI_PRINTF() for usage macros so that the help
messages are ensured to be dumped to the stdout. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
EFI: Add OSL supports for those can be empty.

This patch adds OSLs that can be empty under EFI environment. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
EFI: Fix build errors by adding component/module definitions.

There are build errors for ACPI_DEBUG_OUTPUT enabled tools. This is because
osefixf.c is lacking of component/module definitions. This patch fixes such
build errors by filling this gap. Yizhe Wang.

Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Clib: Add AcpiUtMemmove() to improve portability

This patch implements AcpiUtMemmove() as a native replacement of memmove.
This implementation has been roughly tested under unix. Yizhe Wang.

Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Clib: Add AcpiOsGetFileCharacter()/AcpiOsPutFileCharacter() to improve portability.

This patch added two new OSLs:
1. AcpiOsGetFileCharacter() as a replacement of fgetc()/getc().
2. AcpiOsPutFileCharacter() as a replacement of fputc()/putc().
For Unix/Windows environments, these 2 APIs are implemented using
fgetc()/fputc(). For EFI environment, they are implemented using
AcpiOsReadFile()/AcpiOsWriteFile().

Note in this patch, ACPI_FILE_IN is simply defined as NULL for EFI
environment. Its EFI support should be implemented by further patches.
Yizhe Wang.

Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Common: Modify string/memory/file libc invocations in AcpiOsGetLine() into c library wrappers to improve portability.

This patch cleans up AcpiOsGetLine() by replacing the following libc
invocations into the c library wrappers:
1. strlen -> ACPI_STRLEN
2. strcpy -> ACPI_STRCPY
3. strtoul -> ACPI_STRTOUL
4. strcpy -> ACPI_STRCPY
5. memmove -> ACPI_MEMMOVE
6. memset -> ACPI_MEMSET
7. fprintf -> ACPI_FPRINTF
8. putchar -> AcpiOsPutFileCharacter(ACPI_FILE_OUT)
9. getchar -> AcpiOsGetFileCharacter(ACPI_FILE_IN)
No functional changes for Unix/Windows environments. Yizhe Wang.

Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Clib: Introduce a new file open types - ACPI_FILE_APPENDING/ACPI_FILE_TEXT.

This patch introduced a new types:
1. ACPI_FILE_APPENDING so that "w+" can be expressed as
   (ACPI_FILE_WRITING | ACPI_FILE_APPENDING).
2. ACPI_FILE_TEXT so that "rt" can be expressed as
   (ACPI_FILE_READING | ACPI_FILE_TEXT).
The new types are used by ACPICA applications. Yizhe Wang.

Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Debugger/Utilities: Replace stdio invocations with OSL APIs to improve portability.

This patch improves portability by:
1. Replace fclose() with AcpiOsCloseFile().
2. Replace fopen() with AcpiOsOpenFile().
3. Replace perror() and fprintf with AcpiLogError().
4. Replace type FILE with ACPI_FILE
5. Replace fseek() with AcpiOsSetFileOffset().
6. Replace fread() with AcpiOsReadFile().

Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
EFI: Add stubs for multi-threading OSLs to make EFI ported applications running.

This patch only adds stub supports for multi-threading OSLs to make
EFI ported application running.

In order to fully support acpiexec in a non multi-threading environment,
ACPICA core itself need to be upgraded to contain full asynchrnous support.
Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
EFI: Add stubs for hardware access OSLs to make EFI ported applications running.

This patch only adds stub supports for hardware access OSLs to make EFI
ported application running.

This patch adds the following OSLs for efi:
1. AcpiOsInstallInterruptHandler()/RemoveInterruptHandler().
2. AcpiOsReadPort()/AcpiOsWritePort().
3. AcpiOsReadMemory()/AcpiOsWriteMemory().
3. AcpiOsReadPciConfigration()/AcpiOsWritePciConfiguration().
Currently we will not support real hardware accesses in the EFI
environment, so they can stay stubs. Yizhe Wang.

Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
EFI: Add standard input descriptor support.

This patch implements stdin for EFI environment using
SIMPLE_INPUT_INTERFACE. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
EFI: Add file position seeking/telling support.

This patch adds file position seeking/telling support. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
OSL: Add correct AcpiGbl_DebugTimeout export to allow acpiexec to link.

The AcpiGbl_DebugTimeout implemented in oswinxf.c is only used for WIN32
builds, so acpiexec need to be changed accordingly to make -t option a
no-op for other platforms. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
EFI: Add table OSL supports for acpiexec.

This patch implements table OSLs for acpiexec in EFI environment:
1. Adds AcpiOsTableOverride() to use acpiexec loaded xSDT tables.
2. Adds a stub AcpiOsPhysicalTableOverride().
Note that currently we only support emulator mode acpiexec in EFI
environment, thus all table overrides, RSDP location are implemented in the
same way as its windows/unix versions. Yizhe Wang.

Signed-off-by: Yizhe Wang <yizhe.wang@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
EFI: Add AcpiOsGetTimer() support.

This patch adds AcpiOsGetTimer() support for EFI environment.
Note that currently we don't support timezone. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
EFI: Add AcpiOsStall()/AcpiOsSleep() support.

This patch adds AcpiOsStall() and AcpiOsSleep() support.
Currently we do not support asynchronous polling of key stroke and timer,
so AcpiOsSleep() is simply an invocation of AcpiOsStall(). Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>