- Well, that was a waste of a day
A_OBJ += mm_phys.o mm_virt.o
A_OBJ += proc.o proc.ao time.o vm8086.o
A_OBJ += kpanic.o pci.o vpci.o
A_OBJ += mm_phys.o mm_virt.o
A_OBJ += proc.o proc.ao time.o vm8086.o
A_OBJ += kpanic.o pci.o vpci.o
* - ACPICA Interface
*/
#define DEBUG 1
* - ACPICA Interface
*/
#define DEBUG 1
+#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);
+ #ifdef ACPI_DEBUG_OUTPUT
+ AcpiDbgLevel = ACPI_DB_ALL;
+ #endif
+
rv = AcpiInitializeSubsystem();
if( ACPI_FAILURE(rv) )
{
rv = AcpiInitializeSubsystem();
if( ACPI_FAILURE(rv) )
{
{
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;
return val;
// (Or use EFI)
}
return val;
// (Or use EFI)
}
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;
+ 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
// --- 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)
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 {
case 64: *Value = *(Uint64*)ptr; break;
}
case 64: *Value = *(Uint64*)ptr; break;
}
- if( Address >= 1024*1024 ) {
+ if( Address >= ONEMEG ) {
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 {
va_list args;
va_start(args, Format);
va_list args;
va_start(args, Format);
va_end(args);
}
void AcpiOsVprintf(const char *Format, va_list Args)
{
va_end(args);
}
void AcpiOsVprintf(const char *Format, va_list Args)
{
}
void AcpiOsRedirectOutput(void *Destination)
{
}
void AcpiOsRedirectOutput(void *Destination)
{
- // TODO: is this needed?
+ // TODO: Do I even need to impliment this?
}
// --- Miscellaneous ---
}
// --- Miscellaneous ---
extern void MM_Install(int NPMemRanges, tPMemMapEnt *PMemRanges);
extern void MM_InstallVirtual(void);
extern int Time_Setup(void);
extern void MM_Install(int NPMemRanges, tPMemMapEnt *PMemRanges);
extern void MM_InstallVirtual(void);
extern int Time_Setup(void);
-extern int ACPICA_Initialise(void);
+//extern int ACPICA_Initialise(void);
// === PROTOTYPES ===
int kmain(Uint MbMagic, void *MbInfoPtr);
// === PROTOTYPES ===
int kmain(Uint MbMagic, void *MbInfoPtr);
Threads_Init();
// Poke ACPICA
Threads_Init();
// Poke ACPICA
Log_Log("Arch", "Starting VFS...");
// Load Virtual Filesystem
Log_Log("Arch", "Starting VFS...");
// Load Virtual Filesystem
gaPageReferences = (void*)MM_REFCOUNT_BASE;
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)
);
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);
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);
#if TRACE_ALLOCS
if( now() > 4000 ) {
Log_Debug("PMem", "MM_AllocPhys: RETURN %P (%i free)", ret, giPageCount-giPhysAlloc);
+
+void LogFV(const char *Fmt, va_list args)
+{
+ #if LOCK_DEBUG_OUTPUT
+ SHORTLOCK(&glDebug_Lock);
+ #endif
+
+ Debug_Fmt(1, Fmt, args);
+
+ #if LOCK_DEBUG_OUTPUT
+ SHORTREL(&glDebug_Lock);
+ #endif
+}
+
void LogV(const char *Fmt, va_list args)
{
#if LOCK_DEBUG_OUTPUT
void LogV(const char *Fmt, va_list args)
{
#if LOCK_DEBUG_OUTPUT
{
for( int i = 0; i < NEnts; i ++ )
{
{
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,
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