Added system hive support.
[reactos.git] / freeldr / freeldr / linux.c
1 /*
2 * FreeLoader
3 * Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20
21 #include "freeldr.h"
22 #include "asmcode.h"
23 #include "miscboot.h"
24 #include "stdlib.h"
25 #include "fs.h"
26 #include "tui.h"
27 #include "linux.h"
28
29 void LoadAndBootLinux(int DriveNum, int Partition, char *vmlinuz, char *cmd_line)
30 {
31 /*FILE file;
32 char temp[260];
33 char bootsector[512];
34 char setup[2048];
35 int len;
36
37 BootDrive = DriveNum;
38 BootPartition = Partition;
39
40 if (!OpenDiskDrive(BootDrive, BootPartition))
41 {
42 MessageBox("Failed to open boot drive.");
43 return;
44 }
45
46 if (!OpenFile(vmlinuz, &file))
47 {
48 strcpy(temp, vmlinuz);
49 strcat(temp, " not found.");
50 MessageBox(temp);
51 return;
52 }
53
54 // Read boot sector
55 if (ReadFile(&file, 512, bootsector) != 512)
56 {
57 MessageBox("Disk Read Error");
58 return;
59 }
60 MessageBox("bootsector loaded");
61
62 // Read setup code
63 if (ReadFile(&file, 2048, setup) != 2048)
64 {
65 MessageBox("Disk Read Error");
66 return;
67 }
68 MessageBox("setup loaded");
69
70 // Read kernel code
71 len = GetFileSize(&file) - (2048 + 512);
72 //len = 0x200;
73 if (ReadFile(&file, len, (void*)0x100000) != len)
74 {
75 MessageBox("Disk Read Error");
76 return;
77 }
78 MessageBox("kernel loaded");
79
80 // Check for validity
81 if (*((WORD*)(bootsector + 0x1fe)) != 0xaa55)
82 {
83 MessageBox("Invalid boot sector magic (0xaa55)");
84 return;
85 }
86 if (*((DWORD*)(setup + 2)) != 0x53726448)
87 {
88 MessageBox("Invalid setup magic (\"HdrS\")");
89 return;
90 }
91
92 memcpy((void*)0x90000, bootsector, 512);
93 memcpy((void*)0x90200, setup, 2048);
94
95 RestoreScreen(ScreenBuffer);
96 showcursor();
97 gotoxy(CursorXPos, CursorYPos);
98
99 stop_floppy();
100 JumpToLinuxBootCode();*/
101 }