Various Changes
[tpg/acess2.git] / Kernel / arch / x86 / main.c
1 /*
2  * Acess 2
3  * x86 Kernel Main
4  * arch/x86/main.c
5  */
6 #include <common.h>
7 #include <mboot.h>
8 #include <init.h>
9 #include <mm_virt.h>
10 #include <mp.h>
11
12 #define VGA_ERRORS      0
13
14 // === IMPORTS ===
15 extern void     Heap_Install();
16 extern void     Desctab_Install();
17 extern void     MM_PreinitVirtual();
18 extern void     MM_Install(tMBoot_Info *MBoot);
19 extern void MM_InstallVirtual();
20 extern void     Threads_Init();
21 extern int      Time_Setup();
22 extern Uint     Proc_Clone(Uint *Err, Uint Flags);
23 extern void     Threads_Sleep();
24 extern void     Threads_Exit();
25
26 // === GLOBALS ===
27
28 // === CODE ===
29 int kmain(Uint MbMagic, tMBoot_Info *MbInfo)
30 {
31          int    i;
32         tMBoot_Module   *mods;
33         
34         // Adjust Multiboot structure address
35         MbInfo = (void*)( (Uint)MbInfo + KERNEL_BASE );
36         
37         Desctab_Install();      // Set up GDT and IDT
38         MM_PreinitVirtual();    // Initialise vital mappings
39         MM_Install( MbInfo );   // Set up physical memory manager
40         MM_InstallVirtual();    // Clean up virtual address space
41         Heap_Install();         // Create initial heap
42         
43         Log("Starting Multitasking...");
44         // Start Multitasking
45         Threads_Init();
46         
47         // Start Timers
48         Time_Setup();
49         
50         Log("Starting VFS...");
51         // Load Virtual Filesystem
52         VFS_Init();
53         
54         Log("Loading Modules...");
55         
56         // Load initial modules
57         mods = (void*)( MbInfo->Modules + KERNEL_BASE );
58         for(i=0;i<MbInfo->ModuleCount;i++)
59         {
60                 // Adjust into higher half
61                 mods[i].Start += KERNEL_BASE;
62                 mods[i].End += KERNEL_BASE;
63                 mods[i].String += KERNEL_BASE;
64                 
65                 Log("Loading '%s'", mods[i].String);
66                 
67                 if( !Module_LoadMem( (void *)mods[i].Start, mods[i].End-mods[i].Start, (char *)mods[i].String ) )
68                 {
69                         Warning("Unable to load module\n");
70                 }
71         }
72         
73         // Pass on to Independent Loader
74         Log("Loading Configuration...");
75         System_Init( (char*)(MbInfo->CommandLine + KERNEL_BASE) );
76         
77         // Sleep forever (sleeping beauty)
78         for(;;) Threads_Sleep();
79         return 0;
80 }

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