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 <[email protected]> Reviewed-by: Adrien Destugues <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -140,6 +140,8 @@ __BEGIN_DECLS
|
|||||||
#include "acdebug.h"
|
#include "acdebug.h"
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
#include "arch_init.h"
|
||||||
|
|
||||||
|
|
||||||
ACPI_MODULE_NAME("Haiku ACPI Module")
|
ACPI_MODULE_NAME("Haiku ACPI Module")
|
||||||
|
|
||||||
@@ -239,12 +241,8 @@ AcpiOsGetRootPointer()
|
|||||||
if (acpiRootPointer != NULL)
|
if (acpiRootPointer != NULL)
|
||||||
sACPIRoot = *acpiRootPointer;
|
sACPIRoot = *acpiRootPointer;
|
||||||
|
|
||||||
if (sACPIRoot == 0) {
|
if (sACPIRoot == 0)
|
||||||
ACPI_PHYSICAL_ADDRESS address;
|
sACPIRoot = arch_init_find_root_pointer();
|
||||||
ACPI_STATUS status = AcpiFindRootPointer(&address);
|
|
||||||
if (status == AE_OK)
|
|
||||||
sACPIRoot = address;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return sACPIRoot;
|
return sACPIRoot;
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <ACPI.h>
|
#include <ACPI.h>
|
||||||
#include <apic.h>
|
|
||||||
#include <dpc.h>
|
#include <dpc.h>
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <PCI.h>
|
#include <PCI.h>
|
||||||
@@ -29,6 +28,9 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#include "ACPIPrivate.h"
|
#include "ACPIPrivate.h"
|
||||||
|
|
||||||
|
#include "arch_init.h"
|
||||||
|
|
||||||
|
|
||||||
//#define TRACE_ACPI_BUS
|
//#define TRACE_ACPI_BUS
|
||||||
#ifdef TRACE_ACPI_BUS
|
#ifdef TRACE_ACPI_BUS
|
||||||
#define TRACE(x...) dprintf("acpi: " x)
|
#define TRACE(x...) dprintf("acpi: " x)
|
||||||
@@ -38,9 +40,6 @@ extern "C" {
|
|||||||
|
|
||||||
#define ERROR(x...) dprintf("acpi: " x)
|
#define ERROR(x...) dprintf("acpi: " x)
|
||||||
|
|
||||||
#define PIC_MODE 0
|
|
||||||
#define APIC_MODE 1
|
|
||||||
|
|
||||||
#define ACPI_DEVICE_ID_LENGTH 0x08
|
#define ACPI_DEVICE_ID_LENGTH 0x08
|
||||||
|
|
||||||
extern dpc_module_info* gDPC;
|
extern dpc_module_info* gDPC;
|
||||||
@@ -179,8 +178,6 @@ acpi_std_ops(int32 op,...)
|
|||||||
switch (op) {
|
switch (op) {
|
||||||
case B_MODULE_INIT:
|
case B_MODULE_INIT:
|
||||||
{
|
{
|
||||||
ACPI_OBJECT arg;
|
|
||||||
ACPI_OBJECT_LIST parameter;
|
|
||||||
void *settings;
|
void *settings;
|
||||||
bool acpiDisabled = false;
|
bool acpiDisabled = false;
|
||||||
AcpiGbl_CopyDsdtLocally = true;
|
AcpiGbl_CopyDsdtLocally = true;
|
||||||
@@ -232,13 +229,7 @@ acpi_std_ops(int32 op,...)
|
|||||||
|
|
||||||
/* Install the default address space handlers. */
|
/* Install the default address space handlers. */
|
||||||
|
|
||||||
arg.Integer.Type = ACPI_TYPE_INTEGER;
|
arch_init_interrupt_controller();
|
||||||
arg.Integer.Value = apic_available() ? APIC_MODE : PIC_MODE;
|
|
||||||
|
|
||||||
parameter.Count = 1;
|
|
||||||
parameter.Pointer = &arg;
|
|
||||||
|
|
||||||
AcpiEvaluateObject(NULL, (ACPI_STRING)"\\_PIC", ¶meter, NULL);
|
|
||||||
|
|
||||||
if (checkAndLogFailure(AcpiEnableSubsystem(
|
if (checkAndLogFailure(AcpiEnableSubsystem(
|
||||||
ACPI_FULL_INITIALIZATION),
|
ACPI_FULL_INITIALIZATION),
|
||||||
|
|||||||
@@ -3,10 +3,15 @@ SubDir HAIKU_TOP src add-ons kernel bus_managers acpi ;
|
|||||||
UsePrivateKernelHeaders ;
|
UsePrivateKernelHeaders ;
|
||||||
SubDirHdrs [ FDirName $(SUBDIR) acpica include ] ;
|
SubDirHdrs [ FDirName $(SUBDIR) acpica include ] ;
|
||||||
SubDirHdrs [ FDirName $(SUBDIR) acpica include platform ] ;
|
SubDirHdrs [ FDirName $(SUBDIR) acpica include platform ] ;
|
||||||
|
SubDirHdrs [ FDirName $(SUBDIR) arch $(TARGET_KERNEL_ARCH_DIR) ] ;
|
||||||
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) pci ] ;
|
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) pci ] ;
|
||||||
SubDirCcFlags -D_KERNEL_MODE ;
|
SubDirCcFlags -D_KERNEL_MODE ;
|
||||||
|
|
||||||
|
|
||||||
|
local arch_src =
|
||||||
|
arch_init.cpp
|
||||||
|
;
|
||||||
|
|
||||||
local dispatcher_src =
|
local dispatcher_src =
|
||||||
dsargs.c
|
dsargs.c
|
||||||
dscontrol.c
|
dscontrol.c
|
||||||
@@ -193,7 +198,6 @@ local utilities_src =
|
|||||||
;
|
;
|
||||||
|
|
||||||
StaticLibrary libacpi_ca.a :
|
StaticLibrary libacpi_ca.a :
|
||||||
$(compiler_src)
|
|
||||||
$(dispatcher_src)
|
$(dispatcher_src)
|
||||||
$(events_src)
|
$(events_src)
|
||||||
$(executer_src)
|
$(executer_src)
|
||||||
@@ -205,6 +209,19 @@ StaticLibrary libacpi_ca.a :
|
|||||||
$(utilities_src)
|
$(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 $(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 $(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 ] ;
|
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 $(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 $(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 ] ;
|
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
|
|
||||||
;
|
|
||||||
|
|||||||
@@ -191,7 +191,10 @@ struct mutex;
|
|||||||
/* ACPICA cache implementation is adequate. */
|
/* ACPICA cache implementation is adequate. */
|
||||||
#define ACPI_USE_LOCAL_CACHE
|
#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");
|
#define ACPI_FLUSH_CPU_CACHE() __asm __volatile("wbinvd");
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Based on FreeBSD's due to lack of documentation */
|
/* Based on FreeBSD's due to lack of documentation */
|
||||||
extern int AcpiOsAcquireGlobalLock(uint32 *lock);
|
extern int AcpiOsAcquireGlobalLock(uint32 *lock);
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2022 Adrien Destugues <[email protected]>
|
||||||
|
*
|
||||||
|
* 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", ¶meter, NULL);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2022 Adrien Destugues <[email protected]>
|
||||||
|
*
|
||||||
|
* 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 */
|
||||||
@@ -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 ;
|
||||||
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 ;
|
platform ;
|
||||||
|
SubDirHdrs $(HAIKU_TOP) src add-ons kernel bus_managers acpi arch $(TARGET_KERNEL_ARCH_DIR) ;
|
||||||
|
|
||||||
KernelStaticLibrary pci_arch_bus_manager :
|
KernelStaticLibrary pci_arch_bus_manager :
|
||||||
pci_acpi.cpp
|
pci_acpi.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user