* Mostly format cleanups and comment clarifications.

* Corrected AcpiOsReadable and AcpiOsWritable to always return true in kernel and to better check bit flags otherwise.
* Removed comment about implementing acpi object cache with slab (object_cache). ACPI's own is simple, light and nice enough.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33887 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Fredrik Holmqvist
2009-11-04 22:18:13 +00:00
parent bd34734f11
commit 66db0536d2
2 changed files with 85 additions and 89 deletions
@@ -128,11 +128,11 @@
#define ACPI_USE_STANDARD_HEADERS #define ACPI_USE_STANDARD_HEADERS
/* TODO: add mutex or benaphore code /* TODO: add mutex or benaphore code
#define ACPI_MUTEX_TYPE ACPI_OSL_MUTEX we don't use mutex atm as it doesn't support timeout.
#define ACPI_MUTEX sem_id define ACPI_MUTEX_TYPE ACPI_OSL_MUTEX
define ACPI_MUTEX mutex *
*/ */
//#define ACPI_MUTEX_DEBUG
#define ACPI_USE_NATIVE_DIVIDE #define ACPI_USE_NATIVE_DIVIDE
#define ACPI_THREAD_ID thread_id #define ACPI_THREAD_ID thread_id
@@ -152,12 +152,9 @@
#include <KernelExport.h> #include <KernelExport.h>
/* ACPI's own impl is adequate. */
#define ACPI_USE_LOCAL_CACHE #define ACPI_USE_LOCAL_CACHE
/* TODO: Use Haiku's slab code */
//#define ACPI_CACHE_T struct kmem_cache
#define ACPI_FLUSH_CPU_CACHE() __asm __volatile("wbinvd"); #define ACPI_FLUSH_CPU_CACHE() __asm __volatile("wbinvd");
/* Based on FreeBSD's due to lack of documentation */ /* Based on FreeBSD's due to lack of documentation */
+33 -34
View File
@@ -114,11 +114,10 @@
*****************************************************************************/ *****************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <OS.h> #include <OS.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "acpi.h" #include "acpi.h"
#include "accommon.h" #include "accommon.h"
@@ -126,9 +125,9 @@
#include "acparser.h" #include "acparser.h"
#include "acdebug.h" #include "acdebug.h"
#ifdef _KERNEL_MODE #ifdef _KERNEL_MODE
#include <KernelExport.h> #include <KernelExport.h>
#include <dpc.h> #include <dpc.h>
#include <PCI.h> #include <PCI.h>
#include <vm.h> #include <vm.h>
@@ -177,16 +176,6 @@ FILE *AcpiGbl_OutputFile;
static uint32 sACPIRoot = 0; static uint32 sACPIRoot = 0;
static void *sInterruptHandlerData[32]; static void *sInterruptHandlerData[32];
// Upcalls to AcpiExec
//ACPI_PHYSICAL_ADDRESS
//AeLocalGetRootPointer();
//void
//AeTableOverride(ACPI_TABLE_HEADER *ExistingTable, ACPI_TABLE_HEADER **NewTable);
//typedef void* (*PTHREAD_CALLBACK)(void *);
/****************************************************************************** /******************************************************************************
* *
@@ -426,6 +415,7 @@ AcpiOsGetLine(char *buffer)
return i; return i;
} }
/****************************************************************************** /******************************************************************************
* *
* FUNCTION: AcpiOsMapMemory * FUNCTION: AcpiOsMapMemory
@@ -444,7 +434,8 @@ AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS where, ACPI_SIZE length)
#ifdef _KERNEL_MODE #ifdef _KERNEL_MODE
void *there; void *there;
area_id area = map_physical_memory("acpi_physical_mem_area", (void *)where, area_id area = map_physical_memory("acpi_physical_mem_area", (void *)where,
length, B_ANY_KERNEL_BLOCK_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, &there); length, B_ANY_KERNEL_BLOCK_ADDRESS,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, &there);
DEBUG_FUNCTION_F("addr: 0x%08lx; length: %lu; mapped: %p; area: %ld", DEBUG_FUNCTION_F("addr: 0x%08lx; length: %lu; mapped: %p; area: %ld",
(addr_t)where, (size_t)length, there, area); (addr_t)where, (size_t)length, there, area);
@@ -457,7 +448,7 @@ AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS where, ACPI_SIZE length)
return NULL; return NULL;
#endif #endif
//return ACPI_TO_POINTER((ACPI_SIZE) where); // return ACPI_TO_POINTER((ACPI_SIZE) where);
} }
@@ -754,7 +745,6 @@ AcpiOsRemoveInterruptHandler(UINT32 interruptNumber,
} }
/****************************************************************************** /******************************************************************************
* *
* FUNCTION: AcpiOsExecute * FUNCTION: AcpiOsExecute
@@ -867,7 +857,7 @@ ACPI_STATUS
AcpiOsValidateInterface(char *interface) AcpiOsValidateInterface(char *interface)
{ {
DEBUG_FUNCTION_F("interface: \"%s\"", interface); DEBUG_FUNCTION_F("interface: \"%s\"", interface);
//TODO: This looks unimplemented. // TODO: This looks unimplemented.
return AE_SUPPORT; return AE_SUPPORT;
} }
@@ -1104,17 +1094,20 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS address, UINT32 value, UINT32 width)
BOOLEAN BOOLEAN
AcpiOsReadable(void *pointer, ACPI_SIZE length) AcpiOsReadable(void *pointer, ACPI_SIZE length)
{ {
#ifdef _KERNEL_MODE
return true;
#else
area_id id; area_id id;
area_info info; area_info info;
DEBUG_FUNCTION_F("addr: %p; length: %lu", pointer, (size_t)length); DEBUG_FUNCTION_F("addr: %p; length: %lu", pointer, (size_t)length);
id = area_for(pointer); id = area_for(pointer);
if (id == B_ERROR) if (id == B_ERROR) return false;
return false; if (get_area_info(id, &info) != B_OK) return false;
if (get_area_info(id, &info) != B_OK) return (info.protection & B_READ_AREA) != 0 &&
return false; pointer + length <= info.address + info.ram_size;
return info.protection & B_KERNEL_READ_AREA && #endif
(pointer + length) <= (info.address + info.ram_size);
} }
@@ -1133,17 +1126,21 @@ AcpiOsReadable(void *pointer, ACPI_SIZE length)
BOOLEAN BOOLEAN
AcpiOsWritable(void *pointer, ACPI_SIZE length) AcpiOsWritable(void *pointer, ACPI_SIZE length)
{ {
#ifdef _KERNEL_MODE
return true;
#else
area_id id; area_id id;
area_info info; area_info info;
DEBUG_FUNCTION_F("addr: %p; length: %lu", pointer, (size_t)length); DEBUG_FUNCTION_F("addr: %p; length: %lu", pointer, (size_t)length);
id = area_for(pointer); id = area_for(pointer);
if (id == B_ERROR) if (id == B_ERROR) return false;
return false; if (get_area_info(id, &info) != B_OK) return false;
if (get_area_info(id, &info) != B_OK) return (info.protection & B_READ_AREA) != 0 &&
return false; (info.protection & B_WRITE_AREA) != 0 &&
return info.protection & (B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA) && pointer + length <= info.address + info.ram_size;
(pointer + length) <= (info.address + info.ram_size); #endif
} }
@@ -1165,11 +1162,10 @@ ACPI_THREAD_ID
AcpiOsGetThreadId() AcpiOsGetThreadId()
{ {
thread_id thread = find_thread(NULL); thread_id thread = find_thread(NULL);
// TODO: We arn't allowed threads with id 0, handle this case.
//TODO: Handle if thread_id is 0.
// ACPI treats a 0 return as an error, // ACPI treats a 0 return as an error,
// but we are thread 0 in early boot // but we are thread 0 in early boot
return thread == 0 ? 1 : thread; return thread;
} }
@@ -1207,6 +1203,7 @@ AcpiOsSignal(UINT32 function, void *info)
return AE_OK; return AE_OK;
} }
/* /*
* Adapted from FreeBSD since the documentation of its intended impl * Adapted from FreeBSD since the documentation of its intended impl
* is lacking. * is lacking.
@@ -1217,6 +1214,7 @@ AcpiOsSignal(UINT32 function, void *info)
#define GL_BIT_OWNED 0x02 #define GL_BIT_OWNED 0x02
#define GL_BIT_MASK (GL_BIT_PENDING | GL_BIT_OWNED) #define GL_BIT_MASK (GL_BIT_PENDING | GL_BIT_OWNED)
/* /*
* Adapted from FreeBSD since the documentation of its intended impl * Adapted from FreeBSD since the documentation of its intended impl
* is lacking. * is lacking.
@@ -1239,6 +1237,7 @@ AcpiOsAcquireGlobalLock(uint32 *lock)
return ((new < GL_BIT_MASK) ? GL_ACQUIRED : GL_BUSY); return ((new < GL_BIT_MASK) ? GL_ACQUIRED : GL_BUSY);
} }
/* /*
* Adapted from FreeBSD since the documentation of its intended impl * Adapted from FreeBSD since the documentation of its intended impl
* is lacking. * is lacking.