AcessNative - Cleanup and slight fixes.
[tpg/acess2.git] / AcessNative / acesskernel_src / main.c
1 /*
2  * Acess2 Native Kernel
3  * - Acess kernel emulation on another OS using SDL and UDP
4  *
5  * Kernel Main
6  */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <signal.h>
10 #include <stdint.h>
11
12 // === IMPORTS ===
13 extern int      UI_Initialise(int Width, int Height);
14 extern void     UI_MainLoop(void);
15 extern int      VFS_Init(void);
16 extern int      Video_Install(char **Arguments);
17 extern int      NativeKeyboard_Install(char **Arguments);
18 extern int      NativeFS_Install(char **Arguments);
19 extern void     Debug_SetKTerminal(char *Path);
20 extern int      VT_Install(char **Arguments);
21 extern int      VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
22 extern int      SyscallServer(void);
23 extern const char       gsKernelVersion[];
24 extern const char       gsGitHash[];
25 extern int      giBuildNumber;
26
27 // === GLOBALS ===
28 const char      *gsAcessDir = "../Usermode/Output/i386";
29
30 // === CODE ===
31 int main(int argc, char *argv[])
32 {
33         // Parse command line settings
34         printf("Acess2 Native v%s\n", gsKernelVersion);
35         printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
36
37         // Start UI subsystem
38         UI_Initialise(800, 480);
39         
40         // - Ignore SIGUSR1 (used to wake threads)
41         signal(SIGUSR1, SIG_IGN);
42                 
43         // Initialise VFS
44         VFS_Init();
45         // - Start IO Drivers
46         Video_Install(NULL);
47         NativeKeyboard_Install(NULL);
48         NativeFS_Install(NULL);
49         // - Start VTerm
50         {
51                 char    *args[] = {
52                         "Video=NativeVideo",
53                         "Input=NativeKeyboard",
54                         NULL
55                         };
56                 VT_Install(args);
57         }
58         
59         VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
60
61         Debug_SetKTerminal("/Devices/VTerm/8");
62         
63         // Start syscall server
64         // - Blocks
65         SyscallServer();
66         
67         UI_MainLoop();
68
69         return 0;
70 }
71
72 void AcessNative_Exit(void)
73 {
74         // TODO: Close client applications too
75         exit(0);
76 }
77
78 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
79 {
80         if(Rem) *Rem = Num % Den;
81         return Num / Den;
82 }
83
84 int Module_EnsureLoaded(const char *Name)
85 {
86         return 0;
87 }
88

UCC git Repository :: git.ucc.asn.au