From: John Hodge Date: Sun, 25 Sep 2011 05:17:56 +0000 (+0800) Subject: Kernel/arm7 - Starts, but no IO and task switching (yet) X-Git-Tag: rel0.11~64 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ce736c6330fb48b43caf53f4aca4dcfffab08385;p=tpg%2Facess2.git Kernel/arm7 - Starts, but no IO and task switching (yet) --- diff --git a/Kernel/arch/arm7/lib.c b/Kernel/arch/arm7/lib.c index e8eb7d3b..94c1a3af 100644 --- a/Kernel/arch/arm7/lib.c +++ b/Kernel/arch/arm7/lib.c @@ -6,6 +6,7 @@ #include // === PROTOTYPES === +Uint64 __divmod64(Uint64 Num, Uint64 Den, Uint64 *Rem); Uint64 __udivdi3(Uint64 Num, Uint64 Den); Uint64 __umoddi3(Uint64 Num, Uint64 Den); Uint32 __udivsi3(Uint32 Num, Uint32 Den); @@ -112,6 +113,36 @@ void *memset(void *_dest, int _value, size_t _length) return _dest; } +Uint64 __divmod64(Uint64 Num, Uint64 Den, Uint64 *Rem) +{ + Uint64 ret, add; + + ret = 0; + add = 1; + + // Find what power of two times Den is > Num + while( Num >= Den ) + { + Den <<= 1; + add <<= 1; + } + + // Search backwards + while( add > 1 ) + { + add >>= 1; + Den >>= 1; + // If the numerator is > Den, subtract and add to return value + if( Num > Den ) + { + ret += add; + Num -= Den; + } + } + if(Rem) *Rem = Num; + return ret; +} + Uint64 DivMod64U(Uint64 Num, Uint64 Den, Uint64 *Rem) { Uint64 ret; @@ -132,6 +163,10 @@ Uint64 DivMod64U(Uint64 Num, Uint64 Den, Uint64 *Rem) if(Rem) *Rem = Num & 0xF; return Num >> 4; } + if(Den == 32) { + if(Rem) *Rem = Num & 0x1F; + return Num >> 5; + } if(Den == 0x1000) { if(Rem) *Rem = Num & 0xFFF; return Num >> 12; @@ -156,11 +191,16 @@ Uint64 DivMod64U(Uint64 Num, Uint64 Den, Uint64 *Rem) Den >>= 1; tmp >>= 1; while( } - #else + if(Rem) *Rem = Num; + return ret; + #elif 0 for( ret = 0; Num > Den; ret ++, Num -= Den) ; - #endif if(Rem) *Rem = Num; return ret; + #else + ret = __divmod64(Num, Den, Rem); + return ret; + #endif } // Unsigned Divide 64-bit Integer diff --git a/Kernel/arch/arm7/main.c b/Kernel/arch/arm7/main.c index e8bc3757..2cbe8f28 100644 --- a/Kernel/arch/arm7/main.c +++ b/Kernel/arch/arm7/main.c @@ -11,6 +11,7 @@ extern void Interrupts_Setup(void); extern void Arch_LoadBootModules(void); extern void Heap_Install(void); extern void Threads_Init(void); +extern void System_Init(const char *Commandline); // === PROTOTYPES === int kmain(void); @@ -24,10 +25,20 @@ int kmain(void) MM_SetupPhys(); + LogF("Heap Setup...\n"); Heap_Install(); + LogF("Threads Init...\n"); Threads_Init(); + LogF("VFS Init...\n"); + VFS_Init(); + + // Boot modules? + + // + LogF("Moving to arch-independent init\n"); + System_Init(""); //TODO: LogF("End of kmain(), for(;;);\n"); for(;;); diff --git a/Kernel/arch/arm7/pci.c b/Kernel/arch/arm7/pci.c index 91cfe99b..62b7deaf 100644 --- a/Kernel/arch/arm7/pci.c +++ b/Kernel/arch/arm7/pci.c @@ -20,7 +20,7 @@ void PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint3 Uint32 PCI_CfgReadDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset) { // TODO: Locate PCI base and read/write data - return 0; + return 0xFFFFFFFF; } Uint16 PCI_CfgReadWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset) diff --git a/Kernel/system.c b/Kernel/system.c index cbf828c6..f346d69c 100644 --- a/Kernel/system.c +++ b/Kernel/system.c @@ -110,7 +110,6 @@ void System_ParseCommandLine(char *ArgString) char *str; Log_Log("Config", "Kernel Invocation (%p) \"%s\"", ArgString, ArgString); - Log_Log("Config", "Kernel Invocation '0x%x 0x%x'", ArgString[0], ArgString[1]); // --- Get Arguments --- str = ArgString;