* - ACPICA Interface
*/
#define DEBUG 1
+#define _AcpiModuleName "Shim"
+#define _COMPONENT "Acess"
#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);
{
ACPI_STATUS rv;
+ #ifdef ACPI_DEBUG_OUTPUT
+ AcpiDbgLevel = ACPI_DB_ALL;
+ #endif
+
rv = AcpiInitializeSubsystem();
if( ACPI_FAILURE(rv) )
{
{
ACPI_SIZE val;
ACPI_STATUS rv;
-
+
+ if( gACPI_RSDPOverride )
+ return gACPI_RSDPOverride;
+
rv = AcpiFindRootPointer(&val);
if( ACPI_FAILURE(rv) )
return 0;
+ LOG("val=%x", val);
+
return val;
// (Or use EFI)
}
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;
- return (char*)MM_MapHWPages(PhysicalAddress, npages) + ofs;
+ void *rv = ((char*)MM_MapHWPages(PhysicalAddress, npages)) + ofs;
+ LOG("Map (%P+%i pg) to %p", PhysicalAddress, npages, rv);
+ return rv;
}
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
// --- 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 AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT32 Width)
{
void *ptr;
- if( Address < 1024*1024 ) {
+ if( Address < ONEMEG ) {
ptr = (void*)(KERNEL_BASE | Address);
}
else {
case 64: *Value = *(Uint64*)ptr; break;
}
- if( Address >= 1024*1024 ) {
+ if( Address >= ONEMEG ) {
MM_FreeTemp(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 {
va_list args;
va_start(args, Format);
- LogV(Format, args);
+ LogFV(Format, args);
va_end(args);
}
void AcpiOsVprintf(const char *Format, va_list Args)
{
- LogV(Format, Args);
+ LogFV(Format, Args);
}
void AcpiOsRedirectOutput(void *Destination)
{
- // TODO: is this needed?
+ // TODO: Do I even need to impliment this?
}
// --- Miscellaneous ---
gaPageReferences = (void*)MM_REFCOUNT_BASE;
+ Log_Debug("PMem", "maxAddr = %P", maxAddr);
Log_Log("PMem", "Physical memory set up (%lli pages of ~%lli MiB used)",
giPhysAlloc, (giTotalMemorySize*PAGE_SIZE)/(1024*1024)
);
Mutex_Release( &glPhysAlloc );
LEAVE('X', ret);
+ if( ret == 0x17FFE000 )
+ LogF("TRIP!\n");
#if TRACE_ALLOCS
if( now() > 4000 ) {
Log_Debug("PMem", "MM_AllocPhys: RETURN %P (%i free)", ret, giPageCount-giPhysAlloc);
{
for( int i = 0; i < NEnts; i ++ )
{
- Log_Debug("PMemMap", "%i: %i 0x%02x %08llx+%llx",
+ Log_Debug("PMemMap", "%i: %i 0x%02x %08llx+%llx (end %llx)",
i, map[i].Type, map[i].NUMADomain,
- map[i].Start, map[i].Length
+ map[i].Start, map[i].Length,
+ map[i].Start + map[i].Length
);
}
}