ACPI: Make it compile on architectures other than x86.

Change-Id: Ie72dd2c6a571234399dc99d3573a5de19252737e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5269
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
milek7 2022-03-29 02:53:49 +02:00 committed by Adrien Destugues
parent 409af93462
commit 748b488347
7 changed files with 105 additions and 31 deletions

View File

@ -140,6 +140,8 @@ __BEGIN_DECLS
#include "acdebug.h"
__END_DECLS
#include "arch_init.h"
ACPI_MODULE_NAME("Haiku ACPI Module")
@ -239,12 +241,8 @@ AcpiOsGetRootPointer()
if (acpiRootPointer != NULL)
sACPIRoot = *acpiRootPointer;
if (sACPIRoot == 0) {
ACPI_PHYSICAL_ADDRESS address;
ACPI_STATUS status = AcpiFindRootPointer(&address);
if (status == AE_OK)
sACPIRoot = address;
}
if (sACPIRoot == 0)
sACPIRoot = arch_init_find_root_pointer();
}
return sACPIRoot;
#else

View File

@ -14,7 +14,6 @@
#include <string.h>
#include <ACPI.h>
#include <apic.h>
#include <dpc.h>
#include <KernelExport.h>
#include <PCI.h>
@ -29,6 +28,9 @@ extern "C" {
}
#include "ACPIPrivate.h"
#include "arch_init.h"
//#define TRACE_ACPI_BUS
#ifdef TRACE_ACPI_BUS
#define TRACE(x...) dprintf("acpi: " x)
@ -38,9 +40,6 @@ extern "C" {
#define ERROR(x...) dprintf("acpi: " x)
#define PIC_MODE 0
#define APIC_MODE 1
#define ACPI_DEVICE_ID_LENGTH 0x08
extern dpc_module_info* gDPC;
@ -179,8 +178,6 @@ acpi_std_ops(int32 op,...)
switch (op) {
case B_MODULE_INIT:
{
ACPI_OBJECT arg;
ACPI_OBJECT_LIST parameter;
void *settings;
bool acpiDisabled = false;
AcpiGbl_CopyDsdtLocally = true;
@ -232,13 +229,7 @@ acpi_std_ops(int32 op,...)
/* Install the default address space handlers. */
arg.Integer.Type = ACPI_TYPE_INTEGER;
arg.Integer.Value = apic_available() ? APIC_MODE : PIC_MODE;
parameter.Count = 1;
parameter.Pointer = &arg;
AcpiEvaluateObject(NULL, (ACPI_STRING)"\\_PIC", &parameter, NULL);
arch_init_interrupt_controller();
if (checkAndLogFailure(AcpiEnableSubsystem(
ACPI_FULL_INITIALIZATION),

View File

@ -3,10 +3,15 @@ SubDir HAIKU_TOP src add-ons kernel bus_managers acpi ;
UsePrivateKernelHeaders ;
SubDirHdrs [ FDirName $(SUBDIR) acpica include ] ;
SubDirHdrs [ FDirName $(SUBDIR) acpica include platform ] ;
SubDirHdrs [ FDirName $(SUBDIR) arch $(TARGET_KERNEL_ARCH_DIR) ] ;
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) pci ] ;
SubDirCcFlags -D_KERNEL_MODE ;
local arch_src =
arch_init.cpp
;
local dispatcher_src =
dsargs.c
dscontrol.c
@ -193,7 +198,6 @@ local utilities_src =
;
StaticLibrary libacpi_ca.a :
$(compiler_src)
$(dispatcher_src)
$(events_src)
$(executer_src)
@ -205,6 +209,19 @@ StaticLibrary libacpi_ca.a :
$(utilities_src)
;
KernelAddon acpi :
ACPICAHaiku.cpp
BusManager.cpp
Module.cpp
Device.cpp
NamespaceDump.cpp
EmbeddedController.cpp
$(arch_src)
:
libacpi_ca.a
;
SEARCH on [ FGristFiles $(arch_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi arch $(TARGET_KERNEL_ARCH_DIR) ] ;
SEARCH on [ FGristFiles $(dispatcher_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components dispatcher ] ;
SEARCH on [ FGristFiles $(events_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components events ] ;
SEARCH on [ FGristFiles $(executer_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components executer ] ;
@ -214,14 +231,3 @@ SEARCH on [ FGristFiles $(parser_src) ] = [ FDirName $(HAIKU_TOP) src add-ons k
SEARCH on [ FGristFiles $(resources_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components resources ] ;
SEARCH on [ FGristFiles $(tables_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components tables ] ;
SEARCH on [ FGristFiles $(utilities_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica components utilities ] ;
KernelAddon acpi :
ACPICAHaiku.cpp
BusManager.cpp
Module.cpp
Device.cpp
NamespaceDump.cpp
EmbeddedController.cpp
:
libacpi_ca.a
;

View File

@ -191,7 +191,10 @@ struct mutex;
/* ACPICA cache implementation is adequate. */
#define ACPI_USE_LOCAL_CACHE
/* On other platform the default definition (do nothing) is fine. */
#if defined(__i386__) || defined(__x86_64__)
#define ACPI_FLUSH_CPU_CACHE() __asm __volatile("wbinvd");
#endif
/* Based on FreeBSD's due to lack of documentation */
extern int AcpiOsAcquireGlobalLock(uint32 *lock);

View File

@ -0,0 +1,50 @@
/*
* Copyright 2022 Adrien Destugues <pulkomandy@pulkomandy.tk>
*
* Distributed under terms of the MIT license.
*/
#include <ACPI.h>
#include <apic.h>
extern "C" {
#include "acpi.h"
#include "accommon.h"
#include "acdisasm.h"
#include "acnamesp.h"
}
#include "arch_init.h"
#define PIC_MODE 0
#define APIC_MODE 1
ACPI_PHYSICAL_ADDRESS
arch_init_find_root_pointer()
{
ACPI_PHYSICAL_ADDRESS address;
ACPI_STATUS status = AcpiFindRootPointer(&address);
if (status == AE_OK)
return address;
return 0;
}
void
arch_init_interrupt_controller()
{
ACPI_OBJECT arg;
ACPI_OBJECT_LIST parameter;
arg.Integer.Type = ACPI_TYPE_INTEGER;
arg.Integer.Value = apic_available() ? APIC_MODE : PIC_MODE;
parameter.Count = 1;
parameter.Pointer = &arg;
AcpiEvaluateObject(NULL, (ACPI_STRING)"\\_PIC", &parameter, NULL);
}

View File

@ -0,0 +1,25 @@
/*
* Copyright 2022 Adrien Destugues <pulkomandy@pulkomandy.tk>
*
* Distributed under terms of the MIT license.
*/
#ifndef ARCH_INIT_H
#define ARCH_INIT_H
/** Find the ACPI root pointer using arch or platform-specific code.
*
* For example on x86, search for it in the BIOS.
*/
ACPI_PHYSICAL_ADDRESS arch_init_find_root_pointer();
/** Initialize platform specific interrupt controller configuration.
*
* For example on x86, enable PIC or APIC depending on boot options.
*/
void arch_init_interrupt_controller();
#endif /* !ARCH_INIT_H */

View File

@ -7,6 +7,7 @@ UsePrivateHeaders kernel [ FDirName kernel arch x86 ] [ FDirName kernel util ] ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica include ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel bus_managers acpi acpica include
platform ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel bus_managers acpi arch $(TARGET_KERNEL_ARCH_DIR) ;
KernelStaticLibrary pci_arch_bus_manager :
pci_acpi.cpp