[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
6 years, 4 months
AcpiHwRead/AcpiHwWrite regression in 20160318
by Thomas Faber
Hi,
the new AcpiHwRead/AcpiHwWrite implementations have caused a regression
on VirtualBox here. On ReactOS I'm getting an interrupt storm because
interaction with the event status register is no longer working.
The obvious issue that I observe is that the XPm1aStatus register is
now read from/written to in individual 8-bit operations instead of
using the full 16 bit length as before.
VirtualBox does not seem to allow this:
https://github.com/mdaniel/virtualbox-org-svn-vbox-trunk/blob/master/src/...
The register description looks like this (which seems as expected):
kd> ?? AcpiGbl_FADT.XPm1aEventBlock
struct acpi_generic_address
+0x000 SpaceId : 0x1 ''
+0x001 BitWidth : 0x20 ' '
+0x002 BitOffset : 0 ''
+0x003 AccessWidth : 0x2 ''
+0x004 Address : 0x4000
kd> ?? AcpiGbl_XPm1aStatus
struct acpi_generic_address
+0x000 SpaceId : 0x1 ''
+0x001 BitWidth : 0x10 ''
+0x002 BitOffset : 0 ''
+0x003 AccessWidth : 0 ''
+0x004 Address : 0x4000
It looks like the AccessWidth needs to be explicitly set to 2 here now
rather than defaulting to 0? Alternatively, zero AccessWidth would have
to lead to a smarter default than just assuming 8-bit reads.
For reference, backtraces for reading this register with versions
20160318 and 20160108 showing the arguments passed to the OSL functions
can be found below.
Assuming my analysis is correct, it's probably faster & more correct for
someone else to fix the issue in the code, but I can provide a patch if
you prefer.
Thanks!
-Thomas
Read New (20160318) -- returns 0xff (and so does the follow-up read on port 0x4001):
kd> kp
ChildEBP RetAddr
f392a228 f8b3eb5a acpi!AcpiOsReadPort(unsigned int64 Address = 0x4000, unsigned int * Value = 0xf392a288, unsigned int Width = 8) [reactos\drivers\bus\acpi\osl.c @ 707]
f392a24c f8b3e26d acpi!AcpiHwReadPort(unsigned int64 Address = 0x4000, unsigned int * Value = 0xf392a288, unsigned int Width = 8)+0x5a [reactos\drivers\bus\acpi\acpica\hardware\hwvalid.c @ 258]
f392a29c f8b3ea43 acpi!AcpiHwRead(unsigned int * Value = 0xf392a2b4, struct acpi_generic_address * Reg = 0xf8b68860)+0x11d [reactos\drivers\bus\acpi\acpica\hardware\hwregs.c @ 231]
f392a2bc f8b3e795 acpi!AcpiHwReadMultiple(unsigned int * Value = 0xf392a2d8, struct acpi_generic_address * RegisterA = 0xf8b68860, struct acpi_generic_address * RegisterB = 0xf8b68690)+0x23 [reactos\drivers\bus\acpi\acpica\hardware\hwregs.c @ 780]
f392a2dc f8b3d17a acpi!AcpiHwRegisterRead(unsigned int RegisterId = 1, unsigned int * ReturnValue = 0xf392a2f0)+0x45 [reactos\drivers\bus\acpi\acpica\hardware\hwregs.c @ 565]
f392a2fc f8b4683a acpi!AcpiEvFixedEventDetect(void)+0x1a [reactos\drivers\bus\acpi\acpica\events\evevent.c @ 248]
f392a30c f8b2f1d2 acpi!AcpiEvSciXruptHandler(void * Context = 0xf50dbff0)+0x1a [reactos\drivers\bus\acpi\acpica\events\evsci.c @ 146]
f392a31c 804f160c acpi!OslIsrStub(struct _KINTERRUPT * Interrupt = 0xf50ddd98, void * ServiceContext = 0x00000000)+0x12 [reactos\drivers\bus\acpi\osl.c @ 541]
f392a350 804f1738 nt!KiChainedDispatch(struct _KTRAP_FRAME * TrapFrame = 0xf392a364, struct _KINTERRUPT * Interrupt = 0xf50ddd98)+0xbc [reactos\ntoskrnl\ke\i386\irqobj.c @ 284]
Read Old (20160108) -- returns 0x0000:
kd> kp
ChildEBP RetAddr
f392a350 f8b3f57a acpi!AcpiOsReadPort(unsigned int64 Address = 0x4000, unsigned int * Value = 0xf392a3bc, unsigned int Width = 0x10) [reactos\drivers\bus\acpi\osl.c @ 707]
f392a374 f8b3efbd acpi!AcpiHwReadPort(unsigned int64 Address = 0x4000, unsigned int * Value = 0xf392a3bc, unsigned int Width = 0x10)+0x5a [reactos\drivers\bus\acpi\acpica\hardware\hwvalid.c @ 258]
f392a3a4 f8b3f463 acpi!AcpiHwRead(unsigned int * Value = 0xf392a3bc, struct acpi_generic_address * Reg = 0xf8b68800)+0x7d [reactos\drivers\bus\acpi\acpica\hardware\hwregs.c @ 207]
f392a3c4 f8b3f1b5 acpi!AcpiHwReadMultiple(unsigned int * Value = 0xf392a3e0, struct acpi_generic_address * RegisterA = 0xf8b68800, struct acpi_generic_address * RegisterB = 0xf8b68630)+0x23 [reactos\drivers\bus\acpi\acpica\hardware\hwregs.c @ 646]
f392a3e4 f8b3d72a acpi!AcpiHwRegisterRead(unsigned int RegisterId = 1, unsigned int * ReturnValue = 0xf392a3f8)+0x45 [reactos\drivers\bus\acpi\acpica\hardware\hwregs.c @ 431]
f392a404 f8b46d6a acpi!AcpiEvFixedEventDetect(void)+0x1a [reactos\drivers\bus\acpi\acpica\events\evevent.c @ 248]
f392a414 f8b2f1c2 acpi!AcpiEvSciXruptHandler(void * Context = 0xf4717ff0)+0x1a [reactos\drivers\bus\acpi\acpica\events\evsci.c @ 146]
f392a424 804f160c acpi!OslIsrStub(struct _KINTERRUPT * Interrupt = 0xf4719d98, void * ServiceContext = 0x00000000)+0x12 [reactos\drivers\bus\acpi\osl.c @ 541]
f392a458 804f1738 nt!KiChainedDispatch(struct _KTRAP_FRAME * TrapFrame = 0xf392a46c, struct _KINTERRUPT * Interrupt = 0xf4719d98)+0xbc [reactos\ntoskrnl\ke\i386\irqobj.c @ 284]
6 years, 4 months
Re: [Devel] [PATCH] ACPICA: fix Thunderbolt hotplug
by Moore, Robert
Lv is currently looking at this.
Bob
> -----Original Message-----
> From: Prarit Bhargava [mailto:[email protected]]
> Sent: Thursday, April 14, 2016 4:45 AM
> To: Moore, Robert; devel(a)acpica.org; Zheng, Lv; Wysocki, Rafael J
> Subject: Re: [PATCH] ACPICA: fix Thunderbolt hotplug
>
>
>
> On 04/07/2016 04:12 PM, Moore, Robert wrote:
> > I'll give the change a try here.
>
> Hi Robert, any luck? We have several reports of this patch resolving some
> hotplug issues on TB ports:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=115121
>
> P.
>
> >
> >
> >> -----Original Message-----
> >> From: Prarit Bhargava [mailto:[email protected]]
> >> Sent: Thursday, April 07, 2016 6:51 AM
> >> To: devel(a)acpica.org; Zheng, Lv
> >> Cc: Moore, Robert
> >> Subject: Re: [PATCH] ACPICA: fix Thunderbolt hotplug
> >>
> >>
> >>
> >> On 03/30/2016 05:10 PM, Moore, Robert wrote:
> >>> This patch looks familiar, we may have it fixed already.
> >>>
> >>> Lv should know.
> >>
> >> Lv? Second ping on this ...
> >>
> >> BTW: https://bugzilla.kernel.org/show_bug.cgi?id=115121
> >>
> >> shows three users with positive results. Additionally I'm testing on
> >> two Thunderbolt platforms here and both show positive results.
> >>
> >> P.
6 years, 4 months
Re: [Devel] [PATCH] mailbox: pcc: Support HW-Reduced Communication Subspace Type 2
by Sudeep Holla
Hi,
On 05/04/16 23:14, hotran wrote:
> ACPI 6.1 has a HW-Reduced Communication Subspace Type 2 intended for
> use on HW-Reduce ACPI Platform, which requires read-modify-write sequence
> to acknowledge doorbell interrupt. This patch provides the implementation
> for the Communication Subspace Type 2.
>
> Signed-off-by: Hoan Tran <hotran(a)apm.com>
> ---
> drivers/mailbox/pcc.c | 384 +++++++++++++++++++++++++++++++++++++-------------
> include/acpi/actbl3.h | 8 +-
This(2nd) file is generally imported from ACPICA directly.
So you need to work with acpica-devel list(you can cc Robert Moore) to
get that alone integrated in acpica projected so that iasl tool and
other related components also gain support for this first.
If the ACPI tables are generated by UEFI, it would be good to add the
support in tianocore project. IIRC tianocore has some PCC reference in
Acpi60.h header.
It would help if the above two are done before we start looking into
Linux changes(pcc.c). To summarize this patch needs to be split.
--
Regards,
Sudeep
6 years, 4 months
Re: [Devel] [PATCH] ACPICA: fix Thunderbolt hotplug
by Moore, Robert
I'll give the change a try here.
> -----Original Message-----
> From: Prarit Bhargava [mailto:[email protected]]
> Sent: Thursday, April 07, 2016 6:51 AM
> To: devel(a)acpica.org; Zheng, Lv
> Cc: Moore, Robert
> Subject: Re: [PATCH] ACPICA: fix Thunderbolt hotplug
>
>
>
> On 03/30/2016 05:10 PM, Moore, Robert wrote:
> > This patch looks familiar, we may have it fixed already.
> >
> > Lv should know.
>
> Lv? Second ping on this ...
>
> BTW: https://bugzilla.kernel.org/show_bug.cgi?id=115121
>
> shows three users with positive results. Additionally I'm testing on two
> Thunderbolt platforms here and both show positive results.
>
> P.
6 years, 4 months