export CP = cmd /C copy
#FLAGS = -Wall -nostdinc -fno-builtin
-FLAGS = -Wall -fno-builtin -DDEBUG
+FLAGS = -Wall -fno-builtin -DDEBUG -O3
#FLAGS = -Wall -fno-builtin
# asmcode.o has to be first in the link line because it contains the startup code
-OBJS = asmcode.a asmcode.o mb.o boot.o freeldr.o stdlib.o fs.a fs.o fat.o \
- reactos.o tui.o menu.o miscboot.o options.o linux.o multiboot.o arcname.o \
- mem.o memory.o debug.o parseini.o
+#OBJS = asmcode.a asmcode.o mb.o boot.o freeldr.o stdlib.o fs.a fs.o fat.o \
+# reactos.o tui.o menu.o miscboot.o options.o linux.o multiboot.o arcname.o \
+# mem.o memory.o debug.o parseini.o registry.o import.o
ASM_OBJS = asmcode.o mb.o boot.o mem.o
-C_OBJS = freeldr.o stdlib.o fs.a reactos.o tui.o menu.o miscboot.o options.o linux.o \
- multiboot.o
+C_OBJS = freeldr.o stdlib.o fs.a tui.o menu.o miscboot.o options.o linux.o multiboot.o \
+ reactos/reactos.o reactos/registry.o reactos/reghive.o reactos/hwdetect.o
C_OBJS2 = arcname.o memory.o debug.o parseini.o rs232.o portio.o oslist.o
.PHONY : clean
all: freeldr.sys
freeldr.sys: asmcode.a c_code.a
- $(LD) -N -Ttext=0x8000 --oformat=binary -o f.sys asmcode.a c_code.a
+ $(LD) -N -Ttext=0x8000 --oformat=binary -s -o f.sys asmcode.a c_code.a
../bootsect/stubit ../bootsect/fatstub.bin f.sys freeldr.sys
+freeldr.exe: asmcode.a c_code.a
+ $(LD) -o freeldr.exe asmcode.a c_code.a
+
asmcode.a: $(ASM_OBJS)
$(LD) -r -o asmcode.a $(ASM_OBJS)
asmcode.o: asmcode.S asmcode.h Makefile
$(CC) $(FLAGS) -o asmcode.o -c asmcode.S
-freeldr.o: freeldr.c freeldr.h stdlib.h fs.h reactos.h tui.h asmcode.h menu.h miscboot.h Makefile
+freeldr.o: freeldr.c freeldr.h stdlib.h fs.h reactos/reactos.h tui.h asmcode.h menu.h miscboot.h Makefile
$(CC) $(FLAGS) -o freeldr.o -c freeldr.c
stdlib.o: stdlib.c freeldr.h stdlib.h Makefile
fat.o: fat.c fat.h freeldr.h fs.h stdlib.h tui.h Makefile
$(CC) $(FLAGS) -o fat.o -c fat.c
-reactos.o: reactos.c freeldr.h reactos.h stdlib.h fs.h tui.h multiboot.h Makefile
- $(CC) $(FLAGS) -o reactos.o -c reactos.c
+reactos/reactos.o: reactos/reactos.c freeldr.h reactos/reactos.h reactos/registry.h reactos/hwdetect.h stdlib.h fs.h tui.h multiboot.h Makefile
+ $(CC) $(FLAGS) -o reactos/reactos.o -c reactos/reactos.c
multiboot.o: multiboot.c freeldr.h stdlib.h fs.h multiboot.h tui.h Makefile
$(CC) $(FLAGS) -o multiboot.o -c multiboot.c
oslist.o: oslist.c oslist.h Makefile
$(CC) $(FLAGS) -o oslist.o -c oslist.c
+reactos/registry.o: reactos/registry.c freeldr.h memory.h reactos/registry.h stdlib.h Makefile
+ $(CC) $(FLAGS) -o reactos/registry.o -c reactos/registry.c
+
+reactos/reghive.o: reactos/reghive.c freeldr.h reactos/registry.h stdlib.h memory.h Makefile
+ $(CC) $(FLAGS) -o reactos/reghive.o -c reactos/reghive.c
+
+reactos/hwdetect.o: reactos/hwdetect.c freeldr.h reactos/hwdetect.h Makefile
+ $(CC) $(FLAGS) -o reactos/hwdetect.o -c reactos/hwdetect.c
+
clean:
$(RM) *.o
$(RM) *.a
- $(RM) freeldr.sys
+ $(RM) *.sys
#include "parseini.h"
unsigned long next_module_load_base = 0;
+module_t* pOpenModule = NULL;
+
BOOL MultiBootLoadKernel(FILE *KernelImage)
{
return TRUE;
}
+#if 0
BOOL MultiBootLoadModule(FILE *ModuleImage, char *ModuleName)
{
DWORD dwModuleSize;
return TRUE;
}
+#endif
+
+PVOID MultiBootLoadModule(FILE *ModuleImage, char *ModuleName, PULONG ModuleSize)
+{
+ DWORD dwModuleSize;
+ module_t* pModule;
+ char* ModuleNameString;
+ char * TempName;
+
+ /*
+ * Get current module data structure and module name string array
+ */
+ pModule = &multiboot_modules[mb_info.mods_count];
+ do {
+ TempName = strchr( ModuleName, '\\' );
+ if( TempName )
+ ModuleName = TempName + 1;
+ } while( TempName );
+
+ ModuleNameString = multiboot_module_strings[mb_info.mods_count];
+
+ dwModuleSize = GetFileSize(ModuleImage);
+ pModule->mod_start = next_module_load_base;
+ pModule->mod_end = next_module_load_base + dwModuleSize;
+ strcpy(ModuleNameString, ModuleName);
+ pModule->string = (unsigned long)ModuleNameString;
+
+ /*
+ * Load the file image
+ */
+ ReadFile(ModuleImage, dwModuleSize, NULL, (void*)next_module_load_base);
+
+ next_module_load_base = ROUND_UP(pModule->mod_end, /*PAGE_SIZE*/4096);
+ mb_info.mods_count++;
+
+ if (ModuleSize != NULL)
+ *ModuleSize = dwModuleSize;
+
+ return((PVOID)pModule->mod_start);
+}
int GetBootPartition(char *OperatingSystemName)
{
return BootPartitionNumber;
}
+
+
+PVOID MultiBootCreateModule(char *ModuleName)
+{
+ module_t* pModule;
+ char* ModuleNameString;
+
+ /*
+ * Get current module data structure and module name string array
+ */
+ pModule = &multiboot_modules[mb_info.mods_count];
+
+ ModuleNameString = multiboot_module_strings[mb_info.mods_count];
+
+ pModule->mod_start = next_module_load_base;
+ pModule->mod_end = -1;
+ strcpy(ModuleNameString, ModuleName);
+ pModule->string = (unsigned long)ModuleNameString;
+
+ pOpenModule = pModule;
+
+ return((PVOID)pModule->mod_start);
+}
+
+
+BOOL MultiBootCloseModule(PVOID ModuleBase, DWORD dwModuleSize)
+{
+ module_t* pModule;
+
+ if ((pOpenModule != NULL) &&
+ ((module_t*)ModuleBase == pOpenModule->mod_start) &&
+ (pOpenModule->mod_end == -1))
+ {
+ pModule = pOpenModule;
+ pModule->mod_end = pModule->mod_start + dwModuleSize;
+
+ next_module_load_base = ROUND_UP(pModule->mod_end, /*PAGE_SIZE*/4096);
+ mb_info.mods_count++;
+ pOpenModule = NULL;
+
+ return(TRUE);
+ }
+
+ return(FALSE);
+}
\ No newline at end of file
+++ /dev/null
-/*
- * FreeLoader
- * Copyright (C) 1999, 2000, 2001 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 "asmcode.h"
-#include "reactos.h"
-#include "stdlib.h"
-#include "fs.h"
-#include "tui.h"
-#include "multiboot.h"
-#include "arcname.h"
-#include "memory.h"
-#include "parseini.h"
-
-BOOL LoadReactOSKernel(PUCHAR OperatingSystemName);
-BOOL LoadReactOSDrivers(PUCHAR OperatingSystemName);
-
-void LoadAndBootReactOS(PUCHAR OperatingSystemName)
-{
- PFILE FilePointer;
- char name[1024];
- char value[1024];
- char szFileName[1024];
- char szBootPath[256];
- int i;
- int nNumDriverFiles=0;
- int nNumFilesLoaded=0;
- char MsgBuffer[256];
- ULONG SectionId;
-
- //
- // Open the operating system section
- // specified in the .ini file
- //
- if (!OpenSection(OperatingSystemName, &SectionId))
- {
- sprintf(MsgBuffer,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName);
- MessageBox(MsgBuffer);
- return;
- }
-
- /*
- * Setup multiboot information structure
- */
- mb_info.flags = MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
- mb_info.mem_lower = GetConventionalMemorySize();
- mb_info.mem_upper = GetExtendedMemorySize();
- mb_info.boot_device = 0xffffffff;
- mb_info.cmdline = (unsigned long)multiboot_kernel_cmdline;
- mb_info.mods_count = 0;
- mb_info.mods_addr = (unsigned long)multiboot_modules;
- mb_info.mmap_length = GetBiosMemoryMap(&multiboot_memory_map);
- if (mb_info.mmap_length)
- {
- mb_info.mmap_addr = (unsigned long)&multiboot_memory_map;
- mb_info.flags |= MB_INFO_FLAG_MEMORY_MAP;
- //printf("memory map length: %d\n", mb_info.mmap_length);
- //printf("dumping memory map:\n");
- //for (i=0; i<(mb_info.mmap_length / 4); i++)
- //{
- // printf("0x%x\n", ((unsigned long *)&multiboot_memory_map)[i]);
- //}
- //getch();
- }
- //printf("low_mem = %d\n", mb_info.mem_lower);
- //printf("high_mem = %d\n", mb_info.mem_upper);
-
- /*
- * Make sure the system path is set in the .ini file
- */
- if (!ReadSectionSettingByName(SectionId, "SystemPath", value, 1024))
- {
- MessageBox("System path not specified for selected operating system.");
- return;
- }
-
- /*
- * Verify system path
- */
- if (!DissectArcPath(value, szBootPath, &BootDrive, &BootPartition))
- {
- sprintf(MsgBuffer,"Invalid system path: '%s'", value);
- MessageBox(MsgBuffer);
- return;
- }
-
- /* set boot drive and partition */
- ((char *)(&mb_info.boot_device))[0] = (char)BootDrive;
- ((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
-
- /* copy ARC path into kernel command line */
- strcpy(multiboot_kernel_cmdline, value);
-
- /*
- * Read the optional kernel parameters (if any)
- */
- if (ReadSectionSettingByName(SectionId, "Options", value, 1024))
- {
- strcat(multiboot_kernel_cmdline, " ");
- strcat(multiboot_kernel_cmdline, value);
- }
-
- /* append a backslash */
- if ((strlen(szBootPath)==0) ||
- szBootPath[strlen(szBootPath)] != '\\')
- strcat(szBootPath, "\\");
-
- /*
- * Find the kernel image name
- */
- if(!ReadSectionSettingByName(SectionId, "Kernel", value, 1024))
- {
- MessageBox("Kernel image file not specified for selected operating system.");
- return;
- }
-
- /*
- * Find the hal image name
- */
- if(!ReadSectionSettingByName(SectionId, "Hal", value, 1024))
- {
- MessageBox("HAL image file not specified for selected operating system.");
- return;
- }
-
- DrawBackdrop();
-
- DrawStatusText(" Loading...");
- DrawProgressBar(0);
-
- /*
- * Try to open boot drive
- */
- if (!OpenDiskDrive(BootDrive, BootPartition))
- {
- MessageBox("Failed to open boot drive.");
- return;
- }
-
- /*
- * Parse the ini file and count the kernel, hal and drivers
- */
- for (i=1; i<=GetNumSectionItems(SectionId); i++)
- {
- /*
- * Read the setting and check if it's a driver
- */
- ReadSectionSettingByNumber(SectionId, i, name, 1024, value, 1024);
- if ((stricmp(name, "Kernel") == 0) ||
- (stricmp(name, "Hal") == 0) ||
- (stricmp(name, "Driver") == 0))
- nNumDriverFiles++;
- }
-
- /*
- * Find the kernel image name
- * and try to load the kernel off the disk
- */
- if(ReadSectionSettingByName(SectionId, "Kernel", value, 1024))
- {
- /*
- * Set the name and try to open the PE image
- */
- //strcpy(szFileName, szBootPath);
- //strcat(szFileName, value);
- strcpy(szFileName, value);
-
- FilePointer = OpenFile(szFileName);
- if (FilePointer == NULL)
- {
- strcat(value, " not found.");
- MessageBox(value);
- return;
- }
-
- /*
- * Update the status bar with the current file
- */
- strcpy(name, " Reading ");
- strcat(name, value);
- while (strlen(name) < 80)
- strcat(name, " ");
- DrawStatusText(name);
-
- /*
- * Load the kernel image
- */
- MultiBootLoadKernel(FilePointer);
-
- nNumFilesLoaded++;
- DrawProgressBar((nNumFilesLoaded * 100) / nNumDriverFiles);
- }
-
- /*
- * Find the HAL image name
- * and try to load the kernel off the disk
- */
- if(ReadSectionSettingByName(SectionId, "Hal", value, 1024))
- {
- /*
- * Set the name and try to open the PE image
- */
- //strcpy(szFileName, szBootPath);
- //strcat(szFileName, value);
- strcpy(szFileName, value);
-
- FilePointer = OpenFile(szFileName);
- if (FilePointer == NULL)
- {
- strcat(value, " not found.");
- MessageBox(value);
- return;
- }
-
- /*
- * Update the status bar with the current file
- */
- strcpy(name, " Reading ");
- strcat(name, value);
- while (strlen(name) < 80)
- strcat(name, " ");
- DrawStatusText(name);
-
- /*
- * Load the HAL image
- */
- MultiBootLoadModule(FilePointer, szFileName);
-
- nNumFilesLoaded++;
- DrawProgressBar((nNumFilesLoaded * 100) / nNumDriverFiles);
- }
-
- /*
- * Parse the ini file and load the kernel and
- * load all the drivers specified
- */
- for (i=1; i<=GetNumSectionItems(SectionId); i++)
- {
- /*
- * Read the setting and check if it's a driver
- */
- ReadSectionSettingByNumber(SectionId, i, name, 1024, value, 1024);
- if (stricmp(name, "Driver") == 0)
- {
- /*
- * Set the name and try to open the PE image
- */
- //strcpy(szFileName, szBootPath);
- //strcat(szFileName, value);
- strcpy(szFileName, value);
-
- FilePointer = OpenFile(szFileName);
- if (FilePointer == NULL)
- {
- strcat(value, " not found.");
- MessageBox(value);
- return;
- }
-
- /*
- * Update the status bar with the current file
- */
- strcpy(name, " Reading ");
- strcat(name, value);
- while (strlen(name) < 80)
- strcat(name, " ");
- DrawStatusText(name);
-
- /*
- * Load the driver
- */
- MultiBootLoadModule(FilePointer, szFileName);
-
-
- nNumFilesLoaded++;
- DrawProgressBar((nNumFilesLoaded * 100) / nNumDriverFiles);
- }
- else if (stricmp(name, "MessageBox") == 0)
- {
- DrawStatusText(" Press ENTER to continue");
- MessageBox(value);
- }
- else if (stricmp(name, "MessageLine") == 0)
- MessageLine(value);
- else if (stricmp(name, "ReOpenBootDrive") == 0)
- {
- if (!OpenDiskDrive(BootDrive, BootPartition))
- {
- MessageBox("Failed to open boot drive.");
- return;
- }
- }
- }
-
- /*
- * Clear the screen and redraw the backdrop and status bar
- */
- DrawBackdrop();
- DrawStatusText(" Press any key to boot");
-
- /*
- * Wait for user
- */
- strcpy(name, "Kernel and Drivers loaded.\nPress any key to boot ");
- strcat(name, OperatingSystemName);
- strcat(name, ".");
- //MessageBox(name);
-
- RestoreScreen(ScreenBuffer);
-
- /*
- * Now boot the kernel
- */
- stop_floppy();
- boot_reactos();
-}
-