Fixes to x86_64 - Fixed MM_phys corrupting memory (forgot to initialise bitmap pointers)
[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*)( (Uint)mbInfo->CommandLine + KERNEL_BASE);
39                 Log("gsBootCmdLine = '%s'", gsBootCmdLine);
40                 
41                 MM_InitPhys_Multiboot( mbInfo );        // Set up physical memory manager
42                 break;
43         default:
44                 Panic("Multiboot magic invalid %08x, expected %08x\n",
45                         MbMagic, MULTIBOOT_MAGIC);
46                 return ;
47         }
48         
49         Log("gsBootCmdLine = '%s'", gsBootCmdLine);
50         
51         *(Uint16*)(0xB8000) = 0x1F00|'D';
52         Heap_Install();
53         
54         *(Uint16*)(0xB8000) = 0x1F00|'E';
55         Log_Log("Arch", "Starting threading...");
56         Threads_Init();
57         
58         //Time_Setup();
59         *(Uint16*)(0xB8000) = 0x1F00|'F';
60         
61         Log_Log("Arch", "Starting VFS...");
62         // Load Virtual Filesystem
63         VFS_Init();
64         
65         *(Uint16*)(0xB8000) = 0x1F00|'Z';
66         *(Uint16*)(0xB8002) = 0x1F00|'Z';
67         *(Uint16*)(0xB8004) = 0x1F00|'Z';
68         *(Uint16*)(0xB8006) = 0x1F00|'Z';
69         
70         // Pass on to Independent Loader
71         Log_Log("Arch", "Starting system");
72         System_Init(gsBootCmdLine);
73         
74         // Sleep forever (sleeping beauty)
75         for(;;)
76                 Threads_Sleep();
77 }
78
79 void Arch_LoadBootModules(void)
80 {
81         
82 }
83
84 void StartupPrint(char *String)
85 {
86         
87 }

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