3 * Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
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.
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.
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.
29 void LoadAndBootLinux(int DriveNum
, int Partition
, char *vmlinuz
, char *cmd_line
)
38 BootPartition
= Partition
;
40 if (!OpenDiskDrive(BootDrive
, BootPartition
))
42 MessageBox("Failed to open boot drive.");
46 if (!OpenFile(vmlinuz
, &file
))
48 strcpy(temp
, vmlinuz
);
49 strcat(temp
, " not found.");
55 if (ReadFile(&file
, 512, bootsector
) != 512)
57 MessageBox("Disk Read Error");
60 MessageBox("bootsector loaded");
63 if (ReadFile(&file
, 2048, setup
) != 2048)
65 MessageBox("Disk Read Error");
68 MessageBox("setup loaded");
71 len
= GetFileSize(&file
) - (2048 + 512);
73 if (ReadFile(&file
, len
, (void*)0x100000) != len
)
75 MessageBox("Disk Read Error");
78 MessageBox("kernel loaded");
81 if (*((WORD
*)(bootsector
+ 0x1fe)) != 0xaa55)
83 MessageBox("Invalid boot sector magic (0xaa55)");
86 if (*((DWORD
*)(setup
+ 2)) != 0x53726448)
88 MessageBox("Invalid setup magic (\"HdrS\")");
92 memcpy((void*)0x90000, bootsector
, 512);
93 memcpy((void*)0x90200, setup
, 2048);
95 RestoreScreen(ScreenBuffer
);
97 gotoxy(CursorXPos
, CursorYPos
);
100 JumpToLinuxBootCode();