* 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
/* TODO: add mutex or benaphore code
#define ACPI_MUTEX_TYPE ACPI_OSL_MUTEX
#define ACPI_MUTEX sem_id
we don't use mutex atm as it doesn't support timeout.
define ACPI_MUTEX_TYPE ACPI_OSL_MUTEX
define ACPI_MUTEX mutex *
*/
//#define ACPI_MUTEX_DEBUG
#define ACPI_USE_NATIVE_DIVIDE
#define ACPI_THREAD_ID thread_id
@@ -152,12 +152,9 @@
#include <KernelExport.h>
/* ACPI's own impl is adequate. */
#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");
/* Based on FreeBSD's due to lack of documentation */
+31 -32
View File
@@ -114,11 +114,10 @@
*****************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <OS.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "acpi.h"
#include "accommon.h"
@@ -126,9 +125,9 @@
#include "acparser.h"
#include "acdebug.h"
#ifdef _KERNEL_MODE
#include <KernelExport.h>
#include <dpc.h>
#include <PCI.h>
#include <vm.h>
@@ -177,16 +176,6 @@ FILE *AcpiGbl_OutputFile;
static uint32 sACPIRoot = 0;
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;
}
/******************************************************************************
*
* FUNCTION: AcpiOsMapMemory
@@ -444,7 +434,8 @@ AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS where, ACPI_SIZE length)
#ifdef _KERNEL_MODE
void *there;
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",
(addr_t)where, (size_t)length, there, area);
@@ -754,7 +745,6 @@ AcpiOsRemoveInterruptHandler(UINT32 interruptNumber,
}
/******************************************************************************
*
* FUNCTION: AcpiOsExecute
@@ -1104,17 +1094,20 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS address, UINT32 value, UINT32 width)
BOOLEAN
AcpiOsReadable(void *pointer, ACPI_SIZE length)
{
#ifdef _KERNEL_MODE
return true;
#else
area_id id;
area_info info;
DEBUG_FUNCTION_F("addr: %p; length: %lu", pointer, (size_t)length);
id = area_for(pointer);
if (id == B_ERROR)
return false;
if (get_area_info(id, &info) != B_OK)
return false;
return info.protection & B_KERNEL_READ_AREA &&
(pointer + length) <= (info.address + info.ram_size);
if (id == B_ERROR) return false;
if (get_area_info(id, &info) != B_OK) return false;
return (info.protection & B_READ_AREA) != 0 &&
pointer + length <= info.address + info.ram_size;
#endif
}
@@ -1133,17 +1126,21 @@ AcpiOsReadable(void *pointer, ACPI_SIZE length)
BOOLEAN
AcpiOsWritable(void *pointer, ACPI_SIZE length)
{
#ifdef _KERNEL_MODE
return true;
#else
area_id id;
area_info info;
DEBUG_FUNCTION_F("addr: %p; length: %lu", pointer, (size_t)length);
id = area_for(pointer);
if (id == B_ERROR)
return false;
if (get_area_info(id, &info) != B_OK)
return false;
return info.protection & (B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA) &&
(pointer + length) <= (info.address + info.ram_size);
if (id == B_ERROR) return false;
if (get_area_info(id, &info) != B_OK) return false;
return (info.protection & B_READ_AREA) != 0 &&
(info.protection & B_WRITE_AREA) != 0 &&
pointer + length <= info.address + info.ram_size;
#endif
}
@@ -1165,11 +1162,10 @@ ACPI_THREAD_ID
AcpiOsGetThreadId()
{
thread_id thread = find_thread(NULL);
//TODO: Handle if thread_id is 0.
// TODO: We arn't allowed threads with id 0, handle this case.
// ACPI treats a 0 return as an error,
// 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;
}
/*
* Adapted from FreeBSD since the documentation of its intended impl
* is lacking.
@@ -1217,6 +1214,7 @@ AcpiOsSignal(UINT32 function, void *info)
#define GL_BIT_OWNED 0x02
#define GL_BIT_MASK (GL_BIT_PENDING | GL_BIT_OWNED)
/*
* Adapted from FreeBSD since the documentation of its intended impl
* is lacking.
@@ -1239,6 +1237,7 @@ AcpiOsAcquireGlobalLock(uint32 *lock)
return ((new < GL_BIT_MASK) ? GL_ACQUIRED : GL_BUSY);
}
/*
* Adapted from FreeBSD since the documentation of its intended impl
* is lacking.