From: John Hodge (sonata) Date: Sat, 1 Dec 2012 15:01:57 +0000 (+0800) Subject: Kernel - ACPI debugging, and disabled X-Git-Tag: rel0.15~617 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=fd61b8c2f5e94da0265b3885525beff8e86317f6;p=tpg%2Facess2.git Kernel - ACPI debugging, and disabled - Well, that was a waste of a day --- diff --git a/KernelLand/Kernel/arch/x86/Makefile b/KernelLand/Kernel/arch/x86/Makefile index c8152b9e..9e5a883c 100644 --- a/KernelLand/Kernel/arch/x86/Makefile +++ b/KernelLand/Kernel/arch/x86/Makefile @@ -24,7 +24,7 @@ A_OBJ = start.ao main.o mboot.o lib.o desctab.ao errors.o irq.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 -A_OBJ += acpica.o +#A_OBJ += acpica.o -EXTERNS += ACPICA +#EXTERNS += ACPICA diff --git a/KernelLand/Kernel/arch/x86/acpica.c b/KernelLand/Kernel/arch/x86/acpica.c index 246f1fd9..f310fc5b 100644 --- a/KernelLand/Kernel/arch/x86/acpica.c +++ b/KernelLand/Kernel/arch/x86/acpica.c @@ -6,11 +6,19 @@ * - ACPICA Interface */ #define DEBUG 1 +#define _AcpiModuleName "Shim" +#define _COMPONENT "Acess" #include #include #include #include +#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); @@ -21,6 +29,10 @@ int ACPICA_Initialise(void) { ACPI_STATUS rv; + #ifdef ACPI_DEBUG_OUTPUT + AcpiDbgLevel = ACPI_DB_ALL; + #endif + rv = AcpiInitializeSubsystem(); if( ACPI_FAILURE(rv) ) { @@ -73,11 +85,16 @@ ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer(void) { 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) } @@ -187,13 +204,23 @@ ACPI_STATUS AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object) 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 @@ -237,7 +264,7 @@ BOOLEAN AcpiOsWritable(void *Memory, ACPI_SIZE Length) // --- 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) @@ -444,7 +471,7 @@ ACPI_STATUS AcpiOsRemoveInterruptHandler(UINT32 InterruptLevel, ACPI_OSD_HANDLER 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 { @@ -459,7 +486,7 @@ ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT3 case 64: *Value = *(Uint64*)ptr; break; } - if( Address >= 1024*1024 ) { + if( Address >= ONEMEG ) { MM_FreeTemp(ptr); } @@ -469,7 +496,7 @@ ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT3 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 { @@ -539,19 +566,19 @@ void AcpiOsPrintf(const char *Format, ...) 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 --- diff --git a/KernelLand/Kernel/arch/x86/main.c b/KernelLand/Kernel/arch/x86/main.c index 83ed7fec..8f36f47c 100644 --- a/KernelLand/Kernel/arch/x86/main.c +++ b/KernelLand/Kernel/arch/x86/main.c @@ -24,7 +24,7 @@ extern void MM_PreinitVirtual(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); @@ -86,7 +86,7 @@ int kmain(Uint MbMagic, void *MbInfoPtr) Threads_Init(); // Poke ACPICA - ACPICA_Initialise(); +// ACPICA_Initialise(); Log_Log("Arch", "Starting VFS..."); // Load Virtual Filesystem diff --git a/KernelLand/Kernel/arch/x86/mm_phys.c b/KernelLand/Kernel/arch/x86/mm_phys.c index f785ba45..2b2a7649 100644 --- a/KernelLand/Kernel/arch/x86/mm_phys.c +++ b/KernelLand/Kernel/arch/x86/mm_phys.c @@ -101,6 +101,7 @@ void MM_Install(int NPMemRanges, tPMemMapEnt *PMemRanges) 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) ); @@ -240,6 +241,8 @@ tPAddr MM_AllocPhys(void) 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); diff --git a/KernelLand/Kernel/debug.c b/KernelLand/Kernel/debug.c index 9104262a..6132bd90 100644 --- a/KernelLand/Kernel/debug.c +++ b/KernelLand/Kernel/debug.c @@ -163,6 +163,20 @@ void Debug(const char *Fmt, ...) #endif } + +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 diff --git a/KernelLand/Kernel/pmemmap.c b/KernelLand/Kernel/pmemmap.c index 21ced24d..bf341ff1 100644 --- a/KernelLand/Kernel/pmemmap.c +++ b/KernelLand/Kernel/pmemmap.c @@ -14,9 +14,10 @@ void PMemMap_DumpBlocks(tPMemMapEnt *map, int NEnts) { 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 ); } }