*
* Kernel Main
*/
-#include <acess.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/time.h>
+#include <signal.h>
+#include <stdint.h>
-int main(int argc, char *argv[])
-{
- return 0;
-}
+// === IMPORTS ===
+extern int UI_Initialise(int Width, int Height);
+extern void UI_MainLoop(void);
+extern int VFS_Init(void);
+extern int Video_Install(char **Arguments);
+extern int NativeKeyboard_Install(char **Arguments);
+extern int NativeFS_Install(char **Arguments);
+extern void Debug_SetKTerminal(char *Path);
+extern int VT_Install(char **Arguments);
+extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
+extern int SyscallServer(void);
+extern const char gsKernelVersion[];
+extern const char gsGitHash[];
+extern int giBuildNumber;
-void LogF(const char *Fmt, ...)
-{
- va_list args;
- va_start(args, Fmt);
- vprintf(Fmt, args);
- va_end(args);
-}
+// === GLOBALS ===
+const char *gsAcessDir = "../Usermode/Output/x86";
-void Log(const char *Fmt, ...)
+// === CODE ===
+int main(int argc, char *argv[])
{
- va_list args;
- printf("Log: ");
- va_start(args, Fmt);
- vprintf(Fmt, args);
- va_end(args);
- printf("\n");
-}
+ // Parse command line settings
+ printf("Acess2 Native v%s\n", gsKernelVersion);
+ printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
-void Warning(const char *Fmt, ...)
-{
- va_list args;
- printf("Warning: ");
- va_start(args, Fmt);
- vprintf(Fmt, args);
- va_end(args);
- printf("\n");
-}
+ // Start UI subsystem
+ UI_Initialise(800, 480);
+
+ // - Ignore SIGUSR1 (used to wake threads)
+ signal(SIGUSR1, SIG_IGN);
+
+ // Initialise VFS
+ VFS_Init();
+ // - Start IO Drivers
+ Video_Install(NULL);
+ NativeKeyboard_Install(NULL);
+ NativeFS_Install(NULL);
+ // - Start VTerm
+ {
+ char *args[] = {
+ "Video=NativeVideo",
+ "Input=NativeKeyboard",
+ NULL
+ };
+ VT_Install(args);
+ }
-void Panic(const char *Format, ...)
-{
- va_list args;
- printf("Panic: ");
- va_start(args, Format);
- vprintf(Format, args);
- va_end(args);
- printf("\n");
- exit(-1);
-}
+ VFS_MkDir("/Acess");
+ VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
-void Debug_SetKTerminal(const char *Path)
-{
- // Ignored, kernel debug goes to stdout
-}
-
-void *Heap_Allocate(int Count, const char *File, int Line)
-{
- return malloc(Count);
-}
+ Debug_SetKTerminal("/Devices/VTerm/8");
+
+ // Start syscall server
+ // - Blocks
+ SyscallServer();
+
+ UI_MainLoop();
-tPAddr MM_GetPhysAddr(tVAddr VAddr)
-{
- return VAddr; // HACK!
+ return 0;
}
-Uint MM_GetFlags(tVAddr VAddr)
+void AcessNative_Exit(void)
{
- return 0;
+ // TODO: Close client applications too
+ exit(0);
}
-int Modules_InitialiseBuiltin(const char *Name)
+uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
{
- return 0; // Ignored
+ if(Rem) *Rem = Num % Den;
+ return Num / Den;
}
-Sint64 now(void)
+int Module_EnsureLoaded(const char *Name)
{
- struct timeval tv;
- struct timezone tz;
- gettimeofday(&tv, &tz);
- return tv.tv_sec * 1000 + tv.tv_usec/1000;
+ return 0;
}