root / Whitix / branches / hybrid / kernel / startup.c

Revision 538, 1.3 kB (checked in by mwhitworth, 5 months ago)

Create startup module.

Line 
1#include <fs/vfs.h>
2#include <init.h>
3#include <module.h>
4#include <panic.h>
5#include <sched.h>
6#include <typedefs.h>
7#include <sections.h>
8#include <task.h>
9
10void Start()
11{
12        int fds[]={
13                0,0,0,
14        };
15
16        extern BYTE biosDriveNo;
17        extern WORD rootDevMajor, rootDevMinor;
18
19        DevMountRoot(biosDriveNo, rootDevMajor, rootDevMinor);
20       
21        KePrint("DEVFS: Mounting device filesystem at %s\n", DEVICES_PATH);
22
23        if (VfsMount(NULL,DEVICES_PATH,"DevFs",NULL))
24        {
25                KernelPanic("Failed to mount the device filesystem");
26        }
27
28        KePrint("Mounted the filesystems. Starting the shell\n");
29
30        if (DoOpenFile(&current->files[0], DEVICES_PATH "/Consoles/Console0",FILE_READ | FILE_FORCE_OPEN,0))
31                KernelPanic("Failed to open the first console. Halting");
32
33        extern int Exec(char* pathName,int* fds,char** argv);
34        if (Exec("/System/Startup/startup", fds, NULL) < 0)
35                KernelPanic("Could not launch the startup program. Halting");
36
37        ThrProcessExit(0);
38        ThrSchedule();
39
40        while (1) hlt();
41}
42
43int StartInit()
44{
45        struct Process* start;
46        struct Thread* firstThread;
47
48        start=ThrCreateProcess("KernelLoading");
49        firstThread=ThrCreateThread(start, (DWORD)Start, false, 0, NULL);
50
51        if (!start || !firstThread)
52                KernelPanic("Could not create the starting thread.\n");
53
54        ThrStartThread(firstThread);
55
56        return 0;
57}
58
59ModuleInit(StartInit);
Note: See TracBrowser for help on using the browser.