#include <acess.h>
// === 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);
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;
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;
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
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);
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(;;);
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)
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;