Kernel/x86_64 - Separated task switching from timer interrupt
[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 #include <init.h>
7
8 // === IMPORTS ===
9 extern void     Desctab_Init(void);
10 extern void     MM_InitVirt(void);
11 extern void     Heap_Install(void);
12 extern void     Threads_Init(void);
13 extern int      Time_Setup(void);
14 extern void     System_Init(char *Commandline);
15
16 extern void     MM_InitPhys_Multiboot(tMBoot_Info *MBoot);
17
18 // === PROTOTYPES ===
19 void    kmain(Uint MbMagic, void *MbInfoPtr);
20
21 // === GLOBALS ==
22 char    *gsBootCmdLine = NULL;
23
24 // === CODE ===
25 void kmain(Uint MbMagic, void *MbInfoPtr)
26 {
27         tMBoot_Info     *mbInfo;
28
29         LogF("Acess2 x86_65 v"EXPAND_STR(KERNEL_VERSION)"\n");
30         LogF(" Build %i, Git Hash %s\n", BUILD_NUM, gsGitHash);
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                 Log("gsBootCmdLine = '%s'", gsBootCmdLine);
45                 
46                 MM_InitPhys_Multiboot( mbInfo );        // Set up physical memory manager
47                 break;
48         default:
49                 Panic("Multiboot magic invalid %08x, expected %08x\n",
50                         MbMagic, MULTIBOOT_MAGIC);
51                 return ;
52         }
53         
54         Log("gsBootCmdLine = '%s'", gsBootCmdLine);
55         
56         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'D';
57         Heap_Install();
58         
59         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'E';
60         Log_Log("Arch", "Starting threading...");
61         Threads_Init();
62         
63         Time_Setup();
64         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'F';
65         
66         Log_Log("Arch", "Starting VFS...");
67         // Load Virtual Filesystem
68         VFS_Init();
69         
70         *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'Z';
71         
72         // Pass on to Independent Loader
73         Log_Log("Arch", "Starting system");
74         System_Init(gsBootCmdLine);
75         
76         // Sleep forever (sleeping beauty)
77         for(;;)
78                 Threads_Sleep();
79 }
80
81 void Arch_LoadBootModules(void)
82 {
83         
84 }
85
86 void StartupPrint(const char *String)
87 {
88         
89 }

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