ACPICA: Difference between revisions

166 bytes added ,  11 months ago
no edit summary
[unchecked revision][unchecked revision]
No edit summary
 
(13 intermediate revisions by 4 users not shown)
Line 1:
{{ACPI}}
 
The ACPI Component Architecture '''ACPICA''' provides an operating system (OS)-independent reference implementation of the [[ACPI|Advanced Configuration and Power Interface]]. It can be adapted to any host OS. The ACPICA code is meant to be directly integrated into the host OS, as a kernel-resident subsystem. Hosting the ACPICA requires no changes to the core ACPICA code. However, it does require a small OS-specific interface layer, which must be written specifically for each host OS.
 
Line 21 ⟶ 23:
ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer()
{
ACPI_PHYSICAL_ADDRESS Ret = 0;
Ret = 0;
AcpiFindRootPointer(&Ret);
return Ret;
Line 79 ⟶ 80:
==== AcpiOsExecute ====
ACPI_STATUS AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function, void *Context)
Create a new Threadthread (or process) with entry point at ''Function'' using parameter ''Context''. ''Type'' is not really useful. When the scheduler chooses this thread it has to putpass in ''Context'' onto the first argument (RDI for x86-64, stack for x86-32 (using System V ABI) to have something like:
Function(Context);
 
==== AcpiOsSleep ====
void AcpiOsSleep(UINT64 Milliseconds)
Line 109 ⟶ 111:
==== AcpiOsCreateSemaphore ====
ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_SEMAPHORE *OutHandle)
Create a new semaphoreSemaphore with the counter initialized to ''InitialUnits'' and put its address in *OutHandle. I don't know how tu use MaxUnits. The spec says: The maximum number of units this semaphoreSemaphore will be required to accept.<br> However you should be ok if you ignore this.
 
==== AcpiOsDeleteSemahore ====
==== AcpiOsDeleteSemaphore ====
ACPI_STATUS AcpiOsDeleteSemaphore(ACPI_SEMAPHORE Handle)
-_-'
 
==== AcpiOsWaitSemaphore ====
ACPI_STATUS AcpiOsWaitSemaphore(ACPI_SEMAPHORE Handle, UINT32 Units, UINT16 Timeout)
Line 121 ⟶ 125:
==== AcpiOsCreateLock ====
ACPI_STATUS AcpiOsCreateLock(ACPI_SPINLOCK *OutHandle)
Create a new spinlock and put its address in *OutHandle. Spinlock should disable interrupts on the current cpuCPU to avoid scheduling and make sure that no other cpuCPU will access the reserved area.
 
==== AcpiOsDeleteLock ====
void AcpiOsDeleteLock(ACPI_HANDLE Handle)
Line 137 ⟶ 142:
If you're lucky, your IRQ manager uses handlers of this form:
uint32_t handler(void *);
In this case just assign the handler to the irqIRQ number with that context. I wasn't as lucky so I did:
#include <Irq.h>
ACPI_OSD_HANDLER ServiceRout;
Line 157 ⟶ 162:
==== AcpiOsRemoveInterruptHandler ====
ACPI_STATUS AcpiOsRemoveInterruptHandler(UINT32 InterruptNumber, ACPI_OSD_HANDLER Handler)
Just UnregisterIrq (InterruptNumber). Handler is provided in case you have an IrqIRQ manager which can have many handlers for one IrqIRQ. This would let you know which handler on that IrqIRQ you have to remove.
 
== Using ACPICA in your OS ==
 
Line 171 ⟶ 177:
 
=== Visual Studio experience ===
From Visual Studio, although there is little organization in the files, it is relatively easy to port. In the provided /generate directory, there is a VC 9.0 solution. The only project required for integration is "AcpiSubsystem". Copy this project along with all the files listed (you can keep the old directory structure). #define's can be used to configure certain aspects of it, and perhaps changing #ifdef WIN32 to #ifdef X86 might be a good idea (WIN64Win64 -> X64x64). Once this is done though the base of it is in place, and actypes.h is the only header file that needs any modification (that listed above). It might be an idea to change the option "Compile as C code" to default - it's all .c anyway. This allows you to add C++ to the project without problems. Once this is done, add OSL.c or OSLPP.cpp, write your OS layer and you are done.
 
== Code Examples ==
Line 184 ⟶ 190:
 
== External links ==
*[httphttps://www.acpica.org/ ACPICA Website]
*[httphttps://acpica.org/sites/acpica/files/acpica-reference_2reference_19.pdf ACPICA User Guide and Programmer Reference]. Explains how to integrate it in your OS. Any missing OS layer that isn't documented in this page, must be there.
 
[[Category:ACPI]]
Anonymous user