| 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 | |
|---|
| 10 | void 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(¤t->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 | |
|---|
| 43 | int 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 | |
|---|
| 59 | ModuleInit(StartInit); |
|---|