mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Reworked the boot sector & boot drive code
You can again use FreeLoader to dual boot between two drives or a boot sector file svn path=/trunk/; revision=2547
This commit is contained in:
parent
5a6adb4f13
commit
148e40a24e
5 changed files with 84 additions and 156 deletions
|
@ -102,32 +102,49 @@ VOID BootMain(VOID)
|
|||
|
||||
for (;;)
|
||||
{
|
||||
// Show the operating system list menu
|
||||
if (!DisplayMenu(OperatingSystemDisplayNames, OperatingSystemCount, DefaultOperatingSystem, TimeOut, &SelectedOperatingSystem))
|
||||
{
|
||||
MessageBox("Press ENTER to reboot.\n");
|
||||
return;
|
||||
goto reboot;
|
||||
}
|
||||
|
||||
LoadAndBootReactOS(OperatingSystemSectionNames[SelectedOperatingSystem]);
|
||||
|
||||
/*switch (OSList[nOSToBoot].nOSType)
|
||||
// Try to open the operating system section in the .ini file
|
||||
if (!OpenSection(OperatingSystemSectionNames[SelectedOperatingSystem], &SectionId))
|
||||
{
|
||||
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", OperatingSystemSectionNames[SelectedOperatingSystem]);
|
||||
MessageBox(SettingName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try to read the boot type
|
||||
if (!ReadSectionSettingByName(SectionId, "BootType", SettingValue, 80))
|
||||
{
|
||||
sprintf(SettingName, "BootType= line not found in section [%s] in freeldr.ini.\n", OperatingSystemSectionNames[SelectedOperatingSystem]);
|
||||
MessageBox(SettingName);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stricmp(SettingValue, "ReactOS") == 0)
|
||||
{
|
||||
LoadAndBootReactOS(OperatingSystemSectionNames[SelectedOperatingSystem]);
|
||||
}
|
||||
else if (stricmp(SettingValue, "Linux") == 0)
|
||||
{
|
||||
case OSTYPE_REACTOS:
|
||||
LoadAndBootReactOS(OSList[nOSToBoot].name);
|
||||
break;
|
||||
case OSTYPE_LINUX:
|
||||
MessageBox("Cannot boot this OS type yet!");
|
||||
break;
|
||||
case OSTYPE_BOOTSECTOR:
|
||||
LoadAndBootBootSector(nOSToBoot);
|
||||
break;
|
||||
case OSTYPE_PARTITION:
|
||||
LoadAndBootPartition(nOSToBoot);
|
||||
break;
|
||||
case OSTYPE_DRIVE:
|
||||
LoadAndBootDrive(nOSToBoot);
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
else if (stricmp(SettingValue, "BootSector") == 0)
|
||||
{
|
||||
LoadAndBootBootSector(OperatingSystemSectionNames[SelectedOperatingSystem]);
|
||||
}
|
||||
else if (stricmp(SettingValue, "Partition") == 0)
|
||||
{
|
||||
LoadAndBootPartition(OperatingSystemSectionNames[SelectedOperatingSystem]);
|
||||
}
|
||||
else if (stricmp(SettingValue, "Drive") == 0)
|
||||
{
|
||||
LoadAndBootDrive(OperatingSystemSectionNames[SelectedOperatingSystem]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,39 +25,43 @@
|
|||
#include "fs.h"
|
||||
#include "ui.h"
|
||||
#include "parseini.h"
|
||||
#include "disk.h"
|
||||
|
||||
void LoadAndBootBootSector(int nOSToBoot)
|
||||
VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
|
||||
{
|
||||
FILE* FilePointer;
|
||||
char name[260];
|
||||
char value[260];
|
||||
char szFileName[1024];
|
||||
int i;
|
||||
PFILE FilePointer;
|
||||
UCHAR SettingName[80];
|
||||
UCHAR SettingValue[80];
|
||||
ULONG SectionId;
|
||||
UCHAR FileName[260];
|
||||
ULONG BytesRead;
|
||||
|
||||
// Find all the message box settings and run them
|
||||
/*for (i=1; i<=GetNumSectionItems(OSList[nOSToBoot].name); i++)
|
||||
ShowMessageBoxesInSection(OperatingSystemName);
|
||||
|
||||
// Try to open the operating system section in the .ini file
|
||||
if (!OpenSection(OperatingSystemName, &SectionId))
|
||||
{
|
||||
ReadSectionSettingByNumber(OSList[nOSToBoot].name, i, name, value);
|
||||
if (stricmp(name, "MessageBox") == 0)
|
||||
MessageBox(value);
|
||||
if (stricmp(name, "MessageLine") == 0)
|
||||
MessageLine(value);
|
||||
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", OperatingSystemName);
|
||||
MessageBox(SettingName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ReadSectionSettingByName(OSList[nOSToBoot].name, "BootDrive", value))
|
||||
if (!ReadSectionSettingByName(SectionId, "BootDrive", SettingValue, 80))
|
||||
{
|
||||
MessageBox("Boot drive not specified for selected OS!");
|
||||
return;
|
||||
}
|
||||
|
||||
BootDrive = atoi(value);
|
||||
BootDrive = atoi(SettingValue);
|
||||
|
||||
BootPartition = 0;
|
||||
if (ReadSectionSettingByName(OSList[nOSToBoot].name, "BootPartition", value))
|
||||
BootPartition = atoi(value);
|
||||
if (ReadSectionSettingByName(SectionId, "BootPartition", SettingValue, 80))
|
||||
{
|
||||
BootPartition = atoi(SettingValue);
|
||||
}
|
||||
|
||||
if (!ReadSectionSettingByName(OSList[nOSToBoot].name, "BootSector", value))
|
||||
if (!ReadSectionSettingByName(SectionId, "BootSectorFile", FileName, 260))
|
||||
{
|
||||
MessageBox("Boot sector file not specified for selected OS!");
|
||||
return;
|
||||
|
@ -69,20 +73,18 @@ void LoadAndBootBootSector(int nOSToBoot)
|
|||
return;
|
||||
}
|
||||
|
||||
strcpy(szFileName, value);
|
||||
|
||||
FilePointer = OpenFile(szFileName);
|
||||
FilePointer = OpenFile(FileName);
|
||||
if (FilePointer == NULL)
|
||||
{
|
||||
strcat(value, " not found.");
|
||||
MessageBox(value);
|
||||
strcat(FileName, " not found.");
|
||||
MessageBox(FileName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Read boot sector
|
||||
if (!ReadFile(FilePointer, 512, &BytesRead, (void*)0x7c00) || (BytesRead != 512))
|
||||
{
|
||||
MessageBox("Disk Read Error");
|
||||
DiskError("Disk read error.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -93,15 +95,13 @@ void LoadAndBootBootSector(int nOSToBoot)
|
|||
return;
|
||||
}
|
||||
|
||||
RestoreScreen(ScreenBuffer);
|
||||
clrscr();
|
||||
showcursor();
|
||||
gotoxy(CursorXPos, CursorYPos);
|
||||
|
||||
stop_floppy();
|
||||
JumpToBootCode();*/
|
||||
JumpToBootCode();
|
||||
}
|
||||
|
||||
void LoadAndBootPartition(int nOSToBoot)
|
||||
VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
|
||||
{
|
||||
char name[260];
|
||||
char value[260];
|
||||
|
@ -187,33 +187,34 @@ void LoadAndBootPartition(int nOSToBoot)
|
|||
JumpToBootCode();*/
|
||||
}
|
||||
|
||||
void LoadAndBootDrive(int nOSToBoot)
|
||||
VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
|
||||
{
|
||||
char name[260];
|
||||
char value[260];
|
||||
int i;
|
||||
UCHAR SettingName[80];
|
||||
UCHAR SettingValue[80];
|
||||
ULONG SectionId;
|
||||
|
||||
// Find all the message box settings and run them
|
||||
/*for (i=1; i<=GetNumSectionItems(OSList[nOSToBoot].name); i++)
|
||||
ShowMessageBoxesInSection(OperatingSystemName);
|
||||
|
||||
// Try to open the operating system section in the .ini file
|
||||
if (!OpenSection(OperatingSystemName, &SectionId))
|
||||
{
|
||||
ReadSectionSettingByNumber(OSList[nOSToBoot].name, i, name, value);
|
||||
if (stricmp(name, "MessageBox") == 0)
|
||||
MessageBox(value);
|
||||
if (stricmp(name, "MessageLine") == 0)
|
||||
MessageLine(value);
|
||||
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", OperatingSystemName);
|
||||
MessageBox(SettingName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ReadSectionSettingByName(OSList[nOSToBoot].name, "BootDrive", value))
|
||||
if (!ReadSectionSettingByName(SectionId, "BootDrive", SettingValue, 80))
|
||||
{
|
||||
MessageBox("Boot drive not specified for selected OS!");
|
||||
return;
|
||||
}
|
||||
|
||||
BootDrive = atoi(value);
|
||||
BootDrive = atoi(SettingValue);
|
||||
|
||||
if (!biosdisk(_DISK_READ, BootDrive, 0, 0, 1, 1, (void*)0x7c00))
|
||||
if (!BiosInt13Read(BootDrive, 0, 0, 1, 1, (PVOID)0x7C00))
|
||||
{
|
||||
MessageBox("Disk Read Error");
|
||||
DiskError("Disk read error.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -224,10 +225,8 @@ void LoadAndBootDrive(int nOSToBoot)
|
|||
return;
|
||||
}
|
||||
|
||||
RestoreScreen(ScreenBuffer);
|
||||
clrscr();
|
||||
showcursor();
|
||||
gotoxy(CursorXPos, CursorYPos);
|
||||
|
||||
stop_floppy();
|
||||
JumpToBootCode();*/
|
||||
JumpToBootCode();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
void JumpToBootCode(void); // Implemented in boot.S
|
||||
|
||||
void LoadAndBootBootSector(int nOSToBoot);
|
||||
void LoadAndBootPartition(int nOSToBoot);
|
||||
void LoadAndBootDrive(int nOSToBoot);
|
||||
VOID LoadAndBootBootSector(PUCHAR OperatingSystemName);
|
||||
VOID LoadAndBootPartition(PUCHAR OperatingSystemName);
|
||||
VOID LoadAndBootDrive(PUCHAR OperatingSystemName);
|
||||
|
||||
#endif // defined __BOOT_H
|
||||
|
|
|
@ -431,90 +431,3 @@ BOOL IsValidSetting(char *setting, char *value)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*void SetSetting(char *setting, char *value)
|
||||
{
|
||||
char v[260];
|
||||
|
||||
if(stricmp(setting, "TitleText") == 0)
|
||||
strcpy(szTitleBoxTitleText, value);
|
||||
else if(stricmp(setting, "StatusBarColor") == 0)
|
||||
cStatusBarBgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "StatusBarTextColor") == 0)
|
||||
cStatusBarFgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "BackdropTextColor") == 0)
|
||||
cBackdropFgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "BackdropColor") == 0)
|
||||
cBackdropBgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "BackdropFillStyle") == 0)
|
||||
cBackdropFillStyle = TextToFillStyle(value);
|
||||
else if(stricmp(setting, "TitleBoxTextColor") == 0)
|
||||
cTitleBoxFgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "TitleBoxColor") == 0)
|
||||
cTitleBoxBgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "MessageBoxTextColor") == 0)
|
||||
cMessageBoxFgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "MessageBoxColor") == 0)
|
||||
cMessageBoxBgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "MenuTextColor") == 0)
|
||||
cMenuFgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "MenuColor") == 0)
|
||||
cMenuBgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "TextColor") == 0)
|
||||
cTextColor = TextToColor(value);
|
||||
else if(stricmp(setting, "SelectedTextColor") == 0)
|
||||
cSelectedTextColor = TextToColor(value);
|
||||
else if(stricmp(setting, "SelectedColor") == 0)
|
||||
cSelectedTextBgColor = TextToColor(value);
|
||||
else if(stricmp(setting, "OS") == 0)
|
||||
{
|
||||
if(nNumOS >= 16)
|
||||
{
|
||||
printf("Error: you can only boot to at most 16 different operating systems.\n");
|
||||
printf("Press any key to continue\n");
|
||||
getch();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!GetNumSectionItems(value))
|
||||
{
|
||||
printf("Error: OS \"%s\" listed.\n", value);
|
||||
printf("It does not have it's own [section], or it is empty.\n");
|
||||
printf("Press any key to continue\n");
|
||||
getch();
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(OSList[nNumOS].name, value);
|
||||
|
||||
if (!ReadSectionSettingByName(value, "BootType", v))
|
||||
{
|
||||
printf("Unknown BootType for OS \"%s\"\n", value);
|
||||
printf("Press any key to continue\n");
|
||||
getch();
|
||||
return;
|
||||
}
|
||||
|
||||
if (stricmp(v, "ReactOS") == 0)
|
||||
OSList[nNumOS].nOSType = OSTYPE_REACTOS;
|
||||
else if (stricmp(v, "Linux") == 0)
|
||||
OSList[nNumOS].nOSType = OSTYPE_LINUX;
|
||||
else if (stricmp(v, "BootSector") == 0)
|
||||
OSList[nNumOS].nOSType = OSTYPE_BOOTSECTOR;
|
||||
else if (stricmp(v, "Partition") == 0)
|
||||
OSList[nNumOS].nOSType = OSTYPE_PARTITION;
|
||||
else if (stricmp(v, "Drive") == 0)
|
||||
OSList[nNumOS].nOSType = OSTYPE_DRIVE;
|
||||
else
|
||||
{
|
||||
printf("Unknown BootType for OS \"%s\"\n", value);
|
||||
printf("Press any key to continue\n");
|
||||
getch();
|
||||
return;
|
||||
}
|
||||
|
||||
nNumOS++;
|
||||
}
|
||||
else if(stricmp(setting, "TimeOut") == 0)
|
||||
nTimeOut = atoi(value);
|
||||
}*/
|
||||
|
|
|
@ -36,7 +36,6 @@ ULONG GetNumSectionItems(ULONG SectionId);
|
|||
BOOL ReadSectionSettingByNumber(ULONG SectionId, ULONG SettingNumber, PUCHAR SettingName, ULONG NameSize, PUCHAR SettingValue, ULONG ValueSize);
|
||||
BOOL ReadSectionSettingByName(ULONG SectionId, PUCHAR SettingName, PUCHAR Buffer, ULONG BufferSize);
|
||||
BOOL IsValidSetting(char *setting, char *value);
|
||||
void SetSetting(char *setting, char *value);
|
||||
|
||||
|
||||
#endif // defined __PARSEINI_H
|
||||
|
|
Loading…
Reference in a new issue