Changes in v1.4 (6/27/2002)

- Added separate configuration for a SETUPLDR version

svn path=/trunk/; revision=3158
This commit is contained in:
Brian Palmer 2002-06-28 00:50:16 +00:00
parent 1f6b602dc5
commit 7fc762dac1
8 changed files with 308 additions and 167 deletions

View file

@ -1,3 +1,7 @@
Changes in v1.4 (6/27/2002)
- Added separate configuration for a SETUPLDR version
Changes in v1.3.1 (6/8/2002)
- Implemented MmAllocateMemoryAtAddress()

View file

@ -69,7 +69,7 @@ MAKETARGET = $(MAKE) --no-print-directory -C $(OUTPUT_DIR) \
-f ../../Makefile SRCDIR=$(CURDIR) $(MAKECMDGOALS)
.PHONY: CHANGE_TO_TARGET
CHANGE_TO_TARGET: BUILD_TOOLS $(OBJDIR) $(OBJDIR)/$(TARGET)
CHANGE_TO_TARGET setupldr : BUILD_TOOLS $(OBJDIR) $(OBJDIR)/$(TARGET)
@echo Calculating source file dependencies...
+@$(MAKETARGET)
@ -118,11 +118,19 @@ COMPILER_OPTIONS = -Wall -nostdlib -nostdinc -fno-builtin -O1 -MD
# COMPILER DEFINES
#
ifeq ($(DEBUG),yes)
COMPILER_DEFINES = -DDEBUG
COMPILER_DEBUG_DEFINES = -DDEBUG
else
COMPILER_DEFINES =
COMPILER_DEBUG_DEFINES =
endif
ifeq ($(MAKECMDGOALS),setupldr)
COMPILER_SETUPLDR_DEFINES = -D__SETUPLDR__
else
COMPILER_SETUPLDR_DEFINES =
endif
COMPILER_DEFINES = -D__$(TARGET)__ $(COMPILER_DEBUG_DEFINES) $(COMPILER_SETUPLDR_DEFINES)
#############################################
# INCLUDE DIRECTORY OPTIONS
#
@ -195,7 +203,8 @@ REACTOS_OBJS= reactos.o \
arcname.o \
hwdetect.o \
reghive.o \
registry.o
registry.o \
setupldr.o
COMM_OBJS = rs232.o \
portio.o
@ -224,6 +233,7 @@ FREELDR_OBJS= freeldr.o \
multiboot.o \
debug.o \
oslist.o \
bootmgr.o \
version.o
#############################################
@ -275,6 +285,20 @@ freeldr.sys : $(OBJS)
#############################################
setupldr : setupldr.sys
@echo Make SETUPLDR done.
#############################################
setupldr.sys : $(OBJS)
@echo ===================================================== LINKING $@
# @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o setupldr.sys $(OBJS)
@$(LD) $(LFLAGS) -Map setupldr.map -o setupldr.exe $(OBJS)
@$(NM) --numeric-sort setupldr.exe > setupldr.sym
@$(OBJCOPY) -O binary setupldr.exe setupldr.sys
#############################################
%.o :: %.c
@echo ===================================================== Compiling $*
@$(CC) $(CFLAGS) -o $@ -c $<

195
freeldr/freeldr/bootmgr.c Normal file
View file

@ -0,0 +1,195 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <freeldr.h>
#include <rtl.h>
#include <fs.h>
#include <reactos.h>
#include <ui.h>
#include <arch.h>
#include <miscboot.h>
#include <linux.h>
#include <mm.h>
#include <inifile.h>
#include <debug.h>
#include <oslist.h>
#include <video.h>
#include <bootmgr.h>
VOID RunBootManager(VOID)
{
UCHAR SettingName[80];
UCHAR SettingValue[80];
ULONG SectionId;
ULONG OperatingSystemCount;
PUCHAR *OperatingSystemSectionNames;
PUCHAR *OperatingSystemDisplayNames;
ULONG DefaultOperatingSystem;
LONG TimeOut;
ULONG SelectedOperatingSystem;
if (!IniFileInitialize())
{
printf("Press any key to reboot.\n");
getch();
return;
}
if (!IniOpenSection("FreeLoader", &SectionId))
{
printf("Section [FreeLoader] not found in freeldr.ini.\n");
getch();
return;
}
if (!UiInitialize())
{
printf("Press any key to reboot.\n");
getch();
return;
}
if (!InitOperatingSystemList(&OperatingSystemSectionNames, &OperatingSystemDisplayNames, &OperatingSystemCount))
{
UiMessageBox("Press ENTER to reboot.\n");
goto reboot;
}
if (OperatingSystemCount == 0)
{
UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
goto reboot;
}
DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemSectionNames, OperatingSystemCount);
TimeOut = GetTimeOut();
//
// Find all the message box settings and run them
//
UiShowMessageBoxesInSection("FreeLoader");
for (;;)
{
// Redraw the backdrop
UiDrawBackdrop();
// Show the operating system list menu
if (!UiDisplayMenu(OperatingSystemDisplayNames, OperatingSystemCount, DefaultOperatingSystem, TimeOut, &SelectedOperatingSystem))
{
UiMessageBox("Press ENTER to reboot.\n");
goto reboot;
}
TimeOut = -1;
DefaultOperatingSystem = SelectedOperatingSystem;
// Try to open the operating system section in the .ini file
if (!IniOpenSection(OperatingSystemSectionNames[SelectedOperatingSystem], &SectionId))
{
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", OperatingSystemSectionNames[SelectedOperatingSystem]);
UiMessageBox(SettingName);
continue;
}
// Try to read the boot type
if (!IniReadSettingByName(SectionId, "BootType", SettingValue, 80))
{
sprintf(SettingName, "BootType= line not found in section [%s] in freeldr.ini.\n", OperatingSystemSectionNames[SelectedOperatingSystem]);
UiMessageBox(SettingName);
continue;
}
if (stricmp(SettingValue, "ReactOS") == 0)
{
LoadAndBootReactOS(OperatingSystemSectionNames[SelectedOperatingSystem]);
}
else if (stricmp(SettingValue, "Linux") == 0)
{
LoadAndBootLinux(OperatingSystemSectionNames[SelectedOperatingSystem]);
}
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]);
}
}
reboot:
VideoClearScreen();
VideoShowTextCursor();
return;
}
ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount)
{
UCHAR DefaultOSText[80];
ULONG SectionId;
ULONG DefaultOS = 0;
ULONG Idx;
if (!IniOpenSection("FreeLoader", &SectionId))
{
return 0;
}
if (IniReadSettingByName(SectionId, "DefaultOS", DefaultOSText, 80))
{
for (Idx=0; Idx<OperatingSystemCount; Idx++)
{
if (stricmp(DefaultOSText, OperatingSystemList[Idx]) == 0)
{
DefaultOS = Idx;
break;
}
}
}
return DefaultOS;
}
LONG GetTimeOut(VOID)
{
UCHAR TimeOutText[20];
ULONG TimeOut;
ULONG SectionId;
if (!IniOpenSection("FreeLoader", &SectionId))
{
return -1;
}
if (IniReadSettingByName(SectionId, "TimeOut", TimeOutText, 20))
{
TimeOut = atoi(TimeOutText);
}
else
{
TimeOut = -1;
}
return TimeOut;
}

View file

@ -30,25 +30,14 @@
#include <debug.h>
#include <oslist.h>
#include <video.h>
#include <bootmgr.h>
// Variable BootDrive moved to asmcode.S
//ULONG BootDrive = 0; // BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc.
ULONG BootPartition = 0; // Boot Partition, 1-4
ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount);
LONG GetTimeOut(VOID);
VOID BootMain(VOID)
{
UCHAR SettingName[80];
UCHAR SettingValue[80];
ULONG SectionId;
ULONG OperatingSystemCount;
PUCHAR *OperatingSystemSectionNames;
PUCHAR *OperatingSystemDisplayNames;
ULONG DefaultOperatingSystem;
LONG TimeOut;
ULONG SelectedOperatingSystem;
EnableA20();
@ -63,152 +52,9 @@ VOID BootMain(VOID)
return;
}
if (!IniFileInitialize())
{
printf("Press any key to reboot.\n");
getch();
return;
}
if (!IniOpenSection("FreeLoader", &SectionId))
{
printf("Section [FreeLoader] not found in freeldr.ini.\n");
getch();
return;
}
if (!UiInitialize())
{
printf("Press any key to reboot.\n");
getch();
return;
}
if (!InitOperatingSystemList(&OperatingSystemSectionNames, &OperatingSystemDisplayNames, &OperatingSystemCount))
{
UiMessageBox("Press ENTER to reboot.\n");
goto reboot;
}
if (OperatingSystemCount == 0)
{
UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
goto reboot;
}
DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemSectionNames, OperatingSystemCount);
TimeOut = GetTimeOut();
//
// Find all the message box settings and run them
//
UiShowMessageBoxesInSection("FreeLoader");
for (;;)
{
// Redraw the backdrop
UiDrawBackdrop();
// Show the operating system list menu
if (!UiDisplayMenu(OperatingSystemDisplayNames, OperatingSystemCount, DefaultOperatingSystem, TimeOut, &SelectedOperatingSystem))
{
UiMessageBox("Press ENTER to reboot.\n");
goto reboot;
}
TimeOut = -1;
DefaultOperatingSystem = SelectedOperatingSystem;
// Try to open the operating system section in the .ini file
if (!IniOpenSection(OperatingSystemSectionNames[SelectedOperatingSystem], &SectionId))
{
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", OperatingSystemSectionNames[SelectedOperatingSystem]);
UiMessageBox(SettingName);
continue;
}
// Try to read the boot type
if (!IniReadSettingByName(SectionId, "BootType", SettingValue, 80))
{
sprintf(SettingName, "BootType= line not found in section [%s] in freeldr.ini.\n", OperatingSystemSectionNames[SelectedOperatingSystem]);
UiMessageBox(SettingName);
continue;
}
if (stricmp(SettingValue, "ReactOS") == 0)
{
LoadAndBootReactOS(OperatingSystemSectionNames[SelectedOperatingSystem]);
}
else if (stricmp(SettingValue, "Linux") == 0)
{
LoadAndBootLinux(OperatingSystemSectionNames[SelectedOperatingSystem]);
}
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]);
}
}
reboot:
VideoClearScreen();
VideoShowTextCursor();
return;
}
ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount)
{
UCHAR DefaultOSText[80];
ULONG SectionId;
ULONG DefaultOS = 0;
ULONG Idx;
if (!IniOpenSection("FreeLoader", &SectionId))
{
return 0;
}
if (IniReadSettingByName(SectionId, "DefaultOS", DefaultOSText, 80))
{
for (Idx=0; Idx<OperatingSystemCount; Idx++)
{
if (stricmp(DefaultOSText, OperatingSystemList[Idx]) == 0)
{
DefaultOS = Idx;
break;
}
}
}
return DefaultOS;
}
LONG GetTimeOut(VOID)
{
UCHAR TimeOutText[20];
ULONG TimeOut;
ULONG SectionId;
if (!IniOpenSection("FreeLoader", &SectionId))
{
return -1;
}
if (IniReadSettingByName(SectionId, "TimeOut", TimeOutText, 20))
{
TimeOut = atoi(TimeOutText);
}
else
{
TimeOut = -1;
}
return TimeOut;
#ifdef __SETUPLDR__
ReactOSRunSetupLoader();
#else
RunBootManager();
#endif // defined __SETUPLDR__
}

View file

@ -0,0 +1,29 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __BOOTMGR_H
#define __BOOTMGR_H
VOID RunBootManager(VOID);
ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount);
LONG GetTimeOut(VOID);
#endif // #defined __BOOTMGR_H

View file

@ -28,6 +28,12 @@
///////////////////////////////////////////////////////////////////////////////////////
void LoadAndBootReactOS(PUCHAR OperatingSystemName);
///////////////////////////////////////////////////////////////////////////////////////
//
// ReactOS Setup Loader Functions
//
///////////////////////////////////////////////////////////////////////////////////////
VOID ReactOSRunSetupLoader(VOID);
///////////////////////////////////////////////////////////////////////////////////////
//

View file

@ -22,7 +22,7 @@
/* just some stuff */
#define VERSION "FreeLoader v1.3.1"
#define VERSION "FreeLoader v1.4"
#define COPYRIGHT "Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>"
#define AUTHOR_EMAIL "<brianp@sginet.com>"
#define BY_AUTHOR "by Brian Palmer"
@ -35,8 +35,8 @@
// If you add major functionality then you increment the major version and zero the minor & patch versions
//
#define FREELOADER_MAJOR_VERSION 1
#define FREELOADER_MINOR_VERSION 3
#define FREELOADER_PATCH_VERSION 1
#define FREELOADER_MINOR_VERSION 4
#define FREELOADER_PATCH_VERSION 0
PUCHAR GetFreeLoaderVersionString(VOID);

View file

@ -0,0 +1,37 @@
/*
* FreeLoader
*
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <freeldr.h>
#include <debug.h>
#include <arch.h>
#include <reactos.h>
#include <rtl.h>
#include <fs.h>
#include <ui.h>
#include <multiboot.h>
#include <mm.h>
#include <inifile.h>
#include "registry.h"
#include "hwdetect.h"
VOID ReactOSRunSetupLoader(VOID)
{
}