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

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