Initial commit of kernel only
[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     Proc_Start();
21 extern Uint     Proc_Clone(Uint *Err, Uint Flags);
22 extern void     Proc_Sleep();
23 extern void     Proc_Exit();
24
25 // === GLOBALS ===
26
27 // === CODE ===
28 int kmain(Uint MbMagic, tMBoot_Info *MbInfo)
29 {
30          int    i;
31         tMBoot_Module   *mods;
32         
33         // Adjust Multiboot structure address
34         MbInfo = (void*)( (Uint)MbInfo + KERNEL_BASE );
35         
36         Desctab_Install();      // Set up GDT and IDT
37         MM_PreinitVirtual();    // Initialise vital mappings
38         MM_Install( MbInfo );   // Set up physical memory manager
39         MM_InstallVirtual();    // Clean up virtual address space
40         Heap_Install();         // Create initial heap
41         
42         Log("Starting Multitasking...");
43         // Start Multitasking
44         Proc_Start();
45         
46         Log("Starting VFS...");
47         // Load Virtual Filesystem
48         VFS_Init();
49         
50         Log("Loading Modules...");
51         
52         // Load initial modules
53         mods = (void*)( MbInfo->Modules + KERNEL_BASE );
54         for(i=0;i<MbInfo->ModuleCount;i++)
55         {
56                 // Adjust into higher half
57                 mods[i].Start += KERNEL_BASE;
58                 mods[i].End += KERNEL_BASE;
59                 mods[i].String += KERNEL_BASE;
60                 
61                 Log("Loading '%s'", mods[i].String);
62                 
63                 if( !Module_LoadMem( (void *)mods[i].Start, mods[i].End-mods[i].Start, (char *)mods[i].String ) )
64                 {
65                         Warning("Unable to load module\n");
66                 }
67         }
68         
69         // Pass on to Independent Loader
70         Log("Loading Configuration...");
71         System_Init( (char*)(MbInfo->CommandLine + KERNEL_BASE) );
72         
73         // Sleep forever (sleeping beauty)
74         for(;;) Proc_Sleep();
75         return 0;
76 }

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