Merge branch 'master' of git.mutabah.net:acess2
[tpg/acess2.git] / KernelLand / Kernel / arch / x86_64 / main.c
1 /*
2  * Acess2 x86_64 Project
3  */
4 #include <acess.h>
5 #include <mboot.h>
6 #include <init.h>
7
8 // === CONSTANTS ===
9 #define MAX_PMEMMAP_ENTS        16
10
11 // === IMPORTS ===
12 extern void     Desctab_Init(void);
13 extern void     MM_InitVirt(void);
14 extern void     Heap_Install(void);
15 extern int      Time_Setup(void);
16
17 extern void     MM_InitPhys_Multiboot(tMBoot_Info *MBoot);
18
19 // === PROTOTYPES ===
20 void    kmain(Uint MbMagic, void *MbInfoPtr);
21
22 // === GLOBALS ==
23 char    *gsBootCmdLine = NULL;
24
25 // === CODE ===
26 void kmain(Uint MbMagic, void *MbInfoPtr)
27 {
28         tMBoot_Info     *mbInfo;
29
30         LogF("%s\r\n", gsBuildInfo);
31         
32         Desctab_Init();
33
34         MM_InitVirt();
35         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'C';
36         
37         switch(MbMagic)
38         {
39         // Multiboot 1
40         case MULTIBOOT_MAGIC:
41                 // Adjust Multiboot structure address
42                 mbInfo = (void*)( (Uint)MbInfoPtr + KERNEL_BASE );
43                 gsBootCmdLine = (char*)( (Uint)mbInfo->CommandLine + KERNEL_BASE);
44                 MM_InitPhys_Multiboot( mbInfo );        // Set up physical memory manager
45                 break;
46         default:
47                 Panic("Multiboot magic invalid %08x, expected %08x\n",
48                         MbMagic, MULTIBOOT_MAGIC);
49                 return ;
50         }
51         
52         Log("gsBootCmdLine = '%s'", gsBootCmdLine);
53         
54         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'D';
55         Heap_Install();
56         
57         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'E';
58         Threads_Init();
59         
60         Time_Setup();
61         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'F';
62         
63         // Load Virtual Filesystem
64         Log_Log("Arch", "Starting VFS...");
65         VFS_Init();
66         
67         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'Z';
68         
69         // Pass on to Independent Loader
70         Log_Log("Arch", "Starting system");
71         System_Init(gsBootCmdLine);
72         
73         // Sleep forever (sleeping beauty)
74         for(;;)
75                 Threads_Sleep();
76 }
77
78 void Arch_LoadBootModules(void)
79 {
80         
81 }
82
83 void StartupPrint(const char *String)
84 {
85         
86 }

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