git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git://localhost/acess2
[tpg/acess2.git]
/
KernelLand
/
Kernel
/
arch
/
x86
/
acpica.c
diff --git
a/KernelLand/Kernel/arch/x86/acpica.c
b/KernelLand/Kernel/arch/x86/acpica.c
index
246f1fd
..
43a1854
100644
(file)
--- a/
KernelLand/Kernel/arch/x86/acpica.c
+++ b/
KernelLand/Kernel/arch/x86/acpica.c
@@
-5,12
+5,21
@@
* acpica.c
* - ACPICA Interface
*/
* acpica.c
* - ACPICA Interface
*/
-#define DEBUG 1
+#define ACPI_DEBUG_OUTPUT 1
+#define DEBUG 0
+#define _AcpiModuleName "Shim"
+#define _COMPONENT "Acess"
#include <acpi.h>
#include <timers.h>
#include <mutex.h>
#include <semaphore.h>
#include <acpi.h>
#include <timers.h>
#include <mutex.h>
#include <semaphore.h>
+#define ONEMEG (1024*1024)
+
+// === GLOBALS ===
+// - RSDP Address from uEFI
+tPAddr gACPI_RSDPOverride = 0;
+
// === PROTOTYPES ===
int ACPICA_Initialise(void);
void ACPI_int_InterruptProxy(int IRQ, void *data);
// === PROTOTYPES ===
int ACPICA_Initialise(void);
void ACPI_int_InterruptProxy(int IRQ, void *data);
@@
-21,6
+30,10
@@
int ACPICA_Initialise(void)
{
ACPI_STATUS rv;
{
ACPI_STATUS rv;
+ #ifdef ACPI_DEBUG_OUTPUT
+ AcpiDbgLevel = ACPI_DB_ALL;
+ #endif
+
rv = AcpiInitializeSubsystem();
if( ACPI_FAILURE(rv) )
{
rv = AcpiInitializeSubsystem();
if( ACPI_FAILURE(rv) )
{
@@
-73,11
+86,16
@@
ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer(void)
{
ACPI_SIZE val;
ACPI_STATUS rv;
{
ACPI_SIZE val;
ACPI_STATUS rv;
-
+
+ if( gACPI_RSDPOverride )
+ return gACPI_RSDPOverride;
+
rv = AcpiFindRootPointer(&val);
if( ACPI_FAILURE(rv) )
return 0;
rv = AcpiFindRootPointer(&val);
if( ACPI_FAILURE(rv) )
return 0;
+ LOG("val=%x", val);
+
return val;
// (Or use EFI)
}
return val;
// (Or use EFI)
}
@@
-116,8
+134,13
@@
ACPI_STATUS AcpiOsCreateCache(char *CacheName, UINT16 ObjectSize, UINT16 MaxDept
int namelen = (CacheName ? strlen(CacheName) : 0) + 1;
LOG("CacheName=%s, ObjSize=%x, MaxDepth=%x", CacheName, ObjectSize, MaxDepth);
int namelen = (CacheName ? strlen(CacheName) : 0) + 1;
LOG("CacheName=%s, ObjSize=%x, MaxDepth=%x", CacheName, ObjectSize, MaxDepth);
+ namelen = (namelen + 3) & ~3;
+
ret = malloc(sizeof(*ret) + MaxDepth*sizeof(char) + namelen + MaxDepth*ObjectSize);
ret = malloc(sizeof(*ret) + MaxDepth*sizeof(char) + namelen + MaxDepth*ObjectSize);
- if( !ret ) return AE_NO_MEMORY;
+ if( !ret ) {
+ Log_Notice("ACPICA", "%s: malloc() fail", __func__);
+ return AE_NO_MEMORY;
+ }
ret->nObj = MaxDepth;
ret->ObjectSize = ObjectSize;
ret->nObj = MaxDepth;
ret->ObjectSize = ObjectSize;
@@
-129,7
+152,7
@@
ACPI_STATUS AcpiOsCreateCache(char *CacheName, UINT16 ObjectSize, UINT16 MaxDept
ret->Name[0] = 0;
memset(ret->ObjectStates, 0, sizeof(char)*MaxDepth);
ret->Name[0] = 0;
memset(ret->ObjectStates, 0, sizeof(char)*MaxDepth);
- LOG("Allocated cache
'%s' (%i x 0x%x)"
, CacheName, MaxDepth, ObjectSize);
+ LOG("Allocated cache
%p '%s' (%i x 0x%x)", ret
, CacheName, MaxDepth, ObjectSize);
*ReturnCache = ret;
*ReturnCache = ret;
@@
-157,15
+180,21
@@
ACPI_STATUS AcpiOsPurgeCache(ACPI_CACHE_T *Cache)
void *AcpiOsAcquireObject(ACPI_CACHE_T *Cache)
{
void *AcpiOsAcquireObject(ACPI_CACHE_T *Cache)
{
-
LOG("(Cache=%p)
", Cache);
+
ENTER("pCache
", Cache);
for(int i = 0; i < Cache->nObj; i ++ )
{
if( !Cache->ObjectStates[i] ) {
Cache->ObjectStates[i] = 1;
for(int i = 0; i < Cache->nObj; i ++ )
{
if( !Cache->ObjectStates[i] ) {
Cache->ObjectStates[i] = 1;
- return (char*)Cache->First + i*Cache->ObjectSize;
+ void *rv = (char*)Cache->First + i*Cache->ObjectSize;
+ memset(rv, 0, Cache->ObjectSize);
+ LEAVE('p', rv);
+ return rv;
}
}
}
}
- // TODO
+
+ Log_Debug("ACPICA", "AcpiOsAcquireObject: %i objects used", Cache->nObj);
+
+ LEAVE('n');
return NULL;
}
return NULL;
}
@@
-176,8
+205,9
@@
ACPI_STATUS AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object)
tVAddr delta = (tVAddr)Object - (tVAddr)Cache->First;
delta /= Cache->ObjectSize;
tVAddr delta = (tVAddr)Object - (tVAddr)Cache->First;
delta /= Cache->ObjectSize;
+ LOG("Cache=%p, delta = %i, (limit %i)", Cache, delta, Cache->nObj);
- if( delta > Cache->nObj )
+ if( delta >
=
Cache->nObj )
return AE_BAD_PARAMETER;
Cache->ObjectStates[delta] = 0;
return AE_BAD_PARAMETER;
Cache->ObjectStates[delta] = 0;
@@
-187,13
+217,24
@@
ACPI_STATUS AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object)
void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length)
{
void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length)
{
+ if( PhysicalAddress < ONEMEG )
+ return (void*)(KERNEL_BASE | PhysicalAddress);
+
Uint ofs = PhysicalAddress & (PAGE_SIZE-1);
int npages = (ofs + Length + (PAGE_SIZE-1)) / PAGE_SIZE;
Uint ofs = PhysicalAddress & (PAGE_SIZE-1);
int npages = (ofs + Length + (PAGE_SIZE-1)) / PAGE_SIZE;
- return (char*)MM_MapHWPages(PhysicalAddress, npages) + ofs;
+ void *rv = ((char*)MM_MapHWPages(PhysicalAddress, npages)) + ofs;
+// MM_DumpTables(0, -1);
+ LOG("Map (%P+%i pg) to %p", PhysicalAddress, npages, rv);
+ return rv;
}
void AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Length)
{
}
void AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Length)
{
+ if( (tVAddr)LogicalAddress - KERNEL_BASE < ONEMEG )
+ return ;
+
+ LOG("%p", LogicalAddress);
+
Uint ofs = (tVAddr)LogicalAddress & (PAGE_SIZE-1);
int npages = (ofs + Length + (PAGE_SIZE-1)) / PAGE_SIZE;
// TODO: Validate `Length` is the same as was passed to AcpiOsMapMemory
Uint ofs = (tVAddr)LogicalAddress & (PAGE_SIZE-1);
int npages = (ofs + Length + (PAGE_SIZE-1)) / PAGE_SIZE;
// TODO: Validate `Length` is the same as was passed to AcpiOsMapMemory
@@
-237,7
+278,7
@@
BOOLEAN AcpiOsWritable(void *Memory, ACPI_SIZE Length)
// --- Threads ---
ACPI_THREAD_ID AcpiOsGetThreadId(void)
{
// --- Threads ---
ACPI_THREAD_ID AcpiOsGetThreadId(void)
{
- return Threads_GetTID();
+ return Threads_GetTID()
+ 1
;
}
ACPI_STATUS AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function, void *Context)
}
ACPI_STATUS AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function, void *Context)
@@
-274,8
+315,10
@@
ACPI_STATUS AcpiOsCreateMutex(ACPI_MUTEX *OutHandle)
if( !OutHandle )
return AE_BAD_PARAMETER;
tMutex *ret = calloc( sizeof(tMutex), 1 );
if( !OutHandle )
return AE_BAD_PARAMETER;
tMutex *ret = calloc( sizeof(tMutex), 1 );
- if( !ret )
+ if( !ret ) {
+ Log_Notice("ACPICA", "%s: malloc() fail", __func__);
return AE_NO_MEMORY;
return AE_NO_MEMORY;
+ }
ret->Name = "AcpiOsCreateMutex";
*OutHandle = ret;
ret->Name = "AcpiOsCreateMutex";
*OutHandle = ret;
@@
-309,8
+352,10
@@
ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_SEM
if( !OutHandle )
return AE_BAD_PARAMETER;
tSemaphore *ret = calloc( sizeof(tSemaphore), 1 );
if( !OutHandle )
return AE_BAD_PARAMETER;
tSemaphore *ret = calloc( sizeof(tSemaphore), 1 );
- if( !ret )
+ if( !ret ) {
+ Log_Notice("ACPICA", "%s: malloc() fail", __func__);
return AE_NO_MEMORY;
return AE_NO_MEMORY;
+ }
Semaphore_Init(ret, InitialUnits, MaxUnits, "AcpiOsCreateSemaphore", "");
*OutHandle = ret;
Semaphore_Init(ret, InitialUnits, MaxUnits, "AcpiOsCreateSemaphore", "");
*OutHandle = ret;
@@
-444,7
+489,7
@@
ACPI_STATUS AcpiOsRemoveInterruptHandler(UINT32 InterruptLevel, ACPI_OSD_HANDLER
ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT32 Width)
{
void *ptr;
ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT32 Width)
{
void *ptr;
- if( Address <
1024*1024
) {
+ if( Address <
ONEMEG
) {
ptr = (void*)(KERNEL_BASE | Address);
}
else {
ptr = (void*)(KERNEL_BASE | Address);
}
else {
@@
-459,7
+504,7
@@
ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT3
case 64: *Value = *(Uint64*)ptr; break;
}
case 64: *Value = *(Uint64*)ptr; break;
}
- if( Address >=
1024*1024
) {
+ if( Address >=
ONEMEG
) {
MM_FreeTemp(ptr);
}
MM_FreeTemp(ptr);
}
@@
-469,7
+514,7
@@
ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT3
ACPI_STATUS AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 Value, UINT32 Width)
{
void *ptr;
ACPI_STATUS AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 Value, UINT32 Width)
{
void *ptr;
- if( Address <
1024*1024
) {
+ if( Address <
ONEMEG
) {
ptr = (void*)(KERNEL_BASE | Address);
}
else {
ptr = (void*)(KERNEL_BASE | Address);
}
else {
@@
-539,19
+584,19
@@
void AcpiOsPrintf(const char *Format, ...)
va_list args;
va_start(args, Format);
va_list args;
va_start(args, Format);
- LogV(Format, args);
+ Log
F
V(Format, args);
va_end(args);
}
void AcpiOsVprintf(const char *Format, va_list Args)
{
va_end(args);
}
void AcpiOsVprintf(const char *Format, va_list Args)
{
- LogV(Format, Args);
+ Log
F
V(Format, Args);
}
void AcpiOsRedirectOutput(void *Destination)
{
}
void AcpiOsRedirectOutput(void *Destination)
{
- // TODO:
is this needed
?
+ // TODO:
Do I even need to impliment this
?
}
// --- Miscellaneous ---
}
// --- Miscellaneous ---
UCC
git Repository :: git.ucc.asn.au