AcessNative - Now can use the `dir` CLIShell builtin
[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/x86";
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_MkDir("/Acess");    
60         VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
61
62         Debug_SetKTerminal("/Devices/VTerm/8");
63         
64         // Start syscall server
65         // - Blocks
66         SyscallServer();
67         
68         UI_MainLoop();
69
70         return 0;
71 }
72
73 void AcessNative_Exit(void)
74 {
75         // TODO: Close client applications too
76         exit(0);
77 }
78
79 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
80 {
81         if(Rem) *Rem = Num % Den;
82         return Num / Den;
83 }
84
85 int Module_EnsureLoaded(const char *Name)
86 {
87         return 0;
88 }
89

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