From d65d28717d736d6b3268b4ebb9d171ce9c46833c Mon Sep 17 00:00:00 2001 From: Al Stone Date: Jul 28 2014 20:42:14 +0000 Subject: Imported Upstream version 20140724 --- diff --git a/Makefile b/Makefile index 5ee33d7..80bf379 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,13 @@ # code directories. This prevents collisions between different # compilations of the same source file with different compile options. # -BUILD_DIRECTORY_PATH = "generate/unix" -include generate/unix/Makefile.config -include generate/unix/Makefile.common +ifeq ($(OS),efi) + BUILD_DIRECTORY_PATH = "generate/efi" + include generate/efi/Makefile.config + include generate/efi/Makefile.common +else + BUILD_DIRECTORY_PATH = "generate/unix" + include generate/unix/Makefile.config + include generate/unix/Makefile.common +endif diff --git a/changes.txt b/changes.txt index e93fc4d..eae9f81 100755 --- a/changes.txt +++ b/changes.txt @@ -1,4 +1,186 @@ ---------------------------------------- + +24 July 2014. Summary of changes for version 20140724: + +This release is available at https://acpica.org/downloads + +The ACPI 5.1 specification has been released and is available at: +http://uefi.org/specs/access + + +0) ACPI 5.1 support in ACPICA: + +ACPI 5.1 is fully supported in ACPICA as of this release. + +New predefined names. Support includes iASL and runtime ACPICA +validation. + _CCA (Cache Coherency Attribute). + _DSD (Device-Specific Data). David Box. + +Modifications to existing ACPI tables. Support includes headers, iASL +Data Table compiler, disassembler, and the template generator. + FADT - New fields and flags. Graeme Gregory. + GTDT - One new subtable and new fields. Tomasz Nowicki. + MADT - Two new subtables. Tomasz Nowicki. + PCCT - One new subtable. + +Miscellaneous. + New notification type for System Resource Affinity change events. + + +1) ACPICA kernel-resident subsystem: + +Fixed a regression introduced in 20140627 where a fault can happen during +the deletion of Alias AML namespace objects. The problem affected both +the core ACPICA and the ACPICA tools including iASL and AcpiExec. + +Implemented a new GPE public interface, AcpiMarkGpeForWake. Provides a +simple mechanism to enable wake GPEs that have no associated handler or +control method. Rafael Wysocki. + +Updated the AcpiEnableGpe interface to disallow the enable if there is no +handler or control method associated with the particular GPE. This will +help avoid meaningless GPEs and even GPE floods. Rafael Wysocki. + +Updated GPE handling and dispatch by disabling the GPE before clearing +the status bit for edge-triggered GPEs. Lv Zheng. + +Added Timer() support to the AML Debug object. The current timer value is +now displayed with each invocation of (Store to) the debug object to +enable simple generation of execution times for AML code (method +execution for example.) ACPICA BZ 1093. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 98.7K Code, 27.3K Data, 126.0K Total + Debug Version: 192.0K Code, 79.7K Data, 271.7K Total + Previous Release: + Non-Debug Version: 98.7K Code, 27.2K Data, 125.9K Total + Debug Version: 191.7K Code, 79.6K Data, 271.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed an issue with the recently added local printf implementation, +concerning width/precision specifiers that could cause incorrect output. +Lv Zheng. ACPICA BZ 1094. + +Disassembler: Added support to detect buffers that contain UUIDs and +disassemble them to an invocation of the ToUUID operator. Also emit +commented descriptions of known ACPI-related UUIDs. + +AcpiHelp: Added support to display known ACPI-related UUIDs. New option, +-u. Adds three new files. + +iASL: Update table compiler and disassembler for DMAR table changes that +were introduced in September 2013. With assistance by David Woodhouse. + +---------------------------------------- +27 June 2014. Summary of changes for version 20140627: + +1) ACPICA kernel-resident subsystem: + +Formatted Output: Implemented local versions of standard formatted output +utilities such as printf, etc. Over time, it has been discovered that +there are in fact many portability issues with printf, and the addition +of this feature will fix/prevent these issues once and for all. Some +known issues are summarized below: + +1) Output of 64-bit values is not portable. For example, UINT64 is %ull +for the Linux kernel and is %uI64 for some MSVC versions. +2) Invoking printf consistently in a manner that is portable across both +32-bit and 64-bit platforms is difficult at best in many situations. +3) The output format for pointers varies from system to system (leading +zeros especially), and leads to inconsistent output from ACPICA across +platforms. +4) Certain platform-specific printf formats may conflict with ACPICA use. +5) If there is no local C library available, ACPICA now has local support +for printf. + +-- To address these printf issues in a complete manner, ACPICA now +directly implements a small subset of printf format specifiers, only +those that it requires. Adds a new file, utilities/utprint.c. Lv Zheng. + +Implemented support for ACPICA generation within the EFI environment. +Initially, the AcpiDump utility is supported in the UEFI shell +environment. Lv Zheng. + +Added a new external interface, AcpiLogError, to improve ACPICA +portability. This allows the host to redirect error messages from the +ACPICA utilities. Lv Zheng. + +Added and deployed new OSL file I/O interfaces to improve ACPICA +portability: + AcpiOsOpenFile + AcpiOsCloseFile + AcpiOsReadFile + AcpiOsWriteFile + AcpiOsGetFileOffset + AcpiOsSetFileOffset +There are C library implementations of these functions in the new file +service_layers/oslibcfs.c -- however, the functions can be implemented by +the local host in any way necessary. Lv Zheng. + +Implemented a mechanism to disable/enable ACPI table checksum validation +at runtime. This can be useful when loading tables very early during OS +initialization when it may not be possible to map the entire table in +order to compute the checksum. Lv Zheng. + +Fixed a buffer allocation issue for the Generic Serial Bus support. +Originally, a fixed buffer length was used. This change allows for +variable-length buffers based upon the protocol indicated by the field +access attributes. Reported by Lan Tianyu. Lv Zheng. + +Fixed a problem where an object detached from a namespace node was not +properly terminated/cleared and could cause a circular list problem if +reattached. ACPICA BZ 1063. David Box. + +Fixed a possible recursive lock acquisition in hwregs.c. Rakib Mullick. + +Fixed a possible memory leak in an error return path within the function +AcpiUtCopyIobjectToIobject. ACPICA BZ 1087. Colin Ian King. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 98.7K Code, 27.2K Data, 125.9K Total + Debug Version: 191.7K Code, 79.6K Data, 271.3K Total + Previous Release: + Non-Debug Version: 96.8K Code, 27.2K Data, 124.0K Total + Debug Version: 189.5K Code, 79.7K Data, 269.2K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Add dump of ASCII equivalent text within a comment at the +end of each line of the output for the Buffer() ASL operator. + +AcpiDump: Miscellaneous changes: + Fixed repetitive table dump in -n mode. + For older EFI platforms, use the ACPI 1.0 GUID during RSDP search if +the ACPI 2.0 GUID fails. + +iASL: Fixed a problem where the compiler could fault if incorrectly given +an acpidump output file as input. ACPICA BZ 1088. David Box. + +AcpiExec/AcpiNames: Fixed a problem where these utilities could fault if +they are invoked without any arguments. + +Debugger: Fixed a possible memory leak in an error return path. ACPICA BZ +1086. Colin Ian King. + +Disassembler: Cleaned up a block of code that extracts a parent Op +object. Added a comment that explains that the parent is guaranteed to be +valid in this case. ACPICA BZ 1069. + +---------------------------------------- 24 April 2014. Summary of changes for version 20140424: 1) ACPICA kernel-resident subsystem: diff --git a/generate/unix/acpibin/Makefile b/generate/unix/acpibin/Makefile index c33c085..1be484d 100644 --- a/generate/unix/acpibin/Makefile +++ b/generate/unix/acpibin/Makefile @@ -34,6 +34,7 @@ OBJECTS = \ $(OBJDIR)/utalloc.o\ $(OBJDIR)/utbuffer.o\ $(OBJDIR)/utcache.o\ + $(OBJDIR)/utdebug.o\ $(OBJDIR)/utdecode.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ @@ -41,9 +42,11 @@ OBJECTS = \ $(OBJDIR)/utmath.o\ $(OBJDIR)/utmisc.o\ $(OBJDIR)/utmutex.o\ + $(OBJDIR)/utprint.o\ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/utxferror.o\ + $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o # diff --git a/generate/unix/acpidump/Makefile b/generate/unix/acpidump/Makefile index 8a9cda5..64256ea 100644 --- a/generate/unix/acpidump/Makefile +++ b/generate/unix/acpidump/Makefile @@ -33,13 +33,18 @@ OBJECTS = \ $(OBJDIR)/apmain.o\ $(OBJDIR)/cmfsize.o\ $(OBJDIR)/getopt.o\ + $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixdir.o\ $(OBJDIR)/osunixmap.o\ + $(OBJDIR)/osunixxf.o\ $(OBJDIR)/tbprint.o\ $(OBJDIR)/tbxfroot.o\ $(OBJDIR)/utbuffer.o\ + $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ + $(OBJDIR)/utglobal.o\ $(OBJDIR)/utmath.o\ + $(OBJDIR)/utprint.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/utxferror.o diff --git a/generate/unix/acpiexamples/Makefile b/generate/unix/acpiexamples/Makefile index c2f3c73..4583143 100644 --- a/generate/unix/acpiexamples/Makefile +++ b/generate/unix/acpiexamples/Makefile @@ -20,9 +20,10 @@ PROG = $(OBJDIR)/acpiexamples # vpath %.c \ $(ACPIEXAMPLES)\ - $(ACPICA_DEBUGGER)\ $(ACPICA_DISPATCHER)\ + $(ACPICA_EVENTS)\ $(ACPICA_EXECUTER)\ + $(ACPICA_HARDWARE)\ $(ACPICA_NAMESPACE)\ $(ACPICA_PARSER)\ $(ACPICA_TABLES)\ @@ -51,6 +52,12 @@ OBJECTS = \ $(OBJDIR)/dswload2.o\ $(OBJDIR)/dswscope.o\ $(OBJDIR)/dswstate.o\ + $(OBJDIR)/evhandler.o\ + $(OBJDIR)/evmisc.o\ + $(OBJDIR)/evregion.o\ + $(OBJDIR)/evrgnini.o\ + $(OBJDIR)/evxface.o\ + $(OBJDIR)/evxfregn.o\ $(OBJDIR)/exconfig.o\ $(OBJDIR)/exconvrt.o\ $(OBJDIR)/excreate.o\ @@ -75,8 +82,10 @@ OBJECTS = \ $(OBJDIR)/exstorob.o\ $(OBJDIR)/exsystem.o\ $(OBJDIR)/exutils.o\ + $(OBJDIR)/hwpci.o\ $(OBJDIR)/nsaccess.o\ $(OBJDIR)/nsalloc.o\ + $(OBJDIR)/nsarguments.o\ $(OBJDIR)/nsconvert.o\ $(OBJDIR)/nsdump.o\ $(OBJDIR)/nseval.o\ @@ -85,12 +94,17 @@ OBJECTS = \ $(OBJDIR)/nsnames.o\ $(OBJDIR)/nsobject.o\ $(OBJDIR)/nsparse.o\ + $(OBJDIR)/nspredef.o\ + $(OBJDIR)/nsprepkg.o\ + $(OBJDIR)/nsrepair.o\ + $(OBJDIR)/nsrepair2.o\ $(OBJDIR)/nssearch.o\ $(OBJDIR)/nsutils.o\ $(OBJDIR)/nswalk.o\ $(OBJDIR)/nsxfeval.o\ $(OBJDIR)/nsxfname.o\ $(OBJDIR)/nsxfobj.o\ + $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/psargs.o\ $(OBJDIR)/psloop.o\ @@ -121,8 +135,12 @@ OBJECTS = \ $(OBJDIR)/utdecode.o\ $(OBJDIR)/utdelete.o\ $(OBJDIR)/uterror.o\ + $(OBJDIR)/uteval.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ + $(OBJDIR)/utids.o\ + $(OBJDIR)/utinit.o\ $(OBJDIR)/utlock.o\ $(OBJDIR)/utmath.o\ $(OBJDIR)/utmisc.o\ @@ -130,6 +148,9 @@ OBJECTS = \ $(OBJDIR)/utobject.o\ $(OBJDIR)/utosi.o\ $(OBJDIR)/utownerid.o\ + $(OBJDIR)/utpredef.o\ + $(OBJDIR)/utprint.o\ + $(OBJDIR)/utresrc.o\ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/utxface.o\ diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile index 84cc978..8d7facf 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -45,6 +45,7 @@ OBJECTS = \ $(OBJDIR)/aemain.o\ $(OBJDIR)/aetables.o\ $(OBJDIR)/ahids.o\ + $(OBJDIR)/ahuuids.o\ $(OBJDIR)/cmfsize.o\ $(OBJDIR)/dbcmds.o\ $(OBJDIR)/dbconvert.o\ @@ -155,6 +156,7 @@ OBJECTS = \ $(OBJDIR)/nsxfeval.o\ $(OBJDIR)/nsxfname.o\ $(OBJDIR)/nsxfobj.o\ + $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/psargs.o\ $(OBJDIR)/psloop.o\ @@ -201,7 +203,9 @@ OBJECTS = \ $(OBJDIR)/uterror.o\ $(OBJDIR)/uteval.o\ $(OBJDIR)/utexcep.o\ + $(OBJDIR)/utfileio.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utids.o\ $(OBJDIR)/utinit.o\ $(OBJDIR)/utlock.o\ @@ -212,10 +216,12 @@ OBJECTS = \ $(OBJDIR)/utosi.o\ $(OBJDIR)/utownerid.o\ $(OBJDIR)/utpredef.o\ + $(OBJDIR)/utprint.o\ $(OBJDIR)/utresrc.o\ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/uttrack.o\ + $(OBJDIR)/utuuid.o\ $(OBJDIR)/utxface.o\ $(OBJDIR)/utxferror.o\ $(OBJDIR)/utxfinit.o\ diff --git a/generate/unix/acpihelp/Makefile b/generate/unix/acpihelp/Makefile index da6ee49..ed4ee8a 100644 --- a/generate/unix/acpihelp/Makefile +++ b/generate/unix/acpihelp/Makefile @@ -21,7 +21,8 @@ PROG = $(OBJDIR)/acpihelp vpath %.c \ $(ACPIHELP)\ $(ACPICA_COMMON)\ - $(ACPICA_UTILITIES) + $(ACPICA_UTILITIES)\ + $(ACPICA_OSL) HEADERS = \ $(wildcard $(ACPIHELP)/*.h) @@ -34,9 +35,18 @@ OBJECTS = \ $(OBJDIR)/ahids.o\ $(OBJDIR)/ahpredef.o\ $(OBJDIR)/ahmain.o\ + $(OBJDIR)/ahuuids.o\ $(OBJDIR)/getopt.o\ + $(OBJDIR)/oslibcfs.o\ + $(OBJDIR)/osunixxf.o\ + $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ - $(OBJDIR)/utpredef.o + $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ + $(OBJDIR)/utmath.o\ + $(OBJDIR)/utpredef.o\ + $(OBJDIR)/utprint.o\ + $(OBJDIR)/utuuid.o # # Flags specific to acpihelp diff --git a/generate/unix/acpinames/Makefile b/generate/unix/acpinames/Makefile index 00a0026..743c6c5 100644 --- a/generate/unix/acpinames/Makefile +++ b/generate/unix/acpinames/Makefile @@ -21,7 +21,6 @@ PROG = $(OBJDIR)/acpinames # vpath %.c \ $(ACPINAMES)\ - $(ACPICA_DEBUGGER)\ $(ACPICA_DISPATCHER)\ $(ACPICA_EXECUTER)\ $(ACPICA_NAMESPACE)\ @@ -39,7 +38,6 @@ OBJECTS = \ $(OBJDIR)/anstubs.o\ $(OBJDIR)/antables.o\ $(OBJDIR)/cmfsize.o\ - $(OBJDIR)/dbfileio.o\ $(OBJDIR)/dsfield.o\ $(OBJDIR)/dsmthdat.o\ $(OBJDIR)/dsobject.o\ @@ -49,9 +47,12 @@ OBJECTS = \ $(OBJDIR)/dswscope.o\ $(OBJDIR)/dswstate.o\ $(OBJDIR)/excreate.o\ + $(OBJDIR)/exdump.o\ + $(OBJDIR)/exmutex.o\ $(OBJDIR)/exnames.o\ $(OBJDIR)/exresnte.o\ $(OBJDIR)/exresolv.o\ + $(OBJDIR)/exsystem.o\ $(OBJDIR)/exutils.o\ $(OBJDIR)/getopt.o\ $(OBJDIR)/nsaccess.o\ @@ -68,6 +69,7 @@ OBJECTS = \ $(OBJDIR)/nsxfeval.o\ $(OBJDIR)/nsxfname.o\ $(OBJDIR)/nsxfobj.o\ + $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/psargs.o\ $(OBJDIR)/psloop.o\ @@ -91,13 +93,19 @@ OBJECTS = \ $(OBJDIR)/tbxfroot.o\ $(OBJDIR)/utaddress.o\ $(OBJDIR)/utalloc.o\ + $(OBJDIR)/utbuffer.o\ $(OBJDIR)/utcache.o\ $(OBJDIR)/utdebug.o\ $(OBJDIR)/utdecode.o\ $(OBJDIR)/utdelete.o\ $(OBJDIR)/uterror.o\ + $(OBJDIR)/uteval.o\ $(OBJDIR)/utexcep.o\ + $(OBJDIR)/utfileio.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ + $(OBJDIR)/utids.o\ + $(OBJDIR)/utinit.o\ $(OBJDIR)/utlock.o\ $(OBJDIR)/utmath.o\ $(OBJDIR)/utmisc.o\ @@ -105,6 +113,7 @@ OBJECTS = \ $(OBJDIR)/utobject.o\ $(OBJDIR)/utosi.o\ $(OBJDIR)/utownerid.o\ + $(OBJDIR)/utprint.o\ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/utxface.o\ diff --git a/generate/unix/acpisrc/Makefile b/generate/unix/acpisrc/Makefile index 50199ce..5d40c09 100644 --- a/generate/unix/acpisrc/Makefile +++ b/generate/unix/acpisrc/Makefile @@ -19,6 +19,7 @@ PROG = $(OBJDIR)/acpisrc # vpath %.c \ $(ACPISRC)\ + $(ACPICA_UTILITIES)\ $(ACPICA_COMMON)\ $(ACPICA_OSL) @@ -33,9 +34,17 @@ OBJECTS = \ $(OBJDIR)/asremove.o\ $(OBJDIR)/astable.o\ $(OBJDIR)/asutils.o\ - $(OBJDIR)/cmfsize.o\ + $(OBJDIR)/cmfsize.o\ $(OBJDIR)/getopt.o \ - $(OBJDIR)/osunixdir.o + $(OBJDIR)/oslibcfs.o\ + $(OBJDIR)/osunixdir.o\ + $(OBJDIR)/osunixxf.o\ + $(OBJDIR)/utdebug.o\ + $(OBJDIR)/utexcep.o\ + $(OBJDIR)/utglobal.o\ + $(OBJDIR)/utmath.o\ + $(OBJDIR)/utprint.o\ + $(OBJDIR)/utxferror.o # # Compile flags specific to acpisrc diff --git a/generate/unix/acpixtract/Makefile b/generate/unix/acpixtract/Makefile index 1e5b101..750583e 100644 --- a/generate/unix/acpixtract/Makefile +++ b/generate/unix/acpixtract/Makefile @@ -19,7 +19,9 @@ PROG = $(OBJDIR)/acpixtract # vpath %.c \ $(ACPIXTRACT)\ - $(ACPICA_COMMON) + $(ACPICA_UTILITIES)\ + $(ACPICA_COMMON)\ + $(ACPICA_OSL) HEADERS = \ $(wildcard $(ACPIXTRACT)/*.h) @@ -27,7 +29,15 @@ HEADERS = \ OBJECTS = \ $(OBJDIR)/acpixtract.o\ $(OBJDIR)/axmain.o\ - $(OBJDIR)/getopt.o + $(OBJDIR)/getopt.o\ + $(OBJDIR)/oslibcfs.o\ + $(OBJDIR)/osunixxf.o\ + $(OBJDIR)/utdebug.o\ + $(OBJDIR)/utexcep.o\ + $(OBJDIR)/utglobal.o\ + $(OBJDIR)/utmath.o\ + $(OBJDIR)/utprint.o\ + $(OBJDIR)/utxferror.o # # Flags specific to acpixtract diff --git a/generate/unix/iasl/Makefile b/generate/unix/iasl/Makefile index 8cc8d81..051450c 100644 --- a/generate/unix/iasl/Makefile +++ b/generate/unix/iasl/Makefile @@ -48,6 +48,7 @@ OBJECTS = \ $(OBJDIR)/adwalk.o\ $(OBJDIR)/ahids.o\ $(OBJDIR)/ahpredef.o\ + $(OBJDIR)/ahuuids.o\ $(OBJDIR)/aslanalyze.o\ $(OBJDIR)/aslbtypes.o\ $(OBJDIR)/aslcodegen.o\ @@ -160,6 +161,7 @@ OBJECTS = \ $(OBJDIR)/nswalk.o\ $(OBJDIR)/nsxfobj.o\ $(OBJDIR)/osunixxf.o\ + $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/prexpress.o\ $(OBJDIR)/prmacros.o\ $(OBJDIR)/prscan.o\ @@ -190,7 +192,9 @@ OBJECTS = \ $(OBJDIR)/utdelete.o\ $(OBJDIR)/uterror.o\ $(OBJDIR)/utexcep.o\ + $(OBJDIR)/utfileio.o\ $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ $(OBJDIR)/utinit.o\ $(OBJDIR)/utlock.o\ $(OBJDIR)/utmath.o\ @@ -199,9 +203,11 @@ OBJECTS = \ $(OBJDIR)/utobject.o\ $(OBJDIR)/utownerid.o\ $(OBJDIR)/utpredef.o\ + $(OBJDIR)/utprint.o\ $(OBJDIR)/utresrc.o\ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ + $(OBJDIR)/utuuid.o\ $(OBJDIR)/utxface.o\ $(OBJDIR)/utxferror.o diff --git a/source/common/ahids.c b/source/common/ahids.c index 851393b..13cd100 100644 --- a/source/common/ahids.c +++ b/source/common/ahids.c @@ -174,7 +174,11 @@ const AH_DEVICE_ID AslDeviceIds[] = {"PNP0C60", "Display Sensor Device"}, {"PNP0C70", "Dock Sensor Device"}, {"PNP0C80", "Memory Device"}, - {"PNP0D40", "Standard Compliant SD Host Controller"}, + {"PNP0D10", "XHCI USB Controller with debug"}, + {"PNP0D15", "XHCI USB Controller without debug"}, + {"PNP0D20", "EHCI USB Controller without debug"}, + {"PNP0D25", "EHCI USB Controller with debug"}, + {"PNP0D40", "SDA Standard Compliant SD Host Controller"}, {"PNP0D80", "Windows-compatible System Power Management Controller"}, {"PNP0F03", "Microsoft PS/2-style Mouse"}, {"SMO91D0", "Sensor Hub"}, diff --git a/source/common/ahpredef.c b/source/common/ahpredef.c index bc407b0..893ea1c 100644 --- a/source/common/ahpredef.c +++ b/source/common/ahpredef.c @@ -97,6 +97,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_BTM", "Battery Time", "Returns the battery runtime"), AH_PREDEF ("_BTP", "Battery Trip Point", "Sets a Control Method Battery trip point"), AH_PREDEF ("_CBA", "Configuration Base Address", "Sets the base address for a PCI Express host bridge"), + AH_PREDEF ("_CCA", "Cache Coherency Attribute", "Returns a device's support level for cache coherency"), AH_PREDEF ("_CDM", "Clock Domain", "Returns a logical processor's clock domain identifier"), AH_PREDEF ("_CID", "Compatible ID", "Returns a device's Plug and Play Compatible ID list"), AH_PREDEF ("_CLS", "Class Code", "Returns PCI class code and subclass"), @@ -121,6 +122,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_DOS", "Disable Output Switching", "Sets the display output switching mode"), AH_PREDEF ("_DPL", "Device Selection Polarity", "Polarity of Device Selection signal, Resource Descriptor field"), AH_PREDEF ("_DRS", "Drive Strength", "Drive Strength setting for GPIO connection, Resource Descriptor field"), + AH_PREDEF ("_DSD", "Device-Specific Data", "Returns a list of device property information"), AH_PREDEF ("_DSM", "Device-Specific Method", "Executes device-specific functions"), AH_PREDEF ("_DSS", "Device Set State", "Sets the display device state"), AH_PREDEF ("_DSW", "Device Sleep Wake", "Sets the sleep and wake transition states for a device"), @@ -217,7 +219,6 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_PR3", "Power Resources for D3hot", "Returns a list of dependent power resources to enter state D3hot"), AH_PREDEF ("_PRE", "Power Resources for Enumeration", "Returns a list of dependent power resources to enumerate devices on a bus"), AH_PREDEF ("_PRL", "Power Source Redundancy List", "Returns a list of power source devices in the same redundancy grouping"), - AH_PREDEF ("_PRP", "Device Properties", "Returns a list of device property information"), AH_PREDEF ("_PRS", "Possible Resource Settings", "Returns a list of a device's possible resource settings"), AH_PREDEF ("_PRT", "PCI Routing Table", "Returns a list of PCI interrupt mappings"), AH_PREDEF ("_PRW", "Power Resources for Wake", "Returns a list of dependent power resources for waking"), diff --git a/source/common/ahuuids.c b/source/common/ahuuids.c new file mode 100644 index 0000000..8d0b080 --- /dev/null +++ b/source/common/ahuuids.c @@ -0,0 +1,129 @@ +/****************************************************************************** + * + * Module Name: ahuuids - Table of known ACPI-related UUIDs + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("ahuuids") + +/* + * Table of "known" (ACPI-related) UUIDs + */ +const AH_UUID AcpiUuids[] = +{ + {"PCI Host Bridge Device", + "33db4d5b-1ff7-401c-9657-7441c03dd766"}, + + {"Platform-wide Capabilities", + "0811b06e-4a27-44f9-8d60-3cbbc22e7b48"}, + + {"Dynamic Enumeration", + "d8c1a3a6-be9b-4c9b-91bf-c3cb81fc5daf"}, + + {"GPIO Controller", + "4f248f40-d5e2-499f-834c-27758ea1cd3f"}, + + {"Battery Thermal Limit", + "4c2067e3-887d-475c-9720-4af1d3ed602e"}, + + {"Thermal Extensions", + "14d399cd-7a27-4b18-8fb4-7cb7b9f4e500"}, + + {"USB Controller", + "ce2ee385-00e6-48cb-9f05-2edb927c4899"}, + + {"HID I2C Device", + "3cdff6f7-4267-4555-ad05-b30a3d8938de"}, + + {"Power Button Device", + "dfbcf3c5-e7a5-44e6-9c1f-29c76f6e059c"}, + + {"Device Labeling Interface", + "e5c937d0-3553-4d7a-9117-ea4d19c3434d"}, + + {"SATA Controller", + "e4db149b-fcfe-425b-a6d8-92357d78fc7f"}, + + {"Physical Presence Interface", + "3dddfaa6-361b-4eb4-a424-8d10089d1653"}, + + {NULL, NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiAhMatchUuid + * + * PARAMETERS: Data - Data buffer containing a UUID + * + * RETURN: ASCII description string for the UUID if it is found. + * + * DESCRIPTION: Returns a description string for "known" UUIDs, which are + * are UUIDs that are related to ACPI in some way. + * + ******************************************************************************/ + +const char * +AcpiAhMatchUuid ( + UINT8 *Data) +{ + const AH_UUID *Info; + UINT8 UuidBuffer[UUID_BUFFER_LENGTH]; + + + /* Walk the table of known ACPI-related UUIDs */ + + for (Info = AcpiUuids; Info->Description; Info++) + { + AcpiUtConvertStringToUuid (Info->String, UuidBuffer); + + if (!ACPI_MEMCMP (Data, UuidBuffer, UUID_BUFFER_LENGTH)) + { + return (Info->Description); + } + } + + return (NULL); +} diff --git a/source/common/cmfsize.c b/source/common/cmfsize.c index c8d5a56..904d7d8 100644 --- a/source/common/cmfsize.c +++ b/source/common/cmfsize.c @@ -59,33 +59,34 @@ * RETURN: File Size. On error, -1 (ACPI_UINT32_MAX) * * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open. - * Does not disturb the current file pointer. Uses perror for - * error messages. + * Does not disturb the current file pointer. * ******************************************************************************/ UINT32 CmGetFileSize ( - FILE *File) + ACPI_FILE File) { long FileSize; long CurrentOffset; + ACPI_STATUS Status; /* Save the current file pointer, seek to EOF to obtain file size */ - CurrentOffset = ftell (File); + CurrentOffset = AcpiOsGetFileOffset (File); if (CurrentOffset < 0) { goto OffsetError; } - if (fseek (File, 0, SEEK_END)) + Status = AcpiOsSetFileOffset (File, 0, ACPI_FILE_END); + if (ACPI_FAILURE (Status)) { goto SeekError; } - FileSize = ftell (File); + FileSize = AcpiOsGetFileOffset (File); if (FileSize < 0) { goto OffsetError; @@ -93,7 +94,8 @@ CmGetFileSize ( /* Restore original file pointer */ - if (fseek (File, CurrentOffset, SEEK_SET)) + Status = AcpiOsSetFileOffset (File, CurrentOffset, ACPI_FILE_BEGIN); + if (ACPI_FAILURE (Status)) { goto SeekError; } @@ -102,10 +104,10 @@ CmGetFileSize ( OffsetError: - perror ("Could not get file offset"); + AcpiLogError ("Could not get file offset"); return (ACPI_UINT32_MAX); SeekError: - perror ("Could not seek file"); + AcpiLogError ("Could not set file offset"); return (ACPI_UINT32_MAX); } diff --git a/source/common/dmextern.c b/source/common/dmextern.c index 728207c..37c3a65 100644 --- a/source/common/dmextern.c +++ b/source/common/dmextern.c @@ -406,18 +406,37 @@ AcpiDmGetExternalsFromFile ( while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ExternalRefFile)) { Token = strtok (StringBuffer, METHOD_SEPARATORS); /* "External" */ - if (!Token) continue; - if (strcmp (Token, "External")) continue; + if (!Token) + { + continue; + } + if (strcmp (Token, "External")) + { + continue; + } MethodName = strtok (NULL, METHOD_SEPARATORS); /* Method namepath */ - if (!MethodName) continue; + if (!MethodName) + { + continue; + } Token = strtok (NULL, METHOD_SEPARATORS); /* "MethodObj" */ - if (!Token) continue; - if (strcmp (Token, "MethodObj")) continue; + if (!Token) + { + continue; + } + + if (strcmp (Token, "MethodObj")) + { + continue; + } Token = strtok (NULL, METHOD_SEPARATORS); /* Arg count */ - if (!Token) continue; + if (!Token) + { + continue; + } /* Convert arg count string to an integer */ diff --git a/source/common/dmtable.c b/source/common/dmtable.c index 384f795..e5627d7 100644 --- a/source/common/dmtable.c +++ b/source/common/dmtable.c @@ -87,9 +87,21 @@ static const char *AcpiDmDmarSubnames[] = "Reserved Memory Region", "Root Port ATS Capability", "Remapping Hardware Static Affinity", + "ACPI Namespace Device Declaration", "Unknown SubTable Type" /* Reserved */ }; +static const char *AcpiDmDmarScope[] = +{ + "Reserved value", + "PCI Endpoint Device", + "PCI Bridge Device", + "IOAPIC Device", + "Message-capable HPET Device", + "Namespace Device", + "Unknown Scope Type" /* Reserved */ +}; + static const char *AcpiDmEinjActions[] = { "Begin Operation", @@ -160,6 +172,13 @@ static const char *AcpiDmErstInstructions[] = "Unknown Instruction" }; +static const char *AcpiDmGtdtSubnames[] = +{ + "Generic Timer Block", + "Generic Watchdog Timer", + "Unknown SubTable Type" /* Reserved */ +}; + static const char *AcpiDmHestSubnames[] = { "IA-32 Machine Check Exception", @@ -189,25 +208,28 @@ static const char *AcpiDmHestNotifySubnames[] = static const char *AcpiDmMadtSubnames[] = { - "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */ - "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */ - "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */ - "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */ - "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */ - "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */ - "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ - "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ - "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ - "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ - "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ - "Generic Interrupt Controller", /* ACPI_MADT_GENERIC_INTERRUPT */ - "Generic Interrupt Distributor",/* ACPI_MADT_GENERIC_DISTRIBUTOR */ - "Unknown SubTable Type" /* Reserved */ + "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */ + "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */ + "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */ + "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */ + "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */ + "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */ + "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ + "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ + "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ + "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ + "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ + "Generic Interrupt Controller", /* ACPI_MADT_GENERIC_INTERRUPT */ + "Generic Interrupt Distributor", /* ACPI_MADT_GENERIC_DISTRIBUTOR */ + "Generic MSI Frame", /* ACPI_MADT_GENERIC_MSI_FRAME */ + "Generic Interrupt Redistributor", /* ACPI_MADT_GENERIC_REDISTRIBUTOR */ + "Unknown SubTable Type" /* Reserved */ }; static const char *AcpiDmPcctSubnames[] = { "Generic Communications Subspace", /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */ + "HW-Reduced Communications Subspace", "Unknown SubTable Type" /* Reserved */ }; @@ -306,7 +328,7 @@ ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, DtCompileErst, TemplateErst, "Error Record Serialization Table"}, {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, DtCompileFadt, TemplateFadt, "Fixed ACPI Description Table (FADT)"}, {ACPI_SIG_FPDT, NULL, AcpiDmDumpFpdt, DtCompileFpdt, TemplateFpdt, "Firmware Performance Data Table"}, - {ACPI_SIG_GTDT, AcpiDmTableInfoGtdt, NULL, NULL, TemplateGtdt, "Generic Timer Description Table"}, + {ACPI_SIG_GTDT, NULL, AcpiDmDumpGtdt, DtCompileGtdt, TemplateGtdt, "Generic Timer Description Table"}, {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, DtCompileHest, TemplateHest, "Hardware Error Source Table"}, {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, NULL, TemplateHpet, "High Precision Event Timer table"}, {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, DtCompileIvrs, TemplateIvrs, "I/O Virtualization Reporting Structure"}, @@ -705,6 +727,7 @@ AcpiDmDumpTable ( case ACPI_DMT_SPACEID: case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: + case ACPI_DMT_GTDT: case ACPI_DMT_MADT: case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: @@ -716,6 +739,7 @@ AcpiDmDumpTable ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; @@ -1047,6 +1071,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target), AcpiDmDmarSubnames[Temp16]); break; + case ACPI_DMT_DMAR_SCOPE: + + /* DMAR device scope types */ + + Temp8 = *Target; + if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED) + { + Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmDmarScope[Temp8]); + break; + case ACPI_DMT_EINJACT: /* EINJ Action types */ @@ -1099,6 +1136,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmErstInstructions[Temp8]); break; + case ACPI_DMT_GTDT: + + /* GTDT subtable types */ + + Temp8 = *Target; + if (Temp8 > ACPI_GTDT_TYPE_RESERVED) + { + Temp8 = ACPI_GTDT_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGtdtSubnames[Temp8]); + break; + case ACPI_DMT_HEST: /* HEST subtable types */ diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c index 8d52ce3..72ec095 100644 --- a/source/common/dmtbdump.c +++ b/source/common/dmtbdump.c @@ -891,18 +891,24 @@ AcpiDmDumpDmar ( ScopeOffset = sizeof (ACPI_DMAR_RESERVED_MEMORY); break; - case ACPI_DMAR_TYPE_ATSR: + case ACPI_DMAR_TYPE_ROOT_ATS: InfoTable = AcpiDmTableInfoDmar2; ScopeOffset = sizeof (ACPI_DMAR_ATSR); break; - case ACPI_DMAR_HARDWARE_AFFINITY: + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: InfoTable = AcpiDmTableInfoDmar3; ScopeOffset = sizeof (ACPI_DMAR_RHSA); break; + case ACPI_DMAR_TYPE_NAMESPACE: + + InfoTable = AcpiDmTableInfoDmar4; + ScopeOffset = sizeof (ACPI_DMAR_ANDD); + break; + default: AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n", SubTable->Type); @@ -916,7 +922,16 @@ AcpiDmDumpDmar ( return; } - /* Dump the device scope entries (if any) */ + /* + * Dump the optional device scope entries + */ + if ((SubTable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (SubTable->Type == ACPI_DMAR_TYPE_NAMESPACE)) + { + /* These types do not support device scopes */ + + goto NextSubtable; + } ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, SubTable, ScopeOffset); while (ScopeOffset < SubTable->Length) @@ -956,6 +971,7 @@ AcpiDmDumpDmar ( ScopeTable, ScopeTable->Length); } +NextSubtable: /* Point to next subtable */ Offset += SubTable->Length; @@ -1155,6 +1171,123 @@ NextSubTable: /******************************************************************************* * + * FUNCTION: AcpiDmDumpGtdt + * + * PARAMETERS: Table - A GTDT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a GTDT. This table type consists + * of an open-ended number of subtables. + * + ******************************************************************************/ + +void +AcpiDmDumpGtdt ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + ACPI_GTDT_HEADER *SubTable; + UINT32 Length = Table->Length; + UINT32 Offset = sizeof (ACPI_TABLE_GTDT); + ACPI_DMTABLE_INFO *InfoTable; + UINT32 SubTableLength; + UINT32 GtCount; + ACPI_GTDT_TIMER_ENTRY *GtxTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoGtdt); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Subtables */ + + SubTable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Table, Offset); + while (Offset < Table->Length) + { + /* Common subtable header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Length, AcpiDmTableInfoGtdtHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + GtCount = 0; + switch (SubTable->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + SubTableLength = sizeof (ACPI_GTDT_TIMER_BLOCK); + GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, + SubTable))->TimerCount; + + InfoTable = AcpiDmTableInfoGtdt0; + break; + + case ACPI_GTDT_TYPE_WATCHDOG: + + SubTableLength = sizeof (ACPI_GTDT_WATCHDOG); + + InfoTable = AcpiDmTableInfoGtdt1; + break; + + default: + + /* Cannot continue on unknown type - no length */ + + AcpiOsPrintf ("\n**** Unknown GTDT subtable type 0x%X\n", SubTable->Type); + return; + } + + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Length, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point to end of current subtable (each subtable above is of fixed length) */ + + Offset += SubTableLength; + + /* If there are any Gt Timer Blocks from above, dump them now */ + + if (GtCount) + { + GtxTable = ACPI_ADD_PTR (ACPI_GTDT_TIMER_ENTRY, SubTable, SubTableLength); + SubTableLength += GtCount * sizeof (ACPI_GTDT_TIMER_ENTRY); + + while (GtCount) + { + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, GtxTable, + sizeof (ACPI_GTDT_TIMER_ENTRY), AcpiDmTableInfoGtdt0a); + if (ACPI_FAILURE (Status)) + { + return; + } + Offset += sizeof (ACPI_GTDT_TIMER_ENTRY); + GtxTable++; + GtCount--; + } + } + + /* Point to next subtable */ + + SubTable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, SubTable, SubTableLength); + } +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmDumpHest * * PARAMETERS: Table - A HEST table @@ -1662,6 +1795,16 @@ AcpiDmDumpMadt ( InfoTable = AcpiDmTableInfoMadt12; break; + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + default: AcpiOsPrintf ("\n**** Unknown MADT subtable type 0x%X\n\n", SubTable->Type); @@ -2017,6 +2160,7 @@ AcpiDmDumpPcct ( { ACPI_STATUS Status; ACPI_PCCT_SUBSPACE *SubTable; + ACPI_DMTABLE_INFO *InfoTable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_PCCT); @@ -2044,10 +2188,20 @@ AcpiDmDumpPcct ( return; } - /* ACPI 5.0: Only one type of PCCT subtable is supported */ - - if (SubTable->Header.Type != ACPI_PCCT_TYPE_GENERIC_SUBSPACE) + switch (SubTable->Header.Type) { + case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct0; + break; + + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + + default: + AcpiOsPrintf ( "\n**** Unexpected or unknown PCCT subtable type 0x%X\n\n", SubTable->Header.Type); @@ -2056,7 +2210,7 @@ AcpiDmDumpPcct ( AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Header.Length, AcpiDmTableInfoPcct0); + SubTable->Header.Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -2210,8 +2364,7 @@ AcpiDmDumpPmtt ( if (DomainCount) { AcpiOsPrintf ( - "\n**** DomainCount exceeds subtable length\n\n", - MemSubTable->Type); + "\n**** DomainCount exceeds subtable length\n\n"); } /* Walk the physical component (DIMM) subtables */ diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c index 577dca7..0bfd9e6 100644 --- a/source/common/dmtbinfo.c +++ b/source/common/dmtbinfo.c @@ -137,11 +137,16 @@ #define ACPI_DMAR1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_RESERVED_MEMORY,f) #define ACPI_DMAR2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_ATSR,f) #define ACPI_DMAR3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_RHSA,f) +#define ACPI_DMAR4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_ANDD,f) #define ACPI_EINJ0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_ERST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_FPDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f) #define ACPI_FPDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_BOOT,f) #define ACPI_FPDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_S3PT_PTR,f) +#define ACPI_GTDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_BLOCK,f) +#define ACPI_GTDT0a_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_ENTRY,f) +#define ACPI_GTDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_WATCHDOG,f) +#define ACPI_GTDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_HEADER,f) #define ACPI_HEST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_MACHINE_CHECK,f) #define ACPI_HEST1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_CORRECTED,f) #define ACPI_HEST2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_NMI,f) @@ -174,6 +179,8 @@ #define ACPI_MADT10_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f) #define ACPI_MADT11_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_INTERRUPT,f) #define ACPI_MADT12_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_DISTRIBUTOR,f) +#define ACPI_MADT13_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_MSI_FRAME,f) +#define ACPI_MADT14_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_REDISTRIBUTOR,f) #define ACPI_MADTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SUBTABLE_HEADER,f) #define ACPI_MCFG0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MCFG_ALLOCATION,f) #define ACPI_MPST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MPST_POWER_NODE,f) @@ -184,6 +191,7 @@ #define ACPI_MSCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MSCT_PROXIMITY,f) #define ACPI_MTMR0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MTMR_ENTRY,f) #define ACPI_PCCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_SUBSPACE,f) +#define ACPI_PCCT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_HW_REDUCED,f) #define ACPI_PMTT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_SOCKET,f) #define ACPI_PMTT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_CONTROLLER,f) #define ACPI_PMTT1A_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_DOMAIN,f) @@ -216,6 +224,8 @@ #define ACPI_SRAT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_MEM_AFFINITY,f,o) #define ACPI_SRAT2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f,o) #define ACPI_GTDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_GTDT,f,o) +#define ACPI_GTDT0a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_TIMER_ENTRY,f,o) +#define ACPI_GTDT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_WATCHDOG,f,o) #define ACPI_LPITH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_LPIT_HEADER,f,o) #define ACPI_MADT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_MADT,f,o) #define ACPI_MADT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_APIC,f,o) @@ -227,9 +237,11 @@ #define ACPI_MADT9_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC,f,o) #define ACPI_MADT10_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f,o) #define ACPI_MADT11_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_GENERIC_INTERRUPT,f,o) +#define ACPI_MADT13_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_GENERIC_MSI_FRAME,f,o) #define ACPI_MPST0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MPST_POWER_NODE,f,o) #define ACPI_MPST2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MPST_POWER_DATA,f,o) #define ACPI_PCCT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_PCCT,f,o) +#define ACPI_PCCT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PCCT_HW_REDUCED,f,o) #define ACPI_PMTTH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PMTT_HEADER,f,o) #define ACPI_WDDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_WDDT,f,o) #define ACPI_EINJ0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_WHEA_HEADER,f,o) @@ -440,17 +452,22 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] = { {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, - {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "Reserved", 0}, ACPI_DMT_TERMINATOR }; -/* ACPI 2.0+ Extensions (FADT version 3 and 4) */ +/* ACPI 2.0+ Extensions (FADT version 3, 4, and 5) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = { {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, - {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "ARM Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET(ArmBootFlags,0), "PSCI Compliant", 0}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET(ArmBootFlags,0), "Must use HVC for PSCI", 0}, + ACPI_DMT_NEW_LINE, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "FADT Minor Revision", 0}, {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XFacs), "FACS Address", 0}, {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XDsdt), "DSDT Address", 0}, {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aEventBlock), "PM1A Event Block", 0}, @@ -807,7 +824,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[] = { - {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EntryType), "Device Scope Entry Type", 0}, + {ACPI_DMT_DMAR_SCOPE, ACPI_DMARS_OFFSET (EntryType), "Device Scope Type", 0}, {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (Length), "Entry Length", DT_LENGTH}, {ACPI_DMT_UINT16, ACPI_DMARS_OFFSET (Reserved), "Reserved", 0}, {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EnumerationId), "Enumeration ID", 0}, @@ -859,6 +876,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[] = ACPI_DMT_TERMINATOR }; +/* 4: ACPI Namespace Device Declaration Structure */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoDmar4[] = +{ + {ACPI_DMT_UINT24, ACPI_DMAR4_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_DMAR4_OFFSET (DeviceNumber), "Device Number", 0}, + {ACPI_DMT_STRING, ACPI_DMAR4_OFFSET (DeviceName[0]), "Device Name", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -998,29 +1025,89 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt1[] = ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt[] = { - {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (Address), "Timer Address", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (Flags,0), "Memory Present", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (CounterBlockAddresss), "Counter Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (Reserved), "Reserved", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecurePl1Interrupt), "Secure PL1 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecurePl1Flags), "SPL1 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (SecurePl1Flags,0), "Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (SecurePl1Flags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecureEl1Interrupt), "Secure EL1 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecureEl1Flags), "EL1 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Always On", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl1Interrupt), "Non-Secure PL1 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl1Flags), "NSPL1 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecurePl1Flags,0),"Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecurePl1Flags,0),"Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl1Interrupt), "Non-Secure EL1 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl1Flags), "NEL1 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Always On", 0}, ACPI_DMT_NEW_LINE, {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (VirtualTimerInterrupt), "Virtual Timer Interrupt", 0}, {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (VirtualTimerFlags), "VT Flags (decoded below)", DT_FLAG}, {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Trigger Mode", 0}, {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Always On", 0}, + ACPI_DMT_NEW_LINE, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl2Interrupt), "Non-Secure EL2 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl2Flags), "NEL2 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Always On", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (CounterReadBlockAddress), "Counter Read Block Address", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl2Interrupt), "Non-Secure PL2 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl2Flags), "NSPL2 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecurePl2Flags,0),"Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecurePl2Flags,0),"Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (PlatformTimerCount), "Platform Timer Count", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (PlatformTimerOffset), "Platform Timer Offset", 0}, + ACPI_DMT_TERMINATOR +}; + +/* GTDT Subtable header (one per Subtable) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdtHdr[] = +{ + {ACPI_DMT_GTDT, ACPI_GTDTH_OFFSET (Type), "Subtable Type", 0}, + {ACPI_DMT_UINT16, ACPI_GTDTH_OFFSET (Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR +}; + +/* GTDT Subtables */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0[] = +{ + {ACPI_DMT_UINT8, ACPI_GTDT0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0_OFFSET (BlockAddress), "Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0_OFFSET (TimerCount), "Timer Count", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0_OFFSET (TimerOffset), "Timer Offset", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0a[] = +{ + {ACPI_DMT_UINT8 , ACPI_GTDT0a_OFFSET (FrameNumber), "Frame Number", 0}, + {ACPI_DMT_UINT24, ACPI_GTDT0a_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0a_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0a_OFFSET (El0BaseAddress), "EL0 Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (TimerInterrupt), "Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (TimerFlags), "Timer Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (TimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (TimerFlags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (VirtualTimerInterrupt), "Virtual Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (VirtualTimerFlags), "Virtual Timer Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (VirtualTimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (VirtualTimerFlags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (CommonFlags), "Common Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (CommonFlags,0), "Secure", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (CommonFlags,0), "Always On", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt1[] = +{ + {ACPI_DMT_UINT8, ACPI_GTDT1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT1_OFFSET (RefreshFrameAddress), "Refresh Frame Address", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT1_OFFSET (ControlFrameAddress), "Control Frame Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT1_OFFSET (TimerInterrupt), "Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT1_OFFSET (TimerFlags), "Timer Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Security", 0}, ACPI_DMT_TERMINATOR }; @@ -1527,14 +1614,21 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[] = ACPI_DMTABLE_INFO AcpiDmTableInfoMadt11[] = { {ACPI_DMT_UINT16, ACPI_MADT11_OFFSET (Reserved), "Reserved", 0}, - {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (GicId), "Local GIC Hardware ID", 0}, + {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (CpuInterfaceNumber), "CPU Interface Number", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (Uid), "Processor UID", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, {ACPI_DMT_FLAG0, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Processor Enabled", 0}, + {ACPI_DMT_FLAG1, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Performance Interrupt Trigger Mode", 0}, + {ACPI_DMT_FLAG2, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Virtual GIC Interrupt Trigger Mode", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (ParkingVersion), "Parking Protocol Version", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (PerformanceInterrupt), "Performance Interrupt", 0}, {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (ParkedAddress), "Parked Address", 0}, {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GicvBaseAddress), "Virtual GIC Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GichBaseAddress), "Hypervisor GIC Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (VgicInterrupt), "Virtual GIC Interrupt", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GicrBaseAddress), "Redistributor Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (ArmMpidr), "ARM MPIDR", 0}, ACPI_DMT_TERMINATOR }; @@ -1550,6 +1644,30 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt12[] = ACPI_DMT_TERMINATOR }; +/* 13: Generic MSI Frame (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMadt13[] = +{ + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_MADT13_OFFSET (MsiFrameId), "MSI Frame ID", 0}, + {ACPI_DMT_UINT64, ACPI_MADT13_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT13_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_MADT13_FLAG_OFFSET (Flags,0), "Select SPI", 0}, + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (SpiCount), "SPI Count", 0}, + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (SpiBase), "SPI Base", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 14: Generic Redistributor (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMadt14[] = +{ + {ACPI_DMT_UINT16, ACPI_MADT14_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_MADT14_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT14_OFFSET (Length), "Length", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -1769,6 +1887,26 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[] = ACPI_DMT_TERMINATOR }; +/* 1: HW-reduced Communications Subspace (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[] = +{ + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (DoorbellInterrupt), "Doorbell Interrupt", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT1_OFFSET (Flags), "Flags (Decoded Below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_PCCT1_FLAG_OFFSET (Flags,0), "Polarity", 0}, + {ACPI_DMT_FLAG1, ACPI_PCCT1_FLAG_OFFSET (Flags,0), "Mode", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (Length), "Address Length", 0}, + {ACPI_DMT_GAS, ACPI_PCCT1_OFFSET (DoorbellRegister), "Doorbell Register", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (PreserveMask), "Preserve Mask", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (WriteMask), "Write Mask", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (Latency), "Command Latency", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (MaxAccessRate), "Maximum Access Rate", 0}, + {ACPI_DMT_UINT16, ACPI_PCCT1_OFFSET (MinTurnaroundTime), "Minimum Turnaround Time", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * diff --git a/source/common/getopt.c b/source/common/getopt.c index bca9a6f..5ae1e0a 100644 --- a/source/common/getopt.c +++ b/source/common/getopt.c @@ -51,14 +51,12 @@ * "f|" - Option has required single-char sub-options */ -#include -#include #include "acpi.h" #include "accommon.h" #include "acapps.h" #define ACPI_OPTION_ERROR(msg, badchar) \ - if (AcpiGbl_Opterr) {fprintf (stderr, "%s%c\n", msg, badchar);} + if (AcpiGbl_Opterr) {AcpiLogError ("%s%c\n", msg, badchar);} int AcpiGbl_Opterr = 1; @@ -123,7 +121,7 @@ AcpiGetoptArgument ( * PARAMETERS: argc, argv - from main * opts - options info list * - * RETURN: Option character or EOF + * RETURN: Option character or ACPI_OPT_END * * DESCRIPTION: Get the next option * @@ -145,12 +143,12 @@ AcpiGetopt( argv[AcpiGbl_Optind][0] != '-' || argv[AcpiGbl_Optind][1] == '\0') { - return (EOF); + return (ACPI_OPT_END); } - else if (strcmp (argv[AcpiGbl_Optind], "--") == 0) + else if (ACPI_STRCMP (argv[AcpiGbl_Optind], "--") == 0) { AcpiGbl_Optind++; - return (EOF); + return (ACPI_OPT_END); } } @@ -161,7 +159,7 @@ AcpiGetopt( /* Make sure that the option is legal */ if (CurrentChar == ':' || - (OptsPtr = strchr (opts, CurrentChar)) == NULL) + (OptsPtr = ACPI_STRCHR (opts, CurrentChar)) == NULL) { ACPI_OPTION_ERROR ("Illegal option: -", CurrentChar); diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index 1f94245..10251a8 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -350,10 +350,6 @@ void AeClearErrorLog ( void); -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - /* * asllisting - generate all "listing" type files @@ -899,10 +895,6 @@ void UtDisplaySummary ( UINT32 FileId); -UINT8 -UtHexCharToValue ( - int HexChar); - void UtConvertByteToHex ( UINT8 RawByte, @@ -964,11 +956,6 @@ AuValidateUuid ( char *InString); ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuIdBuffer); - -ACPI_STATUS AuConvertUuidToString ( char *UuIdBuffer, char *OutString); diff --git a/source/compiler/aslcompiler.l b/source/compiler/aslcompiler.l index 286e628..60caa49 100644 --- a/source/compiler/aslcompiler.l +++ b/source/compiler/aslcompiler.l @@ -110,10 +110,10 @@ NamePathTail [.]{NameSeg} [ \t] { count (0); } -"/*" { if (!AslDoComment ()) yyterminate (); } -"//" { if (!AslDoCommentType2 ()) yyterminate (); } +"/*" { if (!AslDoComment ()) {yyterminate ();} } +"//" { if (!AslDoCommentType2 ()) {yyterminate ();} } -"\"" { if (AslDoStringLiteral ()) return (PARSEOP_STRING_LITERAL); else yyterminate (); } +"\"" { if (AslDoStringLiteral ()) {return (PARSEOP_STRING_LITERAL);} else {yyterminate ();} } ";" { count (0); return(';'); } @@ -639,9 +639,9 @@ NamePathTail [.]{NameSeg} AslCompilererror (MsgBuffer);} <> { if (AslPopInputFileStack ()) - yyterminate(); + {yyterminate();} else - return (PARSEOP_INCLUDE_END);}; + {return (PARSEOP_INCLUDE_END);} }; %% diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 9e42a30..636a02c 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -55,7 +55,7 @@ #define ASL_INVOCATION_NAME "iasl" #define ASL_CREATOR_ID "INTL" -#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.0A" +#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.1" /* Configuration constants */ diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index 2707f4d..4896d70 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -63,11 +63,6 @@ #ifdef _DECLARE_GLOBALS UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; -char AslHexLookup[] = -{ - '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' -}; - /* Table below must match ASL_FILE_TYPES in asltypes.h */ @@ -92,7 +87,6 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = #else extern UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; -extern char AslHexLookup[]; extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; #endif diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 6e92d53..3034281 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -341,6 +341,7 @@ main ( return (-1); } + AcpiOsInitialize (); ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Initialize preprocessor and compiler before command line processing */ diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c old mode 100755 new mode 100644 diff --git a/source/compiler/aslmethod.c b/source/compiler/aslmethod.c index 9b0a7a1..a040d92 100644 --- a/source/compiler/aslmethod.c +++ b/source/compiler/aslmethod.c @@ -108,14 +108,14 @@ MtMethodAnalysisWalkBegin ( WalkInfo->MethodStack = MethodInfo; - /* Special handling for _PRP, must have a _HID also */ + /* Special handling for _DSD, must have a _HID also */ - if (!ACPI_STRCMP (METHOD_NAME__PRP, Op->Asl.NameSeg)) + if (!ACPI_STRCMP (METHOD_NAME__DSD, Op->Asl.NameSeg)) { if (!ApFindNameInScope (METHOD_NAME__HID, Op)) { AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, - "_PRP requires _HID in same scope"); + "_DSD requires _HID in same scope"); } } @@ -424,12 +424,12 @@ MtMethodAnalysisWalkBegin ( } } - else if (!ACPI_STRCMP (METHOD_NAME__PRP, Op->Asl.NameSeg)) + else if (!ACPI_STRCMP (METHOD_NAME__DSD, Op->Asl.NameSeg)) { if (!ApFindNameInScope (METHOD_NAME__HID, Op)) { AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, - "_PRP requires _HID in same scope"); + "_DSD requires _HID in same scope"); } } diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index 7c1cd5b..d6f32d2 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -623,10 +623,10 @@ OpcDoEisaId ( (UINT32) ((UINT8) (InString[1] - 0x40)) << 21 | (UINT32) ((UINT8) (InString[2] - 0x40)) << 16 | - (UtHexCharToValue (InString[3])) << 12 | - (UtHexCharToValue (InString[4])) << 8 | - (UtHexCharToValue (InString[5])) << 4 | - UtHexCharToValue (InString[6]); + (AcpiUtAsciiCharToHex (InString[3])) << 12 | + (AcpiUtAsciiCharToHex (InString[4])) << 8 | + (AcpiUtAsciiCharToHex (InString[5])) << 4 | + AcpiUtAsciiCharToHex (InString[6]); /* Swap to little-endian to get final ID (see function header) */ @@ -666,7 +666,7 @@ OpcDoUuId ( ACPI_PARSE_OBJECT *Op) { char *InString; - char *Buffer; + UINT8 *Buffer; ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *NewOp; @@ -681,7 +681,7 @@ OpcDoUuId ( } else { - (void) AuConvertStringToUuid (InString, Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } /* Change Op to a Buffer */ diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 8d52826..039fc7d 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -168,7 +168,7 @@ AslDoOptions ( /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case '@': /* Begin a response file */ diff --git a/source/compiler/aslprepkg.c b/source/compiler/aslprepkg.c index b4f9695..f6fed53 100644 --- a/source/compiler/aslprepkg.c +++ b/source/compiler/aslprepkg.c @@ -289,6 +289,41 @@ ApCheckPackage ( Package, 1, Count); break; + case ACPI_PTYPE2_UUID_PAIR: + + /* The package contains a variable list of UUID Buffer/Package pairs */ + + /* The length of the package must be even */ + + if (Count & 1) + { + sprintf (MsgBuffer, "%4.4s: Package length, %d, must be even.", + Predefined->Info.Name, Count); + + AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, + ParentOp->Asl.Child, MsgBuffer); + } + + /* Validate the alternating types */ + + for (i = 0; i < Count; ++i) + { + if (i & 1) + { + ApCheckObjectType (Predefined->Info.Name, Op, + Package->RetInfo.ObjectType2, i); + } + else + { + ApCheckObjectType (Predefined->Info.Name, Op, + Package->RetInfo.ObjectType1, i); + } + + Op = Op->Asl.Next; + } + + break; + case ACPI_PTYPE2: case ACPI_PTYPE2_FIXED: case ACPI_PTYPE2_MIN: diff --git a/source/compiler/aslstubs.c b/source/compiler/aslstubs.c index 589edb2..6bbb89a 100644 --- a/source/compiler/aslstubs.c +++ b/source/compiler/aslstubs.c @@ -57,13 +57,6 @@ * Things like Events, Global Lock, etc. are not used * by the compiler, so they are stubbed out here. */ -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void) -{ - return (0); -} - void AcpiNsExecModuleCodeList ( void) @@ -232,21 +225,3 @@ AcpiTbFindTable ( { return (AE_SUPPORT); } - -/* OSL interfaces */ - -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - return (1); -} - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - return (AE_SUPPORT); -} diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 7dc0697..b6e6087 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -243,37 +243,6 @@ UtEndEvent ( /******************************************************************************* * - * FUNCTION: UtHexCharToValue - * - * PARAMETERS: HexChar - Hex character in Ascii - * - * RETURN: The binary value of the hex character - * - * DESCRIPTION: Perform ascii-to-hex translation - * - ******************************************************************************/ - -UINT8 -UtHexCharToValue ( - int HexChar) -{ - - if (HexChar <= 0x39) - { - return ((UINT8) (HexChar - 0x30)); - } - - if (HexChar <= 0x46) - { - return ((UINT8) (HexChar - 0x37)); - } - - return ((UINT8) (HexChar - 0x57)); -} - - -/******************************************************************************* - * * FUNCTION: UtConvertByteToHex * * PARAMETERS: RawByte - Binary data @@ -296,8 +265,8 @@ UtConvertByteToHex ( Buffer[0] = '0'; Buffer[1] = 'x'; - Buffer[2] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; - Buffer[3] = (UINT8) AslHexLookup[RawByte & 0xF]; + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); } @@ -312,7 +281,7 @@ UtConvertByteToHex ( * RETURN: Ascii hex byte is stored in Buffer. * * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed - * with "0x" + * with '0', and a trailing 'h' is added. * ******************************************************************************/ @@ -323,8 +292,8 @@ UtConvertByteToAsmHex ( { Buffer[0] = '0'; - Buffer[1] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; - Buffer[2] = (UINT8) AslHexLookup[RawByte & 0xF]; + Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); Buffer[3] = 'h'; } diff --git a/source/compiler/asluuid.c b/source/compiler/asluuid.c index f7b1f0c..f79a33b 100644 --- a/source/compiler/asluuid.c +++ b/source/compiler/asluuid.c @@ -41,42 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asluuid") -/* - * UUID support functions. - * - * This table is used to convert an input UUID ascii string to a 16 byte - * buffer and the reverse. The table maps a UUID buffer index 0-15 to - * the index within the 36-byte UUID string where the associated 2-byte - * hex value can be found. - * - * 36-byte UUID strings are of the form: - * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp - * Where aa-pp are one byte hex numbers, made up of two hex digits - * - * Note: This table is basically the inverse of the string-to-offset table - * found in the ACPI spec in the description of the ToUUID macro. - */ -static UINT8 Gbl_MapToUuidOffset[16] = -{ - 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 -}; - -#define UUID_BUFFER_LENGTH 16 -#define UUID_STRING_LENGTH 36 - -/* Positions for required hyphens (dashes) in UUID strings */ - -#define UUID_HYPHEN1_OFFSET 8 -#define UUID_HYPHEN2_OFFSET 13 -#define UUID_HYPHEN3_OFFSET 18 -#define UUID_HYPHEN4_OFFSET 23 +extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; /******************************************************************************* @@ -137,42 +108,6 @@ AuValidateUuid ( /******************************************************************************* * - * FUNCTION: AuConvertStringToUuid - * - * PARAMETERS: InString - 36-byte formatted UUID string - * UuidBuffer - 16-byte UUID buffer - * - * RETURN: Status - * - * DESCRIPTION: Convert 36-byte formatted UUID string to 16-byte UUID buffer - * - ******************************************************************************/ - -ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuidBuffer) -{ - UINT32 i; - - - if (!InString || !UuidBuffer) - { - return (AE_BAD_PARAMETER); - } - - for (i = 0; i < UUID_BUFFER_LENGTH; i++) - { - UuidBuffer[i] = (char) (UtHexCharToValue (InString[Gbl_MapToUuidOffset[i]]) << 4); - UuidBuffer[i] |= (char) UtHexCharToValue (InString[Gbl_MapToUuidOffset[i] + 1]); - } - - return (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AuConvertUuidToString * * PARAMETERS: UuidBuffer - 16-byte UUID buffer @@ -200,8 +135,11 @@ AuConvertUuidToString ( for (i = 0; i < UUID_BUFFER_LENGTH; i++) { - OutString[Gbl_MapToUuidOffset[i]] = (UINT8) AslHexLookup[(UuidBuffer[i] >> 4) & 0xF]; - OutString[Gbl_MapToUuidOffset[i] + 1] = (UINT8) AslHexLookup[UuidBuffer[i] & 0xF]; + OutString[AcpiGbl_MapToUuidOffset[i]] = + AcpiUtHexToAsciiChar (UuidBuffer[i], 4); + + OutString[AcpiGbl_MapToUuidOffset[i] + 1] = + AcpiUtHexToAsciiChar (UuidBuffer[i], 0); } /* Insert required hyphens (dashes) */ diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index db5d306..cec699c 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -420,6 +420,10 @@ DtCompileFpdt ( void **PFieldList); ACPI_STATUS +DtCompileGtdt ( + void **PFieldList); + +ACPI_STATUS DtCompileHest ( void **PFieldList); diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c index ff77242..98c8779 100644 --- a/source/compiler/dtfield.c +++ b/source/compiler/dtfield.c @@ -259,7 +259,7 @@ DtCompileUuid ( } else { - Status = AuConvertStringToUuid (InString, (char *) Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } return (Status); diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index c341bf2..78a459f 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -736,16 +736,21 @@ DtCompileDmar ( InfoTable = AcpiDmTableInfoDmar1; break; - case ACPI_DMAR_TYPE_ATSR: + case ACPI_DMAR_TYPE_ROOT_ATS: InfoTable = AcpiDmTableInfoDmar2; break; - case ACPI_DMAR_HARDWARE_AFFINITY: + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: InfoTable = AcpiDmTableInfoDmar3; break; + case ACPI_DMAR_TYPE_NAMESPACE: + + InfoTable = AcpiDmTableInfoDmar4; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR"); @@ -762,10 +767,20 @@ DtCompileDmar ( ParentTable = DtPeekSubtable (); DtInsertSubtable (ParentTable, Subtable); - DtPushSubtable (Subtable); - /* Optional Device Scope subtables */ + /* + * Optional Device Scope subtables + */ + if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE)) + { + /* These types do not support device scopes */ + DtPopSubtable (); + continue; + } + + DtPushSubtable (Subtable); DeviceScopeLength = DmarHeader->Length - Subtable->Length - ParentTable->Length; while (DeviceScopeLength) @@ -938,6 +953,125 @@ DtCompileFadt ( return (AE_OK); } +/****************************************************************************** + * + * FUNCTION: DtCompileGtdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile GTDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileGtdt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *GtdtHeader; + ACPI_DMTABLE_INFO *InfoTable; + UINT32 GtCount; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + GtdtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + InfoTable = AcpiDmTableInfoGtdt0; + break; + + case ACPI_GTDT_TYPE_WATCHDOG: + + InfoTable = AcpiDmTableInfoGtdt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "GTDT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Additional GT block subtable data + */ + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, + Subtable->Buffer - sizeof(ACPI_GTDT_HEADER)))->TimerCount; + while (GtCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + + DtInsertSubtable (ParentTable, Subtable); + GtCount--; + } + DtPopSubtable (); + break; + + default: + + break; + } + + DtPopSubtable (); + } + + return (AE_OK); +} + /****************************************************************************** * @@ -1501,6 +1635,16 @@ DtCompileMadt ( InfoTable = AcpiDmTableInfoMadt12; break; + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); @@ -1792,6 +1936,11 @@ DtCompilePcct ( InfoTable = AcpiDmTableInfoPcct0; break; + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index 4c8ba08..67515ea 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -395,7 +395,7 @@ const unsigned char TemplateFadt[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 00000070 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00, /* 00000080 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x02, /* 00000090 "..... .." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ @@ -434,16 +434,34 @@ const unsigned char TemplateFpdt[] = const unsigned char TemplateGtdt[] = { - 0x47,0x54,0x44,0x54,0x50,0x00,0x00,0x00, /* 00000000 "GTDTP..." */ - 0x01,0xF1,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x06,0x11,0x20,0x00,0x00,0x00,0x00, /* 00000020 "#.. ...." */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000028 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000048 "........" */ + 0x47,0x54,0x44,0x54,0xe0,0x00,0x00,0x00, /* 00000000 "GTDT...." */ + 0x02,0xb0,0x4c,0x49,0x4e,0x41,0x52,0x4f, /* 00000008 "..LINARO" */ + 0x52,0x54,0x53,0x4d,0x56,0x45,0x56,0x38, /* 00000010 "RTSMVEV8" */ + 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */ + 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x1d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */ + 0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000040 "........" */ + 0x1a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x02,0x00,0x00,0x00,0x60,0x00,0x00,0x00, /* 00000058 "....`..." */ + 0x00,0x64,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 ".d......" */ + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, /* 00000068 "........" */ + 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000a8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000b0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000b8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x1c,0x00,0x00, /* 000000c0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000d8 "........" */ }; const unsigned char TemplateHest[] = @@ -575,41 +593,48 @@ const unsigned char TemplateLpit[] = 0x00,0x00,0x00,0x00 /* 000000B0 "...." */ }; -/* MADT with ACPI 5.0 subtables */ +/* MADT with ACPI 5.1 subtables */ const unsigned char TemplateMadt[] = { - 0x41,0x50,0x49,0x43,0xF6,0x00,0x00,0x00, /* 00000000 "APIC...." */ - 0x01,0xB0,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x06,0x11,0x20,0x00,0x00,0x00,0x00, /* 00000020 "#.. ...." */ + 0x41,0x50,0x49,0x43,0x2a,0x01,0x00,0x00, /* 00000000 "APIC*..." */ + 0x04,0x34,0x49,0x4e,0x54,0x45,0x4c,0x20, /* 00000008 ".4INTEL " */ + 0x54,0x45,0x4d,0x50,0x4c,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */ + 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */ 0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x00, /* 00000028 "........" */ - 0x01,0x00,0x00,0x00,0x01,0x0C,0x01,0x00, /* 00000030 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x0c,0x01,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x00,0x00,0x03,0x08,0x0D,0x00,0x01,0x00, /* 00000048 "........" */ + 0x02,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x03,0x08,0x0d,0x00,0x01,0x00, /* 00000048 "........" */ 0x00,0x00,0x04,0x06,0x00,0x05,0x00,0x01, /* 00000050 "........" */ - 0x05,0x0C,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x05,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ 0x00,0x00,0x00,0x00,0x06,0x10,0x00,0x00, /* 00000060 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00, /* 00000070 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000078 "........" */ - 0x00,0x00,0x00,0x00,0x5C,0x43,0x50,0x55, /* 00000080 "....\CPU" */ + 0x00,0x00,0x00,0x00,0x5c,0x43,0x50,0x55, /* 00000080 "....\CPU" */ 0x30,0x00,0x08,0x10,0x05,0x00,0x00,0x00, /* 00000088 "0......." */ 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00, /* 00000090 "........" */ 0x00,0x00,0x09,0x10,0x00,0x00,0x00,0x00, /* 00000098 "........" */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ - 0x00,0x00,0x0A,0x0C,0x05,0x00,0x00,0x00, /* 000000A8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x28, /* 000000B0 ".......(" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18, /* 000000D8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00 /* 000000F0 "......" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */ + 0x00,0x00,0x0a,0x0c,0x05,0x00,0x00,0x00, /* 000000a8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x4c, /* 000000b0 ".......L" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000b8 "........" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000c0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f8 "........" */ + 0x00,0x00,0x0e,0x10,0x00,0x00,0x00,0x00, /* 00000100 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */ + 0x00,0x00,0x0c,0x18,0x00,0x00,0x00,0x00, /* 00000110 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */ + 0x00,0x00 /* 00000128 ".. " */ }; const unsigned char TemplateMcfg[] = @@ -703,27 +728,27 @@ const unsigned char TemplateMtmr[] = const unsigned char TemplatePcct[] = { 0x50,0x43,0x43,0x54,0xAC,0x00,0x00,0x00, /* 00000000 "PCCT...." */ - 0x01,0x97,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0xCF,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x27,0x06,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "'.. ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 ".>......" */ - 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, /* 00000038 "........" */ - 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, /* 00000040 """""""""" */ - 0x01,0x32,0x00,0x03,0x33,0x33,0x33,0x33, /* 00000048 ".2..3333" */ - 0x33,0x33,0x33,0x33,0x44,0x44,0x44,0x44, /* 00000050 "3333DDDD" */ - 0x44,0x44,0x44,0x44,0x55,0x55,0x55,0x55, /* 00000058 "DDDDUUUU" */ - 0x55,0x55,0x55,0x55,0x66,0x66,0x66,0x66, /* 00000060 "UUUUffff" */ - 0x77,0x77,0x77,0x77,0x88,0x88,0x00,0x3E, /* 00000068 "wwww...>" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF, /* 00000070 "........" */ - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEE,0xEE, /* 00000078 "........" */ - 0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0x01,0x32, /* 00000080 ".......2" */ - 0x00,0x03,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD, /* 00000088 "........" */ - 0xDD,0xDD,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC, /* 00000090 "........" */ - 0xCC,0xCC,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB, /* 00000098 "........" */ - 0xBB,0xBB,0xAA,0xAA,0xAA,0xAA,0x99,0x99, /* 000000A0 "........" */ - 0x99,0x99,0x88,0x88 /* 000000A8 "...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x01,0x32,0x00,0x03,0x00,0x00,0x00,0x00, /* 00000048 ".2......" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, /* 00000058 "........" */ + 0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00, /* 00000060 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x3E, /* 00000068 ".......>" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x32, /* 00000080 ".......2" */ + 0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000098 "........" */ + 0xFF,0xFF,0x01,0x00,0x00,0x00,0x01,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x01,0x00 /* 000000A8 "...." */ }; const unsigned char TemplatePmtt[] = diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index 281bfb3..9cfd314 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -501,6 +501,7 @@ DtGetFieldLength ( case ACPI_DMT_SPACEID: case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: + case ACPI_DMT_GTDT: case ACPI_DMT_MADT: case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: @@ -512,6 +513,7 @@ DtGetFieldLength ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; diff --git a/source/components/debugger/dbfileio.c b/source/components/debugger/dbfileio.c index a09c1de..ee4ba15 100644 --- a/source/components/debugger/dbfileio.c +++ b/source/components/debugger/dbfileio.c @@ -46,14 +46,7 @@ #include "acpi.h" #include "accommon.h" #include "acdebug.h" - -#ifdef ACPI_APPLICATION #include "actables.h" -#endif - -#ifdef ACPI_ASL_COMPILER -#include "aslcompiler.h" -#endif #if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER) @@ -62,18 +55,6 @@ #ifdef ACPI_DEBUGGER -/* Local prototypes */ - -#ifdef ACPI_APPLICATION - -static ACPI_STATUS -AcpiDbCheckTextModeCorruption ( - UINT8 *Table, - UINT32 TableLength, - UINT32 FileLength); - -#endif - /******************************************************************************* * * FUNCTION: AcpiDbCloseDebugFile @@ -146,245 +127,6 @@ AcpiDbOpenDebugFile ( /******************************************************************************* * - * FUNCTION: AcpiDbCheckTextModeCorruption - * - * PARAMETERS: Table - Table buffer - * TableLength - Length of table from the table header - * FileLength - Length of the file that contains the table - * - * RETURN: Status - * - * DESCRIPTION: Check table for text mode file corruption where all linefeed - * characters (LF) have been replaced by carriage return linefeed - * pairs (CR/LF). - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbCheckTextModeCorruption ( - UINT8 *Table, - UINT32 TableLength, - UINT32 FileLength) -{ - UINT32 i; - UINT32 Pairs = 0; - - - if (TableLength != FileLength) - { - ACPI_WARNING ((AE_INFO, - "File length (0x%X) is not the same as the table length (0x%X)", - FileLength, TableLength)); - } - - /* Scan entire table to determine if each LF has been prefixed with a CR */ - - for (i = 1; i < FileLength; i++) - { - if (Table[i] == 0x0A) - { - if (Table[i - 1] != 0x0D) - { - /* The LF does not have a preceding CR, table not corrupted */ - - return (AE_OK); - } - else - { - /* Found a CR/LF pair */ - - Pairs++; - } - i++; - } - } - - if (!Pairs) - { - return (AE_OK); - } - - /* - * Entire table scanned, each CR is part of a CR/LF pair -- - * meaning that the table was treated as a text file somewhere. - * - * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the - * original table are left untouched by the text conversion process -- - * meaning that we cannot simply replace CR/LF pairs with LFs. - */ - AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); - AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs); - AcpiOsPrintf ("Table cannot be repaired!\n"); - return (AE_BAD_VALUE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbReadTable - * - * PARAMETERS: fp - File that contains table - * Table - Return value, buffer with table - * TableLength - Return value, length of table - * - * RETURN: Status - * - * DESCRIPTION: Load the DSDT from the file pointer - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbReadTable ( - FILE *fp, - ACPI_TABLE_HEADER **Table, - UINT32 *TableLength) -{ - ACPI_TABLE_HEADER TableHeader; - UINT32 Actual; - ACPI_STATUS Status; - UINT32 FileSize; - BOOLEAN StandardHeader = TRUE; - - - /* Get the file size */ - - FileSize = CmGetFileSize (fp); - if (FileSize == ACPI_UINT32_MAX) - { - return (AE_ERROR); - } - - if (FileSize < 4) - { - return (AE_BAD_HEADER); - } - - /* Read the signature */ - - if (fread (&TableHeader, 1, 4, fp) != 4) - { - AcpiOsPrintf ("Could not read the table signature\n"); - return (AE_BAD_HEADER); - } - - fseek (fp, 0, SEEK_SET); - - /* The RSDP table does not have standard ACPI header */ - - if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD ")) - { - *TableLength = FileSize; - StandardHeader = FALSE; - } - else - { - /* Read the table header */ - - if (fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), fp) != - sizeof (ACPI_TABLE_HEADER)) - { - AcpiOsPrintf ("Could not read the table header\n"); - return (AE_BAD_HEADER); - } - -#if 0 - /* Validate the table header/length */ - - Status = AcpiTbValidateTableHeader (&TableHeader); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Table header is invalid!\n"); - return (Status); - } -#endif - - /* File size must be at least as long as the Header-specified length */ - - if (TableHeader.Length > FileSize) - { - AcpiOsPrintf ( - "TableHeader length [0x%X] greater than the input file size [0x%X]\n", - TableHeader.Length, FileSize); - -#ifdef ACPI_ASL_COMPILER - Status = FlCheckForAscii (fp, NULL, FALSE); - if (ACPI_SUCCESS (Status)) - { - AcpiOsPrintf ("File appears to be ASCII only, must be binary\n", - TableHeader.Length, FileSize); - } -#endif - return (AE_BAD_HEADER); - } - -#ifdef ACPI_OBSOLETE_CODE - /* We only support a limited number of table types */ - - if (!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_DSDT) && - !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_PSDT) && - !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_SSDT)) - { - AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", - (char *) TableHeader.Signature); - ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); - return (AE_ERROR); - } -#endif - - *TableLength = TableHeader.Length; - } - - /* Allocate a buffer for the table */ - - *Table = AcpiOsAllocate ((size_t) FileSize); - if (!*Table) - { - AcpiOsPrintf ( - "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", - TableHeader.Signature, *TableLength); - return (AE_NO_MEMORY); - } - - /* Get the rest of the table */ - - fseek (fp, 0, SEEK_SET); - Actual = fread (*Table, 1, (size_t) FileSize, fp); - if (Actual == FileSize) - { - if (StandardHeader) - { - /* Now validate the checksum */ - - Status = AcpiTbVerifyChecksum ((void *) *Table, - ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length); - - if (Status == AE_BAD_CHECKSUM) - { - Status = AcpiDbCheckTextModeCorruption ((UINT8 *) *Table, - FileSize, (*Table)->Length); - return (Status); - } - } - return (AE_OK); - } - - if (Actual > 0) - { - AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", - FileSize, Actual); - return (AE_OK); - } - - AcpiOsPrintf ("Error - could not read the table file\n"); - AcpiOsFree (*Table); - *Table = NULL; - *TableLength = 0; - return (AE_ERROR); -} - - -/******************************************************************************* - * * FUNCTION: AeLocalLoadTable * * PARAMETERS: Table - pointer to a buffer containing the entire @@ -456,62 +198,6 @@ AeLocalLoadTable ( return_ACPI_STATUS (Status); } - - -/******************************************************************************* - * - * FUNCTION: AcpiDbReadTableFromFile - * - * PARAMETERS: Filename - File where table is located - * Table - Where a pointer to the table is returned - * - * RETURN: Status - * - * DESCRIPTION: Get an ACPI table from a file - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDbReadTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **Table) -{ - FILE *File; - UINT32 FileSize; - UINT32 TableLength; - ACPI_STATUS Status = AE_ERROR; - - - /* Open the file, get current size */ - - File = fopen (Filename, "rb"); - if (!File) - { - perror ("Could not open input file"); - return (Status); - } - - FileSize = CmGetFileSize (File); - if (FileSize == ACPI_UINT32_MAX) - { - goto Exit; - } - - /* Get the entire file */ - - fprintf (stderr, "Loading Acpi table from file %10s - Length %.8u (%06X)\n", - Filename, FileSize, FileSize); - - Status = AcpiDbReadTable (File, Table, &TableLength); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not get table from the file\n"); - } - -Exit: - fclose(File); - return (Status); - } #endif @@ -539,7 +225,7 @@ AcpiDbGetTableFromFile ( BOOLEAN IsAmlTable = TRUE; - Status = AcpiDbReadTableFromFile (Filename, &Table); + Status = AcpiUtReadTableFromFile (Filename, &Table); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/source/components/debugger/dbtest.c b/source/components/debugger/dbtest.c index d88372b..33ee4e4 100644 --- a/source/components/debugger/dbtest.c +++ b/source/components/debugger/dbtest.c @@ -1042,6 +1042,7 @@ AcpiDbEvaluateOnePredefinedName ( Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo); if (ACPI_FAILURE (Status)) { + ACPI_FREE (Pathname); return (Status); } diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c index 85f0618..2231ce1 100644 --- a/source/components/disassembler/dmbuffer.c +++ b/source/components/disassembler/dmbuffer.c @@ -41,9 +41,9 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "acpi.h" #include "accommon.h" +#include "acutils.h" #include "acdisasm.h" #include "acparser.h" #include "amlcode.h" @@ -58,6 +58,10 @@ /* Local prototypes */ static void +AcpiDmUuid ( + ACPI_PARSE_OBJECT *Op); + +static void AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op); @@ -72,6 +76,9 @@ AcpiDmPldBuffer ( UINT32 ByteCount); +#define ACPI_BUFFER_BYTES_PER_LINE 8 + + /******************************************************************************* * * FUNCTION: AcpiDmDisasmByteList @@ -94,6 +101,9 @@ AcpiDmDisasmByteList ( UINT32 ByteCount) { UINT32 i; + UINT32 j; + UINT32 CurrentIndex; + UINT8 BufChar; if (!ByteCount) @@ -101,39 +111,68 @@ AcpiDmDisasmByteList ( return; } - /* Dump the byte list */ - - for (i = 0; i < ByteCount; i++) + for (i = 0; i < ByteCount; i += ACPI_BUFFER_BYTES_PER_LINE) { - /* New line every 8 bytes */ + /* Line indent and offset prefix for each new line */ - if (((i % 8) == 0) && (i < ByteCount)) + AcpiDmIndent (Level); + if (ByteCount > ACPI_BUFFER_BYTES_PER_LINE) { - if (i > 0) + AcpiOsPrintf ("/* %04X */ ", i); + } + + /* Dump the actual hex values */ + + for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++) + { + CurrentIndex = i + j; + if (CurrentIndex >= ByteCount) { - AcpiOsPrintf ("\n"); + /* Dump fill spaces */ + + AcpiOsPrintf (" "); + continue; } - AcpiDmIndent (Level); - if (ByteCount > 8) + AcpiOsPrintf (" 0x%2.2X", ByteData[CurrentIndex]); + + /* Add comma if there are more bytes to display */ + + if (CurrentIndex < (ByteCount - 1)) { - AcpiOsPrintf ("/* %04X */ ", i); + AcpiOsPrintf (","); + } + else + { + AcpiOsPrintf (" "); } } - AcpiOsPrintf (" 0x%2.2X", (UINT32) ByteData[i]); + /* Dump the ASCII equivalents within a comment */ - /* Add comma if there are more bytes to display */ - - if (i < (ByteCount -1)) + AcpiOsPrintf (" /* "); + for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++) { - AcpiOsPrintf (","); + CurrentIndex = i + j; + if (CurrentIndex >= ByteCount) + { + break; + } + + BufChar = ByteData[CurrentIndex]; + if (ACPI_IS_PRINT (BufChar)) + { + AcpiOsPrintf ("%c", BufChar); + } + else + { + AcpiOsPrintf ("."); + } } - } - if (Level) - { - AcpiOsPrintf ("\n"); + /* Finished with this line */ + + AcpiOsPrintf (" */\n"); } } @@ -182,6 +221,11 @@ AcpiDmByteList ( AcpiOsPrintf ("\n"); break; + case ACPI_DASM_UUID: + + AcpiDmUuid (Op); + break; + case ACPI_DASM_UNICODE: AcpiDmUnicode (Op); @@ -207,6 +251,137 @@ AcpiDmByteList ( /******************************************************************************* * + * FUNCTION: AcpiDmIsUuidBuffer + * + * PARAMETERS: Op - Buffer Object to be examined + * + * RETURN: TRUE if buffer contains a UUID + * + * DESCRIPTION: Determine if a buffer Op contains a UUID + * + * To help determine whether the buffer is a UUID versus a raw data buffer, + * there a are a couple bytes we can look at: + * + * xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx + * + * The variant covered by the UUID specification is indicated by the two most + * significant bits of N being 1 0 (i.e., the hexadecimal N will always be + * 8, 9, A, or B). + * + * The variant covered by the UUID specification has five versions. For this + * variant, the four bits of M indicates the UUID version (i.e., the + * hexadecimal M will be either 1, 2, 3, 4, or 5). + * + ******************************************************************************/ + +BOOLEAN +AcpiDmIsUuidBuffer ( + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *ByteData; + UINT32 ByteCount; + ACPI_PARSE_OBJECT *SizeOp; + ACPI_PARSE_OBJECT *NextOp; + + + /* Buffer size is the buffer argument */ + + SizeOp = Op->Common.Value.Arg; + + /* Next, the initializer byte list to examine */ + + NextOp = SizeOp->Common.Next; + if (!NextOp) + { + return (FALSE); + } + + /* Extract the byte list info */ + + ByteData = NextOp->Named.Data; + ByteCount = (UINT32) NextOp->Common.Value.Integer; + + /* Byte count must be exactly 16 */ + + if (ByteCount != UUID_BUFFER_LENGTH) + { + return (FALSE); + } + + /* Check for valid "M" and "N" values (see function header above) */ + + if (((ByteData[7] & 0xF0) == 0x00) || /* M={1,2,3,4,5} */ + ((ByteData[7] & 0xF0) > 0x50) || + ((ByteData[8] & 0xF0) < 0x80) || /* N={8,9,A,B} */ + ((ByteData[8] & 0xF0) > 0xB0)) + { + return (FALSE); + } + + /* Ignore the Size argument in the disassembly of this buffer op */ + + SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmUuid + * + * PARAMETERS: Op - Byte List op containing a UUID + * + * RETURN: None + * + * DESCRIPTION: Dump a buffer containing a UUID as a standard ASCII string. + * + * Output Format: + * In its canonical form, the UUID is represented by a string containing 32 + * lowercase hexadecimal digits, displayed in 5 groups separated by hyphens. + * The complete form is 8-4-4-4-12 for a total of 36 characters (32 + * alphanumeric characters representing hex digits and 4 hyphens). In bytes, + * 4-2-2-2-6. Example: + * + * ToUUID ("107ededd-d381-4fd7-8da9-08e9a6c79644") + * + ******************************************************************************/ + +static void +AcpiDmUuid ( + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *Data; + const char *Description; + + + Data = ACPI_CAST_PTR (UINT8, Op->Named.Data); + + /* Emit the 36-byte UUID string in the proper format/order */ + + AcpiOsPrintf ( + "\"%2.2x%2.2x%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\")", + Data[3], Data[2], Data[1], Data[0], + Data[5], Data[4], + Data[7], Data[6], + Data[8], Data[9], + Data[10], Data[11], Data[12], Data[13], Data[14], Data[15]); + + /* Dump the UUID description string if available */ + + Description = AcpiAhMatchUuid (Data); + if (Description) + { + AcpiOsPrintf (" /* %s */", Description); + } +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmIsUnicodeBuffer * * PARAMETERS: Op - Buffer Object to be examined diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 30f985c..52e01a9 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -827,7 +827,12 @@ AcpiDmDisassembleOneOp ( } } - if (AcpiDmIsUnicodeBuffer (Op)) + if (AcpiDmIsUuidBuffer (Op)) + { + Op->Common.DisasmOpcode = ACPI_DASM_UUID; + AcpiOsPrintf ("ToUUID ("); + } + else if (AcpiDmIsUnicodeBuffer (Op)) { Op->Common.DisasmOpcode = ACPI_DASM_UNICODE; AcpiOsPrintf ("Unicode ("); diff --git a/source/components/disassembler/dmwalk.c b/source/components/disassembler/dmwalk.c index 3cf74b3..2da52ea 100644 --- a/source/components/disassembler/dmwalk.c +++ b/source/components/disassembler/dmwalk.c @@ -285,7 +285,8 @@ AcpiDmBlockType ( case AML_BUFFER_OP: - if (Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) + if ((Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) || + (Op->Common.DisasmOpcode == ACPI_DASM_UUID)) { return (BLOCK_NONE); } @@ -958,6 +959,13 @@ AcpiDmAscendingOp ( } /* + * The parent Op is guaranteed to be valid because of the flag + * ACPI_PARSEOP_PARAMLIST -- which means that this op is part of + * a parameter list and thus has a valid parent. + */ + ParentOp = Op->Common.Parent; + + /* * Just completed a parameter node for something like "Buffer (param)". * Close the paren and open up the term list block with a brace */ @@ -965,25 +973,24 @@ AcpiDmAscendingOp ( { AcpiOsPrintf (")"); - /* Emit description comment for Name() with a predefined ACPI name */ - - ParentOp = Op->Common.Parent; - if (ParentOp) + /* + * Emit a description comment for a Name() operator that is a + * predefined ACPI name. Must check the grandparent. + */ + ParentOp = ParentOp->Common.Parent; + if (ParentOp && + (ParentOp->Asl.AmlOpcode == AML_NAME_OP)) { - ParentOp = ParentOp->Common.Parent; - if (ParentOp && ParentOp->Asl.AmlOpcode == AML_NAME_OP) - { - AcpiDmPredefinedDescription (ParentOp); - } + AcpiDmPredefinedDescription (ParentOp); } + AcpiOsPrintf ("\n"); AcpiDmIndent (Level - 1); AcpiOsPrintf ("{\n"); } else { - Op->Common.Parent->Common.DisasmFlags |= - ACPI_PARSEOP_EMPTY_TERMLIST; + ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST; AcpiOsPrintf (") {"); } } diff --git a/source/components/events/evgpe.c b/source/components/events/evgpe.c index c31f0b3..9394025 100644 --- a/source/components/events/evgpe.c +++ b/source/components/events/evgpe.c @@ -761,22 +761,6 @@ AcpiEvGpeDispatch ( } /* - * If edge-triggered, clear the GPE status bit now. Note that - * level-triggered events are cleared after the GPE is serviced. - */ - if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == - ACPI_GPE_EDGE_TRIGGERED) - { - Status = AcpiHwClearGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to clear GPE %02X", GpeNumber)); - return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); - } - } - - /* * Always disable the GPE so that it does not keep firing before * any asynchronous activity completes (either from the execution * of a GPE method or an asynchronous GPE handler.) @@ -794,6 +778,24 @@ AcpiEvGpeDispatch ( } /* + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced. + */ + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_EDGE_TRIGGERED) + { + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to clear GPE %02X", GpeNumber)); + (void) AcpiHwLowSetGpe (GpeEventInfo, + ACPI_GPE_CONDITIONAL_ENABLE); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + } + + /* * Dispatch the GPE to either an installed handler or the control * method associated with this GPE (_Lxx or _Exx). If a handler * exists, we invoke it and do not attempt to run the method. diff --git a/source/components/events/evxfgpe.c b/source/components/events/evxfgpe.c index 73164e1..9e7436a 100644 --- a/source/components/events/evxfgpe.c +++ b/source/components/events/evxfgpe.c @@ -141,12 +141,23 @@ AcpiEnableGpe ( Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - /* Ensure that we have a valid GPE number */ - + /* + * Ensure that we have a valid GPE number and that there is some way + * of handling the GPE (handler or a GPE method). In other words, we + * won't allow a valid GPE to be enabled if there is no way to handle it. + */ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); if (GpeEventInfo) { - Status = AcpiEvAddGpeReference (GpeEventInfo); + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_NONE) + { + Status = AcpiEvAddGpeReference (GpeEventInfo); + } + else + { + Status = AE_NO_HANDLER; + } } AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); @@ -276,6 +287,60 @@ ACPI_EXPORT_SYMBOL (AcpiSetGpe) /******************************************************************************* * + * FUNCTION: AcpiMarkGpeForWake + * + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block + * + * RETURN: Status + * + * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply + * sets the ACPI_GPE_CAN_WAKE flag. + * + * Some potential callers of AcpiSetupGpeForWake may know in advance that + * there won't be any notify handlers installed for device wake notifications + * from the given GPE (one example is a button GPE in Linux). For these cases, + * AcpiMarkGpeForWake should be used instead of AcpiSetupGpeForWake. + * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to + * setup implicit wake notification for it (since there's no handler method). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiMarkGpeForWake ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_STATUS Status = AE_BAD_PARAMETER; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiMarkGpeForWake); + + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (GpeEventInfo) + { + /* Mark the GPE as a possible wake event */ + + GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE; + Status = AE_OK; + } + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiMarkGpeForWake) + + +/******************************************************************************* + * * FUNCTION: AcpiSetupGpeForWake * * PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW) diff --git a/source/components/executer/exdebug.c b/source/components/executer/exdebug.c index df61b79..9223e4b 100644 --- a/source/components/executer/exdebug.c +++ b/source/components/executer/exdebug.c @@ -82,6 +82,7 @@ AcpiExDoDebugObject ( UINT32 Index) { UINT32 i; + UINT32 Timer; ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); @@ -96,12 +97,20 @@ AcpiExDoDebugObject ( } /* + * We will emit the current timer value (in microseconds) with each + * debug output. Only need the lower 26 bits. This allows for 67 + * million microseconds or 67 seconds before rollover. + */ + Timer = (UINT32) (AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */ + Timer &= 0x03FFFFFF; + + /* * Print line header as long as we are not in the middle of an * object display */ if (!((Level > 0) && Index == 0)) { - AcpiOsPrintf ("[ACPI Debug] %*s", Level, " "); + AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " "); } /* Display the index for package output only */ diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c index 815e337..6e7de67 100644 --- a/source/components/executer/exdump.c +++ b/source/components/executer/exdump.c @@ -508,7 +508,7 @@ AcpiExDumpObject ( } } - AcpiOsPrintf ("\n", Next); + AcpiOsPrintf ("\n"); break; case ACPI_EXD_HDLR_LIST: @@ -542,7 +542,7 @@ AcpiExDumpObject ( } } - AcpiOsPrintf ("\n", Next); + AcpiOsPrintf ("\n"); break; case ACPI_EXD_RGN_LIST: @@ -576,7 +576,7 @@ AcpiExDumpObject ( } } - AcpiOsPrintf ("\n", Next); + AcpiOsPrintf ("\n"); break; case ACPI_EXD_NODE: diff --git a/source/components/executer/exfield.c b/source/components/executer/exfield.c index aedc8d9..479eee7 100644 --- a/source/components/executer/exfield.c +++ b/source/components/executer/exfield.c @@ -48,11 +48,80 @@ #include "accommon.h" #include "acdispat.h" #include "acinterp.h" +#include "amlcode.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exfield") +/* Local prototypes */ + +static UINT32 +AcpiExGetSerialAccessLength ( + UINT32 AccessorType, + UINT32 AccessLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetSerialAccessLength + * + * PARAMETERS: AccessorType - The type of the protocol indicated by region + * field access attributes + * AccessLength - The access length of the region field + * + * RETURN: Decoded access length + * + * DESCRIPTION: This routine returns the length of the GenericSerialBus + * protocol bytes + * + ******************************************************************************/ + +static UINT32 +AcpiExGetSerialAccessLength ( + UINT32 AccessorType, + UINT32 AccessLength) +{ + UINT32 Length; + + + switch (AccessorType) + { + case AML_FIELD_ATTRIB_QUICK: + + Length = 0; + break; + + case AML_FIELD_ATTRIB_SEND_RCV: + case AML_FIELD_ATTRIB_BYTE: + + Length = 1; + break; + + case AML_FIELD_ATTRIB_WORD: + case AML_FIELD_ATTRIB_WORD_CALL: + + Length = 2; + break; + + case AML_FIELD_ATTRIB_MULTIBYTE: + case AML_FIELD_ATTRIB_RAW_BYTES: + case AML_FIELD_ATTRIB_RAW_PROCESS: + + Length = AccessLength; + break; + + case AML_FIELD_ATTRIB_BLOCK: + case AML_FIELD_ATTRIB_BLOCK_CALL: + default: + + Length = ACPI_GSBUS_BUFFER_SIZE - 2; + break; + } + + return (Length); +} + /******************************************************************************* * @@ -80,6 +149,7 @@ AcpiExReadDataFromField ( ACPI_SIZE Length; void *Buffer; UINT32 Function; + UINT16 AccessorType; ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); @@ -129,8 +199,19 @@ AcpiExReadDataFromField ( } else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) { - Length = ACPI_GSBUS_BUFFER_SIZE; - Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); + AccessorType = ObjDesc->Field.Attribute; + Length = AcpiExGetSerialAccessLength (AccessorType, + ObjDesc->Field.AccessLength); + + /* + * Add additional 2 bytes for the GenericSerialBus data buffer: + * + * Status; (Byte 0 of the data buffer) + * Length; (Byte 1 of the data buffer) + * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) + */ + Length += 2; + Function = ACPI_READ | (AccessorType << 16); } else /* IPMI */ { @@ -251,6 +332,7 @@ AcpiExWriteDataToField ( void *Buffer; ACPI_OPERAND_OBJECT *BufferDesc; UINT32 Function; + UINT16 AccessorType; ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); @@ -310,8 +392,19 @@ AcpiExWriteDataToField ( } else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) { - Length = ACPI_GSBUS_BUFFER_SIZE; - Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); + AccessorType = ObjDesc->Field.Attribute; + Length = AcpiExGetSerialAccessLength (AccessorType, + ObjDesc->Field.AccessLength); + + /* + * Add additional 2 bytes for the GenericSerialBus data buffer: + * + * Status; (Byte 0 of the data buffer) + * Length; (Byte 1 of the data buffer) + * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) + */ + Length += 2; + Function = ACPI_WRITE | (AccessorType << 16); } else /* IPMI */ { diff --git a/source/components/hardware/hwregs.c b/source/components/hardware/hwregs.c index a24fc5c..94c508a 100644 --- a/source/components/hardware/hwregs.c +++ b/source/components/hardware/hwregs.c @@ -310,17 +310,19 @@ AcpiHwClearAcpiStatus ( Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, ACPI_BITMASK_ALL_FIXED_STATUS); + + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + if (ACPI_FAILURE (Status)) { - goto UnlockAndExit; + goto Exit; } /* Clear the GPE Bits in all GPE registers in all GPE blocks */ Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); -UnlockAndExit: - AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); +Exit: return_ACPI_STATUS (Status); } diff --git a/source/components/namespace/nsobject.c b/source/components/namespace/nsobject.c index 3317591..7550fed 100644 --- a/source/components/namespace/nsobject.c +++ b/source/components/namespace/nsobject.c @@ -263,6 +263,16 @@ AcpiNsDetachObject ( { Node->Object = Node->Object->Common.NextObject; } + + /* + * Detach the object from any data objects (which are still held by + * the namespace node) + */ + if (ObjDesc->Common.NextObject && + ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + ObjDesc->Common.NextObject = NULL; + } } /* Reset the node type to untyped */ diff --git a/source/components/tables/tbdata.c b/source/components/tables/tbdata.c index 549c555..e0c5f3a 100644 --- a/source/components/tables/tbdata.c +++ b/source/components/tables/tbdata.c @@ -352,7 +352,43 @@ AcpiTbInvalidateTable ( /****************************************************************************** * - * FUNCTION: AcpiTbVerifyTable + * FUNCTION: AcpiTbValidateTempTable + * + * PARAMETERS: TableDesc - Table descriptor + * + * RETURN: Status + * + * DESCRIPTION: This function is called to validate the table, the returned + * table descriptor is in "VALIDATED" state. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbValidateTempTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + if (!TableDesc->Pointer && !AcpiGbl_VerifyTableChecksum) + { + /* + * Only validates the header of the table. + * Note that Length contains the size of the mapping after invoking + * this work around, this value is required by + * AcpiTbReleaseTempTable(). + * We can do this because in AcpiInitTableDescriptor(), the Length + * field of the installed descriptor is filled with the actual + * table length obtaining from the table header. + */ + TableDesc->Length = sizeof (ACPI_TABLE_HEADER); + } + + return (AcpiTbValidateTable (TableDesc)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbVerifyTempTable * * PARAMETERS: TableDesc - Table descriptor * Signature - Table signature to verify @@ -365,19 +401,19 @@ AcpiTbInvalidateTable ( *****************************************************************************/ ACPI_STATUS -AcpiTbVerifyTable ( +AcpiTbVerifyTempTable ( ACPI_TABLE_DESC *TableDesc, char *Signature) { ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE (TbVerifyTable); + ACPI_FUNCTION_TRACE (TbVerifyTempTable); /* Validate the table */ - Status = AcpiTbValidateTable (TableDesc); + Status = AcpiTbValidateTempTable (TableDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -397,16 +433,19 @@ AcpiTbVerifyTable ( /* Verify the checksum */ - Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); - if (ACPI_FAILURE (Status)) + if (AcpiGbl_VerifyTableChecksum) { - ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, - "%4.4s " ACPI_PRINTF_UINT - " Attempted table install failed", - AcpiUtValidAcpiName (TableDesc->Signature.Ascii) ? - TableDesc->Signature.Ascii : "????", - ACPI_FORMAT_TO_UINT (TableDesc->Address))); - goto InvalidateAndExit; + Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, + "%4.4s " ACPI_PRINTF_UINT + " Attempted table install failed", + AcpiUtValidAcpiName (TableDesc->Signature.Ascii) ? + TableDesc->Signature.Ascii : "????", + ACPI_FORMAT_TO_UINT (TableDesc->Address))); + goto InvalidateAndExit; + } } return_ACPI_STATUS (AE_OK); diff --git a/source/components/tables/tbinstal.c b/source/components/tables/tbinstal.c index 9dcaa91..791979c 100644 --- a/source/components/tables/tbinstal.c +++ b/source/components/tables/tbinstal.c @@ -210,7 +210,7 @@ AcpiTbInstallFixedTable ( /* Validate and verify a table before installation */ - Status = AcpiTbVerifyTable (&NewTableDesc, Signature); + Status = AcpiTbVerifyTempTable (&NewTableDesc, Signature); if (ACPI_FAILURE (Status)) { goto ReleaseAndExit; @@ -290,7 +290,7 @@ AcpiTbInstallStandardTable ( /* Validate and verify a table before installation */ - Status = AcpiTbVerifyTable (&NewTableDesc, NULL); + Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL); if (ACPI_FAILURE (Status)) { goto ReleaseAndExit; @@ -455,7 +455,7 @@ FinishOverride: /* Validate and verify a table before overriding */ - Status = AcpiTbVerifyTable (&NewTableDesc, NULL); + Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL); if (ACPI_FAILURE (Status)) { return; @@ -477,7 +477,7 @@ FinishOverride: */ AcpiTbInitTableDescriptor (OldTableDesc, NewTableDesc.Address, NewTableDesc.Flags, NewTableDesc.Pointer); - AcpiTbValidateTable (OldTableDesc); + AcpiTbValidateTempTable (OldTableDesc); /* Release the temporary table descriptor */ diff --git a/source/components/tables/tbutils.c b/source/components/tables/tbutils.c index 4b207d9..56fd46d 100644 --- a/source/components/tables/tbutils.c +++ b/source/components/tables/tbutils.c @@ -427,10 +427,6 @@ NextTable: TableEntry += TableEntrySize; } - /* - * It is not possible to map more than one entry in some environments, - * so unmap the root table here before mapping other tables - */ AcpiOsUnmapMemory (Table, Length); return_ACPI_STATUS (AE_OK); diff --git a/source/components/utilities/utbuffer.c b/source/components/utilities/utbuffer.c index 6b110f5..a946aab 100644 --- a/source/components/utilities/utbuffer.c +++ b/source/components/utilities/utbuffer.c @@ -218,3 +218,138 @@ AcpiUtDebugDumpBuffer ( AcpiUtDumpBuffer (Buffer, Count, Display, 0); } + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBufferToFile + * + * PARAMETERS: File - File descriptor + * Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display: + * DB_BYTE_DISPLAY + * DB_WORD_DISPLAY + * DB_DWORD_DISPLAY + * DB_QWORD_DISPLAY + * BaseOffset - Beginning buffer offset (display only) + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii to a file. + * + ******************************************************************************/ + +void +AcpiUtDumpBufferToFile ( + ACPI_FILE File, + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 BaseOffset) +{ + UINT32 i = 0; + UINT32 j; + UINT32 Temp32; + UINT8 BufChar; + + + if (!Buffer) + { + AcpiUtFilePrintf (File, "Null Buffer Pointer in DumpBuffer!\n"); + return; + } + + if ((Count < 4) || (Count & 0x01)) + { + Display = DB_BYTE_DISPLAY; + } + + /* Nasty little dump buffer routine! */ + + while (i < Count) + { + /* Print current offset */ + + AcpiUtFilePrintf (File, "%6.4X: ", (BaseOffset + i)); + + /* Print 16 hex chars */ + + for (j = 0; j < 16;) + { + if (i + j >= Count) + { + /* Dump fill spaces */ + + AcpiUtFilePrintf (File, "%*s", ((Display * 2) + 1), " "); + j += Display; + continue; + } + + switch (Display) + { + case DB_BYTE_DISPLAY: + default: /* Default is BYTE display */ + + AcpiUtFilePrintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]); + break; + + case DB_WORD_DISPLAY: + + ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiUtFilePrintf (File, "%04X ", Temp32); + break; + + case DB_DWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiUtFilePrintf (File, "%08X ", Temp32); + break; + + case DB_QWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiUtFilePrintf (File, "%08X", Temp32); + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]); + AcpiUtFilePrintf (File, "%08X ", Temp32); + break; + } + + j += Display; + } + + /* + * Print the ASCII equivalent characters but watch out for the bad + * unprintable ones (printable chars are 0x20 through 0x7E) + */ + AcpiUtFilePrintf (File, " "); + for (j = 0; j < 16; j++) + { + if (i + j >= Count) + { + AcpiUtFilePrintf (File, "\n"); + return; + } + + BufChar = Buffer[(ACPI_SIZE) i + j]; + if (ACPI_IS_PRINT (BufChar)) + { + AcpiUtFilePrintf (File, "%c", BufChar); + } + else + { + AcpiUtFilePrintf (File, "."); + } + } + + /* Done with that line. */ + + AcpiUtFilePrintf (File, "\n"); + i += 16; + } + + return; +} +#endif diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c index 09fe7ad..d7faee9 100644 --- a/source/components/utilities/utclib.c +++ b/source/components/utilities/utclib.c @@ -308,8 +308,6 @@ AcpiUtStrcmp ( } -#ifdef ACPI_FUTURE_IMPLEMENTATION -/* Not used at this time */ /******************************************************************************* * * FUNCTION: AcpiUtStrchr (strchr) @@ -340,7 +338,7 @@ AcpiUtStrchr ( return (NULL); } -#endif + /******************************************************************************* * diff --git a/source/components/utilities/utcopy.c b/source/components/utilities/utcopy.c index 26eb878..6ab8709 100644 --- a/source/components/utilities/utcopy.c +++ b/source/components/utilities/utcopy.c @@ -1063,5 +1063,12 @@ AcpiUtCopyIobjectToIobject ( Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); } + /* Delete the allocated object if copy failed */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference(*DestDesc); + } + return_ACPI_STATUS (Status); } diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c index 4a25fb2..973d4ec 100644 --- a/source/components/utilities/utdebug.c +++ b/source/components/utilities/utdebug.c @@ -636,3 +636,33 @@ AcpiUtPtrExit ( } #endif + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiLogError + * + * PARAMETERS: Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print error message to the console, used by applications. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiLogError ( + const char *Format, + ...) +{ + va_list Args; + + va_start (Args, Format); + (void) AcpiUtFileVprintf (ACPI_FILE_ERR, Format, Args); + va_end (Args); +} + +ACPI_EXPORT_SYMBOL (AcpiLogError) +#endif diff --git a/source/components/utilities/utdecode.c b/source/components/utilities/utdecode.c index 28617dd..1666a36 100644 --- a/source/components/utilities/utdecode.c +++ b/source/components/utilities/utdecode.c @@ -93,38 +93,6 @@ const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = /******************************************************************************* * - * FUNCTION: AcpiUtHexToAsciiChar - * - * PARAMETERS: Integer - Contains the hex digit - * Position - bit position of the digit within the - * integer (multiple of 4) - * - * RETURN: The converted Ascii character - * - * DESCRIPTION: Convert a hex digit to an Ascii character - * - ******************************************************************************/ - -/* Hex to ASCII conversion table */ - -static const char AcpiGbl_HexToAscii[] = -{ - '0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F' -}; - -char -AcpiUtHexToAsciiChar ( - UINT64 Integer, - UINT32 Position) -{ - - return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); -} - - -/******************************************************************************* - * * FUNCTION: AcpiUtGetRegionName * * PARAMETERS: Space ID - ID for the region @@ -541,7 +509,8 @@ static const char *AcpiGbl_GenericNotify[ACPI_NOTIFY_MAX + 1] = /* 09 */ "Device PLD Check", /* 0A */ "Reserved", /* 0B */ "System Locality Update", - /* 0C */ "Shutdown Request" + /* 0C */ "Shutdown Request", + /* 0D */ "System Resource Affinity Update" }; static const char *AcpiGbl_DeviceNotify[4] = @@ -575,7 +544,7 @@ AcpiUtGetNotifyName ( ACPI_OBJECT_TYPE Type) { - /* 00 - 0C are common to all object types */ + /* 00 - 0D are common to all object types */ if (NotifyValue <= ACPI_NOTIFY_MAX) { diff --git a/source/components/utilities/utfileio.c b/source/components/utilities/utfileio.c new file mode 100644 index 0000000..c6b66ae --- /dev/null +++ b/source/components/utilities/utfileio.c @@ -0,0 +1,362 @@ +/******************************************************************************* + * + * Module Name: utfileio - simple file I/O routines + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" +#include "acapps.h" + +#ifdef ACPI_ASL_COMPILER +#include "aslcompiler.h" +#endif + + +#define _COMPONENT ACPI_CA_DEBUGGER + ACPI_MODULE_NAME ("utfileio") + + +#ifdef ACPI_APPLICATION + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCheckTextModeCorruption ( + UINT8 *Table, + UINT32 TableLength, + UINT32 FileLength); + +static ACPI_STATUS +AcpiUtReadTable ( + FILE *fp, + ACPI_TABLE_HEADER **Table, + UINT32 *TableLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCheckTextModeCorruption + * + * PARAMETERS: Table - Table buffer + * TableLength - Length of table from the table header + * FileLength - Length of the file that contains the table + * + * RETURN: Status + * + * DESCRIPTION: Check table for text mode file corruption where all linefeed + * characters (LF) have been replaced by carriage return linefeed + * pairs (CR/LF). + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCheckTextModeCorruption ( + UINT8 *Table, + UINT32 TableLength, + UINT32 FileLength) +{ + UINT32 i; + UINT32 Pairs = 0; + + + if (TableLength != FileLength) + { + ACPI_WARNING ((AE_INFO, + "File length (0x%X) is not the same as the table length (0x%X)", + FileLength, TableLength)); + } + + /* Scan entire table to determine if each LF has been prefixed with a CR */ + + for (i = 1; i < FileLength; i++) + { + if (Table[i] == 0x0A) + { + if (Table[i - 1] != 0x0D) + { + /* The LF does not have a preceding CR, table not corrupted */ + + return (AE_OK); + } + else + { + /* Found a CR/LF pair */ + + Pairs++; + } + i++; + } + } + + if (!Pairs) + { + return (AE_OK); + } + + /* + * Entire table scanned, each CR is part of a CR/LF pair -- + * meaning that the table was treated as a text file somewhere. + * + * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the + * original table are left untouched by the text conversion process -- + * meaning that we cannot simply replace CR/LF pairs with LFs. + */ + AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); + AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs); + AcpiOsPrintf ("Table cannot be repaired!\n"); + return (AE_BAD_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReadTable + * + * PARAMETERS: fp - File that contains table + * Table - Return value, buffer with table + * TableLength - Return value, length of table + * + * RETURN: Status + * + * DESCRIPTION: Load the DSDT from the file pointer + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtReadTable ( + FILE *fp, + ACPI_TABLE_HEADER **Table, + UINT32 *TableLength) +{ + ACPI_TABLE_HEADER TableHeader; + UINT32 Actual; + ACPI_STATUS Status; + UINT32 FileSize; + BOOLEAN StandardHeader = TRUE; + INT32 Count; + + /* Get the file size */ + + FileSize = CmGetFileSize (fp); + if (FileSize == ACPI_UINT32_MAX) + { + return (AE_ERROR); + } + + if (FileSize < 4) + { + return (AE_BAD_HEADER); + } + + /* Read the signature */ + + fseek (fp, 0, SEEK_SET); + + Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), fp); + if (Count != sizeof (ACPI_TABLE_HEADER)) + { + AcpiOsPrintf ("Could not read the table header\n"); + return (AE_BAD_HEADER); + } + + /* The RSDP table does not have standard ACPI header */ + + if (ACPI_VALIDATE_RSDP_SIG (TableHeader.Signature)) + { + *TableLength = FileSize; + StandardHeader = FALSE; + } + else + { + +#if 0 + /* Validate the table header/length */ + + Status = AcpiTbValidateTableHeader (&TableHeader); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Table header is invalid!\n"); + return (Status); + } +#endif + + /* File size must be at least as long as the Header-specified length */ + + if (TableHeader.Length > FileSize) + { + AcpiOsPrintf ( + "TableHeader length [0x%X] greater than the input file size [0x%X]\n", + TableHeader.Length, FileSize); + +#ifdef ACPI_ASL_COMPILER + Status = FlCheckForAscii (fp, NULL, FALSE); + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf ("File appears to be ASCII only, must be binary\n"); + } +#endif + return (AE_BAD_HEADER); + } + +#ifdef ACPI_OBSOLETE_CODE + /* We only support a limited number of table types */ + + if (!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_PSDT) && + !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_SSDT)) + { + AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", + (char *) TableHeader.Signature); + ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_ERROR); + } +#endif + + *TableLength = TableHeader.Length; + } + + /* Allocate a buffer for the table */ + + *Table = AcpiOsAllocate ((size_t) FileSize); + if (!*Table) + { + AcpiOsPrintf ( + "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", + TableHeader.Signature, *TableLength); + return (AE_NO_MEMORY); + } + + /* Get the rest of the table */ + + fseek (fp, 0, SEEK_SET); + Actual = fread (*Table, 1, (size_t) FileSize, fp); + if (Actual == FileSize) + { + if (StandardHeader) + { + /* Now validate the checksum */ + + Status = AcpiTbVerifyChecksum ((void *) *Table, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length); + + if (Status == AE_BAD_CHECKSUM) + { + Status = AcpiUtCheckTextModeCorruption ((UINT8 *) *Table, + FileSize, (*Table)->Length); + return (Status); + } + } + return (AE_OK); + } + + if (Actual > 0) + { + AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", + FileSize, Actual); + return (AE_OK); + } + + AcpiOsPrintf ("Error - could not read the table file\n"); + AcpiOsFree (*Table); + *Table = NULL; + *TableLength = 0; + return (AE_ERROR); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReadTableFromFile + * + * PARAMETERS: Filename - File where table is located + * Table - Where a pointer to the table is returned + * + * RETURN: Status + * + * DESCRIPTION: Get an ACPI table from a file + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtReadTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table) +{ + FILE *File; + UINT32 FileSize; + UINT32 TableLength; + ACPI_STATUS Status = AE_ERROR; + + + /* Open the file, get current size */ + + File = fopen (Filename, "rb"); + if (!File) + { + perror ("Could not open input file"); + return (Status); + } + + FileSize = CmGetFileSize (File); + if (FileSize == ACPI_UINT32_MAX) + { + goto Exit; + } + + /* Get the entire file */ + + fprintf (stderr, "Loading Acpi table from file %10s - Length %.8u (%06X)\n", + Filename, FileSize, FileSize); + + Status = AcpiUtReadTable (File, Table, &TableLength); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not get table from the file\n"); + } + +Exit: + fclose(File); + return (Status); +} + +#endif diff --git a/source/components/utilities/utglobal.c b/source/components/utilities/utglobal.c index c89d414..3504348 100644 --- a/source/components/utilities/utglobal.c +++ b/source/components/utilities/utglobal.c @@ -173,163 +173,6 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = }; #endif /* !ACPI_REDUCED_HARDWARE */ - -/******************************************************************************* - * - * FUNCTION: AcpiUtInitGlobals - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize ACPICA globals. All globals that require specific - * initialization should be initialized here. This allows for - * a warm restart. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtInitGlobals ( - void) -{ - ACPI_STATUS Status; - UINT32 i; - - - ACPI_FUNCTION_TRACE (UtInitGlobals); - - - /* Create all memory caches */ - - Status = AcpiUtCreateCaches (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Address Range lists */ - - for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) - { - AcpiGbl_AddressRangeList[i] = NULL; - } - - /* Mutex locked flags */ - - for (i = 0; i < ACPI_NUM_MUTEX; i++) - { - AcpiGbl_MutexInfo[i].Mutex = NULL; - AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; - AcpiGbl_MutexInfo[i].UseCount = 0; - } - - for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) - { - AcpiGbl_OwnerIdMask[i] = 0; - } - - /* Last OwnerID is never valid */ - - AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; - - /* Event counters */ - - AcpiMethodCount = 0; - AcpiSciCount = 0; - AcpiGpeCount = 0; - - for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) - { - AcpiFixedEventCount[i] = 0; - } - -#if (!ACPI_REDUCED_HARDWARE) - - /* GPE/SCI support */ - - AcpiGbl_AllGpesInitialized = FALSE; - AcpiGbl_GpeXruptListHead = NULL; - AcpiGbl_GpeFadtBlocks[0] = NULL; - AcpiGbl_GpeFadtBlocks[1] = NULL; - AcpiCurrentGpeCount = 0; - - AcpiGbl_GlobalEventHandler = NULL; - AcpiGbl_SciHandlerList = NULL; - -#endif /* !ACPI_REDUCED_HARDWARE */ - - /* Global handlers */ - - AcpiGbl_GlobalNotify[0].Handler = NULL; - AcpiGbl_GlobalNotify[1].Handler = NULL; - AcpiGbl_ExceptionHandler = NULL; - AcpiGbl_InitHandler = NULL; - AcpiGbl_TableHandler = NULL; - AcpiGbl_InterfaceHandler = NULL; - - /* Global Lock support */ - - AcpiGbl_GlobalLockSemaphore = NULL; - AcpiGbl_GlobalLockMutex = NULL; - AcpiGbl_GlobalLockAcquired = FALSE; - AcpiGbl_GlobalLockHandle = 0; - AcpiGbl_GlobalLockPresent = FALSE; - - /* Miscellaneous variables */ - - AcpiGbl_DSDT = NULL; - AcpiGbl_CmSingleStep = FALSE; - AcpiGbl_Shutdown = FALSE; - AcpiGbl_NsLookupCount = 0; - AcpiGbl_PsFindCount = 0; - AcpiGbl_AcpiHardwarePresent = TRUE; - AcpiGbl_LastOwnerIdIndex = 0; - AcpiGbl_NextOwnerIdOffset = 0; - AcpiGbl_TraceDbgLevel = 0; - AcpiGbl_TraceDbgLayer = 0; - AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; - AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; - AcpiGbl_OsiMutex = NULL; - AcpiGbl_RegMethodsExecuted = FALSE; - - /* Hardware oriented */ - - AcpiGbl_EventsInitialized = FALSE; - AcpiGbl_SystemAwakeAndRunning = TRUE; - - /* Namespace */ - - AcpiGbl_ModuleCodeList = NULL; - AcpiGbl_RootNode = NULL; - AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; - AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; - AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; - AcpiGbl_RootNodeStruct.Parent = NULL; - AcpiGbl_RootNodeStruct.Child = NULL; - AcpiGbl_RootNodeStruct.Peer = NULL; - AcpiGbl_RootNodeStruct.Object = NULL; - - -#ifdef ACPI_DISASSEMBLER - AcpiGbl_ExternalList = NULL; - AcpiGbl_NumExternalMethods = 0; - AcpiGbl_ResolvedExternalMethods = 0; -#endif - -#ifdef ACPI_DEBUG_OUTPUT - AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); -#endif - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - AcpiGbl_DisplayFinalMemStats = FALSE; - AcpiGbl_DisableMemTracking = FALSE; -#endif - - ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = FALSE); - - return_ACPI_STATUS (AE_OK); -} - /* Public globals */ ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) diff --git a/source/components/utilities/uthex.c b/source/components/utilities/uthex.c new file mode 100644 index 0000000..e71cacd --- /dev/null +++ b/source/components/utilities/uthex.c @@ -0,0 +1,113 @@ +/****************************************************************************** + * + * Module Name: uthex -- Hex/ASCII support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#define __UTHEX_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("uthex") + + +/* Hex to ASCII conversion table */ + +static char AcpiGbl_HexToAscii[] = +{ + '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtHexToAsciiChar + * + * PARAMETERS: Integer - Contains the hex digit + * Position - bit position of the digit within the + * integer (multiple of 4) + * + * RETURN: The converted Ascii character + * + * DESCRIPTION: Convert a hex digit to an Ascii character + * + ******************************************************************************/ + +char +AcpiUtHexToAsciiChar ( + UINT64 Integer, + UINT32 Position) +{ + + return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtHexCharToValue + * + * PARAMETERS: AsciiChar - Hex character in Ascii + * + * RETURN: The binary value of the ascii/hex character + * + * DESCRIPTION: Perform ascii-to-hex translation + * + ******************************************************************************/ + +UINT8 +AcpiUtAsciiCharToHex ( + int HexChar) +{ + + if (HexChar <= 0x39) + { + return ((UINT8) (HexChar - 0x30)); + } + + if (HexChar <= 0x46) + { + return ((UINT8) (HexChar - 0x37)); + } + + return ((UINT8) (HexChar - 0x57)); +} diff --git a/source/components/utilities/utinit.c b/source/components/utilities/utinit.c index f2de225..17030be 100644 --- a/source/components/utilities/utinit.c +++ b/source/components/utilities/utinit.c @@ -116,6 +116,162 @@ AcpiUtFreeGpeLists ( #endif /* !ACPI_REDUCED_HARDWARE */ +/******************************************************************************* + * + * FUNCTION: AcpiUtInitGlobals + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize ACPICA globals. All globals that require specific + * initialization should be initialized here. This allows for + * a warm restart. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInitGlobals ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtInitGlobals); + + + /* Create all memory caches */ + + Status = AcpiUtCreateCaches (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Address Range lists */ + + for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) + { + AcpiGbl_AddressRangeList[i] = NULL; + } + + /* Mutex locked flags */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + AcpiGbl_MutexInfo[i].Mutex = NULL; + AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[i].UseCount = 0; + } + + for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) + { + AcpiGbl_OwnerIdMask[i] = 0; + } + + /* Last OwnerID is never valid */ + + AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; + + /* Event counters */ + + AcpiMethodCount = 0; + AcpiSciCount = 0; + AcpiGpeCount = 0; + + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + AcpiFixedEventCount[i] = 0; + } + +#if (!ACPI_REDUCED_HARDWARE) + + /* GPE/SCI support */ + + AcpiGbl_AllGpesInitialized = FALSE; + AcpiGbl_GpeXruptListHead = NULL; + AcpiGbl_GpeFadtBlocks[0] = NULL; + AcpiGbl_GpeFadtBlocks[1] = NULL; + AcpiCurrentGpeCount = 0; + + AcpiGbl_GlobalEventHandler = NULL; + AcpiGbl_SciHandlerList = NULL; + +#endif /* !ACPI_REDUCED_HARDWARE */ + + /* Global handlers */ + + AcpiGbl_GlobalNotify[0].Handler = NULL; + AcpiGbl_GlobalNotify[1].Handler = NULL; + AcpiGbl_ExceptionHandler = NULL; + AcpiGbl_InitHandler = NULL; + AcpiGbl_TableHandler = NULL; + AcpiGbl_InterfaceHandler = NULL; + + /* Global Lock support */ + + AcpiGbl_GlobalLockSemaphore = NULL; + AcpiGbl_GlobalLockMutex = NULL; + AcpiGbl_GlobalLockAcquired = FALSE; + AcpiGbl_GlobalLockHandle = 0; + AcpiGbl_GlobalLockPresent = FALSE; + + /* Miscellaneous variables */ + + AcpiGbl_DSDT = NULL; + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_Shutdown = FALSE; + AcpiGbl_NsLookupCount = 0; + AcpiGbl_PsFindCount = 0; + AcpiGbl_AcpiHardwarePresent = TRUE; + AcpiGbl_LastOwnerIdIndex = 0; + AcpiGbl_NextOwnerIdOffset = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; + AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; + AcpiGbl_OsiMutex = NULL; + AcpiGbl_RegMethodsExecuted = FALSE; + + /* Hardware oriented */ + + AcpiGbl_EventsInitialized = FALSE; + AcpiGbl_SystemAwakeAndRunning = TRUE; + + /* Namespace */ + + AcpiGbl_ModuleCodeList = NULL; + AcpiGbl_RootNode = NULL; + AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; + AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; + AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; + AcpiGbl_RootNodeStruct.Parent = NULL; + AcpiGbl_RootNodeStruct.Child = NULL; + AcpiGbl_RootNodeStruct.Peer = NULL; + AcpiGbl_RootNodeStruct.Object = NULL; + + +#ifdef ACPI_DISASSEMBLER + AcpiGbl_ExternalList = NULL; + AcpiGbl_NumExternalMethods = 0; + AcpiGbl_ResolvedExternalMethods = 0; +#endif + +#ifdef ACPI_DEBUG_OUTPUT + AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); +#endif + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + AcpiGbl_DisplayFinalMemStats = FALSE; + AcpiGbl_DisableMemTracking = FALSE; +#endif + + ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = FALSE); + + return_ACPI_STATUS (AE_OK); +} + + /****************************************************************************** * * FUNCTION: AcpiUtTerminate diff --git a/source/components/utilities/utprint.c b/source/components/utilities/utprint.c new file mode 100644 index 0000000..21f7034 --- /dev/null +++ b/source/components/utilities/utprint.c @@ -0,0 +1,811 @@ +/****************************************************************************** + * + * Module Name: utprint - Formatted printing routines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utprint") + + +#define ACPI_FORMAT_SIGN 0x01 +#define ACPI_FORMAT_SIGN_PLUS 0x02 +#define ACPI_FORMAT_SIGN_PLUS_SPACE 0x04 +#define ACPI_FORMAT_ZERO 0x08 +#define ACPI_FORMAT_LEFT 0x10 +#define ACPI_FORMAT_UPPER 0x20 +#define ACPI_FORMAT_PREFIX 0x40 + + +/* Local prototypes */ + +static ACPI_SIZE +AcpiUtBoundStringLength ( + const char *String, + ACPI_SIZE Count); + +static char * +AcpiUtBoundStringOutput ( + char *String, + const char *End, + char c); + +static char * +AcpiUtFormatNumber ( + char *String, + char *End, + UINT64 Number, + UINT8 Base, + INT32 Width, + INT32 Precision, + UINT8 Type); + +static char * +AcpiUtPutNumber ( + char *String, + UINT64 Number, + UINT8 Base, + BOOLEAN Upper); + + +/* Module globals */ + +static const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; +static const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtBoundStringLength + * + * PARAMETERS: String - String with boundary + * Count - Boundary of the string + * + * RETURN: Length of the string. Less than or equal to Count. + * + * DESCRIPTION: Calculate the length of a string with boundary. + * + ******************************************************************************/ + +static ACPI_SIZE +AcpiUtBoundStringLength ( + const char *String, + ACPI_SIZE Count) +{ + UINT32 Length = 0; + + + while (*String && Count) + { + Length++; + String++; + Count--; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtBoundStringOutput + * + * PARAMETERS: String - String with boundary + * End - Boundary of the string + * c - Character to be output to the string + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Output a character into a string with boundary check. + * + ******************************************************************************/ + +static char * +AcpiUtBoundStringOutput ( + char *String, + const char *End, + char c) +{ + + if (String < End) + { + *String = c; + } + + ++String; + return (String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPutNumber + * + * PARAMETERS: String - Buffer to hold reverse-ordered string + * Number - Integer to be converted + * Base - Base of the integer + * Upper - Whether or not using upper cased digits + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Convert an integer into a string, note that, the string holds a + * reversed ordered number without the trailing zero. + * + ******************************************************************************/ + +static char * +AcpiUtPutNumber ( + char *String, + UINT64 Number, + UINT8 Base, + BOOLEAN Upper) +{ + const char *Digits; + UINT64 DigitIndex; + char *Pos; + + + Pos = String; + Digits = Upper ? AcpiGbl_UpperHexDigits : AcpiGbl_LowerHexDigits; + + if (Number == 0) + { + *(Pos++) = '0'; + } + else + { + while (Number) + { + (void) AcpiUtDivide (Number, Base, &Number, &DigitIndex); + *(Pos++) = Digits[DigitIndex]; + } + } + + /* *(Pos++) = '0'; */ + return (Pos); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtScanNumber + * + * PARAMETERS: String - String buffer + * NumberPtr - Where the number is returned + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Scan a string for a decimal integer. + * + ******************************************************************************/ + +const char * +AcpiUtScanNumber ( + const char *String, + UINT64 *NumberPtr) +{ + UINT64 Number = 0; + + + while (ACPI_IS_DIGIT (*String)) + { + Number *= 10; + Number += *(String++) - '0'; + } + + *NumberPtr = Number; + return (String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPrintNumber + * + * PARAMETERS: String - String buffer + * Number - The number to be converted + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Print a decimal integer into a string. + * + ******************************************************************************/ + +const char * +AcpiUtPrintNumber ( + char *String, + UINT64 Number) +{ + char AsciiString[20]; + const char *Pos1; + char *Pos2; + + + Pos1 = AcpiUtPutNumber (AsciiString, Number, 10, FALSE); + Pos2 = String; + + while (Pos1 != AsciiString) + { + *(Pos2++) = *(--Pos1); + } + + *Pos2 = 0; + return (String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFormatNumber + * + * PARAMETERS: String - String buffer with boundary + * End - Boundary of the string + * Number - The number to be converted + * Base - Base of the integer + * Width - Field width + * Precision - Precision of the integer + * Type - Special printing flags + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Print an integer into a string with any base and any precision. + * + ******************************************************************************/ + +static char * +AcpiUtFormatNumber ( + char *String, + char *End, + UINT64 Number, + UINT8 Base, + INT32 Width, + INT32 Precision, + UINT8 Type) +{ + char *Pos; + char Sign; + char Zero; + BOOLEAN NeedPrefix; + BOOLEAN Upper; + INT32 i; + char ReversedString[66]; + + + /* Parameter validation */ + + if (Base < 2 || Base > 16) + { + return (NULL); + } + + if (Type & ACPI_FORMAT_LEFT) + { + Type &= ~ACPI_FORMAT_ZERO; + } + + NeedPrefix = ((Type & ACPI_FORMAT_PREFIX) && Base != 10) ? TRUE : FALSE; + Upper = (Type & ACPI_FORMAT_UPPER) ? TRUE : FALSE; + Zero = (Type & ACPI_FORMAT_ZERO) ? '0' : ' '; + + /* Calculate size according to sign and prefix */ + + Sign = '\0'; + if (Type & ACPI_FORMAT_SIGN) + { + if ((INT64) Number < 0) + { + Sign = '-'; + Number = - (INT64) Number; + Width--; + } + else if (Type & ACPI_FORMAT_SIGN_PLUS) + { + Sign = '+'; + Width--; + } + else if (Type & ACPI_FORMAT_SIGN_PLUS_SPACE) + { + Sign = ' '; + Width--; + } + } + if (NeedPrefix) + { + Width--; + if (Base == 16) + { + Width--; + } + } + + /* Generate full string in reverse order */ + + Pos = AcpiUtPutNumber (ReversedString, Number, Base, Upper); + i = ACPI_PTR_DIFF (Pos, ReversedString); + + /* Printing 100 using %2d gives "100", not "00" */ + + if (i > Precision) + { + Precision = i; + } + + Width -= Precision; + + /* Output the string */ + + if (!(Type & (ACPI_FORMAT_ZERO | ACPI_FORMAT_LEFT))) + { + while (--Width >= 0) + { + String = AcpiUtBoundStringOutput (String, End, ' '); + } + } + if (Sign) + { + String = AcpiUtBoundStringOutput (String, End, Sign); + } + if (NeedPrefix) + { + String = AcpiUtBoundStringOutput (String, End, '0'); + if (Base == 16) + { + String = AcpiUtBoundStringOutput (String, End, + Upper ? 'X' : 'x'); + } + } + if (!(Type & ACPI_FORMAT_LEFT)) + { + while (--Width >= 0) + { + String = AcpiUtBoundStringOutput (String, End, Zero); + } + } + + while (i <= --Precision) + { + String = AcpiUtBoundStringOutput (String, End, '0'); + } + while (--i >= 0) + { + String = AcpiUtBoundStringOutput (String, End, + ReversedString[i]); + } + while (--Width >= 0) + { + String = AcpiUtBoundStringOutput (String, End, ' '); + } + + return (String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtVsnprintf + * + * PARAMETERS: String - String with boundary + * Size - Boundary of the string + * Format - Standard printf format + * Args - Argument list + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Formatted output to a string using argument list pointer. + * + ******************************************************************************/ + +int +AcpiUtVsnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + va_list Args) +{ + UINT8 Base = 10; + UINT8 Type = 0; + INT32 Width = -1; + INT32 Precision = -1; + char Qualifier = 0; + UINT64 Number; + char *Pos; + char *End; + char c; + const char *s; + const void *p; + INT32 Length; + int i; + + + Pos = String; + End = String + Size; + + for (; *Format; ++Format) + { + if (*Format != '%') + { + Pos = AcpiUtBoundStringOutput (Pos, End, *Format); + continue; + } + + /* Process sign */ + + do + { + ++Format; + if (*Format == '#') + { + Type |= ACPI_FORMAT_PREFIX; + } + else if (*Format == '0') + { + Type |= ACPI_FORMAT_ZERO; + } + else if (*Format == '+') + { + Type |= ACPI_FORMAT_SIGN_PLUS; + } + else if (*Format == ' ') + { + Type |= ACPI_FORMAT_SIGN_PLUS_SPACE; + } + else if (*Format == '-') + { + Type |= ACPI_FORMAT_LEFT; + } + else + { + break; + } + } while (1); + + /* Process width */ + + Width = -1; + if (ACPI_IS_DIGIT (*Format)) + { + Format = AcpiUtScanNumber (Format, &Number); + Width = (INT32) Number; + } + else if (*Format == '*') + { + ++Format; + Width = va_arg (Args, int); + if (Width < 0) + { + Width = -Width; + Type |= ACPI_FORMAT_LEFT; + } + } + + /* Process precision */ + + Precision = -1; + if (*Format == '.') + { + ++Format; + if (ACPI_IS_DIGIT(*Format)) + { + Format = AcpiUtScanNumber (Format, &Number); + Precision = (INT32) Number; + } + else if (*Format == '*') + { + ++Format; + Precision = va_arg (Args, int); + } + if (Precision < 0) + { + Precision = 0; + } + } + + /* Process qualifier */ + + Qualifier = -1; + if (*Format == 'h' || *Format == 'l' || *Format == 'L') + { + Qualifier = *Format; + ++Format; + + if (Qualifier == 'l' && *Format == 'l') + { + Qualifier = 'L'; + ++Format; + } + } + + switch (*Format) + { + case '%': + + Pos = AcpiUtBoundStringOutput (Pos, End, '%'); + continue; + + case 'c': + + if (!(Type & ACPI_FORMAT_LEFT)) + { + while (--Width > 0) + { + Pos = AcpiUtBoundStringOutput (Pos, End, ' '); + } + } + + c = (char) va_arg (Args, int); + Pos = AcpiUtBoundStringOutput (Pos, End, c); + + while (--Width > 0) + { + Pos = AcpiUtBoundStringOutput (Pos, End, ' '); + } + continue; + + case 's': + + s = va_arg (Args, char *); + if (!s) + { + s = ""; + } + Length = AcpiUtBoundStringLength (s, Precision); + if (!(Type & ACPI_FORMAT_LEFT)) + { + while (Length < Width--) + { + Pos = AcpiUtBoundStringOutput (Pos, End, ' '); + } + } + for (i = 0; i < Length; ++i) + { + Pos = AcpiUtBoundStringOutput (Pos, End, *s); + ++s; + } + while (Length < Width--) + { + Pos = AcpiUtBoundStringOutput (Pos, End, ' '); + } + continue; + + case 'o': + + Base = 8; + break; + + case 'X': + + Type |= ACPI_FORMAT_UPPER; + + case 'x': + + Base = 16; + break; + + case 'd': + case 'i': + + Type |= ACPI_FORMAT_SIGN; + + case 'u': + + break; + + case 'p': + + if (Width == -1) + { + Width = 2 * sizeof (void *); + Type |= ACPI_FORMAT_ZERO; + } + + p = va_arg (Args, void *); + Pos = AcpiUtFormatNumber (Pos, End, + ACPI_TO_INTEGER (p), 16, Width, Precision, Type); + continue; + + default: + + Pos = AcpiUtBoundStringOutput (Pos, End, '%'); + if (*Format) + { + Pos = AcpiUtBoundStringOutput (Pos, End, *Format); + } + else + { + --Format; + } + continue; + } + + if (Qualifier == 'L') + { + Number = va_arg (Args, UINT64); + if (Type & ACPI_FORMAT_SIGN) + { + Number = (INT64) Number; + } + } + else if (Qualifier == 'l') + { + Number = va_arg (Args, unsigned long); + if (Type & ACPI_FORMAT_SIGN) + { + Number = (INT32) Number; + } + } + else if (Qualifier == 'h') + { + Number = (UINT16) va_arg (Args, int); + if (Type & ACPI_FORMAT_SIGN) + { + Number = (INT16) Number; + } + } + else + { + Number = va_arg (Args, unsigned int); + if (Type & ACPI_FORMAT_SIGN) + { + Number = (signed int) Number; + } + } + + Pos = AcpiUtFormatNumber (Pos, End, Number, Base, + Width, Precision, Type); + } + + if (Size > 0) + { + if (Pos < End) + { + *Pos = '\0'; + } + else + { + End[-1] = '\0'; + } + } + + return (ACPI_PTR_DIFF (Pos, String)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtSnprintf + * + * PARAMETERS: String - String with boundary + * Size - Boundary of the string + * Format, ... - Standard printf format + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Formatted output to a string. + * + ******************************************************************************/ + +int +AcpiUtSnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + ...) +{ + va_list Args; + int Length; + + + va_start (Args, Format); + Length = AcpiUtVsnprintf (String, Size, Format, Args); + va_end (Args); + + return (Length); +} + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiUtFileVprintf + * + * PARAMETERS: File - File descriptor + * Format - Standard printf format + * Args - Argument list + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Formatted output to a file using argument list pointer. + * + ******************************************************************************/ + +int +AcpiUtFileVprintf ( + ACPI_FILE File, + const char *Format, + va_list Args) +{ + ACPI_CPU_FLAGS Flags; + int Length; + + + Flags = AcpiOsAcquireLock (AcpiGbl_PrintLock); + Length = AcpiUtVsnprintf (AcpiGbl_PrintBuffer, + sizeof (AcpiGbl_PrintBuffer), Format, Args); + + (void) AcpiOsWriteFile (File, AcpiGbl_PrintBuffer, Length, 1); + AcpiOsReleaseLock (AcpiGbl_PrintLock, Flags); + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFilePrintf + * + * PARAMETERS: File - File descriptor + * Format, ... - Standard printf format + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Formatted output to a file. + * + ******************************************************************************/ + +int +AcpiUtFilePrintf ( + ACPI_FILE File, + const char *Format, + ...) +{ + va_list Args; + int Length; + + + va_start (Args, Format); + Length = AcpiUtFileVprintf (File, Format, Args); + va_end (Args); + + return (Length); +} +#endif diff --git a/source/components/utilities/utuuid.c b/source/components/utilities/utuuid.c new file mode 100644 index 0000000..ebf0323 --- /dev/null +++ b/source/components/utilities/utuuid.c @@ -0,0 +1,103 @@ +/****************************************************************************** + * + * Module Name: utuuid -- UUID support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#define __UTUUID_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("utuuid") + + +/* + * UUID support functions. + * + * This table is used to convert an input UUID ascii string to a 16 byte + * buffer and the reverse. The table maps a UUID buffer index 0-15 to + * the index within the 36-byte UUID string where the associated 2-byte + * hex value can be found. + * + * 36-byte UUID strings are of the form: + * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp + * Where aa-pp are one byte hex numbers, made up of two hex digits + * + * Note: This table is basically the inverse of the string-to-offset table + * found in the ACPI spec in the description of the ToUUID macro. + */ +const UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH] = +{ + 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtConvertStringToUuid + * + * PARAMETERS: InString - 36-byte formatted UUID string + * UuidBuffer - Where the 16-byte UUID buffer is returned + * + * RETURN: None. Output data is returned in the UuidBuffer + * + * DESCRIPTION: Convert a 36-byte formatted UUID string to 16-byte UUID buffer + * + ******************************************************************************/ + +void +AcpiUtConvertStringToUuid ( + char *InString, + UINT8 *UuidBuffer) +{ + UINT32 i; + + + for (i = 0; i < UUID_BUFFER_LENGTH; i++) + { + UuidBuffer[i] = + (AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i]]) << 4); + + UuidBuffer[i] |= + AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i] + 1]); + } +} diff --git a/source/include/acapps.h b/source/include/acapps.h index fa8e386..f754789 100644 --- a/source/include/acapps.h +++ b/source/include/acapps.h @@ -84,10 +84,13 @@ /* Macros for usage messages */ #define ACPI_USAGE_HEADER(Usage) \ - printf ("Usage: %s\nOptions:\n", Usage); + AcpiOsPrintf ("Usage: %s\nOptions:\n", Usage); + +#define ACPI_USAGE_TEXT(Description) \ + AcpiOsPrintf (Description); #define ACPI_OPTION(Name, Description) \ - printf (" %-18s%s\n", Name, Description); + AcpiOsPrintf (" %-18s%s\n", Name, Description); #define FILE_SUFFIX_DISASSEMBLY "dsl" @@ -119,7 +122,7 @@ extern char *AcpiGbl_Optarg; */ UINT32 CmGetFileSize ( - FILE *File); + ACPI_FILE File); #ifndef ACPI_DUMP_APP diff --git a/source/include/acconfig.h b/source/include/acconfig.h index 4cad6f4..69242ee 100644 --- a/source/include/acconfig.h +++ b/source/include/acconfig.h @@ -223,6 +223,25 @@ /****************************************************************************** * + * Miscellaneous constants + * + *****************************************************************************/ + +/* UUID constants */ + +#define UUID_BUFFER_LENGTH 16 /* Length of UUID in memory */ +#define UUID_STRING_LENGTH 36 /* Total length of a UUID string */ + +/* Positions for required hyphens (dashes) in UUID strings */ + +#define UUID_HYPHEN1_OFFSET 8 +#define UUID_HYPHEN2_OFFSET 13 +#define UUID_HYPHEN3_OFFSET 18 +#define UUID_HYPHEN4_OFFSET 23 + + +/****************************************************************************** + * * ACPI AML Debugger * *****************************************************************************/ diff --git a/source/include/acdebug.h b/source/include/acdebug.h index f85ec01..a856257 100644 --- a/source/include/acdebug.h +++ b/source/include/acdebug.h @@ -377,11 +377,6 @@ AcpiDbGetTableFromFile ( char *Filename, ACPI_TABLE_HEADER **Table); -ACPI_STATUS -AcpiDbReadTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **Table); - /* * dbhistry - debugger HISTORY command diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h index 7de84ac..094356a 100644 --- a/source/include/acdisasm.h +++ b/source/include/acdisasm.h @@ -137,11 +137,13 @@ typedef enum ACPI_DMT_ASF, ACPI_DMT_DMAR, + ACPI_DMT_DMAR_SCOPE, ACPI_DMT_EINJACT, ACPI_DMT_EINJINST, ACPI_DMT_ERSTACT, ACPI_DMT_ERSTINST, ACPI_DMT_FADTPM, + ACPI_DMT_GTDT, ACPI_DMT_HEST, ACPI_DMT_HESTNTFY, ACPI_DMT_HESTNTYP, @@ -255,6 +257,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[]; @@ -272,6 +275,10 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGas[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdtHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[]; @@ -309,6 +316,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt11[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt12[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt13[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt14[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; @@ -332,6 +341,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmttHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcctHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoS3pt[]; @@ -445,6 +455,10 @@ AcpiDmDumpFpdt ( ACPI_TABLE_HEADER *Table); void +AcpiDmDumpGtdt ( + ACPI_TABLE_HEADER *Table); + +void AcpiDmDumpHest ( ACPI_TABLE_HEADER *Table); @@ -655,6 +669,10 @@ AcpiDmDecompressEisaId ( UINT32 EncodedId); BOOLEAN +AcpiDmIsUuidBuffer ( + ACPI_PARSE_OBJECT *Op); + +BOOLEAN AcpiDmIsUnicodeBuffer ( ACPI_PARSE_OBJECT *Op); diff --git a/source/include/acglobal.h b/source/include/acglobal.h index 06225c1..a83f8c3 100644 --- a/source/include/acglobal.h +++ b/source/include/acglobal.h @@ -301,7 +301,7 @@ ACPI_GLOBAL (UINT32, AcpiGbl_TraceDbgLayer); * ****************************************************************************/ -ACPI_GLOBAL (UINT8, AcpiGbl_DbOutputFlags); +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DbOutputFlags, ACPI_DB_CONSOLE_OUTPUT); #ifdef ACPI_DISASSEMBLER @@ -367,6 +367,12 @@ ACPI_GLOBAL (UINT32, AcpiGbl_NumObjects); #ifdef ACPI_APPLICATION ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_DebugFile, NULL); +ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_OutputFile, NULL); + +/* Print buffer */ + +ACPI_GLOBAL (ACPI_SPINLOCK, AcpiGbl_PrintLock); /* For print buffer */ +ACPI_GLOBAL (char, AcpiGbl_PrintBuffer[1024]); #endif /* ACPI_APPLICATION */ diff --git a/source/include/aclocal.h b/source/include/aclocal.h index 3fcfe1f..7b9e83d 100644 --- a/source/include/aclocal.h +++ b/source/include/aclocal.h @@ -878,12 +878,13 @@ typedef union acpi_parse_value #define ACPI_DASM_STRING 0x02 /* Buffer is a ASCII string */ #define ACPI_DASM_UNICODE 0x03 /* Buffer is a Unicode string */ #define ACPI_DASM_PLD_METHOD 0x04 /* Buffer is a _PLD method bit-packed buffer */ -#define ACPI_DASM_EISAID 0x05 /* Integer is an EISAID */ -#define ACPI_DASM_MATCHOP 0x06 /* Parent opcode is a Match() operator */ -#define ACPI_DASM_LNOT_PREFIX 0x07 /* Start of a LNotEqual (etc.) pair of opcodes */ -#define ACPI_DASM_LNOT_SUFFIX 0x08 /* End of a LNotEqual (etc.) pair of opcodes */ -#define ACPI_DASM_HID_STRING 0x09 /* String is a _HID or _CID */ -#define ACPI_DASM_IGNORE 0x0A /* Not used at this time */ +#define ACPI_DASM_UUID 0x05 /* Buffer is a UUID/GUID */ +#define ACPI_DASM_EISAID 0x06 /* Integer is an EISAID */ +#define ACPI_DASM_MATCHOP 0x07 /* Parent opcode is a Match() operator */ +#define ACPI_DASM_LNOT_PREFIX 0x08 /* Start of a LNotEqual (etc.) pair of opcodes */ +#define ACPI_DASM_LNOT_SUFFIX 0x09 /* End of a LNotEqual (etc.) pair of opcodes */ +#define ACPI_DASM_HID_STRING 0x0A /* String is a _HID or _CID */ +#define ACPI_DASM_IGNORE 0x0B /* Not used at this time */ /* * Generic operation (for example: If, While, Store) @@ -1358,4 +1359,11 @@ typedef struct ah_device_id } AH_DEVICE_ID; +typedef struct ah_uuid +{ + char *Description; + char *String; + +} AH_UUID; + #endif /* __ACLOCAL_H__ */ diff --git a/source/include/acnames.h b/source/include/acnames.h index 3db143c..b8322e6 100644 --- a/source/include/acnames.h +++ b/source/include/acnames.h @@ -55,7 +55,7 @@ #define METHOD_NAME__HID "_HID" #define METHOD_NAME__INI "_INI" #define METHOD_NAME__PLD "_PLD" -#define METHOD_NAME__PRP "_PRP" +#define METHOD_NAME__DSD "_DSD" #define METHOD_NAME__PRS "_PRS" #define METHOD_NAME__PRT "_PRT" #define METHOD_NAME__PRW "_PRW" diff --git a/source/include/acpi.h b/source/include/acpi.h index 8c65613..fb1f565 100644 --- a/source/include/acpi.h +++ b/source/include/acpi.h @@ -62,8 +62,6 @@ #include "acrestyp.h" /* Resource Descriptor structs */ #include "acpiosxf.h" /* OSL interfaces (ACPICA-to-OS) */ #include "acpixf.h" /* ACPI core subsystem external interfaces */ -#ifdef ACPI_NATIVE_INTERFACE_HEADER -#include ACPI_NATIVE_INTERFACE_HEADER -#endif +#include "platform/acenvex.h" /* Extra environment-specific items */ #endif /* __ACPI_H__ */ diff --git a/source/include/acpiosxf.h b/source/include/acpiosxf.h index ebbcb6b..3888b48 100644 --- a/source/include/acpiosxf.h +++ b/source/include/acpiosxf.h @@ -551,4 +551,53 @@ AcpiOsCloseDirectory ( #endif +/* + * File I/O and related support + */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenFile +ACPI_FILE +AcpiOsOpenFile ( + const char *Path, + UINT8 Modes); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseFile +void +AcpiOsCloseFile ( + ACPI_FILE File); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadFile +int +AcpiOsReadFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteFile +int +AcpiOsWriteFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetFileOffset +long +AcpiOsGetFileOffset ( + ACPI_FILE File); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSetFileOffset +ACPI_STATUS +AcpiOsSetFileOffset ( + ACPI_FILE File, + long Offset, + UINT8 From); +#endif + + #endif /* __ACPIOSXF_H__ */ diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 53d2c1f..7174101 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20140424 +#define ACPI_CA_VERSION 0x20140724 #include "acconfig.h" #include "actypes.h" @@ -162,6 +162,15 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_CreateOsiMethod, TRUE); ACPI_INIT_GLOBAL (UINT8, AcpiGbl_UseDefaultRegisterWidths, TRUE); /* + * Whether or not to verify the table checksum before installation. Set + * this to TRUE to verify the table checksum before install it to the table + * manager. Note that enabling this option causes errors to happen in some + * OSPMs during early initialization stages. Default behavior is to do such + * verification. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_VerifyTableChecksum, TRUE); + +/* * Optionally enable output from the AML Debug Object. */ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_EnableAmlDebugObject, FALSE); @@ -334,6 +343,24 @@ ACPI_GLOBAL (BOOLEAN, AcpiGbl_SystemAwakeAndRunning); #endif /* ACPI_DEBUG_OUTPUT */ +/* + * Application prototypes + * + * All interfaces used by application will be configured + * out of the ACPICA build unless the ACPI_APPLICATION + * flag is defined. + */ +#ifdef ACPI_APPLICATION +#define ACPI_APP_DEPENDENT_RETURN_VOID(Prototype) \ + Prototype; + +#else +#define ACPI_APP_DEPENDENT_RETURN_VOID(Prototype) \ + static ACPI_INLINE Prototype {return;} + +#endif /* ACPI_APPLICATION */ + + /***************************************************************************** * * ACPICA public interface prototypes @@ -824,6 +851,12 @@ AcpiFinishGpe ( ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS +AcpiMarkGpeForWake ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber)) + +ACPI_HW_DEPENDENT_RETURN_STATUS ( +ACPI_STATUS AcpiSetupGpeForWake ( ACPI_HANDLE ParentDevice, ACPI_HANDLE GpeDevice, @@ -1136,4 +1169,11 @@ AcpiDebugPrintRaw ( const char *Format, ...)) +ACPI_APP_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(1) +void ACPI_INTERNAL_VAR_XFACE +AcpiLogError ( + const char *Format, + ...)) + #endif /* __ACXFACE_H__ */ diff --git a/source/include/acpredef.h b/source/include/acpredef.h index d7af2db..c41ab03 100644 --- a/source/include/acpredef.h +++ b/source/include/acpredef.h @@ -106,6 +106,11 @@ * count = 0 (optional) * (Used for _DLM) * + * ACPI_PTYPE2_UUID_PAIR: Each subpackage is preceded by a UUID Buffer. The UUID + * defines the format of the package. Zero-length parent package is + * allowed. + * (Used for _DSD) + * *****************************************************************************/ enum AcpiReturnPackageTypes @@ -119,7 +124,8 @@ enum AcpiReturnPackageTypes ACPI_PTYPE2_FIXED = 7, ACPI_PTYPE2_MIN = 8, ACPI_PTYPE2_REV_FIXED = 9, - ACPI_PTYPE2_FIX_VAR = 10 + ACPI_PTYPE2_FIX_VAR = 10, + ACPI_PTYPE2_UUID_PAIR = 11 }; @@ -366,6 +372,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_CBA", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* See PCI firmware spec 3.0 */ + {{"_CCA", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* ACPI 5.1 */ + {{"_CDM", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, @@ -434,6 +443,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_DOS", METHOD_1ARGS (ACPI_TYPE_INTEGER), METHOD_NO_RETURN_VALUE}}, + {{"_DSD", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: 1 Buf, 1 Pkg */ + PACKAGE_INFO (ACPI_PTYPE2_UUID_PAIR, ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_PACKAGE, 1,0), + {{"_DSM", METHOD_4ARGS (ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_PACKAGE), METHOD_RETURNS (ACPI_RTYPE_ALL)}}, /* Must return a value, but it can be of any type */ @@ -688,12 +701,6 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0), - {{"_PRP", METHOD_0ARGS, - METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: 1 Str, 1 Int/Str/Pkg */ - PACKAGE_INFO (ACPI_PTYPE2, ACPI_RTYPE_STRING, 1, - ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | - ACPI_RTYPE_PACKAGE | ACPI_RTYPE_REFERENCE, 1,0), - {{"_PRS", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, diff --git a/source/include/actables.h b/source/include/actables.h index 672b6b4..e266924 100644 --- a/source/include/actables.h +++ b/source/include/actables.h @@ -86,6 +86,15 @@ void AcpiTbReleaseTempTable ( ACPI_TABLE_DESC *TableDesc); +ACPI_STATUS +AcpiTbValidateTempTable ( + ACPI_TABLE_DESC *TableDesc); + +ACPI_STATUS +AcpiTbVerifyTempTable ( + ACPI_TABLE_DESC *TableDesc, + char *Signature); + BOOLEAN AcpiTbIsTableLoaded ( UINT32 TableIndex); @@ -135,11 +144,6 @@ void AcpiTbInvalidateTable ( ACPI_TABLE_DESC *TableDesc); -ACPI_STATUS -AcpiTbVerifyTable ( - ACPI_TABLE_DESC *TableDesc, - char *Signature); - void AcpiTbOverrideTable ( ACPI_TABLE_DESC *OldTableDesc); diff --git a/source/include/actbl.h b/source/include/actbl.h index a419195..6ef64e1 100644 --- a/source/include/actbl.h +++ b/source/include/actbl.h @@ -296,7 +296,8 @@ typedef struct acpi_table_fadt UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ - UINT8 Reserved4[3]; /* Reserved, must be zero */ + UINT16 ArmBootFlags; /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ + UINT8 MinorRevision; /* FADT Minor Revision (ACPI 5.1) */ UINT64 XFacs; /* 64-bit physical address of FACS */ UINT64 XDsdt; /* 64-bit physical address of DSDT */ ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ @@ -313,7 +314,7 @@ typedef struct acpi_table_fadt } ACPI_TABLE_FADT; -/* Masks for FADT Boot Architecture Flags (BootFlags) [Vx]=Introduced in this FADT revision */ +/* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) [Vx]=Introduced in this FADT revision */ #define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */ #define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */ @@ -322,6 +323,11 @@ typedef struct acpi_table_fadt #define ACPI_FADT_NO_ASPM (1<<4) /* 04: [V4] PCIe ASPM control must not be enabled */ #define ACPI_FADT_NO_CMOS_RTC (1<<5) /* 05: [V5] No CMOS real-time clock present */ +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */ + +#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5+] PSCI 0.2+ is implemented */ +#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5+] HVC must be used instead of SMC as the PSCI conduit */ + /* Masks for FADT flags */ #define ACPI_FADT_WBINVD (1) /* 00: [V1] The WBINVD instruction works properly */ @@ -435,7 +441,7 @@ typedef struct acpi_table_desc * FADT V5 size: 0x10C */ #define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) -#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (Reserved4[0]) + 3) +#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (MinorRevision) + 1) #define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) #define ACPI_FADT_V5_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) diff --git a/source/include/actbl1.h b/source/include/actbl1.h index fe47a73..f9aa1e0 100644 --- a/source/include/actbl1.h +++ b/source/include/actbl1.h @@ -762,20 +762,22 @@ typedef struct acpi_table_madt enum AcpiMadtType { - ACPI_MADT_TYPE_LOCAL_APIC = 0, - ACPI_MADT_TYPE_IO_APIC = 1, - ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, - ACPI_MADT_TYPE_NMI_SOURCE = 3, - ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, - ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, - ACPI_MADT_TYPE_IO_SAPIC = 6, - ACPI_MADT_TYPE_LOCAL_SAPIC = 7, - ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, - ACPI_MADT_TYPE_LOCAL_X2APIC = 9, - ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, - ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11, - ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12, - ACPI_MADT_TYPE_RESERVED = 13 /* 13 and greater are reserved */ + ACPI_MADT_TYPE_LOCAL_APIC = 0, + ACPI_MADT_TYPE_IO_APIC = 1, + ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, + ACPI_MADT_TYPE_NMI_SOURCE = 3, + ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, + ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, + ACPI_MADT_TYPE_IO_SAPIC = 6, + ACPI_MADT_TYPE_LOCAL_SAPIC = 7, + ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, + ACPI_MADT_TYPE_LOCAL_X2APIC = 9, + ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, + ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11, + ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12, + ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13, + ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14, + ACPI_MADT_TYPE_RESERVED = 15 /* 15 and greater are reserved */ }; @@ -936,16 +938,27 @@ typedef struct acpi_madt_generic_interrupt { ACPI_SUBTABLE_HEADER Header; UINT16 Reserved; /* Reserved - must be zero */ - UINT32 GicId; + UINT32 CpuInterfaceNumber; UINT32 Uid; UINT32 Flags; UINT32 ParkingVersion; UINT32 PerformanceInterrupt; UINT64 ParkedAddress; UINT64 BaseAddress; + UINT64 GicvBaseAddress; + UINT64 GichBaseAddress; + UINT32 VgicInterrupt; + UINT64 GicrBaseAddress; + UINT64 ArmMpidr; } ACPI_MADT_GENERIC_INTERRUPT; +/* Masks for Flags field above */ + +/* ACPI_MADT_ENABLED (1) Processor is usable if set */ +#define ACPI_MADT_PERFORMANCE_IRQ_MODE (1<<1) /* 01: Performance Interrupt Mode */ +#define ACPI_MADT_VGIC_IRQ_MODE (1<<2) /* 02: VGIC Maintenance Interrupt mode */ + /* 12: Generic Distributor (ACPI 5.0) */ @@ -961,11 +974,42 @@ typedef struct acpi_madt_generic_distributor } ACPI_MADT_GENERIC_DISTRIBUTOR; +/* 13: Generic MSI Frame (ACPI 5.1) */ + +typedef struct acpi_madt_generic_msi_frame +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved - must be zero */ + UINT32 MsiFrameId; + UINT64 BaseAddress; + UINT32 Flags; + UINT16 SpiCount; + UINT16 SpiBase; + +} ACPI_MADT_GENERIC_MSI_FRAME; + +/* Masks for Flags field above */ + +#define ACPI_MADT_OVERRIDE_SPI_VALUES (1) + + +/* 14: Generic Redistributor (ACPI 5.1) */ + +typedef struct acpi_madt_generic_redistributor +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* reserved - must be zero */ + UINT64 BaseAddress; + UINT32 Length; + +} ACPI_MADT_GENERIC_REDISTRIBUTOR; + + /* * Common flags fields for MADT subtables */ -/* MADT Local APIC flags (LapicFlags) and GIC flags */ +/* MADT Local APIC flags */ #define ACPI_MADT_ENABLED (1) /* 00: Processor is usable if set */ diff --git a/source/include/actbl2.h b/source/include/actbl2.h index df6692f..a6f2f20 100644 --- a/source/include/actbl2.h +++ b/source/include/actbl2.h @@ -450,7 +450,7 @@ typedef struct acpi_table_dbgp * Version 1 * * Conforms to "Intel Virtualization Technology for Directed I/O", - * Version 1.2, Sept. 2008 + * Version 2.2, Sept. 2013 * ******************************************************************************/ @@ -483,9 +483,10 @@ enum AcpiDmarType { ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, - ACPI_DMAR_TYPE_ATSR = 2, - ACPI_DMAR_HARDWARE_AFFINITY = 3, - ACPI_DMAR_TYPE_RESERVED = 4 /* 4 and greater are reserved */ + ACPI_DMAR_TYPE_ROOT_ATS = 2, + ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3, + ACPI_DMAR_TYPE_NAMESPACE = 4, + ACPI_DMAR_TYPE_RESERVED = 5 /* 5 and greater are reserved */ }; @@ -501,7 +502,7 @@ typedef struct acpi_dmar_device_scope } ACPI_DMAR_DEVICE_SCOPE; -/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ +/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE - device types */ enum AcpiDmarScopeType { @@ -510,7 +511,8 @@ enum AcpiDmarScopeType ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, ACPI_DMAR_SCOPE_TYPE_HPET = 4, - ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ + ACPI_DMAR_SCOPE_TYPE_NAMESPACE = 5, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 6 /* 6 and greater are reserved */ }; typedef struct acpi_dmar_pci_path @@ -587,6 +589,18 @@ typedef struct acpi_dmar_rhsa } ACPI_DMAR_RHSA; +/* 4: ACPI Namespace Device Declaration Structure */ + +typedef struct acpi_dmar_andd +{ + ACPI_DMAR_HEADER Header; + UINT8 Reserved[3]; + UINT8 DeviceNumber; + char DeviceName[1]; + +} ACPI_DMAR_ANDD; + + /******************************************************************************* * * HPET - High Precision Event Timer table diff --git a/source/include/actbl3.h b/source/include/actbl3.h index ce69acd..37bbd3e 100644 --- a/source/include/actbl3.h +++ b/source/include/actbl3.h @@ -280,35 +280,111 @@ typedef struct acpi_s3pt_suspend /******************************************************************************* * - * GTDT - Generic Timer Description Table (ACPI 5.0) - * Version 1 + * GTDT - Generic Timer Description Table (ACPI 5.1) + * Version 2 * ******************************************************************************/ typedef struct acpi_table_gtdt { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT64 Address; - UINT32 Flags; - UINT32 SecurePl1Interrupt; - UINT32 SecurePl1Flags; - UINT32 NonSecurePl1Interrupt; - UINT32 NonSecurePl1Flags; + UINT64 CounterBlockAddresss; + UINT32 Reserved; + UINT32 SecureEl1Interrupt; + UINT32 SecureEl1Flags; + UINT32 NonSecureEl1Interrupt; + UINT32 NonSecureEl1Flags; UINT32 VirtualTimerInterrupt; UINT32 VirtualTimerFlags; - UINT32 NonSecurePl2Interrupt; - UINT32 NonSecurePl2Flags; + UINT32 NonSecureEl2Interrupt; + UINT32 NonSecureEl2Flags; + UINT64 CounterReadBlockAddress; + UINT32 PlatformTimerCount; + UINT32 PlatformTimerOffset; } ACPI_TABLE_GTDT; -/* Values for Flags field above */ +/* Flag Definitions: Timer Block Physical Timers and Virtual timers */ + +#define ACPI_GTDT_INTERRUPT_MODE (1) +#define ACPI_GTDT_INTERRUPT_POLARITY (1<<1) +#define ACPI_GTDT_ALWAYS_ON (1<<2) + + +/* Common GTDT subtable header */ + +typedef struct acpi_gtdt_header +{ + UINT8 Type; + UINT16 Length; + +} ACPI_GTDT_HEADER; + +/* Values for GTDT subtable type above */ + +enum AcpiGtdtType +{ + ACPI_GTDT_TYPE_TIMER_BLOCK = 0, + ACPI_GTDT_TYPE_WATCHDOG = 1, + ACPI_GTDT_TYPE_RESERVED = 2 /* 2 and greater are reserved */ +}; + + +/* GTDT Subtables, correspond to Type in acpi_gtdt_header */ + +/* 0: Generic Timer Block */ + +typedef struct acpi_gtdt_timer_block +{ + ACPI_GTDT_HEADER Header; + UINT8 Reserved; + UINT64 BlockAddress; + UINT32 TimerCount; + UINT32 TimerOffset; + +} ACPI_GTDT_TIMER_BLOCK; + +/* Timer Sub-Structure, one per timer */ + +typedef struct acpi_gtdt_timer_entry +{ + UINT8 FrameNumber; + UINT8 Reserved[3]; + UINT64 BaseAddress; + UINT64 El0BaseAddress; + UINT32 TimerInterrupt; + UINT32 TimerFlags; + UINT32 VirtualTimerInterrupt; + UINT32 VirtualTimerFlags; + UINT32 CommonFlags; + +} ACPI_GTDT_TIMER_ENTRY; + + +/* Flag Definitions: CommonFlags above */ + +#define ACPI_GTDT_GT_IS_SECURE_TIMER (1) +#define ACPI_GTDT_GT_ALWAYS_ON (1<<1) + -#define ACPI_GTDT_MAPPED_BLOCK_PRESENT 1 +/* 1: SBSA Generic Watchdog Structure */ -/* Values for all "TimerFlags" fields above */ +typedef struct acpi_gtdt_watchdog +{ + ACPI_GTDT_HEADER Header; + UINT8 Reserved; + UINT64 RefreshFrameAddress; + UINT64 ControlFrameAddress; + UINT32 TimerInterrupt; + UINT32 TimerFlags; + +} ACPI_GTDT_WATCHDOG; -#define ACPI_GTDT_INTERRUPT_MODE 1 -#define ACPI_GTDT_INTERRUPT_POLARITY 2 +/* Flag Definitions: TimerFlags above */ + +#define ACPI_GTDT_WATCHDOG_IRQ_MODE (1) +#define ACPI_GTDT_WATCHDOG_IRQ_POLARITY (1<<1) +#define ACPI_GTDT_WATCHDOG_SECURE (1<<2) /******************************************************************************* @@ -453,7 +529,8 @@ typedef struct acpi_table_pcct enum AcpiPcctType { ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0, - ACPI_PCCT_TYPE_RESERVED = 1 /* 1 and greater are reserved */ + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE = 1, + ACPI_PCCT_TYPE_RESERVED = 2 /* 2 and greater are reserved */ }; /* @@ -478,6 +555,31 @@ typedef struct acpi_pcct_subspace } ACPI_PCCT_SUBSPACE; +/* 1: HW-reduced Communications Subspace (ACPI 5.1) */ + +typedef struct acpi_pcct_hw_reduced +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 DoorbellInterrupt; + UINT8 Flags; + UINT8 Reserved; + UINT64 BaseAddress; + UINT64 Length; + ACPI_GENERIC_ADDRESS DoorbellRegister; + UINT64 PreserveMask; + UINT64 WriteMask; + UINT32 Latency; + UINT32 MaxAccessRate; + UINT16 MinTurnaroundTime; + +} ACPI_PCCT_HW_REDUCED; + +/* Values for doorbell flags above */ + +#define ACPI_PCCT_INTERRUPT_POLARITY (1) +#define ACPI_PCCT_INTERRUPT_MODE (1<<1) + + /* * PCC memory structures (not part of the ACPI table) */ diff --git a/source/include/actypes.h b/source/include/actypes.h index 7a8d5c5..8171923 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -127,6 +127,7 @@ typedef unsigned char BOOLEAN; typedef unsigned char UINT8; typedef unsigned short UINT16; +typedef short INT16; typedef COMPILER_DEPENDENT_UINT64 UINT64; typedef COMPILER_DEPENDENT_INT64 INT64; @@ -523,7 +524,7 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i) #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL) -#define ACPI_OFFSET(d, f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL) +#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) NULL) #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) @@ -617,8 +618,9 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NOTIFY_RESERVED (UINT8) 0x0A #define ACPI_NOTIFY_LOCALITY_UPDATE (UINT8) 0x0B #define ACPI_NOTIFY_SHUTDOWN_REQUEST (UINT8) 0x0C +#define ACPI_NOTIFY_AFFINITY_UPDATE (UINT8) 0x0D -#define ACPI_NOTIFY_MAX 0x0C +#define ACPI_NOTIFY_MAX 0x0D /* * Types associated with ACPI names and objects. The first group of @@ -1336,4 +1338,19 @@ typedef struct acpi_memory_list #define ACPI_OSI_WIN_8 0x0C +/* Definitions of file IO */ + +#define ACPI_FILE_READING 0x01 +#define ACPI_FILE_WRITING 0x02 +#define ACPI_FILE_BINARY 0x04 + +#define ACPI_FILE_BEGIN 0x01 +#define ACPI_FILE_END 0x02 + + +/* Definitions of getopt */ + +#define ACPI_OPT_END -1 + + #endif /* __ACTYPES_H__ */ diff --git a/source/include/acutils.h b/source/include/acutils.h index 5c87313..e5656c4 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -96,7 +96,6 @@ extern const char *AcpiGbl_PtDecode[]; #ifdef ACPI_ASL_COMPILER #include -extern FILE *AcpiGbl_OutputFile; #define ACPI_MSG_REDIRECT_BEGIN \ FILE *OutputFile = AcpiGbl_OutputFile; \ @@ -226,6 +225,10 @@ AcpiUtHexToAsciiChar ( UINT64 Integer, UINT32 Position); +UINT8 +AcpiUtAsciiCharToHex ( + int HexChar); + BOOLEAN AcpiUtValidObjectType ( ACPI_OBJECT_TYPE Type); @@ -253,6 +256,11 @@ AcpiUtStrlen ( const char *String); char * +AcpiUtStrchr ( + const char *String, + int ch); + +char * AcpiUtStrcpy ( char *DstString, const char *SrcString); @@ -340,7 +348,7 @@ extern const UINT8 _acpi_ctype[]; #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) #define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) -#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) +#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU)) #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) #endif /* !ACPI_USE_SYSTEM_CLIBRARY */ @@ -482,6 +490,16 @@ AcpiUtDumpBuffer ( UINT32 Display, UINT32 Offset); +#ifdef ACPI_APPLICATION +void +AcpiUtDumpBufferToFile ( + ACPI_FILE File, + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 BaseOffset); +#endif + void AcpiUtReportError ( char *ModuleName, @@ -551,6 +569,17 @@ AcpiUtExecutePowerMethods ( /* + * utfileio - file operations + */ +#ifdef ACPI_APPLICATION +ACPI_STATUS +AcpiUtReadTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table); +#endif + + +/* * utids - device ID support */ ACPI_STATUS @@ -1110,4 +1139,57 @@ const AH_DEVICE_ID * AcpiAhMatchHardwareId ( char *Hid); +const char * +AcpiAhMatchUuid ( + UINT8 *Data); + +/* + * utprint - printf/vprintf output functions + */ +const char * +AcpiUtScanNumber ( + const char *String, + UINT64 *NumberPtr); + +const char * +AcpiUtPrintNumber ( + char *String, + UINT64 Number); + +int +AcpiUtVsnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + va_list Args); + +int +AcpiUtSnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + ...); + +#ifdef ACPI_APPLICATION +int +AcpiUtFileVprintf ( + ACPI_FILE File, + const char *Format, + va_list Args); + +int +AcpiUtFilePrintf ( + ACPI_FILE File, + const char *Format, + ...); +#endif + +/* + * utuuid -- UUID support functions + */ +void +AcpiUtConvertStringToUuid ( + char *InString, + UINT8 *UuidBuffer); + #endif /* _ACUTILS_H */ diff --git a/source/include/platform/accygwin.h b/source/include/platform/accygwin.h index cf8a2a3..09581c4 100644 --- a/source/include/platform/accygwin.h +++ b/source/include/platform/accygwin.h @@ -92,11 +92,14 @@ /* - * The vsnprintf function is defined by c99, but cygwin/gcc does not - * enable this prototype when the -ansi flag is set. Also related to - * __STRICT_ANSI__. So, we just declare the prototype here. + * The vsnprintf/snprintf functions are defined by c99, but cygwin/gcc + * does not enable this prototype when the -ansi flag is set. Also related + * to __STRICT_ANSI__. So, we just declare the prototype here. */ int vsnprintf (char *s, size_t n, const char *format, va_list ap); +int +snprintf (char *s, size_t n, const char *format, ...); + #endif /* __ACCYGWIN_H__ */ diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index 1fafeb4..cc24fbb 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -44,11 +44,20 @@ #ifndef __ACEFI_H__ #define __ACEFI_H__ +#include +#if defined(_GNU_EFI) +#include +#include +#endif #include #include #include +/* AED EFI definitions */ + +#if defined(_AED_EFI) + /* _int64 works for both IA32 and IA64 */ #define COMPILER_DEPENDENT_INT64 __int64 @@ -71,5 +80,57 @@ #pragma warning(disable:4142) +#endif + + +/* GNU EFI definitions */ + +#if defined(_GNU_EFI) + +/* Using GCC for GNU EFI */ + +#include "acgcc.h" + +#undef ACPI_USE_SYSTEM_CLIBRARY +#undef ACPI_USE_STANDARD_HEADERS +#undef ACPI_USE_NATIVE_DIVIDE +#define ACPI_USE_SYSTEM_INTTYPES + +#define ACPI_FILE SIMPLE_TEXT_OUTPUT_INTERFACE * +#define ACPI_FILE_OUT ST->ConOut +#define ACPI_FILE_ERR ST->ConOut + +/* + * Math helpers + */ +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ + do { \ + UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \ + (q32) = DivU64x32 ((__n), (d32), &(r32)); \ + } while (0) + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ + do { \ + (n_lo) >>= 1; \ + (n_lo) |= (((n_hi) & 1) << 31); \ + (n_hi) >>= 1; \ + } while (0) + +/* + * EFI specific prototypes + */ +EFI_STATUS +efi_main ( + EFI_HANDLE Image, + EFI_SYSTEM_TABLE *SystemTab); + +int +acpi_main ( + int argc, + char *argv[]); + + +#endif + #endif /* __ACEFI_H__ */ diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index e0100b1..b7444f0 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -88,20 +88,14 @@ #define ACPI_DBG_TRACK_ALLOCATIONS #endif -/* AcpiNames configuration. Single threaded with debugger output enabled. */ - -#ifdef ACPI_NAMES_APP -#define ACPI_DEBUGGER -#define ACPI_APPLICATION -#define ACPI_SINGLE_THREADED -#endif - /* - * AcpiBin/AcpiDump/AcpiSrc/AcpiXtract/Example configuration. All single - * threaded, with no debug output. + * AcpiBin/AcpiDump/AcpiHelp/AcpiNames/AcpiSrc/AcpiXtract/Example configuration. + * All single threaded. */ #if (defined ACPI_BIN_APP) || \ (defined ACPI_DUMP_APP) || \ + (defined ACPI_HELP_APP) || \ + (defined ACPI_NAMES_APP) || \ (defined ACPI_SRC_APP) || \ (defined ACPI_XTRACT_APP) || \ (defined ACPI_EXAMPLE_APP) @@ -109,12 +103,40 @@ #define ACPI_SINGLE_THREADED #endif +/* AcpiHelp configuration. Error messages disabled. */ + #ifdef ACPI_HELP_APP -#define ACPI_APPLICATION -#define ACPI_SINGLE_THREADED #define ACPI_NO_ERROR_MESSAGES #endif +/* AcpiNames configuration. Debug output enabled. */ + +#ifdef ACPI_NAMES_APP +#define ACPI_DEBUG_OUTPUT +#endif + +/* AcpiExec/AcpiNames/Example configuration. Native RSDP used. */ + +#if (defined ACPI_EXEC_APP) || \ + (defined ACPI_EXAMPLE_APP) || \ + (defined ACPI_NAMES_APP) +#define ACPI_USE_NATIVE_RSDP_POINTER +#endif + +/* AcpiDump configuration. Native mapping used if provied by OSPMs */ + +#ifdef ACPI_DUMP_APP +#define ACPI_USE_NATIVE_MEMORY_MAPPING +#define USE_NATIVE_ALLOCATE_ZEROED +#endif + +/* AcpiNames/Example configuration. Hardware disabled */ + +#if (defined ACPI_EXAMPLE_APP) || \ + (defined ACPI_NAMES_APP) +#define ACPI_REDUCED_HARDWARE 1 +#endif + /* Linkable ACPICA library */ #ifdef ACPI_LIBRARY @@ -185,6 +207,9 @@ #elif defined(_AED_EFI) #include "acefi.h" +#elif defined(_GNU_EFI) +#include "acefi.h" + #elif defined(__HAIKU__) #include "achaiku.h" @@ -401,8 +426,12 @@ typedef char *va_list; #ifdef ACPI_APPLICATION #include #define ACPI_FILE FILE * +#define ACPI_FILE_OUT stdout +#define ACPI_FILE_ERR stderr #else #define ACPI_FILE void * +#define ACPI_FILE_OUT NULL +#define ACPI_FILE_ERR NULL #endif /* ACPI_APPLICATION */ #endif /* ACPI_FILE */ diff --git a/source/include/platform/acenvex.h b/source/include/platform/acenvex.h new file mode 100644 index 0000000..a1de87f --- /dev/null +++ b/source/include/platform/acenvex.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * + * Name: acenvex.h - Extra host and compiler configuration + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef __ACENVEX_H__ +#define __ACENVEX_H__ + +/*! [Begin] no source code translation */ + +/****************************************************************************** + * + * Extra host configuration files. All ACPICA headers are included before + * including these files. + * + *****************************************************************************/ + +#if defined(_LINUX) || defined(__linux__) +#include "aclinuxex.h" + +#endif + +/*! [End] no source code translation !*/ + +#endif /* __ACENVEX_H__ */ diff --git a/source/include/platform/achaiku.h b/source/include/platform/achaiku.h index ab8bf0d..931ebf9 100644 --- a/source/include/platform/achaiku.h +++ b/source/include/platform/achaiku.h @@ -60,7 +60,8 @@ struct mutex; #define ACPI_USE_NATIVE_DIVIDE -// #define ACPI_THREAD_ID thread_id +/* #define ACPI_THREAD_ID thread_id */ + #define ACPI_SEMAPHORE sem_id #define ACPI_SPINLOCK spinlock * #define ACPI_CPU_FLAGS cpu_status diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h index a57f7f0..30f53e9 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -48,13 +48,18 @@ #define ACPI_USE_SYSTEM_CLIBRARY #define ACPI_USE_DO_WHILE_0 -#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE #ifdef __KERNEL__ #define ACPI_USE_SYSTEM_INTTYPES +/* Compile for reduced hardware mode only with this kernel config */ + +#ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY +#define ACPI_REDUCED_HARDWARE 1 +#endif + #include #include #include @@ -66,7 +71,7 @@ #ifdef EXPORT_ACPI_INTERFACES #include #endif -#include +#include #ifndef CONFIG_ACPI @@ -109,6 +114,40 @@ #define ACPI_SPINLOCK spinlock_t * #define ACPI_CPU_FLAGS unsigned long +/* Use native linux version of AcpiOsAllocateZeroed */ + +#define USE_NATIVE_ALLOCATE_ZEROED + +/* + * Overrides for in-kernel ACPICA + */ +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitialize +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminate +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocate +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocateZeroed +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsFree +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireObject +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetThreadId +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateLock + +/* + * OSL interfaces used by debugger/disassembler + */ +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable + +/* + * OSL interfaces used by utilities + */ +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRedirectOutput +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByName +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByIndex +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByAddress +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenDirectory +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetNextFilename +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseDirectory + #else /* !__KERNEL__ */ #include @@ -123,10 +162,6 @@ #define __init #endif -#ifndef __iomem -#define __iomem -#endif - /* Host-dependent types and defines for user-space ACPICA */ #define ACPI_FLUSH_CPU_CACHE() @@ -154,153 +189,4 @@ #include "acgcc.h" - -#ifdef __KERNEL__ - -/* - * FIXME: Inclusion of actypes.h - * Linux kernel need this before defining inline OSL interfaces as - * actypes.h need to be included to find ACPICA type definitions. - * Since from ACPICA's perspective, the actypes.h should be included after - * acenv.h (aclinux.h), this leads to a inclusion mis-ordering issue. - */ -#include - -/* - * Overrides for in-kernel ACPICA - */ -ACPI_STATUS __init AcpiOsInitialize ( - void); -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitialize - -ACPI_STATUS AcpiOsTerminate ( - void); -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminate - -/* - * Memory allocation/deallocation - */ - -/* - * The irqs_disabled() check is for resume from RAM. - * Interrupts are off during resume, just like they are for boot. - * However, boot has (system_state != SYSTEM_RUNNING) - * to quiet __might_sleep() in kmalloc() and resume does not. - */ -static inline void * -AcpiOsAllocate ( - ACPI_SIZE Size) -{ - return kmalloc (Size, irqs_disabled () ? GFP_ATOMIC : GFP_KERNEL); -} -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocate - -/* Use native linux version of AcpiOsAllocateZeroed */ - -static inline void * -AcpiOsAllocateZeroed ( - ACPI_SIZE Size) -{ - return kzalloc (Size, irqs_disabled () ? GFP_ATOMIC : GFP_KERNEL); -} -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocateZeroed -#define USE_NATIVE_ALLOCATE_ZEROED - -static inline void -AcpiOsFree ( - void *Memory) -{ - kfree (Memory); -} -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsFree - -static inline void * -AcpiOsAcquireObject ( - ACPI_CACHE_T *Cache) -{ - return kmem_cache_zalloc (Cache, - irqs_disabled () ? GFP_ATOMIC : GFP_KERNEL); -} -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireObject - -static inline ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - return (ACPI_THREAD_ID) (unsigned long) current; -} -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetThreadId - -#ifndef CONFIG_PREEMPT - -/* - * Used within ACPICA to show where it is safe to preempt execution - * when CONFIG_PREEMPT=n - */ -#define ACPI_PREEMPTION_POINT() \ - do { \ - if (!irqs_disabled()) \ - cond_resched(); \ - } while (0) - -#endif - -/* - * When lockdep is enabled, the spin_lock_init() macro stringifies it's - * argument and uses that as a name for the lock in debugging. - * By executing spin_lock_init() in a macro the key changes from "lock" for - * all locks to the name of the argument of acpi_os_create_lock(), which - * prevents lockdep from reporting false positives for ACPICA locks. - */ -#define AcpiOsCreateLock(__Handle) \ - ({ \ - spinlock_t *Lock = ACPI_ALLOCATE(sizeof(*Lock)); \ - if (Lock) { \ - *(__Handle) = Lock; \ - spin_lock_init(*(__Handle)); \ - } \ - Lock ? AE_OK : AE_NO_MEMORY; \ - }) -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateLock - -void __iomem * -AcpiOsMapMemory ( - ACPI_PHYSICAL_ADDRESS Where, - ACPI_SIZE Length); -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsMapMemory - -void -AcpiOsUnmapMemory ( - void __iomem *LogicalAddress, - ACPI_SIZE Size); -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsUnmapMemory - -/* - * OSL interfaces used by debugger/disassembler - */ -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable - -/* - * OSL interfaces used by utilities - */ -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRedirectOutput -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByName -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByIndex -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByAddress -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenDirectory -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetNextFilename -#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseDirectory - -/* - * OSL interfaces added by Linux - */ -void -EarlyAcpiOsUnmapMemory ( - void __iomem *Virt, - ACPI_SIZE Size); - -#endif /* __KERNEL__ */ - #endif /* __ACLINUX_H__ */ diff --git a/source/include/platform/aclinuxex.h b/source/include/platform/aclinuxex.h new file mode 100644 index 0000000..c51f90c --- /dev/null +++ b/source/include/platform/aclinuxex.h @@ -0,0 +1,127 @@ +/****************************************************************************** + * + * Name: aclinuxex.h - Extra OS specific defines, etc. for Linux + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef __ACLINUXEX_H__ +#define __ACLINUXEX_H__ + +#ifdef __KERNEL__ + +/* + * Overrides for in-kernel ACPICA + */ +ACPI_STATUS __init AcpiOsInitialize ( + void); + +ACPI_STATUS AcpiOsTerminate ( + void); + +/* + * The irqs_disabled() check is for resume from RAM. + * Interrupts are off during resume, just like they are for boot. + * However, boot has (system_state != SYSTEM_RUNNING) + * to quiet __might_sleep() in kmalloc() and resume does not. + */ +static inline void * +AcpiOsAllocate ( + ACPI_SIZE Size) +{ + return kmalloc (Size, irqs_disabled () ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void * +AcpiOsAllocateZeroed ( + ACPI_SIZE Size) +{ + return kzalloc (Size, irqs_disabled () ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void +AcpiOsFree ( + void *Memory) +{ + kfree (Memory); +} + +static inline void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache) +{ + return kmem_cache_zalloc (Cache, + irqs_disabled () ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (ACPI_THREAD_ID) (unsigned long) current; +} + +/* + * When lockdep is enabled, the spin_lock_init() macro stringifies it's + * argument and uses that as a name for the lock in debugging. + * By executing spin_lock_init() in a macro the key changes from "lock" for + * all locks to the name of the argument of acpi_os_create_lock(), which + * prevents lockdep from reporting false positives for ACPICA locks. + */ +#define AcpiOsCreateLock(__Handle) \ + ({ \ + spinlock_t *Lock = ACPI_ALLOCATE(sizeof(*Lock)); \ + if (Lock) { \ + *(__Handle) = Lock; \ + spin_lock_init(*(__Handle)); \ + } \ + Lock ? AE_OK : AE_NO_MEMORY; \ + }) + +/* + * OSL interfaces added by Linux + */ +void +EarlyAcpiOsUnmapMemory ( + void __iomem *Virt, + ACPI_SIZE Size); + +#endif /* __KERNEL__ */ + +#endif /* __ACLINUXEX_H__ */ diff --git a/source/os_specific/service_layers/osefitbl.c b/source/os_specific/service_layers/osefitbl.c new file mode 100644 index 0000000..341f3dd --- /dev/null +++ b/source/os_specific/service_layers/osefitbl.c @@ -0,0 +1,1033 @@ +/****************************************************************************** + * + * Module Name: osefitbl - EFI OSL for obtaining ACPI tables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpidump.h" + + +#define _COMPONENT ACPI_OS_SERVICES + ACPI_MODULE_NAME ("osefitbl") + + +#ifndef PATH_MAX +#define PATH_MAX 256 +#endif + + +/* List of information about obtained ACPI tables */ + +typedef struct osl_table_info +{ + struct osl_table_info *Next; + UINT32 Instance; + char Signature[ACPI_NAME_SIZE]; + +} OSL_TABLE_INFO; + +/* Local prototypes */ + +static ACPI_STATUS +OslTableInitialize ( + void); + +static ACPI_STATUS +OslAddTableToList ( + char *Signature, + UINT32 Instance); + +static ACPI_STATUS +OslMapTable ( + ACPI_SIZE Address, + char *Signature, + ACPI_TABLE_HEADER **Table); + +static void +OslUnmapTable ( + ACPI_TABLE_HEADER *Table); + +static ACPI_STATUS +OslLoadRsdp ( + void); + +static ACPI_STATUS +OslListTables ( + void); + +static ACPI_STATUS +OslGetTable ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **Table, + ACPI_PHYSICAL_ADDRESS *Address); + + +/* File locations */ + +#define EFI_SYSTAB "/sys/firmware/efi/systab" + +/* Initialization flags */ + +UINT8 Gbl_TableListInitialized = FALSE; + +/* Local copies of main ACPI tables */ + +ACPI_TABLE_RSDP Gbl_Rsdp; +ACPI_TABLE_FADT *Gbl_Fadt = NULL; +ACPI_TABLE_RSDT *Gbl_Rsdt = NULL; +ACPI_TABLE_XSDT *Gbl_Xsdt = NULL; + +/* Table addresses */ + +ACPI_PHYSICAL_ADDRESS Gbl_FadtAddress = 0; +ACPI_PHYSICAL_ADDRESS Gbl_RsdpAddress = 0; + +/* Revision of RSD PTR */ + +UINT8 Gbl_Revision = 0; + +OSL_TABLE_INFO *Gbl_TableListHead = NULL; +UINT32 Gbl_TableCount = 0; + + +/****************************************************************************** + * + * FUNCTION: AcpiOsGetTableByAddress + * + * PARAMETERS: Address - Physical address of the ACPI table + * Table - Where a pointer to the table is returned + * + * RETURN: Status; Table buffer is returned if AE_OK. + * AE_NOT_FOUND: A valid table was not found at the address + * + * DESCRIPTION: Get an ACPI table via a physical memory address. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsGetTableByAddress ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER **Table) +{ + UINT32 TableLength; + ACPI_TABLE_HEADER *MappedTable; + ACPI_TABLE_HEADER *LocalTable = NULL; + ACPI_STATUS Status = AE_OK; + + + /* Get main ACPI tables from memory on first invocation of this function */ + + Status = OslTableInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Map the table and validate it */ + + Status = OslMapTable (Address, NULL, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Copy table to local buffer and return it */ + + TableLength = ApGetTableLength (MappedTable); + if (TableLength == 0) + { + Status = AE_BAD_HEADER; + goto Exit; + } + + LocalTable = ACPI_ALLOCATE_ZEROED (TableLength); + if (!LocalTable) + { + Status = AE_NO_MEMORY; + goto Exit; + } + + ACPI_MEMCPY (LocalTable, MappedTable, TableLength); + +Exit: + OslUnmapTable (MappedTable); + *Table = LocalTable; + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsGetTableByName + * + * PARAMETERS: Signature - ACPI Signature for desired table. Must be + * a null terminated 4-character string. + * Instance - Multiple table support for SSDT/UEFI (0...n) + * Must be 0 for other tables. + * Table - Where a pointer to the table is returned + * Address - Where the table physical address is returned + * + * RETURN: Status; Table buffer and physical address returned if AE_OK. + * AE_LIMIT: Instance is beyond valid limit + * AE_NOT_FOUND: A table with the signature was not found + * + * NOTE: Assumes the input signature is uppercase. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsGetTableByName ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **Table, + ACPI_PHYSICAL_ADDRESS *Address) +{ + ACPI_STATUS Status; + + + /* Get main ACPI tables from memory on first invocation of this function */ + + Status = OslTableInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Not a main ACPI table, attempt to extract it from the RSDT/XSDT */ + + if (!Gbl_DumpCustomizedTables) + { + /* Attempt to get the table from the memory */ + + Status = OslGetTable (Signature, Instance, Table, Address); + } + else + { + /* Attempt to get the table from the static directory */ + + Status = AE_SUPPORT; + } + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: OslAddTableToList + * + * PARAMETERS: Signature - Table signature + * Instance - Table instance + * + * RETURN: Status; Successfully added if AE_OK. + * AE_NO_MEMORY: Memory allocation error + * + * DESCRIPTION: Insert a table structure into OSL table list. + * + *****************************************************************************/ + +static ACPI_STATUS +OslAddTableToList ( + char *Signature, + UINT32 Instance) +{ + OSL_TABLE_INFO *NewInfo; + OSL_TABLE_INFO *Next; + UINT32 NextInstance = 0; + BOOLEAN Found = FALSE; + + + NewInfo = ACPI_ALLOCATE_ZEROED (sizeof (OSL_TABLE_INFO)); + if (!NewInfo) + { + return (AE_NO_MEMORY); + } + + ACPI_MOVE_NAME (NewInfo->Signature, Signature); + + if (!Gbl_TableListHead) + { + Gbl_TableListHead = NewInfo; + } + else + { + Next = Gbl_TableListHead; + while (1) + { + if (ACPI_COMPARE_NAME (Next->Signature, Signature)) + { + if (Next->Instance == Instance) + { + Found = TRUE; + } + if (Next->Instance >= NextInstance) + { + NextInstance = Next->Instance + 1; + } + } + + if (!Next->Next) + { + break; + } + Next = Next->Next; + } + Next->Next = NewInfo; + } + + if (Found) + { + if (Instance) + { + AcpiLogError ( + "%4.4s: Warning unmatched table instance %d, expected %d\n", + Signature, Instance, NextInstance); + } + Instance = NextInstance; + } + + NewInfo->Instance = Instance; + Gbl_TableCount++; + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsGetTableByIndex + * + * PARAMETERS: Index - Which table to get + * Table - Where a pointer to the table is returned + * Instance - Where a pointer to the table instance no. is + * returned + * Address - Where the table physical address is returned + * + * RETURN: Status; Table buffer and physical address returned if AE_OK. + * AE_LIMIT: Index is beyond valid limit + * + * DESCRIPTION: Get an ACPI table via an index value (0 through n). Returns + * AE_LIMIT when an invalid index is reached. Index is not + * necessarily an index into the RSDT/XSDT. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsGetTableByIndex ( + UINT32 Index, + ACPI_TABLE_HEADER **Table, + UINT32 *Instance, + ACPI_PHYSICAL_ADDRESS *Address) +{ + OSL_TABLE_INFO *Info; + ACPI_STATUS Status; + UINT32 i; + + + /* Get main ACPI tables from memory on first invocation of this function */ + + Status = OslTableInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Validate Index */ + + if (Index >= Gbl_TableCount) + { + return (AE_LIMIT); + } + + /* Point to the table list entry specified by the Index argument */ + + Info = Gbl_TableListHead; + for (i = 0; i < Index; i++) + { + Info = Info->Next; + } + + /* Now we can just get the table via the signature */ + + Status = AcpiOsGetTableByName (Info->Signature, Info->Instance, + Table, Address); + + if (ACPI_SUCCESS (Status)) + { + *Instance = Info->Instance; + } + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: OslLoadRsdp + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Scan and load RSDP. + * + *****************************************************************************/ + +static ACPI_STATUS +OslLoadRsdp ( + void) +{ + ACPI_TABLE_HEADER *MappedTable; + UINT8 *RsdpAddress; + ACPI_PHYSICAL_ADDRESS RsdpBase; + ACPI_SIZE RsdpSize; + + + /* Get RSDP from memory */ + + RsdpSize = sizeof (ACPI_TABLE_RSDP); + if (Gbl_RsdpBase) + { + RsdpBase = Gbl_RsdpBase; + } + else + { + RsdpBase = AcpiOsGetRootPointer (); + } + + if (!RsdpBase) + { + RsdpBase = ACPI_HI_RSDP_WINDOW_BASE; + RsdpSize = ACPI_HI_RSDP_WINDOW_SIZE; + } + + RsdpAddress = AcpiOsMapMemory (RsdpBase, RsdpSize); + if (!RsdpAddress) + { + return (AE_BAD_ADDRESS); + } + + /* Search low memory for the RSDP */ + + MappedTable = ACPI_CAST_PTR (ACPI_TABLE_HEADER, + AcpiTbScanMemoryForRsdp (RsdpAddress, RsdpSize)); + if (!MappedTable) + { + AcpiOsUnmapMemory (RsdpAddress, RsdpSize); + return (AE_NOT_FOUND); + } + + Gbl_RsdpAddress = RsdpBase + (ACPI_CAST8 (MappedTable) - RsdpAddress); + + ACPI_MEMCPY (&Gbl_Rsdp, MappedTable, sizeof (ACPI_TABLE_RSDP)); + AcpiOsUnmapMemory (RsdpAddress, RsdpSize); + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: OslCanUseXsdt + * + * PARAMETERS: None + * + * RETURN: TRUE if XSDT is allowed to be used. + * + * DESCRIPTION: This function collects logic that can be used to determine if + * XSDT should be used instead of RSDT. + * + *****************************************************************************/ + +static BOOLEAN +OslCanUseXsdt ( + void) +{ + if (Gbl_Revision && !AcpiGbl_DoNotUseXsdt) + { + return (TRUE); + } + else + { + return (FALSE); + } +} + + +/****************************************************************************** + * + * FUNCTION: OslTableInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize ACPI table data. Get and store main ACPI tables to + * local variables. Main ACPI tables include RSDT, FADT, RSDT, + * and/or XSDT. + * + *****************************************************************************/ + +static ACPI_STATUS +OslTableInitialize ( + void) +{ + ACPI_STATUS Status; + ACPI_PHYSICAL_ADDRESS Address; + + + if (Gbl_TableListInitialized) + { + return (AE_OK); + } + + /* Get RSDP from memory */ + + Status = OslLoadRsdp (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Get XSDT from memory */ + + if (Gbl_Rsdp.Revision && !Gbl_DoNotDumpXsdt) + { + if (Gbl_Xsdt) + { + ACPI_FREE (Gbl_Xsdt); + Gbl_Xsdt = NULL; + } + + Gbl_Revision = 2; + Status = OslGetTable (ACPI_SIG_XSDT, 0, + ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Xsdt), &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* Get RSDT from memory */ + + if (Gbl_Rsdp.RsdtPhysicalAddress) + { + if (Gbl_Rsdt) + { + ACPI_FREE (Gbl_Rsdt); + Gbl_Rsdt = NULL; + } + + Status = OslGetTable (ACPI_SIG_RSDT, 0, + ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Rsdt), &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* Get FADT from memory */ + + if (Gbl_Fadt) + { + ACPI_FREE (Gbl_Fadt); + Gbl_Fadt = NULL; + } + + Status = OslGetTable (ACPI_SIG_FADT, 0, + ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Fadt), &Gbl_FadtAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Gbl_DumpCustomizedTables) + { + /* Add mandatory tables to global table list first */ + + Status = OslAddTableToList (ACPI_RSDP_NAME, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = OslAddTableToList (ACPI_SIG_RSDT, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Gbl_Revision == 2) + { + Status = OslAddTableToList (ACPI_SIG_XSDT, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + Status = OslAddTableToList (ACPI_SIG_DSDT, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = OslAddTableToList (ACPI_SIG_FACS, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Add all tables found in the memory */ + + Status = OslListTables (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + else + { + /* Add all tables found in the static directory */ + + Status = AE_SUPPORT; + } + + Gbl_TableListInitialized = TRUE; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: OslListTables + * + * PARAMETERS: None + * + * RETURN: Status; Table list is initialized if AE_OK. + * + * DESCRIPTION: Add ACPI tables to the table list from memory. + * + *****************************************************************************/ + +static ACPI_STATUS +OslListTables ( + void) +{ + ACPI_TABLE_HEADER *MappedTable = NULL; + UINT8 *TableData; + UINT8 NumberOfTables; + UINT8 ItemSize; + ACPI_PHYSICAL_ADDRESS TableAddress = 0; + ACPI_STATUS Status = AE_OK; + UINT32 i; + + + if (OslCanUseXsdt ()) + { + ItemSize = sizeof (UINT64); + TableData = ACPI_CAST8 (Gbl_Xsdt) + sizeof (ACPI_TABLE_HEADER); + NumberOfTables = + (UINT8) ((Gbl_Xsdt->Header.Length - sizeof (ACPI_TABLE_HEADER)) + / ItemSize); + } + else /* Use RSDT if XSDT is not available */ + { + ItemSize = sizeof (UINT32); + TableData = ACPI_CAST8 (Gbl_Rsdt) + sizeof (ACPI_TABLE_HEADER); + NumberOfTables = + (UINT8) ((Gbl_Rsdt->Header.Length - sizeof (ACPI_TABLE_HEADER)) + / ItemSize); + } + + /* Search RSDT/XSDT for the requested table */ + + for (i = 0; i < NumberOfTables; ++i, TableData += ItemSize) + { + if (OslCanUseXsdt ()) + { + TableAddress = + (ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST64 (TableData)); + } + else + { + TableAddress = + (ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST32 (TableData)); + } + + /* Skip NULL entries in RSDT/XSDT */ + + if (!TableAddress) + { + continue; + } + + Status = OslMapTable (TableAddress, NULL, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + OslAddTableToList (MappedTable->Signature, 0); + OslUnmapTable (MappedTable); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: OslGetTable + * + * PARAMETERS: Signature - ACPI Signature for common table. Must be + * a null terminated 4-character string. + * Instance - Multiple table support for SSDT/UEFI (0...n) + * Must be 0 for other tables. + * Table - Where a pointer to the table is returned + * Address - Where the table physical address is returned + * + * RETURN: Status; Table buffer and physical address returned if AE_OK. + * AE_LIMIT: Instance is beyond valid limit + * AE_NOT_FOUND: A table with the signature was not found + * + * DESCRIPTION: Get a BIOS provided ACPI table + * + * NOTE: Assumes the input signature is uppercase. + * + *****************************************************************************/ + +static ACPI_STATUS +OslGetTable ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **Table, + ACPI_PHYSICAL_ADDRESS *Address) +{ + ACPI_TABLE_HEADER *LocalTable = NULL; + ACPI_TABLE_HEADER *MappedTable = NULL; + UINT8 *TableData; + UINT8 NumberOfTables; + UINT8 ItemSize; + UINT32 CurrentInstance = 0; + ACPI_PHYSICAL_ADDRESS TableAddress = 0; + UINT32 TableLength = 0; + ACPI_STATUS Status = AE_OK; + UINT32 i; + + + /* Handle special tables whose addresses are not in RSDT/XSDT */ + + if (ACPI_COMPARE_NAME (Signature, ACPI_RSDP_NAME) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_RSDT) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_XSDT) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) + { + /* + * Get the appropriate address, either 32-bit or 64-bit. Be very + * careful about the FADT length and validate table addresses. + * Note: The 64-bit addresses have priority. + */ + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT)) + { + if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_XDSDT) && + Gbl_Fadt->XDsdt) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->XDsdt; + } + else if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_DSDT) && + Gbl_Fadt->Dsdt) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->Dsdt; + } + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) + { + if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_XFACS) && + Gbl_Fadt->XFacs) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->XFacs; + } + else if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_FACS) && + Gbl_Fadt->Facs) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->Facs; + } + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_XSDT)) + { + if (!Gbl_Revision) + { + return (AE_BAD_SIGNATURE); + } + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Rsdp.XsdtPhysicalAddress; + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_RSDT)) + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Rsdp.RsdtPhysicalAddress; + } + else + { + TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_RsdpAddress; + Signature = ACPI_SIG_RSDP; + } + + /* Now we can get the requested special table */ + + Status = OslMapTable (TableAddress, Signature, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + TableLength = ApGetTableLength (MappedTable); + } + else /* Case for a normal ACPI table */ + { + if (OslCanUseXsdt ()) + { + ItemSize = sizeof (UINT64); + TableData = ACPI_CAST8 (Gbl_Xsdt) + sizeof (ACPI_TABLE_HEADER); + NumberOfTables = + (UINT8) ((Gbl_Xsdt->Header.Length - sizeof (ACPI_TABLE_HEADER)) + / ItemSize); + } + else /* Use RSDT if XSDT is not available */ + { + ItemSize = sizeof (UINT32); + TableData = ACPI_CAST8 (Gbl_Rsdt) + sizeof (ACPI_TABLE_HEADER); + NumberOfTables = + (UINT8) ((Gbl_Rsdt->Header.Length - sizeof (ACPI_TABLE_HEADER)) + / ItemSize); + } + + /* Search RSDT/XSDT for the requested table */ + + for (i = 0; i < NumberOfTables; ++i, TableData += ItemSize) + { + if (OslCanUseXsdt ()) + { + TableAddress = + (ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST64 (TableData)); + } + else + { + TableAddress = + (ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST32 (TableData)); + } + + /* Skip NULL entries in RSDT/XSDT */ + + if (!TableAddress) + { + continue; + } + + Status = OslMapTable (TableAddress, NULL, &MappedTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + TableLength = MappedTable->Length; + + /* Does this table match the requested signature? */ + + if (!ACPI_COMPARE_NAME (MappedTable->Signature, Signature)) + { + OslUnmapTable (MappedTable); + MappedTable = NULL; + continue; + } + + /* Match table instance (for SSDT/UEFI tables) */ + + if (CurrentInstance != Instance) + { + OslUnmapTable (MappedTable); + MappedTable = NULL; + CurrentInstance++; + continue; + } + + break; + } + } + + if (!MappedTable) + { + return (AE_LIMIT); + } + + if (TableLength == 0) + { + Status = AE_BAD_HEADER; + goto Exit; + } + + /* Copy table to local buffer and return it */ + + LocalTable = ACPI_ALLOCATE_ZEROED (TableLength); + if (!LocalTable) + { + Status = AE_NO_MEMORY; + goto Exit; + } + + ACPI_MEMCPY (LocalTable, MappedTable, TableLength); + *Address = TableAddress; + *Table = LocalTable; + +Exit: + OslUnmapTable (MappedTable); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: OslMapTable + * + * PARAMETERS: Address - Address of the table in memory + * Signature - Optional ACPI Signature for desired table. + * Null terminated 4-character string. + * Table - Where a pointer to the mapped table is + * returned + * + * RETURN: Status; Mapped table is returned if AE_OK. + * AE_NOT_FOUND: A valid table was not found at the address + * + * DESCRIPTION: Map entire ACPI table into caller's address space. + * + *****************************************************************************/ + +static ACPI_STATUS +OslMapTable ( + ACPI_SIZE Address, + char *Signature, + ACPI_TABLE_HEADER **Table) +{ + ACPI_TABLE_HEADER *MappedTable; + UINT32 Length; + + + if (!Address) + { + return (AE_BAD_ADDRESS); + } + + /* + * Map the header so we can get the table length. + * Use sizeof (ACPI_TABLE_HEADER) as: + * 1. it is bigger than 24 to include RSDP->Length + * 2. it is smaller than sizeof (ACPI_TABLE_RSDP) + */ + MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!MappedTable) + { + AcpiLogError ("Could not map table header at 0x%8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Address)); + return (AE_BAD_ADDRESS); + } + + /* If specified, signature must match */ + + if (Signature) + { + if (ACPI_VALIDATE_RSDP_SIG (Signature)) + { + if (!ACPI_VALIDATE_RSDP_SIG (MappedTable->Signature)) + { + AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER)); + return (AE_BAD_SIGNATURE); + } + } + else if (!ACPI_COMPARE_NAME (Signature, MappedTable->Signature)) + { + AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER)); + return (AE_BAD_SIGNATURE); + } + } + + /* Map the entire table */ + + Length = ApGetTableLength (MappedTable); + AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER)); + if (Length == 0) + { + return (AE_BAD_HEADER); + } + + MappedTable = AcpiOsMapMemory (Address, Length); + if (!MappedTable) + { + AcpiLogError ("Could not map table at 0x%8.8X%8.8X length %8.8X\n", + ACPI_FORMAT_UINT64 (Address), Length); + return (AE_INVALID_TABLE_LENGTH); + } + + (void) ApIsValidChecksum (MappedTable); + + *Table = MappedTable; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: OslUnmapTable + * + * PARAMETERS: Table - A pointer to the mapped table + * + * RETURN: None + * + * DESCRIPTION: Unmap entire ACPI table. + * + *****************************************************************************/ + +static void +OslUnmapTable ( + ACPI_TABLE_HEADER *Table) +{ + if (Table) + { + AcpiOsUnmapMemory (Table, ApGetTableLength (Table)); + } +} diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c new file mode 100644 index 0000000..bbb68d8 --- /dev/null +++ b/source/os_specific/service_layers/osefixf.c @@ -0,0 +1,1083 @@ +/****************************************************************************** + * + * Module Name: osefixf - EFI OSL interfaces + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include "acpi.h" +#include "accommon.h" +#include "acapps.h" + + +/* Local definitions */ + +#define ACPI_EFI_PRINT_LENGTH 256 + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiEfiArgify ( + char *String, + int *ArgcPtr, + char ***ArgvPtr); + +static BOOLEAN +AcpiEfiCompareGuid ( + EFI_GUID *Guid1, + EFI_GUID *Guid2); + +static ACPI_STATUS +AcpiEfiConvertArgcv ( + CHAR16 *LoadOpt, + UINT32 LoadOptSize, + int *ArgcPtr, + char ***ArgvPtr, + char **BufferPtr); + +static ACPI_PHYSICAL_ADDRESS +AcpiEfiGetRsdpViaGuid ( + EFI_GUID *Guid); + +static CHAR16 * +AcpiEfiFlushFile ( + ACPI_FILE File, + CHAR16 *Begin, + CHAR16 *End, + CHAR16 *Pos, + BOOLEAN FlushAll); + + +/* Local variables */ + +static EFI_FILE_HANDLE AcpiGbl_EfiCurrentVolume = NULL; + + +/****************************************************************************** + * + * FUNCTION: AcpiEfiGetRsdpViaGuid + * + * PARAMETERS: Guid1 - GUID to compare + * Guid2 - GUID to compare + * + * RETURN: TRUE if Guid1 == Guid2 + * + * DESCRIPTION: Compares two GUIDs + * + *****************************************************************************/ + +static BOOLEAN +AcpiEfiCompareGuid ( + EFI_GUID *Guid1, + EFI_GUID *Guid2) +{ + INT32 *g1; + INT32 *g2; + INT32 r; + + + g1 = (INT32 *) Guid1; + g2 = (INT32 *) Guid2; + + r = g1[0] - g2[0]; + r |= g1[1] - g2[1]; + r |= g1[2] - g2[2]; + r |= g1[3] - g2[3]; + + return (r ? FALSE : TRUE); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEfiGetRsdpViaGuid + * + * PARAMETERS: None + * + * RETURN: RSDP address if found + * + * DESCRIPTION: Find RSDP address via EFI using specified GUID. + * + *****************************************************************************/ + +static ACPI_PHYSICAL_ADDRESS +AcpiEfiGetRsdpViaGuid ( + EFI_GUID *Guid) +{ + unsigned long Address = 0; + int i; + + + for (i = 0; i < ST->NumberOfTableEntries; i++) + { + if (AcpiEfiCompareGuid (&ST->ConfigurationTable[i].VendorGuid, Guid)) + { + Address = (ACPI_PHYSICAL_ADDRESS) + ST->ConfigurationTable[i].VendorTable; + break; + } + } + + return ((ACPI_PHYSICAL_ADDRESS) (Address)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsGetRootPointer + * + * PARAMETERS: None + * + * RETURN: RSDP physical address + * + * DESCRIPTION: Gets the ACPI root pointer (RSDP) + * + *****************************************************************************/ + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void) +{ + ACPI_PHYSICAL_ADDRESS Address; + EFI_GUID Guid10 = ACPI_TABLE_GUID; + EFI_GUID Guid20 = ACPI_20_TABLE_GUID; + + + Address = AcpiEfiGetRsdpViaGuid (&Guid20); + if (!Address) + { + Address = AcpiEfiGetRsdpViaGuid (&Guid10); + } + + return (Address); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsMapMemory + * + * PARAMETERS: where - Physical address of memory to be mapped + * length - How much memory to map + * + * RETURN: Pointer to mapped memory. Null on error. + * + * DESCRIPTION: Map physical memory into caller's address space + * + *****************************************************************************/ + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS where, + ACPI_SIZE length) +{ + + return (ACPI_TO_POINTER ((ACPI_SIZE) where)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsUnmapMemory + * + * PARAMETERS: where - Logical address of memory to be unmapped + * length - How much memory to unmap + * + * RETURN: None + * + * DESCRIPTION: Delete a previously created mapping. Where and Length must + * correspond to a previous mapping exactly. + * + *****************************************************************************/ + +void +AcpiOsUnmapMemory ( + void *where, + ACPI_SIZE length) +{ + + return; +} + + +/****************************************************************************** + * + * FUNCTION: Spinlock interfaces + * + * DESCRIPTION: No-op on single threaded BIOS + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle) +{ + return (AE_OK); +} + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle) +{ +} + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_SPINLOCK Handle) +{ + return (0); +} + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags) +{ +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsAllocate + * + * PARAMETERS: Size - Amount to allocate, in bytes + * + * RETURN: Pointer to the new allocation. Null on error. + * + * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. + * + *****************************************************************************/ + +void * +AcpiOsAllocate ( + ACPI_SIZE Size) +{ + EFI_STATUS EfiStatus; + void *Mem; + + + EfiStatus = uefi_call_wrapper (BS->AllocatePool, 3, + EfiLoaderData, Size, &Mem); + if (EFI_ERROR (EfiStatus)) + { + AcpiLogError ("EFI_BOOT_SERVICES->AllocatePool(EfiLoaderData) failure.\n"); + return (NULL); + } + + return (Mem); +} + + +#ifdef USE_NATIVE_ALLOCATE_ZEROED +/****************************************************************************** + * + * FUNCTION: AcpiOsAllocateZeroed + * + * PARAMETERS: Size - Amount to allocate, in bytes + * + * RETURN: Pointer to the new allocation. Null on error. + * + * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS. + * + *****************************************************************************/ + +void * +AcpiOsAllocateZeroed ( + ACPI_SIZE Size) +{ + void *Mem; + + + Mem = AcpiOsAllocate (Size); + if (Mem) + { + ACPI_MEMSET (Mem, 0, Size); + } + + return (Mem); +} +#endif + + +/****************************************************************************** + * + * FUNCTION: AcpiOsFree + * + * PARAMETERS: Mem - Pointer to previously allocated memory + * + * RETURN: None + * + * DESCRIPTION: Free memory allocated via AcpiOsAllocate + * + *****************************************************************************/ + +void +AcpiOsFree ( + void *Mem) +{ + + uefi_call_wrapper (BS->FreePool, 1, Mem); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsOpenFile + * + * PARAMETERS: Path - File path + * Modes - File operation type + * + * RETURN: File descriptor + * + * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing + * (ACPI_FILE_WRITING). + * + ******************************************************************************/ + +ACPI_FILE +AcpiOsOpenFile ( + const char *Path, + UINT8 Modes) +{ + EFI_STATUS EfiStatus = EFI_SUCCESS; + UINT64 OpenModes; + EFI_FILE_HANDLE EfiFile = NULL; + CHAR16 *Path16 = NULL; + CHAR16 *Pos16; + const char *Pos; + INTN Count, i; + + + if (!Path) + { + return (NULL); + } + + /* Convert modes */ + + OpenModes = EFI_FILE_MODE_READ; + if (Modes & ACPI_FILE_WRITING) + { + OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); + } + + /* Allocate path buffer */ + + Count = ACPI_STRLEN (Path); + Path16 = ACPI_ALLOCATE_ZEROED ((Count + 1) * sizeof (CHAR16)); + if (!Path16) + { + EfiStatus = EFI_BAD_BUFFER_SIZE; + goto ErrorExit; + } + Pos = Path; + Pos16 = Path16; + while (*Pos == '/' || *Pos == '\\') + { + Pos++; + Count--; + } + for (i = 0; i < Count; i++) + { + if (*Pos == '/') + { + *Pos16++ = '\\'; + Pos++; + } + else + { + *Pos16++ = *Pos++; + } + } + *Pos16 = '\0'; + + EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Open, 5, + AcpiGbl_EfiCurrentVolume, &EfiFile, Path16, OpenModes, 0); + if (EFI_ERROR (EfiStatus)) + { + AcpiLogError ("EFI_FILE_HANDLE->Open() failure.\n"); + goto ErrorExit; + } + +ErrorExit: + + if (Path16) + { + ACPI_FREE (Path16); + } + + return ((ACPI_FILE) EfiFile); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsCloseFile + * + * PARAMETERS: File - File descriptor + * + * RETURN: None. + * + * DESCRIPTION: Close a file. + * + ******************************************************************************/ + +void +AcpiOsCloseFile ( + ACPI_FILE File) +{ + EFI_FILE_HANDLE EfiFile; + + + if (File == ACPI_FILE_OUT || + File == ACPI_FILE_ERR) + { + return; + } + EfiFile = (EFI_FILE_HANDLE) File; + (void) uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Close, 1, EfiFile); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsReadFile + * + * PARAMETERS: File - File descriptor + * Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks + * + * RETURN: Size of successfully read buffer + * + * DESCRIPTION: Read from a file. + * + ******************************************************************************/ + +int +AcpiOsReadFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count) +{ + int Length = -1; + EFI_FILE_HANDLE EfiFile; + UINTN ReadSize; + EFI_STATUS EfiStatus; + + + if (File == ACPI_FILE_OUT || + File == ACPI_FILE_ERR) + { + } + else + { + EfiFile = (EFI_FILE_HANDLE) File; + if (!EfiFile) + { + goto ErrorExit; + } + ReadSize = Size * Count; + + EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Read, 3, + EfiFile, &ReadSize, Buffer); + if (EFI_ERROR (EfiStatus)) + { + AcpiLogError ("EFI_FILE_HANDLE->Read() failure.\n"); + goto ErrorExit; + } + Length = ReadSize; + } + +ErrorExit: + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEfiFlushFile + * + * PARAMETERS: File - File descriptor + * Begin - String with boundary + * End - Boundary of the string + * Pos - Current position + * FlushAll - Whether checking boundary before flushing + * + * RETURN: Updated position + * + * DESCRIPTION: Flush cached buffer to the file. + * + ******************************************************************************/ + +static CHAR16 * +AcpiEfiFlushFile ( + ACPI_FILE File, + CHAR16 *Begin, + CHAR16 *End, + CHAR16 *Pos, + BOOLEAN FlushAll) +{ + + if (FlushAll || Pos >= (End - 1)) + { + *Pos = 0; + uefi_call_wrapper (File->OutputString, 2, File, Begin); + Pos = Begin; + } + + return (Pos); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsWriteFile + * + * PARAMETERS: File - File descriptor + * Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks + * + * RETURN: Size of successfully written buffer + * + * DESCRIPTION: Write to a file. + * + ******************************************************************************/ + +int +AcpiOsWriteFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count) +{ + int Length = -1; + CHAR16 String[ACPI_EFI_PRINT_LENGTH]; + const char *Ascii; + CHAR16 *End; + CHAR16 *Pos; + int i, j; + EFI_FILE_HANDLE EfiFile; + UINTN WriteSize; + EFI_STATUS EfiStatus; + + + if (File == ACPI_FILE_OUT || + File == ACPI_FILE_ERR) + { + Pos = String; + End = String + ACPI_EFI_PRINT_LENGTH - 1; + Ascii = ACPI_CAST_PTR (const char, Buffer); + Length = 0; + + for (j = 0; j < Count; j++) + { + for (i = 0; i < Size; i++) + { + if (*Ascii == '\n') + { + *Pos++ = '\r'; + Pos = AcpiEfiFlushFile (File, String, + End, Pos, FALSE); + } + *Pos++ = *Ascii++; + Length++; + Pos = AcpiEfiFlushFile (File, String, + End, Pos, FALSE); + } + } + Pos = AcpiEfiFlushFile (File, String, End, Pos, TRUE); + } + else + { + EfiFile = (EFI_FILE_HANDLE) File; + if (!EfiFile) + { + goto ErrorExit; + } + WriteSize = Size * Count; + + EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Write, 3, + EfiFile, &WriteSize, Buffer); + if (EFI_ERROR (EfiStatus)) + { + AcpiLogError ("EFI_FILE_HANDLE->Write() failure.\n"); + goto ErrorExit; + } + Length = WriteSize; + } + +ErrorExit: + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsGetFileOffset + * + * PARAMETERS: File - File descriptor + * + * RETURN: Size of current position + * + * DESCRIPTION: Get current file offset. + * + ******************************************************************************/ + +long +AcpiOsGetFileOffset ( + ACPI_FILE File) +{ + long Offset = -1; + + + return (Offset); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsSetFileOffset + * + * PARAMETERS: File - File descriptor + * Offset - File offset + * From - From begin/end of file + * + * RETURN: Status + * + * DESCRIPTION: Set current file offset. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsSetFileOffset ( + ACPI_FILE File, + long Offset, + UINT8 From) +{ + + return (AE_SUPPORT); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsPrintf + * + * PARAMETERS: Format, ... - Standard printf format + * + * RETURN: None + * + * DESCRIPTION: Formatted output. + * + *****************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Format, + ...) +{ + va_list Args; + + + va_start (Args, Format); + AcpiOsVprintf (Format, Args); + va_end (Args); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsVprintf + * + * PARAMETERS: Format - Standard printf format + * Args - Argument list + * + * RETURN: None + * + * DESCRIPTION: Formatted output with arguments list pointer. + * + *****************************************************************************/ + +void +AcpiOsVprintf ( + const char *Format, + va_list Args) +{ + + (void) AcpiUtFileVprintf (ACPI_FILE_OUT, Format, Args); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize this module. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsInitialize ( + void) +{ + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEfiArgify + * + * PARAMETERS: String - Pointer to command line argument strings + * which are seperated with spaces + * ArgcPtr - Return number of the arguments + * ArgvPtr - Return vector of the arguments + * + * RETURN: Status + * + * DESCRIPTION: Convert EFI arguments into C arguments. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiEfiArgify ( + char *String, + int *ArgcPtr, + char ***ArgvPtr) +{ + char *CopyBuffer; + int MaxArgc = *ArgcPtr; + int Argc = 0; + char **Argv = *ArgvPtr; + char *Arg; + BOOLEAN IsSingleQuote = FALSE; + BOOLEAN IsDoubleQuote = FALSE; + BOOLEAN IsEscape = FALSE; + + + if (String == NULL) + { + return (AE_BAD_PARAMETER); + } + + CopyBuffer = String; + + while (*String != '\0') + { + while (ACPI_IS_SPACE (*String)) + { + *String++ = '\0'; + } + Arg = CopyBuffer; + while (*String != '\0') + { + if (ACPI_IS_SPACE (*String) && + !IsSingleQuote && !IsDoubleQuote && !IsEscape) + { + *Arg++ = '\0'; + String++; + break; + } + if (IsEscape) + { + IsEscape = FALSE; + *Arg++ = *String; + } + else if (*String == '\\') + { + IsEscape = TRUE; + } + else if (IsSingleQuote) + { + if (*String == '\'') + { + IsSingleQuote = FALSE; + *Arg++ = '\0'; + } + else + { + *Arg++ = *String; + } + } + else if (IsDoubleQuote) + { + if (*String == '"') + { + IsDoubleQuote = FALSE; + *Arg = '\0'; + } + else + { + *Arg++ = *String; + } + } + else + { + if (*String == '\'') + { + IsSingleQuote = TRUE; + } + else if (*String == '"') + { + IsDoubleQuote = TRUE; + } + else + { + *Arg++ = *String; + } + } + String++; + } + if (Argv && Argc < MaxArgc) + { + Argv[Argc] = CopyBuffer; + } + Argc++; + CopyBuffer = Arg; + } + if (Argv && Argc < MaxArgc) + { + Argv[Argc] = NULL; + } + + *ArgcPtr = Argc; + *ArgvPtr = Argv; + + return ((MaxArgc < Argc) ? AE_NO_MEMORY : AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEfiConvertArgcv + * + * PARAMETERS: LoadOptions - Pointer to the EFI options buffer, which + * is NULL terminated + * LoadOptionsSize - Size of the EFI options buffer + * ArgcPtr - Return number of the arguments + * ArgvPtr - Return vector of the arguments + * BufferPtr - Buffer to contain the argument strings + * + * RETURN: Status + * + * DESCRIPTION: Convert EFI arguments into C arguments. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiEfiConvertArgcv ( + CHAR16 *LoadOptions, + UINT32 LoadOptionsSize, + int *ArgcPtr, + char ***ArgvPtr, + char **BufferPtr) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Count = LoadOptionsSize / sizeof (CHAR16); + UINT32 i; + CHAR16 *From; + char *To; + int Argc = 0; + char **Argv = NULL; + char *Buffer; + + + /* Prepare a buffer to contain the argument strings */ + + Buffer = ACPI_ALLOCATE_ZEROED (Count); + if (!Buffer) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } + +TryAgain: + + /* Extend the argument vector */ + + if (Argv) + { + ACPI_FREE (Argv); + Argv = NULL; + } + if (Argc > 0) + { + Argv = ACPI_ALLOCATE_ZEROED (sizeof (char *) * (Argc + 1)); + if (!Argv) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } + } + + /* + * Note: As AcpiEfiArgify() will modify the content of the buffer, so + * we need to restore it each time before invoking + * AcpiEfiArgify(). + */ + From = LoadOptions; + To = ACPI_CAST_PTR (char, Buffer); + for (i = 0; i < Count; i++) + { + *To++ = (char) *From++; + } + + /* + * The "Buffer" will contain NULL terminated strings after invoking + * AcpiEfiArgify(). The number of the strings are saved in Argc and the + * pointers of the strings are saved in Argv. + */ + Status = AcpiEfiArgify (Buffer, &Argc, &Argv); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NO_MEMORY) + { + goto TryAgain; + } + } + +ErrorExit: + + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (Buffer); + ACPI_FREE (Argv); + } + else + { + *ArgcPtr = Argc; + *ArgvPtr = Argv; + *BufferPtr = Buffer; + } + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: efi_main + * + * PARAMETERS: Image - EFI image handle + * SystemTab - EFI system table + * + * RETURN: EFI Status + * + * DESCRIPTION: Entry point of EFI executable + * + *****************************************************************************/ + +EFI_STATUS +efi_main ( + EFI_HANDLE Image, + EFI_SYSTEM_TABLE *SystemTab) +{ + EFI_LOADED_IMAGE *Info; + EFI_STATUS EfiStatus = EFI_SUCCESS; + ACPI_STATUS Status; + int argc; + char **argv = NULL; + char *OptBuffer = NULL; + EFI_FILE_IO_INTERFACE *Volume = NULL; + + + /* Initialize EFI library */ + + InitializeLib (Image, SystemTab); + + /* Retrieve image information */ + + EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, + Image, &LoadedImageProtocol, ACPI_CAST_PTR (VOID, &Info)); + if (EFI_ERROR (EfiStatus)) + { + AcpiLogError ("EFI_BOOT_SERVICES->HandleProtocol(LoadedImageProtocol) failure.\n"); + return (EfiStatus); + } + EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, + Info->DeviceHandle, &FileSystemProtocol, (void **) &Volume); + if (EFI_ERROR (EfiStatus)) + { + AcpiLogError ("EFI_BOOT_SERVICES->HandleProtocol(FileSystemProtocol) failure.\n"); + return (EfiStatus); + } + EfiStatus = uefi_call_wrapper (Volume->OpenVolume, 2, + Volume, &AcpiGbl_EfiCurrentVolume); + if (EFI_ERROR (EfiStatus)) + { + AcpiLogError ("EFI_FILE_IO_INTERFACE->OpenVolume() failure.\n"); + return (EfiStatus); + } + + Status = AcpiEfiConvertArgcv (Info->LoadOptions, + Info->LoadOptionsSize, &argc, &argv, &OptBuffer); + if (ACPI_FAILURE (Status)) + { + EfiStatus = EFI_DEVICE_ERROR; + goto ErrorAlloc; + } + + acpi_main (argc, argv); + +ErrorAlloc: + + if (argv) + { + ACPI_FREE (argv); + } + if (OptBuffer) + { + ACPI_FREE (OptBuffer); + } + + return (EfiStatus); +} diff --git a/source/os_specific/service_layers/oslibcfs.c b/source/os_specific/service_layers/oslibcfs.c new file mode 100644 index 0000000..606e3a9 --- /dev/null +++ b/source/os_specific/service_layers/oslibcfs.c @@ -0,0 +1,255 @@ +/****************************************************************************** + * + * Module Name: oslibcfs - C library OSL for file I/O + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpi.h" +#include +#include + +#define _COMPONENT ACPI_OS_SERVICES + ACPI_MODULE_NAME ("oslibcfs") + + +/******************************************************************************* + * + * FUNCTION: AcpiOsOpenFile + * + * PARAMETERS: Path - File path + * Modes - File operation type + * + * RETURN: File descriptor. + * + * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing + * (ACPI_FILE_WRITING). + * + ******************************************************************************/ + +ACPI_FILE +AcpiOsOpenFile ( + const char *Path, + UINT8 Modes) +{ + ACPI_FILE File; + UINT32 i = 0; + char ModesStr[4]; + + + if (Modes & ACPI_FILE_READING) + { + ModesStr[i++] = 'r'; + } + if (Modes & ACPI_FILE_WRITING) + { + ModesStr[i++] = 'w'; + } + if (Modes & ACPI_FILE_BINARY) + { + ModesStr[i++] = 'b'; + } + + ModesStr[i++] = '\0'; + + File = fopen (Path, ModesStr); + if (!File) + { + perror ("Could not open file"); + } + + return (File); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsCloseFile + * + * PARAMETERS: File - An open file descriptor + * + * RETURN: None. + * + * DESCRIPTION: Close a file opened via AcpiOsOpenFile. + * + ******************************************************************************/ + +void +AcpiOsCloseFile ( + ACPI_FILE File) +{ + fclose (File); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsReadFile + * + * PARAMETERS: File - An open file descriptor + * Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks + * + * RETURN: Number of bytes actually read. + * + * DESCRIPTION: Read from a file. + * + ******************************************************************************/ + +int +AcpiOsReadFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count) +{ + int Length; + + + Length = fread (Buffer, Size, Count, File); + if (Length < 0) + { + perror ("Error reading file"); + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsWriteFile + * + * PARAMETERS: File - An open file descriptor + * Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Write to a file. + * + ******************************************************************************/ + +int +AcpiOsWriteFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count) +{ + int Length; + + + Length = fwrite (Buffer, Size, Count, File); + if (Length < 0) + { + perror ("Error writing file"); + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsGetFileOffset + * + * PARAMETERS: File - An open file descriptor + * + * RETURN: Current file pointer position. + * + * DESCRIPTION: Get current file offset. + * + ******************************************************************************/ + +long +AcpiOsGetFileOffset ( + ACPI_FILE File) +{ + long Offset; + + + Offset = ftell (File); + return (Offset); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsSetFileOffset + * + * PARAMETERS: File - An open file descriptor + * Offset - New file offset + * From - From begin/end of file + * + * RETURN: Status + * + * DESCRIPTION: Set current file offset. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsSetFileOffset ( + ACPI_FILE File, + long Offset, + UINT8 From) +{ + int Ret = 0; + + + if (From == ACPI_FILE_BEGIN) + { + Ret = fseek (File, Offset, SEEK_SET); + } + if (From == ACPI_FILE_END) + { + Ret = fseek (File, Offset, SEEK_END); + } + + if (Ret < 0) + { + return (AE_ERROR); + } + else + { + return (AE_OK); + } +} diff --git a/source/os_specific/service_layers/oslinuxtbl.c b/source/os_specific/service_layers/oslinuxtbl.c index aee929e..aae9332 100644 --- a/source/os_specific/service_layers/oslinuxtbl.c +++ b/source/os_specific/service_layers/oslinuxtbl.c @@ -98,6 +98,11 @@ OslUnmapTable ( ACPI_TABLE_HEADER *Table); static ACPI_PHYSICAL_ADDRESS +OslFindRsdpViaEfiByKeyword ( + FILE *File, + const char *Keyword); + +static ACPI_PHYSICAL_ADDRESS OslFindRsdpViaEfi ( void); @@ -490,6 +495,44 @@ AcpiOsGetTableByIndex ( /****************************************************************************** * + * FUNCTION: OslFindRsdpViaEfiByKeyword + * + * PARAMETERS: Keyword - Character string indicating ACPI GUID version + * in the EFI table + * + * RETURN: RSDP address if found + * + * DESCRIPTION: Find RSDP address via EFI using keyword indicating the ACPI + * GUID version. + * + *****************************************************************************/ + +static ACPI_PHYSICAL_ADDRESS +OslFindRsdpViaEfiByKeyword ( + FILE *File, + const char *Keyword) +{ + char Buffer[80]; + unsigned long long Address = 0; + char Format[32]; + + + snprintf (Format, 32, "%s=%s", Keyword, "%llx"); + fseek (File, 0, SEEK_SET); + while (fgets (Buffer, 80, File)) + { + if (sscanf (Buffer, Format, &Address) == 1) + { + break; + } + } + + return ((ACPI_PHYSICAL_ADDRESS) (Address)); +} + + +/****************************************************************************** + * * FUNCTION: OslFindRsdpViaEfi * * PARAMETERS: None @@ -505,24 +548,21 @@ OslFindRsdpViaEfi ( void) { FILE *File; - char Buffer[80]; - unsigned long Address = 0; + ACPI_PHYSICAL_ADDRESS Address = 0; File = fopen (EFI_SYSTAB, "r"); if (File) { - while (fgets (Buffer, 80, File)) + Address = OslFindRsdpViaEfiByKeyword (File, "ACPI20"); + if (!Address) { - if (sscanf (Buffer, "ACPI20=0x%lx", &Address) == 1) - { - break; - } + Address = OslFindRsdpViaEfiByKeyword (File, "ACPI"); } fclose (File); } - return ((ACPI_PHYSICAL_ADDRESS) (Address)); + return (Address); } @@ -907,6 +947,11 @@ OslGetBiosTable ( ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) || ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) { + if (Instance > 0) + { + return (AE_LIMIT); + } + /* * Get the appropriate address, either 32-bit or 64-bit. Be very * careful about the FADT length and validate table addresses. diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index dd151ee..b2df842 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -65,16 +65,11 @@ ACPI_MODULE_NAME ("osunixxf") -FILE *AcpiGbl_OutputFile; BOOLEAN AcpiGbl_DebugTimeout = FALSE; /* Upcalls to AcpiExec */ -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - void AeTableOverride ( ACPI_TABLE_HEADER *ExistingTable, @@ -214,10 +209,19 @@ ACPI_STATUS AcpiOsInitialize ( void) { + ACPI_STATUS Status; + AcpiGbl_OutputFile = stdout; OsEnterLineEditMode (); + + Status = AcpiOsCreateLock (&AcpiGbl_PrintLock); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + return (AE_OK); } @@ -231,6 +235,7 @@ AcpiOsTerminate ( } +#ifndef ACPI_USE_NATIVE_RSDP_POINTER /****************************************************************************** * * FUNCTION: AcpiOsGetRootPointer @@ -248,8 +253,9 @@ AcpiOsGetRootPointer ( void) { - return (AeLocalGetRootPointer ()); + return (0); } +#endif /****************************************************************************** @@ -548,6 +554,7 @@ AcpiOsGetLine ( #endif +#ifndef ACPI_USE_NATIVE_MEMORY_MAPPING /****************************************************************************** * * FUNCTION: AcpiOsMapMemory @@ -593,6 +600,7 @@ AcpiOsUnmapMemory ( return; } +#endif /****************************************************************************** @@ -619,6 +627,32 @@ AcpiOsAllocate ( } +#ifdef USE_NATIVE_ALLOCATE_ZEROED +/****************************************************************************** + * + * FUNCTION: AcpiOsAllocateZeroed + * + * PARAMETERS: Size - Amount to allocate, in bytes + * + * RETURN: Pointer to the new allocation. Null on error. + * + * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS. + * + *****************************************************************************/ + +void * +AcpiOsAllocateZeroed ( + ACPI_SIZE size) +{ + void *Mem; + + + Mem = (void *) calloc (1, (size_t) size); + return (Mem); +} +#endif + + /****************************************************************************** * * FUNCTION: AcpiOsFree @@ -1125,7 +1159,7 @@ AcpiOsGetTimer ( * FUNCTION: AcpiOsReadPciConfiguration * * PARAMETERS: PciId - Seg/Bus/Dev - * Register - Device Register + * PciRegister - Device Register * Value - Buffer where value is placed * Width - Number of bits * @@ -1138,7 +1172,7 @@ AcpiOsGetTimer ( ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 PciRegister, UINT64 *Value, UINT32 Width) { @@ -1153,7 +1187,7 @@ AcpiOsReadPciConfiguration ( * FUNCTION: AcpiOsWritePciConfiguration * * PARAMETERS: PciId - Seg/Bus/Dev - * Register - Device Register + * PciRegister - Device Register * Value - Value to be written * Width - Number of bits * @@ -1166,7 +1200,7 @@ AcpiOsReadPciConfiguration ( ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 PciRegister, UINT64 Value, UINT32 Width) { @@ -1454,6 +1488,26 @@ AcpiOsExecute ( return (0); } +#else /* ACPI_SINGLE_THREADED */ +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (1); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + + Function (Context); + + return (AE_OK); +} + #endif /* ACPI_SINGLE_THREADED */ diff --git a/source/os_specific/service_layers/oswintbl.c b/source/os_specific/service_layers/oswintbl.c index 0afde68..7c8ec2b 100644 --- a/source/os_specific/service_layers/oswintbl.c +++ b/source/os_specific/service_layers/oswintbl.c @@ -329,7 +329,7 @@ AcpiOsGetTableByName ( WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, NULL, &DataSize); - if (WinStatus = ERROR_SUCCESS) + if (WinStatus != ERROR_SUCCESS) { fprintf (stderr, "Could not read the %s table size: %s\n", Signature, WindowsFormatException (WinStatus)); @@ -350,7 +350,7 @@ AcpiOsGetTableByName ( WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, (UCHAR *) ReturnTable, &DataSize); - if (WinStatus = ERROR_SUCCESS) + if (WinStatus != ERROR_SUCCESS) { fprintf (stderr, "Could not read %s data: %s\n", Signature, WindowsFormatException (WinStatus)); diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c index 667a9f9..140bfdb 100644 --- a/source/os_specific/service_layers/oswinxf.c +++ b/source/os_specific/service_layers/oswinxf.c @@ -64,7 +64,6 @@ ACPI_MODULE_NAME ("oswinxf") -FILE *AcpiGbl_OutputFile; UINT64 TimerFrequency; char TableName[ACPI_NAME_SIZE + 1]; @@ -73,10 +72,6 @@ char TableName[ACPI_NAME_SIZE + 1]; /* Upcalls to AcpiExec application */ -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - void AeTableOverride ( ACPI_TABLE_HEADER *ExistingTable, @@ -143,6 +138,7 @@ ACPI_STATUS AcpiOsInitialize ( void) { + ACPI_STATUS Status; LARGE_INTEGER LocalTimerFrequency; @@ -164,10 +160,17 @@ AcpiOsInitialize ( TimerFrequency = LocalTimerFrequency.QuadPart; } + Status = AcpiOsCreateLock (&AcpiGbl_PrintLock); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + return (AE_OK); } +#ifndef ACPI_USE_NATIVE_RSDP_POINTER /****************************************************************************** * * FUNCTION: AcpiOsGetRootPointer @@ -185,8 +188,9 @@ AcpiOsGetRootPointer ( void) { - return (AeLocalGetRootPointer ()); + return (0); } +#endif /****************************************************************************** @@ -554,6 +558,7 @@ AcpiOsGetLine ( } +#ifndef ACPI_USE_NATIVE_MEMORY_MAPPING /****************************************************************************** * * FUNCTION: AcpiOsMapMemory @@ -599,6 +604,7 @@ AcpiOsUnmapMemory ( return; } +#endif /****************************************************************************** @@ -626,6 +632,33 @@ AcpiOsAllocate ( } +#ifdef USE_NATIVE_ALLOCATE_ZEROED +/****************************************************************************** + * + * FUNCTION: AcpiOsAllocateZeroed + * + * PARAMETERS: Size - Amount to allocate, in bytes + * + * RETURN: Pointer to the new allocation. Null on error. + * + * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS. + * + *****************************************************************************/ + +void * +AcpiOsAllocateZeroed ( + ACPI_SIZE Size) +{ + void *Mem; + + + Mem = (void *) calloc (1, (size_t) Size); + + return (Mem); +} +#endif + + /****************************************************************************** * * FUNCTION: AcpiOsFree @@ -1486,6 +1519,26 @@ AcpiOsExecute ( return (0); } +#else /* ACPI_SINGLE_THREADED */ +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (1); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + + Function (Context); + + return (AE_OK); +} + #endif /* ACPI_SINGLE_THREADED */ diff --git a/source/tools/acpibin/abcompare.c b/source/tools/acpibin/abcompare.c index d843400..84eb3c2 100644 --- a/source/tools/acpibin/abcompare.c +++ b/source/tools/acpibin/abcompare.c @@ -77,10 +77,6 @@ AbPrintHeadersInfo ( ACPI_TABLE_HEADER *Header, ACPI_TABLE_HEADER *Header2); -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - /****************************************************************************** * @@ -628,26 +624,3 @@ Exit1: * DESCRIPTION: For linkage * ******************************************************************************/ - -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void) -{ - return (AE_OK); -} - -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - return (0xFFFF); -} - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - return (AE_SUPPORT); -} diff --git a/source/tools/acpibin/abmain.c b/source/tools/acpibin/abmain.c index d8c740c..d6b1acd 100644 --- a/source/tools/acpibin/abmain.c +++ b/source/tools/acpibin/abmain.c @@ -119,7 +119,7 @@ main ( /* Command line options */ - while ((j = AcpiGetopt (argc, argv, AB_SUPPORTED_OPTIONS)) != EOF) switch(j) + while ((j = AcpiGetopt (argc, argv, AB_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'c': /* Compare Files */ diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h index 1064eb4..f5c021a 100644 --- a/source/tools/acpidump/acpidump.h +++ b/source/tools/acpidump/acpidump.h @@ -48,7 +48,6 @@ #ifdef _DECLARE_GLOBALS #define EXTERN #define INIT_GLOBAL(a,b) a=b -#define DEFINE_ACPI_GLOBALS 1 #else #define EXTERN extern #define INIT_GLOBAL(a,b) a @@ -71,7 +70,7 @@ EXTERN BOOLEAN INIT_GLOBAL (Gbl_VerboseMode, FALSE); EXTERN BOOLEAN INIT_GLOBAL (Gbl_BinaryMode, FALSE); EXTERN BOOLEAN INIT_GLOBAL (Gbl_DumpCustomizedTables, FALSE); EXTERN BOOLEAN INIT_GLOBAL (Gbl_DoNotDumpXsdt, FALSE); -EXTERN FILE INIT_GLOBAL (*Gbl_OutputFile, NULL); +EXTERN ACPI_FILE INIT_GLOBAL (Gbl_OutputFile, NULL); EXTERN char INIT_GLOBAL (*Gbl_OutputFilename, NULL); EXTERN UINT64 INIT_GLOBAL (Gbl_RsdpBase, 0); diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index 0bd0294..ab5c32c 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -76,7 +76,7 @@ ApIsValidHeader ( if (!AcpiUtValidAcpiName (Table->Signature)) { - fprintf (stderr, "Table signature (0x%8.8X) is invalid\n", + AcpiLogError ("Table signature (0x%8.8X) is invalid\n", *(UINT32 *) Table->Signature); return (FALSE); } @@ -85,7 +85,7 @@ ApIsValidHeader ( if (Table->Length < sizeof (ACPI_TABLE_HEADER)) { - fprintf (stderr, "Table length (0x%8.8X) is invalid\n", + AcpiLogError ("Table length (0x%8.8X) is invalid\n", Table->Length); return (FALSE); } @@ -131,7 +131,7 @@ ApIsValidChecksum ( if (ACPI_FAILURE (Status)) { - fprintf (stderr, "%4.4s: Warning: wrong checksum in table\n", + AcpiLogError ("%4.4s: Warning: wrong checksum in table\n", Table->Signature); } @@ -223,12 +223,13 @@ ApDumpTableBuffer ( * Note: simplest to just always emit a 64-bit address. AcpiXtract * utility can handle this. */ - printf ("%4.4s @ 0x%8.8X%8.8X\n", Table->Signature, - ACPI_FORMAT_UINT64 (Address)); + AcpiUtFilePrintf (Gbl_OutputFile, "%4.4s @ 0x%8.8X%8.8X\n", + Table->Signature, ACPI_FORMAT_UINT64 (Address)); - AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table), TableLength, + AcpiUtDumpBufferToFile (Gbl_OutputFile, + ACPI_CAST_PTR (UINT8, Table), TableLength, DB_BYTE_DISPLAY, 0); - printf ("\n"); + AcpiUtFilePrintf (Gbl_OutputFile, "\n"); return (0); } @@ -273,20 +274,20 @@ ApDumpAllTables ( } else if (i == 0) { - fprintf (stderr, "Could not get ACPI tables, %s\n", + AcpiLogError ("Could not get ACPI tables, %s\n", AcpiFormatException (Status)); return (-1); } else { - fprintf (stderr, "Could not get ACPI table at index %u, %s\n", + AcpiLogError ("Could not get ACPI table at index %u, %s\n", i, AcpiFormatException (Status)); continue; } } TableStatus = ApDumpTableBuffer (Table, Instance, Address); - free (Table); + ACPI_FREE (Table); if (TableStatus) { @@ -328,7 +329,7 @@ ApDumpTableByAddress ( Status = AcpiUtStrtoul64 (AsciiAddress, 0, &LongAddress); if (ACPI_FAILURE (Status)) { - fprintf (stderr, "%s: Could not convert to a physical address\n", + AcpiLogError ("%s: Could not convert to a physical address\n", AsciiAddress); return (-1); } @@ -337,14 +338,14 @@ ApDumpTableByAddress ( Status = AcpiOsGetTableByAddress (Address, &Table); if (ACPI_FAILURE (Status)) { - fprintf (stderr, "Could not get table at 0x%8.8X%8.8X, %s\n", + AcpiLogError ("Could not get table at 0x%8.8X%8.8X, %s\n", ACPI_FORMAT_UINT64 (Address), AcpiFormatException (Status)); return (-1); } TableStatus = ApDumpTableBuffer (Table, 0, Address); - free (Table); + ACPI_FREE (Table); return (TableStatus); } @@ -374,9 +375,9 @@ ApDumpTableByName ( int TableStatus; - if (strlen (Signature) != ACPI_NAME_SIZE) + if (ACPI_STRLEN (Signature) != ACPI_NAME_SIZE) { - fprintf (stderr, + AcpiLogError ( "Invalid table signature [%s]: must be exactly 4 characters\n", Signature); return (-1); @@ -384,18 +385,18 @@ ApDumpTableByName ( /* Table signatures are expected to be uppercase */ - strcpy (LocalSignature, Signature); + ACPI_STRCPY (LocalSignature, Signature); AcpiUtStrupr (LocalSignature); /* To be friendly, handle tables whose signatures do not match the name */ if (ACPI_COMPARE_NAME (LocalSignature, "FADT")) { - strcpy (LocalSignature, ACPI_SIG_FADT); + ACPI_STRCPY (LocalSignature, ACPI_SIG_FADT); } else if (ACPI_COMPARE_NAME (LocalSignature, "MADT")) { - strcpy (LocalSignature, ACPI_SIG_MADT); + ACPI_STRCPY (LocalSignature, ACPI_SIG_MADT); } /* Dump all instances of this signature (to handle multiple SSDTs) */ @@ -413,14 +414,14 @@ ApDumpTableByName ( return (0); } - fprintf (stderr, + AcpiLogError ( "Could not get ACPI table with signature [%s], %s\n", LocalSignature, AcpiFormatException (Status)); return (-1); } TableStatus = ApDumpTableBuffer (Table, Instance, Address); - free (Table); + ACPI_FREE (Table); if (TableStatus) { @@ -467,7 +468,7 @@ ApDumpTableFromFile ( if (Table->Length > FileSize) { - fprintf (stderr, + AcpiLogError ( "Table length (0x%X) is too large for input file (0x%X) %s\n", Table->Length, FileSize, Pathname); goto Exit; @@ -475,7 +476,7 @@ ApDumpTableFromFile ( if (Gbl_VerboseMode) { - fprintf (stderr, + AcpiLogError ( "Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n", Pathname, Table->Signature, FileSize, FileSize); } @@ -483,35 +484,6 @@ ApDumpTableFromFile ( TableStatus = ApDumpTableBuffer (Table, 0, 0); Exit: - free (Table); + ACPI_FREE (Table); return (TableStatus); } - - -/****************************************************************************** - * - * FUNCTION: AcpiOs* print functions - * - * DESCRIPTION: Used for linkage with ACPICA modules - * - ******************************************************************************/ - -void ACPI_INTERNAL_VAR_XFACE -AcpiOsPrintf ( - const char *Fmt, - ...) -{ - va_list Args; - - va_start (Args, Fmt); - vfprintf (stdout, Fmt, Args); - va_end (Args); -} - -void -AcpiOsVprintf ( - const char *Fmt, - va_list Args) -{ - vfprintf (stdout, Fmt, Args); -} diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c index 1588f2e..6633ce9 100644 --- a/source/tools/acpidump/apfiles.c +++ b/source/tools/acpidump/apfiles.c @@ -45,6 +45,36 @@ #include "acapps.h" +/* Local prototypes */ + +static int +ApIsExistingFile ( + char *Pathname); + + +static int +ApIsExistingFile ( + char *Pathname) +{ +#ifndef _GNU_EFI + struct stat StatInfo; + + + if (!stat (Pathname, &StatInfo)) + { + AcpiLogError ("Target path already exists, overwrite? [y|n] "); + + if (getchar () != 'y') + { + return (-1); + } + } +#endif + + return 0; +} + + /****************************************************************************** * * FUNCTION: ApOpenOutputFile @@ -62,28 +92,22 @@ int ApOpenOutputFile ( char *Pathname) { - struct stat StatInfo; - FILE *File; + ACPI_FILE File; /* If file exists, prompt for overwrite */ - if (!stat (Pathname, &StatInfo)) + if (ApIsExistingFile (Pathname) != 0) { - fprintf (stderr, "Target path already exists, overwrite? [y|n] "); - - if (getchar () != 'y') - { - return (-1); - } + return (-1); } /* Point stdout to the file */ - File = freopen (Pathname, "w", stdout); + File = AcpiOsOpenFile (Pathname, ACPI_FILE_WRITING); if (!File) { - perror ("Could not open output file"); + AcpiLogError ("Could not open output file: %s\n", Pathname); return (-1); } @@ -116,7 +140,7 @@ ApWriteToBinaryFile ( { char Filename[ACPI_NAME_SIZE + 16]; char InstanceStr [16]; - FILE *File; + ACPI_FILE File; size_t Actual; UINT32 TableLength; @@ -145,37 +169,38 @@ ApWriteToBinaryFile ( if (Instance > 0) { - sprintf (InstanceStr, "%u", Instance); - strcat (Filename, InstanceStr); + AcpiUtSnprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance); + ACPI_STRCAT (Filename, InstanceStr); } - strcat (Filename, ACPI_TABLE_FILE_SUFFIX); + ACPI_STRCAT (Filename, ACPI_TABLE_FILE_SUFFIX); if (Gbl_VerboseMode) { - fprintf (stderr, + AcpiLogError ( "Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n", Table->Signature, Filename, Table->Length, Table->Length); } /* Open the file and dump the entire table in binary mode */ - File = fopen (Filename, "wb"); + File = AcpiOsOpenFile (Filename, + ACPI_FILE_WRITING | ACPI_FILE_BINARY); if (!File) { - perror ("Could not open output file"); + AcpiLogError ("Could not open output file: %s\n", Filename); return (-1); } - Actual = fwrite (Table, 1, TableLength, File); + Actual = AcpiOsWriteFile (File, Table, 1, TableLength); if (Actual != TableLength) { - perror ("Error writing binary output file"); - fclose (File); + AcpiLogError ("Error writing binary output file: %s\n", Filename); + AcpiOsCloseFile (File); return (-1); } - fclose (File); + AcpiOsCloseFile (File); return (0); } @@ -199,17 +224,17 @@ ApGetTableFromFile ( UINT32 *OutFileSize) { ACPI_TABLE_HEADER *Buffer = NULL; - FILE *File; + ACPI_FILE File; UINT32 FileSize; size_t Actual; /* Must use binary mode */ - File = fopen (Pathname, "rb"); + File = AcpiOsOpenFile (Pathname, ACPI_FILE_READING | ACPI_FILE_BINARY); if (!File) { - perror ("Could not open input file"); + AcpiLogError ("Could not open input file: %s\n", Pathname); return (NULL); } @@ -218,29 +243,29 @@ ApGetTableFromFile ( FileSize = CmGetFileSize (File); if (FileSize == ACPI_UINT32_MAX) { - fprintf (stderr, + AcpiLogError ( "Could not get input file size: %s\n", Pathname); goto Cleanup; } /* Allocate a buffer for the entire file */ - Buffer = calloc (1, FileSize); + Buffer = ACPI_ALLOCATE_ZEROED (FileSize); if (!Buffer) { - fprintf (stderr, + AcpiLogError ( "Could not allocate file buffer of size: %u\n", FileSize); goto Cleanup; } /* Read the entire file */ - Actual = fread (Buffer, 1, FileSize, File); + Actual = AcpiOsReadFile (File, Buffer, 1, FileSize); if (Actual != FileSize) { - fprintf (stderr, + AcpiLogError ( "Could not read input file: %s\n", Pathname); - free (Buffer); + ACPI_FREE (Buffer); Buffer = NULL; goto Cleanup; } @@ -248,6 +273,6 @@ ApGetTableFromFile ( *OutFileSize = FileSize; Cleanup: - fclose (File); + AcpiOsCloseFile (File); return (Buffer); } diff --git a/source/tools/acpidump/apmain.c b/source/tools/acpidump/apmain.c index 8929b0f..ffd1a2a 100644 --- a/source/tools/acpidump/apmain.c +++ b/source/tools/acpidump/apmain.c @@ -79,7 +79,7 @@ ApDoOptions ( int argc, char **argv); -static void +static int ApInsertAction ( char *Argument, UINT32 ToBeDone); @@ -119,7 +119,7 @@ ApDisplayUsage ( ACPI_OPTION ("-v", "Display version information"); ACPI_OPTION ("-z", "Verbose mode"); - printf ("\nTable Options:\n"); + ACPI_USAGE_TEXT ("\nTable Options:\n"); ACPI_OPTION ("-a
", "Get table via a physical address"); ACPI_OPTION ("-f ", "Get table via a binary file"); @@ -127,7 +127,7 @@ ApDisplayUsage ( ACPI_OPTION ("-x", "Do not use but dump XSDT"); ACPI_OPTION ("-x -x", "Do not use or dump XSDT"); - printf ( + ACPI_USAGE_TEXT ( "\n" "Invocation without parameters dumps all available tables\n" "Multiple mixed instances of -a, -f, and -n are supported\n\n"); @@ -141,13 +141,13 @@ ApDisplayUsage ( * PARAMETERS: Argument - Pointer to the argument for this action * ToBeDone - What to do to process this action * - * RETURN: None. Exits program if action table becomes full. + * RETURN: Status * * DESCRIPTION: Add an action item to the action table * ******************************************************************************/ -static void +static int ApInsertAction ( char *Argument, UINT32 ToBeDone) @@ -161,9 +161,11 @@ ApInsertAction ( CurrentAction++; if (CurrentAction > AP_MAX_ACTIONS) { - fprintf (stderr, "Too many table options (max %u)\n", AP_MAX_ACTIONS); - exit (-1); + AcpiLogError ("Too many table options (max %u)\n", AP_MAX_ACTIONS); + return (-1); } + + return (0); } @@ -191,7 +193,7 @@ ApDoOptions ( /* Command line options */ - while ((j = AcpiGetopt (argc, argv, AP_SUPPORTED_OPTIONS)) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, AP_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { /* * Global options @@ -210,13 +212,13 @@ ApDoOptions ( case '?': ApDisplayUsage (); - exit (0); + return (1); case 'o': /* Redirect output to a single file */ if (ApOpenOutputFile (AcpiGbl_Optarg)) { - exit (-1); + return (-1); } continue; @@ -225,9 +227,9 @@ ApDoOptions ( Status = AcpiUtStrtoul64 (AcpiGbl_Optarg, 0, &Gbl_RsdpBase); if (ACPI_FAILURE (Status)) { - fprintf (stderr, "%s: Could not convert to a physical address\n", + AcpiLogError ("%s: Could not convert to a physical address\n", AcpiGbl_Optarg); - exit (-1); + return (-1); } continue; @@ -250,13 +252,13 @@ ApDoOptions ( case 'v': /* Revision/version */ - printf (ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); - exit (0); + AcpiOsPrintf (ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); + return (1); case 'z': /* Verbose mode */ Gbl_VerboseMode = TRUE; - fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); + AcpiLogError (ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); continue; /* @@ -264,30 +266,42 @@ ApDoOptions ( */ case 'a': /* Get table by physical address */ - ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_ADDRESS); + if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_ADDRESS)) + { + return (-1); + } break; case 'f': /* Get table from a file */ - ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_FILE); + if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_FILE)) + { + return (-1); + } break; case 'n': /* Get table by input name (signature) */ - ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_NAME); + if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_NAME)) + { + return (-1); + } break; default: ApDisplayUsage (); - exit (-1); + return (-1); } /* If there are no actions, this means "get/dump all tables" */ if (CurrentAction == 0) { - ApInsertAction (NULL, AP_DUMP_ALL_TABLES); + if (ApInsertAction (NULL, AP_DUMP_ALL_TABLES)) + { + return (-1); + } } return (0); @@ -306,10 +320,17 @@ ApDoOptions ( * ******************************************************************************/ +#ifndef _GNU_EFI int ACPI_SYSTEM_XFACE main ( int argc, char *argv[]) +#else +int ACPI_SYSTEM_XFACE +acpi_main ( + int argc, + char *argv[]) +#endif { int Status = 0; AP_DUMP_ACTION *Action; @@ -318,12 +339,19 @@ main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ + AcpiOsInitialize (); + Gbl_OutputFile = ACPI_FILE_OUT; /* Process command line options */ - if (ApDoOptions (argc, argv)) + Status = ApDoOptions (argc, argv); + if (Status > 0) { - return (-1); + return (0); + } + if (Status < 0) + { + return (Status); } /* Get/dump ACPI table(s) as requested */ @@ -355,7 +383,7 @@ main ( default: - fprintf (stderr, "Internal error, invalid action: 0x%X\n", + AcpiLogError ("Internal error, invalid action: 0x%X\n", Action->ToBeDone); return (-1); } @@ -366,18 +394,18 @@ main ( } } - if (Gbl_OutputFile) + if (Gbl_OutputFilename) { if (Gbl_VerboseMode) { /* Summary for the output file */ FileSize = CmGetFileSize (Gbl_OutputFile); - fprintf (stderr, "Output file %s contains 0x%X (%u) bytes\n\n", + AcpiLogError ("Output file %s contains 0x%X (%u) bytes\n\n", Gbl_OutputFilename, FileSize, FileSize); } - fclose (Gbl_OutputFile); + AcpiOsCloseFile (Gbl_OutputFile); } return (Status); diff --git a/source/tools/acpiexec/aehandlers.c b/source/tools/acpiexec/aehandlers.c index 5ad24e9..9f32ae7 100644 --- a/source/tools/acpiexec/aehandlers.c +++ b/source/tools/acpiexec/aehandlers.c @@ -1055,11 +1055,21 @@ AeInstallEarlyHandlers ( Status = AcpiDetachData (Handle, AeAttachedDataHandler); AE_CHECK_OK (AcpiDetachData, Status); - Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); + /* Test attach data at the root object */ + + Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler, + AcpiGbl_RootNode); + AE_CHECK_OK (AcpiAttachData, Status); + + Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2, + AcpiGbl_RootNode); AE_CHECK_OK (AcpiAttachData, Status); /* Test support for multiple attaches */ + Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); + AE_CHECK_OK (AcpiAttachData, Status); + Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle); AE_CHECK_OK (AcpiAttachData, Status); } @@ -1305,6 +1315,10 @@ AeRegionHandler ( switch (Function >> 16) { case AML_FIELD_ATTRIB_QUICK: + + Length = 0; + break; + case AML_FIELD_ATTRIB_SEND_RCV: case AML_FIELD_ATTRIB_BYTE: @@ -1327,8 +1341,7 @@ AeRegionHandler ( case AML_FIELD_ATTRIB_RAW_BYTES: case AML_FIELD_ATTRIB_RAW_PROCESS: - /* (-2) for status/length */ - Length = MyContext->AccessLength - 2; + Length = MyContext->AccessLength; break; default: @@ -1362,8 +1375,7 @@ AeRegionHandler ( case AML_FIELD_ATTRIB_RAW_BYTES: case AML_FIELD_ATTRIB_RAW_PROCESS: - /* (-2) for status/length */ - Length = MyContext->AccessLength - 2; + Length = MyContext->AccessLength; break; default: diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 3aa9343..99dd1a2 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -166,7 +166,7 @@ AeDoOptions ( int j; - while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case 'b': @@ -375,22 +375,14 @@ main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ - - printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME)); - if (argc < 2) - { - usage (); - return (0); - } - signal (SIGINT, AeCtrlCHandler); - /* Init globals */ + /* Init debug globals */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT; AcpiDbgLayer = 0xFFFFFFFF; - /* Init ACPI and start debugger thread */ + /* Init ACPICA and start debugger thread */ Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); @@ -399,6 +391,13 @@ main ( goto ErrorExit; } + printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME)); + if (argc < 2) + { + usage (); + return (0); + } + /* Get the command line options */ if (AeDoOptions (argc, argv)) @@ -422,7 +421,7 @@ main ( { /* Get one entire table */ - Status = AcpiDbReadTableFromFile (argv[AcpiGbl_Optind], &Table); + Status = AcpiUtReadTableFromFile (argv[AcpiGbl_Optind], &Table); if (ACPI_FAILURE (Status)) { printf ("**** Could not get table from file %s, %s\n", diff --git a/source/tools/acpiexec/aetables.c b/source/tools/acpiexec/aetables.c index e873b48..a9becc2 100644 --- a/source/tools/acpiexec/aetables.c +++ b/source/tools/acpiexec/aetables.c @@ -60,10 +60,6 @@ AeTableOverride ( ACPI_TABLE_HEADER *ExistingTable, ACPI_TABLE_HEADER **NewTable); -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - /* User table (DSDT) */ static ACPI_TABLE_HEADER *DsdtToInstallOverride; @@ -545,7 +541,7 @@ AeInstallTables ( /****************************************************************************** * - * FUNCTION: AeLocalGetRootPointer + * FUNCTION: AcpiOsGetRootPointer * * PARAMETERS: Flags - not used * Address - Where the root pointer is returned @@ -558,7 +554,7 @@ AeInstallTables ( *****************************************************************************/ ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( +AcpiOsGetRootPointer ( void) { diff --git a/source/tools/acpihelp/acpihelp.h b/source/tools/acpihelp/acpihelp.h index da15e4e..5e7a40f 100644 --- a/source/tools/acpihelp/acpihelp.h +++ b/source/tools/acpihelp/acpihelp.h @@ -71,6 +71,7 @@ #define AH_DISPLAY_DEVICE_IDS 6 #define AH_DECODE_EXCEPTION 7 #define AH_DECODE_ASL_AML 8 +#define AH_DISPLAY_UUIDS 9 #define AH_MAX_ASL_LINE_LENGTH 70 #define AH_MAX_AML_LINE_LENGTH 100 @@ -109,6 +110,7 @@ typedef struct ah_asl_keyword extern const AH_AML_OPCODE AmlOpcodeInfo[]; extern const AH_ASL_OPERATOR AslOperatorInfo[]; extern const AH_ASL_KEYWORD AslKeywordInfo[]; +extern const AH_UUID AcpiUuids[]; extern BOOLEAN AhDisplayAll; void @@ -147,4 +149,8 @@ void AhDisplayDeviceIds ( char *Name); +void +AhDisplayUuids ( + void); + #endif /* __ACPIHELP_H */ diff --git a/source/tools/acpihelp/ahdecode.c b/source/tools/acpihelp/ahdecode.c index 60e3808..3857071 100644 --- a/source/tools/acpihelp/ahdecode.c +++ b/source/tools/acpihelp/ahdecode.c @@ -873,6 +873,34 @@ AhDisplayDeviceIds ( /******************************************************************************* * + * FUNCTION: AhDisplayUuids + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display all known UUIDs. + * + ******************************************************************************/ + +void +AhDisplayUuids ( + void) +{ + const AH_UUID *Info; + + + printf ("ACPI-related UUIDs:\n\n"); + + for (Info = AcpiUuids; Info->Description; Info++) + { + printf ("%32s : %s\n", Info->Description, Info->String); + } +} + + +/******************************************************************************* + * * FUNCTION: AhDecodeException * * PARAMETERS: HexString - ACPI status string from command line, in diff --git a/source/tools/acpihelp/ahmain.c b/source/tools/acpihelp/ahmain.c index a340598..4749e5b 100644 --- a/source/tools/acpihelp/ahmain.c +++ b/source/tools/acpihelp/ahmain.c @@ -51,7 +51,7 @@ AhDisplayUsage ( void); #define AH_UTILITY_NAME "ACPI Help Utility" -#define AH_SUPPORTED_OPTIONS "aehikmopsv" +#define AH_SUPPORTED_OPTIONS "aehikmopsuv" /****************************************************************************** @@ -71,26 +71,27 @@ AhDisplayUsage ( ACPI_OPTION ("-h", "Display help"); ACPI_OPTION ("-v", "Display version information"); - printf ("\nAML (ACPI Machine Language) Names and Encodings:\n"); + ACPI_USAGE_TEXT ("\nAML (ACPI Machine Language) Names and Encodings:\n"); ACPI_OPTION ("-a [Name/Prefix]", "Find/Display both ASL operator and AML opcode name(s)"); ACPI_OPTION ("-m [Name/Prefix]", "Find/Display AML opcode name(s)"); - printf ("\nASL (ACPI Source Language) Names and Symbols:\n"); + ACPI_USAGE_TEXT ("\nASL (ACPI Source Language) Names and Symbols:\n"); ACPI_OPTION ("-k [Name/Prefix]", "Find/Display ASL non-operator keyword(s)"); ACPI_OPTION ("-p [Name/Prefix]", "Find/Display ASL predefined method name(s)"); ACPI_OPTION ("-s [Name/Prefix]", "Find/Display ASL operator name(s)"); - printf ("\nOther ACPI Names:\n"); + ACPI_USAGE_TEXT ("\nOther ACPI Names:\n"); ACPI_OPTION ("-i [Name/Prefix]", "Find/Display ACPI/PNP Hardware ID(s)"); + ACPI_OPTION ("-u", "Display ACPI-related UUIDs"); - printf ("\nACPI Values:\n"); + ACPI_USAGE_TEXT ("\nACPI Values:\n"); ACPI_OPTION ("-e [HexValue]", "Decode ACPICA exception code"); ACPI_OPTION ("-o [HexValue]", "Decode hex AML opcode"); - printf ("\nName/Prefix or HexValue not specified means \"Display All\"\n"); - printf ("\nDefault search with valid Name/Prefix and no options:\n"); - printf (" Find ASL/AML operator names - if NamePrefix does not start with underscore\n"); - printf (" Find ASL predefined method names - if NamePrefix starts with underscore\n"); + ACPI_USAGE_TEXT ("\nName/Prefix or HexValue not specified means \"Display All\"\n"); + ACPI_USAGE_TEXT ("\nDefault search with valid Name/Prefix and no options:\n"); + ACPI_USAGE_TEXT (" Find ASL/AML operator names - if NamePrefix does not start with underscore\n"); + ACPI_USAGE_TEXT (" Find ASL predefined method names - if NamePrefix starts with underscore\n"); } @@ -112,6 +113,7 @@ main ( int j; + AcpiOsInitialize (); ACPI_DEBUG_INITIALIZE (); /* For debug version only */ printf (ACPI_COMMON_SIGNON (AH_UTILITY_NAME)); DecodeType = AH_DECODE_DEFAULT; @@ -124,7 +126,7 @@ main ( /* Command line options */ - while ((j = AcpiGetopt (argc, argv, AH_SUPPORTED_OPTIONS)) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, AH_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case 'a': @@ -166,6 +168,11 @@ main ( DecodeType = AH_DECODE_ASL; break; + case 'u': + + DecodeType = AH_DISPLAY_UUIDS; + break; + case 'v': /* -v: (Version): signon already emitted, just exit */ return (0); @@ -223,6 +230,11 @@ main ( AhDecodeException (Name); break; + case AH_DISPLAY_UUIDS: + + AhDisplayUuids (); + break; + default: if (!Name) diff --git a/source/tools/acpinames/anmain.c b/source/tools/acpinames/anmain.c index e65e6e9..a7ea9a9 100644 --- a/source/tools/acpinames/anmain.c +++ b/source/tools/acpinames/anmain.c @@ -105,7 +105,7 @@ NsDumpEntireNamespace ( /* Open the binary AML file and read the entire table */ - Status = AcpiDbReadTableFromFile (AmlFilename, &Table); + Status = AcpiUtReadTableFromFile (AmlFilename, &Table); if (ACPI_FAILURE (Status)) { printf ("**** Could not get input table %s, %s\n", AmlFilename, @@ -241,25 +241,29 @@ main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ - printf (ACPI_COMMON_SIGNON (AN_UTILITY_NAME)); - if (argc < 2) - { - usage (); - return (0); - } - - /* Init globals and ACPICA */ + /* Init debug globals and ACPICA */ - AcpiDbgLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; + AcpiDbgLevel = ACPI_LV_TABLES; AcpiDbgLayer = 0xFFFFFFFF; Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); + if (ACPI_FAILURE (Status)) + { + return (-1); + } + + printf (ACPI_COMMON_SIGNON (AN_UTILITY_NAME)); + if (argc < 2) + { + usage (); + return (0); + } /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != EOF) switch(j) + while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'v': /* -v: (Version): signon already emitted, just exit */ diff --git a/source/tools/acpinames/anstubs.c b/source/tools/acpinames/anstubs.c index dedc40f..5933be3 100644 --- a/source/tools/acpinames/anstubs.c +++ b/source/tools/acpinames/anstubs.c @@ -60,71 +60,6 @@ /* Utilities */ -void -AcpiUtSubsystemShutdown ( - void) -{ -} - -ACPI_STATUS -AcpiUtExecute_STA ( - ACPI_NAMESPACE_NODE *DeviceNode, - UINT32 *StatusFlags) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecute_HID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID **ReturnId) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecute_CID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID_LIST **ReturnCidList) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecute_UID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID **ReturnId) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecute_SUB ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID **ReturnId) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecutePowerMethods ( - ACPI_NAMESPACE_NODE *DeviceNode, - const char **MethodNames, - UINT8 MethodCount, - UINT8 *OutValues) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtEvaluateNumericObject ( - char *ObjectName, - ACPI_NAMESPACE_NODE *DeviceNode, - UINT64 *Value) -{ - return (AE_NOT_IMPLEMENTED); -} - ACPI_STATUS AcpiUtCopyIobjectToEobject ( ACPI_OPERAND_OBJECT *Obj, @@ -151,33 +86,9 @@ AcpiUtCopyIobjectToIobject ( } -/* Hardware manager */ - -UINT32 -AcpiHwGetMode ( - void) -{ - return (0); -} - - /* Event manager */ ACPI_STATUS -AcpiEvInstallXruptHandlers ( - void) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEvInitializeEvents ( - void) -{ - return (AE_OK); -} - -ACPI_STATUS AcpiEvInstallRegionHandlers ( void) { @@ -199,37 +110,9 @@ AcpiEvInitializeRegion ( return (AE_OK); } -#if (!ACPI_REDUCED_HARDWARE) -ACPI_STATUS -AcpiEvDeleteGpeBlock ( - ACPI_GPE_BLOCK_INFO *GpeBlock) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEnable ( - void) -{ - return (AE_OK); -} -#endif /* !ACPI_REDUCED_HARDWARE */ - /* AML Interpreter */ -void -AcpiExUnlinkMutex ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ -} - -void -AcpiExReleaseAllMutexes ( - ACPI_THREAD_STATE *Thread) -{ -} - ACPI_STATUS AcpiExReadDataFromField ( ACPI_WALK_STATE *WalkState, @@ -256,22 +139,6 @@ AcpiExPrepFieldValue ( } ACPI_STATUS -AcpiExAcquireMutexObject ( - UINT16 Timeout, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_THREAD_ID ThreadId) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiExReleaseMutexObject ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - return (AE_OK); -} - -ACPI_STATUS AcpiExStoreObjectToNode ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, @@ -406,44 +273,3 @@ AcpiDsExecEndOp ( { return (AE_NOT_IMPLEMENTED); } - - -/* AML Debugger */ - -void -AcpiDbDisplayArgumentObject ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_WALK_STATE *WalkState) -{ -} - -ACPI_STATUS -AcpiDbInitialize ( - void) -{ - return (AE_OK); -} - -void -AcpiDbTerminate ( - void) -{ -} - -/* OSL interfaces */ - -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - return (0xFFFF); -} - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - return (AE_SUPPORT); -} diff --git a/source/tools/acpinames/antables.c b/source/tools/acpinames/antables.c index 8ad3c5c..b91b425 100644 --- a/source/tools/acpinames/antables.c +++ b/source/tools/acpinames/antables.c @@ -48,10 +48,6 @@ /* Local prototypes */ -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - /* Non-AML tables that are constructed locally and installed */ static ACPI_TABLE_RSDP LocalRSDP; @@ -284,7 +280,7 @@ AeBuildLocalTables ( /****************************************************************************** * - * FUNCTION: AeLocalGetRootPointer + * FUNCTION: AcpiOsGetRootPointer * * PARAMETERS: None * @@ -296,7 +292,7 @@ AeBuildLocalTables ( *****************************************************************************/ ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( +AcpiOsGetRootPointer ( void) { diff --git a/source/tools/acpisrc/asconvrt.c b/source/tools/acpisrc/asconvrt.c index 53c0c54..5184b8b 100644 --- a/source/tools/acpisrc/asconvrt.c +++ b/source/tools/acpisrc/asconvrt.c @@ -268,7 +268,7 @@ AsCheckAndSkipLiterals ( * * FUNCTION: AsAsCheckForBraces * - * DESCRIPTION: Check for an open brace after each if statement + * DESCRIPTION: Check for an open brace after each if/else statement * ******************************************************************************/ @@ -280,14 +280,69 @@ AsCheckForBraces ( char *SubBuffer = Buffer; char *NextBrace; char *NextSemicolon; - char *NextIf; UINT32 TotalLines = 1; + char *EndBuffer; - while (*SubBuffer) + EndBuffer = SubBuffer + strlen (SubBuffer); + + while (SubBuffer <= EndBuffer) { + /* TBD: Update this function to work properly, as per code below */ + /* SubBuffer = AsCheckAndSkipLiterals (SubBuffer, &TotalLines); */ + + /* Skip normal comments */ + + if ((*SubBuffer == '/') && + (*(SubBuffer + 1) == '*')) + { + /* Must maintain line count */ + + SubBuffer += 2; + while (strncmp ("*/", SubBuffer, 2)) + { + if (*SubBuffer == '\n') + { + TotalLines++; + } + SubBuffer++; + } + SubBuffer += 2; + continue; + } + + /* Skip single quoted chars */ + + if (*SubBuffer == '\'') + { + SubBuffer++; + if (*SubBuffer == '\\') + { + SubBuffer++; + } + SubBuffer++; + continue; + } - SubBuffer = AsCheckAndSkipLiterals (SubBuffer, &TotalLines); + /* Skip quoted strings */ + + if (*SubBuffer == '"') + { + SubBuffer++; + while (*SubBuffer != '"') + { + /* Handle escapes within the string */ + + if (*SubBuffer == '\\') + { + SubBuffer++; + } + SubBuffer++; + } + + SubBuffer++; + continue; + } if (*SubBuffer == '\n') { @@ -296,13 +351,12 @@ AsCheckForBraces ( else if (!(strncmp (" if", SubBuffer, 3))) { SubBuffer += 2; + NextBrace = strstr (SubBuffer, "{"); NextSemicolon = strstr (SubBuffer, ";"); - NextIf = strstr (SubBuffer, " if"); if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon)) || - (NextIf && (NextBrace > NextIf))) + (NextSemicolon && (NextBrace > NextSemicolon))) { Gbl_MissingBraces++; @@ -315,19 +369,18 @@ AsCheckForBraces ( else if (!(strncmp (" else if", SubBuffer, 8))) { SubBuffer += 7; + NextBrace = strstr (SubBuffer, "{"); NextSemicolon = strstr (SubBuffer, ";"); - NextIf = strstr (SubBuffer, " if"); if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon)) || - (NextIf && (NextBrace > NextIf))) + (NextSemicolon && (NextBrace > NextSemicolon))) { Gbl_MissingBraces++; if (!Gbl_QuietMode) { - printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); + printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); } } } @@ -336,11 +389,9 @@ AsCheckForBraces ( SubBuffer += 4; NextBrace = strstr (SubBuffer, "{"); NextSemicolon = strstr (SubBuffer, ";"); - NextIf = strstr (SubBuffer, " if"); if ((!NextBrace) || - (NextSemicolon && (NextBrace > NextSemicolon)) || - (NextIf && (NextBrace > NextIf))) + (NextSemicolon && (NextBrace > NextSemicolon))) { Gbl_MissingBraces++; @@ -1192,6 +1243,9 @@ AsCountTabs ( * DESCRIPTION: Count the number of "//" comments. This type of comment is * non-ANSI C. * + * NOTE: July 2014: Allows // within quoted strings and within normal + * comments. Eliminates extraneous warnings from this utility. + * ******************************************************************************/ void @@ -1200,22 +1254,82 @@ AsCountNonAnsiComments ( char *Filename) { char *SubBuffer = Buffer; + char *EndBuffer; UINT32 CommentCount = 0; + char *StartBuffer; + + EndBuffer = SubBuffer + strlen (SubBuffer); - while (SubBuffer) + while (SubBuffer <= EndBuffer) { - SubBuffer = strstr (SubBuffer, "//"); - if (SubBuffer) + /* Skip normal comments */ + + if ((*SubBuffer == '/') && + (*(SubBuffer + 1) == '*')) { - CommentCount++; + SubBuffer = strstr (SubBuffer + 2, "*/"); + if (!SubBuffer) + { + break; + } + SubBuffer += 2; + continue; + } + + /* Skip single quoted chars */ + + if (*SubBuffer == '\'') + { + SubBuffer++; + if (*SubBuffer == '\\') + { + SubBuffer++; + } + SubBuffer++; + continue; + } + + /* Skip quoted strings */ + + if (*SubBuffer == '"') + { + StartBuffer = SubBuffer; +AcpiOsPrintf ("START STRING: %.64s\n", StartBuffer); + SubBuffer++; + while (*SubBuffer != '"') + { + /* Handle escapes within the string */ + + if (*SubBuffer == '\\') + { + SubBuffer++; + } + SubBuffer++; + } + + SubBuffer++; + continue; + } + + /* Finally: check for slash-slash comment */ + + if ((*SubBuffer == '/') && + (*(SubBuffer + 1) == '/')) + { + CommentCount++; + SubBuffer++; } + + SubBuffer++; } + /* Error if any slash-slash comments found */ + if (CommentCount) { - AsPrint ("Non-ANSI Comments found", CommentCount, Filename); + AsPrint ("Non-ANSI // Comments Found", CommentCount, Filename); Gbl_NonAnsiComments += CommentCount; } } diff --git a/source/tools/acpisrc/asmain.c b/source/tools/acpisrc/asmain.c index 8c75769..8b26ebc 100644 --- a/source/tools/acpisrc/asmain.c +++ b/source/tools/acpisrc/asmain.c @@ -297,7 +297,7 @@ AsDisplayUsage ( ACPI_OPTION ("-l", "Generate Linux version of the source"); ACPI_OPTION ("-u", "Generate Custom source translation"); - printf ("\n"); + ACPI_USAGE_TEXT ("\n"); ACPI_OPTION ("-d", "Leave debug statements in code"); ACPI_OPTION ("-s", "Generate source statistics only"); ACPI_OPTION ("-v", "Display version information"); @@ -327,6 +327,7 @@ main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ + AcpiOsInitialize (); printf (ACPI_COMMON_SIGNON (AS_UTILITY_NAME)); if (argc < 2) @@ -337,7 +338,7 @@ main ( /* Command line options */ - while ((j = AcpiGetopt (argc, argv, AS_SUPPORTED_OPTIONS)) != EOF) switch(j) + while ((j = AcpiGetopt (argc, argv, AS_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'l': diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c index 9e127a4..1f6f09d 100644 --- a/source/tools/acpisrc/astable.c +++ b/source/tools/acpisrc/astable.c @@ -253,6 +253,9 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_INTERPRETER_MODE", SRC_TYPE_SIMPLE}, {"ACPI_IO_ADDRESS", SRC_TYPE_SIMPLE}, {"ACPI_IO_ATTRIBUTE", SRC_TYPE_STRUCT}, + {"ACPI_LPIT_HEADER", SRC_TYPE_STRUCT}, + {"ACPI_LPIT_IO", SRC_TYPE_STRUCT}, + {"ACPI_LPIT_NATIVE", SRC_TYPE_STRUCT}, {"ACPI_MEM_SPACE_CONTEXT", SRC_TYPE_STRUCT}, {"ACPI_MEMORY_ATTRIBUTE", SRC_TYPE_STRUCT}, {"ACPI_MEMORY_LIST", SRC_TYPE_STRUCT}, @@ -400,6 +403,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_TABLE_HEADER", SRC_TYPE_STRUCT}, {"ACPI_TABLE_INFO", SRC_TYPE_STRUCT}, {"ACPI_TABLE_LIST", SRC_TYPE_STRUCT}, + {"ACPI_TABLE_LPIT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_MTMR", SRC_TYPE_STRUCT}, {"ACPI_TABLE_SUPPORT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_TYPE", SRC_TYPE_SIMPLE}, @@ -502,6 +506,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_TABLE_FACS", SRC_TYPE_STRUCT}, {"ACPI_TABLE_FADT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_FPDT", SRC_TYPE_STRUCT}, + {"ACPI_TABLE_GTDT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_HEST", SRC_TYPE_STRUCT}, {"ACPI_TABLE_HPET", SRC_TYPE_STRUCT}, {"ACPI_TABLE_IBFT", SRC_TYPE_STRUCT}, @@ -547,17 +552,22 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_DBG2_DEVICE", SRC_TYPE_STRUCT}, {"ACPI_DMAR_HEADER", SRC_TYPE_STRUCT}, {"ACPI_DMAR_DEVICE_SCOPE", SRC_TYPE_STRUCT}, + {"ACPI_DMAR_ANDD", SRC_TYPE_STRUCT}, {"ACPI_DMAR_ATSR", SRC_TYPE_STRUCT}, {"ACPI_DMAR_RHSA", SRC_TYPE_STRUCT}, {"ACPI_DMAR_HARDWARE_UNIT", SRC_TYPE_STRUCT}, {"ACPI_DMAR_RESERVED_MEMORY", SRC_TYPE_STRUCT}, {"ACPI_EINJ_ENTRY", SRC_TYPE_STRUCT}, {"ACPI_EINJ_TRIGGER", SRC_TYPE_STRUCT}, + {"ACPI_ERST_ENTRY", SRC_TYPE_STRUCT}, + {"ACPI_ERST_INFO", SRC_TYPE_STRUCT}, {"ACPI_FPDT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_FPDT_BOOT", SRC_TYPE_STRUCT}, {"ACPI_FPDT_S3PT_PTR", SRC_TYPE_STRUCT}, - {"ACPI_ERST_ENTRY", SRC_TYPE_STRUCT}, - {"ACPI_ERST_INFO", SRC_TYPE_STRUCT}, + {"ACPI_GTDT_HEADER", SRC_TYPE_STRUCT}, + {"ACPI_GTDT_TIMER_BLOCK", SRC_TYPE_STRUCT}, + {"ACPI_GTDT_TIMER_ENTRY", SRC_TYPE_STRUCT}, + {"ACPI_GTDT_WATCHDOG", SRC_TYPE_STRUCT}, {"ACPI_HEST_AER_COMMON", SRC_TYPE_STRUCT}, {"ACPI_HEST_HEADER", SRC_TYPE_STRUCT}, {"ACPI_HEST_NOTIFY", SRC_TYPE_STRUCT}, @@ -585,6 +595,8 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_IVRS_DEVICE8C", SRC_TYPE_STRUCT}, {"ACPI_IVRS_MEMORY", SRC_TYPE_STRUCT}, {"ACPI_MADT_ADDRESS_OVERRIDE", SRC_TYPE_STRUCT}, + {"ACPI_MADT_GENERIC_MSI_FRAME", SRC_TYPE_STRUCT}, + {"ACPI_MADT_GENERIC_REDISTRIBUTOR", SRC_TYPE_STRUCT}, {"ACPI_MADT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_MADT_IO_APIC", SRC_TYPE_STRUCT}, {"ACPI_MADT_IO_SAPIC", SRC_TYPE_STRUCT}, @@ -607,6 +619,8 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_MPST_POWER_STATE", SRC_TYPE_STRUCT}, {"ACPI_MCFG_ALLOCATION", SRC_TYPE_STRUCT}, {"ACPI_MSCT_PROXIMITY", SRC_TYPE_STRUCT}, + {"ACPI_PCCT_HW_REDUCED", SRC_TYPE_STRUCT}, + {"ACPI_PCCT_SHARED_MEMORY", SRC_TYPE_STRUCT}, {"ACPI_PCCT_SUBSPACE", SRC_TYPE_STRUCT}, {"ACPI_RSDP_COMMON", SRC_TYPE_STRUCT}, {"ACPI_RSDP_EXTENSION", SRC_TYPE_STRUCT}, @@ -648,6 +662,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"AH_ASL_KEYWORD", SRC_TYPE_STRUCT}, {"AH_DEVICE_ID", SRC_TYPE_STRUCT}, {"AH_PREDEFINED_NAME", SRC_TYPE_STRUCT}, + {"AH_UUID", SRC_TYPE_STRUCT}, /* AcpiXtract utility */ @@ -720,8 +735,10 @@ ACPI_STRING_TABLE LinuxSpecialStrings[] = { {"\"actbl3.h\"", "", REPLACE_WHOLE_WORD}, {"\"actypes.h\"", "", REPLACE_WHOLE_WORD}, {"\"platform/acenv.h\"", "", REPLACE_WHOLE_WORD}, + {"\"platform/acenvex.h\"", "", REPLACE_WHOLE_WORD}, {"\"acgcc.h\"", "", REPLACE_WHOLE_WORD}, {"\"aclinux.h\"", "", REPLACE_WHOLE_WORD}, + {"\"aclinuxex.h\"", "", REPLACE_WHOLE_WORD}, {NULL, NULL, 0} }; diff --git a/source/tools/acpixtract/axmain.c b/source/tools/acpixtract/axmain.c index b1bdb8b..ec0bd61 100644 --- a/source/tools/acpixtract/axmain.c +++ b/source/tools/acpixtract/axmain.c @@ -98,8 +98,8 @@ DisplayUsage ( ACPI_OPTION ("-s ", "Extract all tables with "); ACPI_OPTION ("-v", "Display version information"); - printf ("\nExtract binary ACPI tables from text acpidump output\n"); - printf ("Default invocation extracts the DSDT and all SSDTs\n"); + ACPI_USAGE_TEXT ("\nExtract binary ACPI tables from text acpidump output\n"); + ACPI_USAGE_TEXT ("Default invocation extracts the DSDT and all SSDTs\n"); } @@ -122,6 +122,7 @@ main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ + AcpiOsInitialize (); printf (ACPI_COMMON_SIGNON (AX_UTILITY_NAME)); if (argc < 2) @@ -132,7 +133,7 @@ main ( /* Command line options */ - while ((j = AcpiGetopt (argc, argv, AX_SUPPORTED_OPTIONS)) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, AX_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case 'a': diff --git a/source/tools/examples/examples.c b/source/tools/examples/examples.c index 8de3a05..762118a 100644 --- a/source/tools/examples/examples.c +++ b/source/tools/examples/examples.c @@ -86,6 +86,22 @@ NotifyHandler ( UINT32 Value, void *Context); +static ACPI_STATUS +RegionHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + UINT64 *Value, + void *HandlerContext, + void *RegionContext); + +static ACPI_STATUS +RegionInit ( + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + static void ExecuteMAIN (void); @@ -336,6 +352,43 @@ NotifyHandler ( static ACPI_STATUS +RegionInit ( + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = RegionHandle; + } + + return (AE_OK); +} + + +static ACPI_STATUS +RegionHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + UINT64 *Value, + void *HandlerContext, + void *RegionContext) +{ + + ACPI_INFO ((AE_INFO, "Received a region access")); + + return (AE_OK); +} + + +static ACPI_STATUS InstallHandlers (void) { ACPI_STATUS Status; @@ -351,6 +404,14 @@ InstallHandlers (void) return (Status); } + Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_SYSTEM_MEMORY, + RegionHandler, RegionInit, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While installing an OpRegion handler")); + return (Status); + } + return (AE_OK); } diff --git a/source/tools/examples/exstubs.c b/source/tools/examples/exstubs.c index df2ca25..9d5b25b 100644 --- a/source/tools/examples/exstubs.c +++ b/source/tools/examples/exstubs.c @@ -58,91 +58,8 @@ *****************************************************************************/ -/* Utilities */ - -void -AcpiUtSubsystemShutdown ( - void) -{ -} - -ACPI_STATUS -AcpiUtExecute_STA ( - ACPI_NAMESPACE_NODE *DeviceNode, - UINT32 *StatusFlags) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecute_HID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID **ReturnId) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecute_CID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID_LIST **ReturnCidList) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecute_UID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID **ReturnId) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecute_SUB ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_PNP_DEVICE_ID **ReturnId) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtExecutePowerMethods ( - ACPI_NAMESPACE_NODE *DeviceNode, - const char **MethodNames, - UINT8 MethodCount, - UINT8 *OutValues) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtEvaluateNumericObject ( - char *ObjectName, - ACPI_NAMESPACE_NODE *DeviceNode, - UINT64 *Value) -{ - return (AE_NOT_IMPLEMENTED); -} - -ACPI_STATUS -AcpiUtGetResourceEndTag ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT8 **EndTag) -{ - return (AE_OK); -} - - /* Hardware manager */ -UINT32 -AcpiHwGetMode ( - void) -{ - return (0); -} - ACPI_STATUS AcpiHwReadPort ( ACPI_IO_ADDRESS Address, @@ -165,175 +82,8 @@ AcpiHwWritePort ( /* Event manager */ ACPI_STATUS -AcpiInstallNotifyHandler ( - ACPI_HANDLE Device, - UINT32 HandlerType, - ACPI_NOTIFY_HANDLER Handler, - void *Context) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEvInstallXruptHandlers ( - void) -{ - return (AE_OK); -} - -ACPI_STATUS AcpiEvInitializeEvents ( void) { return (AE_OK); } - -ACPI_STATUS -AcpiEvInstallRegionHandlers ( - void) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEvInitializeOpRegions ( - void) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEvInitializeRegion ( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsLocked) -{ - return (AE_OK); -} - -#if (!ACPI_REDUCED_HARDWARE) -ACPI_STATUS -AcpiEvDeleteGpeBlock ( - ACPI_GPE_BLOCK_INFO *GpeBlock) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEnable ( - void) -{ - return (AE_OK); -} -#endif /* !ACPI_REDUCED_HARDWARE */ - -void -AcpiEvUpdateGpes ( - ACPI_OWNER_ID TableOwnerId) -{ -} - -ACPI_STATUS -AcpiEvAddressSpaceDispatch ( - ACPI_OPERAND_OBJECT *RegionObj, - ACPI_OPERAND_OBJECT *FieldObj, - UINT32 Function, - UINT32 RegionOffset, - UINT32 BitWidth, - UINT64 *Value) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEvAcquireGlobalLock ( - UINT16 Timeout) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEvReleaseGlobalLock ( - void) -{ - return (AE_OK); -} - -ACPI_STATUS -AcpiEvQueueNotifyRequest ( - ACPI_NAMESPACE_NODE *Node, - UINT32 NotifyValue) -{ - return (AE_OK); -} - -BOOLEAN -AcpiEvIsNotifyObject ( - ACPI_NAMESPACE_NODE *Node) -{ - return (TRUE); -} - - -/* Namespace manager */ - -ACPI_STATUS -AcpiNsCheckReturnValue ( - ACPI_NAMESPACE_NODE *Node, - ACPI_EVALUATE_INFO *Info, - UINT32 UserParamCount, - ACPI_STATUS ReturnStatus, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - return (AE_OK); -} - -void -AcpiNsCheckArgumentTypes ( - ACPI_EVALUATE_INFO *Info) -{ - return; -} - -void -AcpiNsCheckArgumentCount ( - char *Pathname, - ACPI_NAMESPACE_NODE *Node, - UINT32 UserParamCount, - const ACPI_PREDEFINED_INFO *Predefined) -{ - return; -} - -void -AcpiNsCheckAcpiCompliance ( - char *Pathname, - ACPI_NAMESPACE_NODE *Node, - const ACPI_PREDEFINED_INFO *Predefined) -{ - return; -} - -const ACPI_PREDEFINED_INFO * -AcpiUtMatchPredefinedMethod ( - char *Name) -{ - return (NULL); -} - -/* OSL interfaces */ - -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - return (1); -} - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - return (AE_SUPPORT); -} diff --git a/source/tools/examples/extables.c b/source/tools/examples/extables.c index c33be95..aa5fc1f 100644 --- a/source/tools/examples/extables.c +++ b/source/tools/examples/extables.c @@ -49,10 +49,6 @@ #define _COMPONENT ACPI_EXAMPLE ACPI_MODULE_NAME ("extables") -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - /****************************************************************************** * @@ -148,19 +144,24 @@ static unsigned char FacsCode[] = static unsigned char DsdtCode[] = { - 0x44,0x53,0x44,0x54,0x67,0x00,0x00,0x00, /* 00000000 "DSDTg..." */ - 0x02,0x97,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ + 0x44,0x53,0x44,0x54,0x8C,0x00,0x00,0x00, /* 00000000 "DSDT...." */ + 0x02,0x76,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".vIntel." */ 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x15,0x11,0x13,0x20,0x14,0x42,0x04,0x4D, /* 00000020 "... .B.M" */ - 0x41,0x49,0x4E,0x01,0x70,0x73,0x0D,0x4D, /* 00000028 "AIN.ps.M" */ - 0x61,0x69,0x6E,0x2F,0x41,0x72,0x67,0x30, /* 00000030 "ain/Arg0" */ - 0x3A,0x20,0x00,0x68,0x00,0x5B,0x31,0xA4, /* 00000038 ": .h.[1." */ - 0x0D,0x4D,0x61,0x69,0x6E,0x20,0x73,0x75, /* 00000040 ".Main su" */ - 0x63,0x63,0x65,0x73,0x73,0x66,0x75,0x6C, /* 00000048 "ccessful" */ - 0x6C,0x79,0x20,0x63,0x6F,0x6D,0x70,0x6C, /* 00000050 "ly compl" */ - 0x65,0x74,0x65,0x64,0x20,0x65,0x78,0x65, /* 00000058 "eted exe" */ - 0x63,0x75,0x74,0x69,0x6F,0x6E,0x00 /* 00000060 "cution." */ + 0x24,0x04,0x14,0x20,0x5B,0x80,0x47,0x4E, /* 00000020 "$.. [.GN" */ + 0x56,0x53,0x00,0x0C,0x98,0xEE,0xBB,0xDF, /* 00000028 "VS......" */ + 0x0A,0x13,0x5B,0x81,0x0B,0x47,0x4E,0x56, /* 00000030 "..[..GNV" */ + 0x53,0x00,0x46,0x4C,0x44,0x31,0x08,0x14, /* 00000038 "S.FLD1.." */ + 0x4C,0x04,0x4D,0x41,0x49,0x4E,0x01,0x70, /* 00000040 "L.MAIN.p" */ + 0x73,0x0D,0x4D,0x61,0x69,0x6E,0x2F,0x41, /* 00000048 "s.Main/A" */ + 0x72,0x67,0x30,0x3A,0x20,0x00,0x68,0x00, /* 00000050 "rg0: .h." */ + 0x5B,0x31,0x70,0x00,0x46,0x4C,0x44,0x31, /* 00000058 "[1p.FLD1" */ + 0x86,0x5C,0x00,0x00,0xA4,0x0D,0x4D,0x61, /* 00000060 ".\....Ma" */ + 0x69,0x6E,0x20,0x73,0x75,0x63,0x63,0x65, /* 00000068 "in succe" */ + 0x73,0x73,0x66,0x75,0x6C,0x6C,0x79,0x20, /* 00000070 "ssfully " */ + 0x63,0x6F,0x6D,0x70,0x6C,0x65,0x74,0x65, /* 00000078 "complete" */ + 0x64,0x20,0x65,0x78,0x65,0x63,0x75,0x74, /* 00000080 "d execut" */ + 0x69,0x6F,0x6E,0x00 /* 00000088 "ion." */ }; @@ -232,7 +233,7 @@ ExInitializeAcpiTables ( *****************************************************************************/ ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( +AcpiOsGetRootPointer ( void) { @@ -475,9 +476,17 @@ AeLocalGetRootPointer ( DefinitionBlock ("dsdt.aml", "DSDT", 2, "Intel", "Template", 0x00000001) { + OperationRegion (GNVS, SystemMemory, 0xDFBBEE98, 0x00000013) + Field (GNVS, AnyAcc, NoLock, Preserve) + { + FLD1, 8, + } + Method (MAIN, 1, NotSerialized) { Store (Concatenate ("Main/Arg0: ", Arg0), Debug) + Store (Zero, FLD1) + Notify (\, Zero) Return ("Main successfully completed execution") } } diff --git a/tests/aapits/Makefile b/tests/aapits/Makefile index 81971fa..188ffa9 100644 --- a/tests/aapits/Makefile +++ b/tests/aapits/Makefile @@ -15,11 +15,12 @@ SRCS= atexec.c atmain.c \ atosxfctrl.c \ atosxfwrap.c \ osunixxf.c \ + ../../source/common/ahids.c \ + ../../source/common/cmfsize.c \ + ../../source/common/getopt.c \ ../../source/components/hardware/hwtimer.c \ ../../source/components/hardware/hwvalid.c \ ../../source/components/hardware/hwxface.c \ - ../../source/common/cmfsize.c \ - ../../source/common/getopt.c \ ../../source/components/debugger/dbcmds.c \ ../../source/components/debugger/dbconvert.c \ ../../source/components/debugger/dbdisply.c \ @@ -151,6 +152,7 @@ SRCS= atexec.c atmain.c \ ../../source/components/resources/rsutils.c \ ../../source/components/resources/rsxface.c \ ../../source/components/resources/rsinfo.c \ + ../../source/components/tables/tbdata.c \ ../../source/components/tables/tbfadt.c \ ../../source/components/tables/tbfind.c \ ../../source/components/tables/tbinstal.c \ @@ -170,6 +172,7 @@ SRCS= atexec.c atmain.c \ ../../source/components/utilities/uterror.c \ ../../source/components/utilities/uteval.c \ ../../source/components/utilities/utexcep.c \ + ../../source/components/utilities/utfileio.c \ ../../source/components/utilities/utglobal.c \ ../../source/components/utilities/utids.c \ ../../source/components/utilities/utinit.c \ @@ -181,17 +184,19 @@ SRCS= atexec.c atmain.c \ ../../source/components/utilities/utosi.c \ ../../source/components/utilities/utownerid.c \ ../../source/components/utilities/utpredef.c \ + ../../source/components/utilities/utprint.c \ ../../source/components/utilities/utresrc.c \ ../../source/components/utilities/utstate.c \ ../../source/components/utilities/utstring.c \ ../../source/components/utilities/uttrack.c \ ../../source/components/utilities/utxface.c \ ../../source/components/utilities/utxferror.c \ - ../../source/components/utilities/utxfinit.c -# ../../source/components/osunixxf.c + ../../source/components/utilities/utxfinit.c \ + ../../source/os_specific/service_layers/oslibcfs.c +# ../../source/os_specific/service_layers/osunixxf.c -CFLAGS+= -Wall -g -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP -D_MULTI_THREADED -Wstrict-prototypes -I../../source/include +CFLAGS+= -Wall -g -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_APITS -DACPI_EXEC_APP -D_MULTI_THREADED -Wstrict-prototypes -I../../source/include acpiexec : $(patsubst %.c,%.o, $(SRCS)) diff --git a/tests/aslts/src/runtime/collections/functional/region/regionfield.asl b/tests/aslts/src/runtime/collections/functional/region/regionfield.asl index a046893..5ee4d5d 100644 --- a/tests/aslts/src/runtime/collections/functional/region/regionfield.asl +++ b/tests/aslts/src/runtime/collections/functional/region/regionfield.asl @@ -454,12 +454,10 @@ Method(m751, 1, Serialized) if (LNotEqual(OB10, 0x7A)) { err(arg0, z143, 28, 0, 0, OB10, 0x7A) } - if (LNotEqual(LEN0, 0x01)) { - err(arg0, z143, 32, 0, 0, LEN0, 0x01) - } - if (LNotEqual(DAT0, 0xA0)) { - err(arg0, z143, 36, 0, 0, DAT0, 0xA0) + if (LNotEqual(LEN0, 0x00)) { // Length is zero for Quick operations + err(arg0, z143, 32, 0, 0, LEN0, 0x00) } + /* Note: Since LEN0 should be zero there's no need to check DAT0 */ } // Read/Write Quick (SMBQuick) @@ -950,12 +948,10 @@ Method(m758, 1, Serialized) if (LNotEqual(OB10, 0x7A)) { err(arg0, z143, 256, 0, 0, OB10, 0x7A) } - if (LNotEqual(LEN0, 0x01)) { - err(arg0, z143, 260, 0, 0, LEN0, 0x01) - } - if (LNotEqual(DAT0, 0xA0)) { - err(arg0, z143, 264, 0, 0, DAT0, 0xA0) + if (LNotEqual(LEN0, 0x00)) { // Length is zero for Quick operations + err(arg0, z143, 260, 0, 0, LEN0, 0x00) } + /* Note: Since LEN0 should be zero there's no need to check DAT0 */ } // Read/Write Quick (AttribQuick) @@ -1385,7 +1381,11 @@ Method(m75f, 1, Serialized) OperationRegion(GSBD, GenericSerialBus, 0xB400, 0x100) Field(GSBD, BufferAcc, NoLock, Preserve) { - AccessAs (BufferAcc, AttribBytes (34)), + /* + * Note: AccessLength for AttribBytes here must at least 2 less than the + * transfer buffer to account for the status and length bytes + */ + AccessAs (BufferAcc, AttribBytes (32)), // A Connection is required Connection ( @@ -1452,7 +1452,11 @@ Method(m760, 1, Serialized) OperationRegion(GSBD, GenericSerialBus, 0xB400, 0x100) Field(GSBD, BufferAcc, NoLock, Preserve) { - AccessAs (BufferAcc, AttribRawBytes (34)), + /* + * Note: AccessLength for AttribBytes here must at least 2 less than the + * transfer buffer to account for the status and length bytes + */ + AccessAs (BufferAcc, AttribRawBytes (32)), // A Connection is required Connection ( @@ -1519,7 +1523,11 @@ Method(m761, 1, Serialized) OperationRegion(GSBD, GenericSerialBus, 0xB400, 0x100) Field(GSBD, BufferAcc, NoLock, Preserve) { - AccessAs (BufferAcc, AttribRawProcessBytes (34)), + /* + * Note: AccessLength for AttribBytes here must at least 2 less than the + * transfer buffer to account for the status and length bytes + */ + AccessAs (BufferAcc, AttribRawProcessBytes (32)), // A Connection is required Connection ( diff --git a/tests/misc/grammar.aml b/tests/misc/grammar.aml index 27ba71f..2bfe915 100755 Binary files a/tests/misc/grammar.aml and b/tests/misc/grammar.aml differ