[PATCH v2] Introduce AcpiOs(Read|Write)Cmos and enable these in AcpiExCmosSpaceHandler
by Adam Goode
This introduces a generic OSL interface for reading and writing
SystemCMOS spaces. It is needed on Linux for registering a generic
handler for SystemCMOS because some firmware accesses CMOS in _INI.
(The first time I sent a somewhat corrupted patch file. This one should
be better).
---
source/components/events/evhandler.c | 1 +
source/components/executer/exregion.c | 23 +++++++++
source/include/acconfig.h | 2 +-
source/include/acpiosxf.h | 18 +++++++
source/os_specific/service_layers/osunixxf.c | 64 +++++++++++++++++++++++
source/os_specific/service_layers/oswinxf.c | 64 +++++++++++++++++++++++
tests/aapits/atosxfctrl.c | 2 +
tests/aapits/atosxfctrl.h | 3 ++
tests/aapits/atosxfwrap.c | 76 ++++++++++++++++++++++++++++
tests/aapits/atosxfwrap.h | 16 ++++++
10 files changed, 268 insertions(+), 1 deletion(-)
diff --git a/source/components/events/evhandler.c b/source/components/events/evhandler.c
index d02ea53..634c18e 100644
--- a/source/components/events/evhandler.c
+++ b/source/components/events/evhandler.c
@@ -139,6 +139,7 @@ UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] =
ACPI_ADR_SPACE_SYSTEM_MEMORY,
ACPI_ADR_SPACE_SYSTEM_IO,
ACPI_ADR_SPACE_PCI_CONFIG,
+ ACPI_ADR_SPACE_CMOS,
ACPI_ADR_SPACE_DATA_TABLE
};
diff --git a/source/components/executer/exregion.c b/source/components/executer/exregion.c
index 31bbb60..bd9addd 100644
--- a/source/components/executer/exregion.c
+++ b/source/components/executer/exregion.c
@@ -551,6 +551,29 @@ AcpiExCmosSpaceHandler (
ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "System-CMOS (width %u) R/W %u Address=%8.8X%8.8X\n",
+ BitWidth, Function, ACPI_FORMAT_UINT64(Address)));
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ Status = AcpiOsReadCmos(Address, Value, BitWidth);
+ break;
+
+ case ACPI_WRITE:
+
+ Status = AcpiOsWriteCmos(Address, *Value, BitWidth);
+ break;
+
+ default:
+
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
return_ACPI_STATUS (Status);
}
diff --git a/source/include/acconfig.h b/source/include/acconfig.h
index 41fa33d..dcecfa7 100644
--- a/source/include/acconfig.h
+++ b/source/include/acconfig.h
@@ -270,7 +270,7 @@
/* Maximum SpaceIds for Operation Regions */
#define ACPI_MAX_ADDRESS_SPACE 255
-#define ACPI_NUM_DEFAULT_SPACES 4
+#define ACPI_NUM_DEFAULT_SPACES 5
/* Array sizes. Used for range checking also */
diff --git a/source/include/acpiosxf.h b/source/include/acpiosxf.h
index 68d79c7..31523ea 100644
--- a/source/include/acpiosxf.h
+++ b/source/include/acpiosxf.h
@@ -452,6 +452,24 @@ AcpiOsWritePort (
UINT32 Width);
#endif
+/*
+ * Platform and hardware-independent CMOS memory interfaces
+ */
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadCmos
+ACPI_STATUS
+AcpiOsReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteCmos
+ACPI_STATUS
+AcpiOsWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width);
+#endif
/*
* Platform and hardware-independent physical memory interfaces
diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c
index c48f581..b763ddc 100644
--- a/source/os_specific/service_layers/osunixxf.c
+++ b/source/os_specific/service_layers/osunixxf.c
@@ -1361,6 +1361,70 @@ AcpiOsWritePort (
}
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiOsReadCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to read
+ * Value - Where value is placed
+ * Width - Number of bits
+ *
+ * RETURN: Value read from CMOS memory
+ *
+ * DESCRIPTION: Read data from CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width)
+{
+
+ switch (Width)
+ {
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+
+ *Value = 0;
+ break;
+
+ default:
+
+ return (AE_BAD_PARAMETER);
+ }
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsWriteCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to write
+ * Value - Value to write
+ * Width - Number of bits
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write data to CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width)
+{
+
+ return (AE_OK);
+}
+
+
/******************************************************************************
*
* FUNCTION: AcpiOsReadMemory
diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c
index 66ce8c8..80086fd 100644
--- a/source/os_specific/service_layers/oswinxf.c
+++ b/source/os_specific/service_layers/oswinxf.c
@@ -1356,6 +1356,70 @@ AcpiOsWritePort (
}
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiOsReadCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to read
+ * Value - Where value is placed
+ * Width - Number of bits
+ *
+ * RETURN: Value read from CMOS memory
+ *
+ * DESCRIPTION: Read data from CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width)
+{
+
+ switch (Width)
+ {
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+
+ *Value = 0;
+ break;
+
+ default:
+
+ return (AE_BAD_PARAMETER);
+ }
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsWriteCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to write
+ * Value - Value to write
+ * Width - Number of bits
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write data to CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width)
+{
+
+ return (AE_OK);
+}
+
+
/******************************************************************************
*
* FUNCTION: AcpiOsReadMemory
diff --git a/tests/aapits/atosxfctrl.c b/tests/aapits/atosxfctrl.c
index fe8b562..9a6b41c 100644
--- a/tests/aapits/atosxfctrl.c
+++ b/tests/aapits/atosxfctrl.c
@@ -160,6 +160,8 @@ const char *OsxfNames[] = {
"AcpiOsDerivePciId",
"AcpiOsReadPort",
"AcpiOsWritePort",
+ "AcpiOsReadCmos",
+ "AcpiOsWriteCmos",
"AcpiOsReadMemory",
"AcpiOsWriteMemory",
"AcpiOsSignal"};
diff --git a/tests/aapits/atosxfctrl.h b/tests/aapits/atosxfctrl.h
index 66a361d..2c8b9e5 100644
--- a/tests/aapits/atosxfctrl.h
+++ b/tests/aapits/atosxfctrl.h
@@ -162,6 +162,8 @@ typedef enum
AcpiOsDerivePciIdC,
AcpiOsReadPortC,
AcpiOsWritePortC,
+ AcpiOsReadCmosC,
+ AcpiOsWriteCmosC,
AcpiOsReadMemoryC,
AcpiOsWriteMemoryC,
AcpiOsSignalC,
@@ -229,6 +231,7 @@ typedef struct acpi_os_emul_reg
*/
#define EMUL_REG_SYS 0x01
#define EMUL_REG_IO 0x02
+#define EMUL_REG_CMOS 0x03
/*
* Fixed ACPI h/w emulated registers numbers
diff --git a/tests/aapits/atosxfwrap.c b/tests/aapits/atosxfwrap.c
index 7c5de39..0088212 100644
--- a/tests/aapits/atosxfwrap.c
+++ b/tests/aapits/atosxfwrap.c
@@ -1272,6 +1272,82 @@ AcpiOsWritePort (
}
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiOsReadCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to read
+ * Value - Where value is placed
+ * Width - Number of bits
+ *
+ * RETURN: Value read from CMOS memory
+ *
+ * DESCRIPTION: Read data from CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width)
+{
+ AT_CTRL_DECL(AcpiOsReadCmos);
+
+ AT_CHCK_RET_STATUS(AcpiOsReadCmos);
+
+ if (!EMUL_REG_MODE) {
+ Status = AcpiOsActualReadCmos(Address, Value, Width);
+ }
+ else
+ {
+ Status = OsxfCtrlReadReg(EMUL_REG_CMOS, Address, Value, Width);
+ }
+
+ AT_CTRL_SUCCESS(AcpiOsReadCmos);
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsWriteCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to write
+ * Value - Value to write
+ * Width - Number of bits
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write data to CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width)
+{
+ AT_CTRL_DECL(AcpiOsWriteCmos);
+
+ AT_CHCK_RET_STATUS(AcpiOsWriteCmos);
+
+ if (!EMUL_REG_MODE) {
+ Status = AcpiOsActualWriteCmos(Address, Value, Width);
+ }
+ else
+ {
+ Status = OsxfCtrlWriteReg(EMUL_REG_CMOS, Address, Value, Width);
+ }
+
+ AT_CTRL_SUCCESS(AcpiOsWriteCmos);
+
+ return (Status);
+}
+
+
/******************************************************************************
*
* FUNCTION: AcpiOsReadMemory
diff --git a/tests/aapits/atosxfwrap.h b/tests/aapits/atosxfwrap.h
index 27224d0..48e2100 100644
--- a/tests/aapits/atosxfwrap.h
+++ b/tests/aapits/atosxfwrap.h
@@ -324,6 +324,22 @@ AcpiOsActualWritePort (
/*
+ * Platform and hardware-independent CMOS memory interfaces
+ */
+ACPI_STATUS
+AcpiOsActualReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width);
+
+ACPI_STATUS
+AcpiOsActualWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width);
+
+
+/*
* Platform and hardware-independent physical memory interfaces
*/
ACPI_STATUS
--
2.3.7
4 years, 10 months
ACPICA version 20150930 released
by Moore, Robert
30 September 2015. Summary of changes for version 20150930:
This release is available at https://acpica.org/downloads
1) ACPICA kernel-resident subsystem:
Debugger: Implemented several changes and bug fixes to assist support for the in-kernel version of the AML debugger. Lv Zheng.
- Fix the "predefined" command for in-kernel debugger.
- Do not enter debug command loop for the help and version commands.
- Disallow "execute" command during execution/single-step of a method.
Interpreter: Updated runtime typechecking for all operators that have target operands. The operand is resolved and validated that it is legal. For example, the target cannot be a non-data object such as a Device, Mutex, ThermalZone, etc., as per the ACPI specification.
Debugger: Fixed the double-mutex user I/O handshake to work when local deadlock detection is enabled.
Debugger: limited display of method locals and arguments (LocalX and ArgX) to only those that have actually been initialized. This prevents lines of extraneous output.
Updated the definition of the NFIT table to correct the bit polarity of one flag: ACPI_NFIT_MEM_ARMED --> ACPI_NFIT_MEM_NOT_ARMED
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: 101.7K Code, 27.9K Data, 129.6K Total
Debug Version: 199.3K Code, 81.4K Data, 280.7K Total
Previous Release:
Non-Debug Version: 101.3K Code, 27.7K Data, 129.0K Total
Debug Version: 198.6K Code, 80.9K Data, 279.5K Total
2) iASL Compiler/Disassembler and Tools:
iASL: Improved the compile-time typechecking for operands of many of the ASL operators:
-- Added an option to disable compiler operand/operator typechecking (-ot).
-- For the following operators, the TermArg operands are now validated when possible to be Integer data objects: BankField, OperationRegion, DataTableRegion, Buffer, and Package.
-- Store (Source, Target): Both the source and target operands are resolved and checked that the operands are both legal. For example, neither operand can be a non-data object such as a Device, Mutex, ThermalZone, etc. Note, as per the ACPI specification, the CopyObject operator can be used to store an object to any type of target object.
-- Store (Source, Target): If the source is a Package object, the target must be a Package object, LocalX, ArgX, or Debug. Likewise, if the target is a Package, the source must also be a Package.
-- Store (Source, Target): A warning is issued if the source and target resolve to the identical named object.
-- Store (Source, <method invocation>): An error is generated for the target method invocation, as this construct is not supported by the AML interpreter.
-- For all ASL math and logic operators, the target operand must be a data object (Integer, String, Buffer, LocalX, ArgX, or Debug). This includes the function return value also.
-- External declarations are also included in the typechecking where possible. External objects defined using the UnknownObj keyword cannot be typechecked, however.
iASL and Disassembler: Added symbolic (ASL+) support for the ASL Index operator:
- Legacy code: Index(PKG1, 3)
- New ASL+ code: PKG1[3]
This completes the ACPI 6.0 ASL+ support as it was the only operator not supported.
iASL: Fixed the file suffix for the preprocessor output file (.i). Two spaces were inadvertently appended to the filename, causing file access and deletion problems on some systems.
ASL Test Suite (ASLTS): Updated the master makefile to generate all possible compiler output files when building the test suite -- thus exercising these features of the compiler. These files are automatically deleted when the test suite exits.
5 years, 5 months
Re: [Devel] [PATCH] ACPICA: fix possible NULL dereference
by Zheng, Lv
If it is intentional, can we put something like assert(), BUG_ON() there so that the checker can always be coded but not compiled when the binary is released?
Thanks
-Lv
> From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com]
> Sent: Friday, September 18, 2015 2:06 PM
>
> On Thu, Sep 10, 2015 at 07:06:02PM +0000, Moore, Robert wrote:
> > One of the things we always have to think about and look at is that often, things like this are *guaranteed" to be valid simply by
> virtue of the fact that the code has gotten as far as it has.
> >
> > So, rather than litter the code with NULL checks for every single access, we know up front that the object is valid.
> >
> > This isn't always true and there are some valid situations, but we would appreciate it if you help track this down.
> I tried but looks like acpi is very tough to understand. The only
> argument I can give in favor of my patch is that in all the places this
> function acpi_ns_get_secondary_object() has been used the return has
> been checked, only the three calls in this file acpi/acpica/dsargs.c
> has not checked the return. Like you said it might be intentional also
> to not check the return only in this file.
>
> regards
> sudip
5 years, 5 months
compliance of acpi-enabled motherboards
by Michał Zegan
Hello.
I am actually quite curious, if today's motherboard (with uefi) do have
good acpi implementations, or do they still require dirty hacks, usually?
5 years, 5 months
PATCH proposal removing use of strtoul in events/evgpeinit.c
by Richard PALO
I'm noticing on catching up recently, e.g. on 20150717, that there is the following issue:
> /home/richard/ws/illumos-gate/usr/src/common/acpica/components/events/evgpeinit.c: In function 'AcpiEvMatchGpeMethod':
> /home/richard/ws/illumos-gate/usr/src/common/acpica/components/events/evgpeinit.c:398: error: implicit declaration of function 'strtoul' [-Wimplicit-function-declaration]
strtoul is indirectly defined in acsolaris via a system header as:
I like to propose the following patch substituting for a simplified, specific conversion
in the file events/evgpeinit.c.
>extern unsigned long strtoul(const char *, char **, int);
This seems to be the only real use of strtoul with _KERNEL defined.
Looking at the code in question, for two hex digits is doesn't seem the worth to use it so I propose
to replace as follows:
> diff --git a/usr/src/common/acpica/components/events/evgpeinit.c b/usr/src/common/acpica/components/events/evgpeinit.c
> index d23a345..de1e15a 100644
> --- a/usr/src/common/acpica/components/events/evgpeinit.c
> +++ b/usr/src/common/acpica/components/events/evgpeinit.c
> @@ -395,8 +395,22 @@ AcpiEvMatchGpeMethod (
>
> /* 4) The last two characters of the name are the hex GPE Number */
>
> - GpeNumber = strtoul (&Name[2], NULL, 16);
> - if (GpeNumber == ACPI_UINT32_MAX)
> + /* GpeNumber = strtoul (&Name[2], NULL, 16); */
> + /*
> + * As this function can be called in KERNEL, not all systems have
> + * strtoul() available. Since this is only for a single hex value,
> + * manually convert nibble by nibble, checking for possible errors.
> + */
> + GpeNumber = isdigit(Name[2]) ? (Name[2] - '0')<<4 :
> + isxdigit(Name[2]) ? (toupper(Name[2]) - 'A' + 10)<<4 : 0xFFFF;
> +
> + if (GpeNumber != 0xFFFF) {
> + GpeNumber = isdigit(Name[3]) ? GpeNumber + (Name[3] - '0') :
> + isxdigit(Name[3]) ? GpeNumber + (toupper(Name[3]) - 'A' + 10) :
> + 0xFFFF;
> + }
> +
> + if (GpeNumber == 0xFFFF || Name[4] != '\0')
> {
> /* Conversion failed; invalid method, just ignore it */
>
--
Richard PALO
5 years, 5 months
Re: [Devel] [PATCH] ACPICA: fix possible NULL dereference
by Moore, Robert
One of the things we always have to think about and look at is that often, things like this are *guaranteed" to be valid simply by virtue of the fact that the code has gotten as far as it has.
So, rather than litter the code with NULL checks for every single access, we know up front that the object is valid.
This isn't always true and there are some valid situations, but we would appreciate it if you help track this down.
Bob
> -----Original Message-----
> From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com]
> Sent: Thursday, September 10, 2015 3:19 AM
> To: Moore, Robert; Zheng, Lv; Wysocki, Rafael J; Len Brown
> Cc: linux-kernel(a)vger.kernel.org; linux-acpi(a)vger.kernel.org;
> devel(a)acpica.org; Sudip Mukherjee
> Subject: [PATCH] ACPICA: fix possible NULL dereference
>
> acpi_ns_get_secondary_object() can return NULL, and if it returns NULL
> then we were dereferencing it while calling acpi_ds_execute_arguments().
>
> Lets have a NULL check and return AE_NOT_EXIST.
>
> Signed-off-by: Sudip Mukherjee <sudip(a)vectorindia.org>
> ---
> drivers/acpi/acpica/dsargs.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/acpi/acpica/dsargs.c b/drivers/acpi/acpica/dsargs.c
> index e2ab59e..4bb8952 100644
> --- a/drivers/acpi/acpica/dsargs.c
> +++ b/drivers/acpi/acpica/dsargs.c
> @@ -192,6 +192,9 @@ acpi_ds_get_buffer_field_arguments(union
> acpi_operand_object *obj_desc)
> /* Get the AML pointer (method object) and buffer_field node */
>
> extra_desc = acpi_ns_get_secondary_object(obj_desc);
> + if (!extra_desc)
> + return_ACPI_STATUS(AE_NOT_EXIST);
> +
> node = obj_desc->buffer_field.node;
>
>
> ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_BUFFER_FIELD
> ,
> --
> 1.9.1
5 years, 5 months