Changes in v1.8.13 (6/05/2003) (brianp)

- Added support for booting Linux 2.4.x kernels
- i386 exception handler now reports FreeLoader version number

svn path=/trunk/; revision=4844
This commit is contained in:
Brian Palmer 2003-06-05 20:06:48 +00:00
parent 1179903bd5
commit 5320d2eb3f
11 changed files with 143 additions and 12 deletions

View file

@ -1,3 +1,8 @@
Changes in v1.8.13 (6/05/2003) (brianp)
- Added support for booting Linux 2.4.x kernels
- i386 exception handler now reports FreeLoader version number
Changes in v1.8.12 (5/25/2003) (ekohl) Changes in v1.8.12 (5/25/2003) (ekohl)
- Added .inf-file parser - Added .inf-file parser

View file

@ -736,7 +736,7 @@ DetectHardware(VOID)
{ {
HKEY SystemKey; HKEY SystemKey;
U32 BusNumber = 0; U32 BusNumber = 0;
S32 Error S32 Error;
DbgPrint((DPRINT_HWDETECT, "DetectHardware()\n")); DbgPrint((DPRINT_HWDETECT, "DetectHardware()\n"));

View file

@ -22,6 +22,7 @@
#define ASM #define ASM
#include <arch.h> #include <arch.h>
#include <version.h>
@ -80,7 +81,10 @@
i386ExceptionHandlerText: i386ExceptionHandlerText:
.ascii "FreeLoader i386 Exception Handler\n" .ascii "FreeLoader i386 Exception Handler\n"
.asciz "Report bugs to Brian Palmer <brianp@reactos.org>\n\n" .ascii VERSION
.ascii "\n"
// .asciz "Report bugs to Brian Palmer <brianp@reactos.org>\n\n"
.asciz "Report bugs to ReactOS Kernel mailing list <ros-kernel@reactos.com>\n\n"
i386DivideByZeroText: i386DivideByZeroText:
.asciz "Exception 00: DIVIDE BY ZERO\n\n" .asciz "Exception 00: DIVIDE BY ZERO\n\n"

View file

@ -26,10 +26,10 @@
#ifdef DEBUG #ifdef DEBUG
//#define DEBUG_ALL //#define DEBUG_ALL
#define DEBUG_INIFILE //#define DEBUG_INIFILE
//#define DEBUG_REACTOS //#define DEBUG_REACTOS
//#define DEBUG_CUSTOM //#define DEBUG_CUSTOM
//#define DEBUG_NONE #define DEBUG_NONE
#if defined (DEBUG_ALL) #if defined (DEBUG_ALL)
U32 DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM | U32 DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
@ -40,7 +40,7 @@ U32 DebugPrintMask = DPRINT_INIFILE;
#elif defined (DEBUG_REACTOS) #elif defined (DEBUG_REACTOS)
U32 DebugPrintMask = DPRINT_REACTOS | DPRINT_REGISTRY; U32 DebugPrintMask = DPRINT_REACTOS | DPRINT_REGISTRY;
#elif defined (DEBUG_CUSTOM) #elif defined (DEBUG_CUSTOM)
U32 DebugPrintMask = DPRINT_WARNING|DPRINT_FILESYSTEM; U32 DebugPrintMask = DPRINT_WARNING|DPRINT_FILESYSTEM|DPRINT_MEMORY|DPRINT_LINUX;
#else //#elif defined (DEBUG_NONE) #else //#elif defined (DEBUG_NONE)
U32 DebugPrintMask = 0; U32 DebugPrintMask = 0;
#endif #endif

View file

@ -41,6 +41,8 @@
#define LINUX_FLAG_LOAD_HIGH 0x01 #define LINUX_FLAG_LOAD_HIGH 0x01
#define LINUX_FLAG_CAN_USE_HEAP 0x80 #define LINUX_FLAG_CAN_USE_HEAP 0x80
#define LINUX_MAX_INITRD_ADDRESS 0x38000000
typedef struct typedef struct
{ {
U8 BootCode1[0x20]; U8 BootCode1[0x20];
@ -115,6 +117,9 @@ typedef struct
U16 HeapEnd; // space from here (exclusive) down to U16 HeapEnd; // space from here (exclusive) down to
// end of setup code can be used by setup // end of setup code can be used by setup
// for local heap purposes. // for local heap purposes.
U16 Pad1;
U32 CommandLinePointer; // 32-bit pointer to the kernel command line
U32 InitrdAddressMax; // Highest legal initrd address
} PACKED LINUX_SETUPSECTOR, *PLINUX_SETUPSECTOR; } PACKED LINUX_SETUPSECTOR, *PLINUX_SETUPSECTOR;

View file

@ -53,5 +53,6 @@ VOID MmFreeMemory(PVOID MemoryPointer);
//PVOID MmAllocateLowMemory(U32 MemorySize); //PVOID MmAllocateLowMemory(U32 MemorySize);
//VOID MmFreeLowMemory(PVOID MemoryPointer); //VOID MmFreeLowMemory(PVOID MemoryPointer);
PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress); PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress);
PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress);
#endif // defined __MEMORY_H #endif // defined __MEMORY_H

View file

@ -22,7 +22,7 @@
/* just some stuff */ /* just some stuff */
#define VERSION "FreeLoader v1.8.12" #define VERSION "FreeLoader v1.8.13"
#define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>" #define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>"
#define AUTHOR_EMAIL "<brianp@sginet.com>" #define AUTHOR_EMAIL "<brianp@sginet.com>"
#define BY_AUTHOR "by Brian Palmer" #define BY_AUTHOR "by Brian Palmer"
@ -36,10 +36,14 @@
// //
#define FREELOADER_MAJOR_VERSION 1 #define FREELOADER_MAJOR_VERSION 1
#define FREELOADER_MINOR_VERSION 8 #define FREELOADER_MINOR_VERSION 8
#define FREELOADER_PATCH_VERSION 12 #define FREELOADER_PATCH_VERSION 13
#ifndef ASM
PUCHAR GetFreeLoaderVersionString(VOID); PUCHAR GetFreeLoaderVersionString(VOID);
#endif // ASM
#endif // defined __VERSION_H #endif // defined __VERSION_H

View file

@ -146,8 +146,15 @@ VOID LoadAndBootLinux(PUCHAR OperatingSystemName, PUCHAR Description)
LinuxBootSector->RootDevice = 0x0200; LinuxBootSector->RootDevice = 0x0200;
} }
LinuxBootSector->CommandLineMagic = LINUX_COMMAND_LINE_MAGIC; if (LinuxSetupSector->Version >= 0x0202)
LinuxBootSector->CommandLineOffset = 0x9000; {
LinuxSetupSector->CommandLinePointer = 0x99000;
}
else
{
LinuxBootSector->CommandLineMagic = LINUX_COMMAND_LINE_MAGIC;
LinuxBootSector->CommandLineOffset = 0x9000;
}
if (NewStyleLinuxKernel) if (NewStyleLinuxKernel)
{ {
@ -455,7 +462,17 @@ BOOL LinuxReadInitrd(PFILE LinuxInitrdFile)
UiDrawStatusText(StatusText); UiDrawStatusText(StatusText);
// Allocate memory for the ramdisk // Allocate memory for the ramdisk
LinuxInitrdLoadAddress = MmAllocateMemory(LinuxInitrdSize); //LinuxInitrdLoadAddress = MmAllocateMemory(LinuxInitrdSize);
// Try to align it at the next MB boundary after the kernel
//LinuxInitrdLoadAddress = MmAllocateMemoryAtAddress(LinuxInitrdSize, (PVOID)ROUND_UP((LINUX_KERNEL_LOAD_ADDRESS + LinuxKernelSize), 0x100000));
if (LinuxSetupSector->Version <= 0x0202)
{
LinuxInitrdLoadAddress = MmAllocateHighestMemoryBelowAddress(LinuxInitrdSize, (PVOID)LINUX_MAX_INITRD_ADDRESS);
}
else
{
LinuxInitrdLoadAddress = MmAllocateHighestMemoryBelowAddress(LinuxInitrdSize, (PVOID)LinuxSetupSector->InitrdAddressMax);
}
if (LinuxInitrdLoadAddress == NULL) if (LinuxInitrdLoadAddress == NULL)
{ {
return FALSE; return FALSE;
@ -465,6 +482,14 @@ BOOL LinuxReadInitrd(PFILE LinuxInitrdFile)
LinuxSetupSector->RamdiskAddress = (U32)LinuxInitrdLoadAddress; LinuxSetupSector->RamdiskAddress = (U32)LinuxInitrdLoadAddress;
LinuxSetupSector->RamdiskSize = LinuxInitrdSize; LinuxSetupSector->RamdiskSize = LinuxInitrdSize;
DbgPrint((DPRINT_LINUX, "RamdiskAddress: 0x%x\n", LinuxSetupSector->RamdiskAddress));
DbgPrint((DPRINT_LINUX, "RamdiskSize: 0x%x\n", LinuxSetupSector->RamdiskSize));
if (LinuxSetupSector->Version >= 0x0203)
{
DbgPrint((DPRINT_LINUX, "InitrdAddressMax: 0x%x\n", LinuxSetupSector->InitrdAddressMax));
}
// Read in the ramdisk // Read in the ramdisk
for (BytesLoaded=0; BytesLoaded<LinuxInitrdSize; ) for (BytesLoaded=0; BytesLoaded<LinuxInitrdSize; )
{ {

View file

@ -62,6 +62,7 @@ VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCoun
VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount); // Allocates the specified pages in the lookup table VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount); // Allocates the specified pages in the lookup table
U32 MmCountFreePagesInLookupTable(PVOID PageLookupTable, U32 TotalPageCount); // Returns the number of free pages in the lookup table U32 MmCountFreePagesInLookupTable(PVOID PageLookupTable, U32 TotalPageCount); // Returns the number of free pages in the lookup table
U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded); // Returns the page number of the first available page range from the end of memory U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded); // Returns the page number of the first available page range from the end of memory
U32 MmFindAvailablePagesBeforePage(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded, U32 LastPage); // Returns the page number of the first available page range before the specified page
VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount); // Removes entries in the memory map that describe memory above 4G VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount); // Removes entries in the memory map that describe memory above 4G
VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory
BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, U32 TotalPageCount, PVOID PageAddress, U32 PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, U32 TotalPageCount, PVOID PageAddress, U32 PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE

View file

@ -342,7 +342,6 @@ U32 MmCountFreePagesInLookupTable(PVOID PageLookupTable, U32 TotalPageCount)
U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded) U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded)
{ {
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 AvailablePageStart;
U32 AvailablePagesSoFar; U32 AvailablePagesSoFar;
U32 Index; U32 Index;
@ -351,7 +350,6 @@ U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 P
LastFreePageHint = TotalPageCount; LastFreePageHint = TotalPageCount;
} }
AvailablePageStart = 0;
AvailablePagesSoFar = 0; AvailablePagesSoFar = 0;
for (Index=LastFreePageHint-1; Index>0; Index--) for (Index=LastFreePageHint-1; Index>0; Index--)
{ {
@ -374,6 +372,39 @@ U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 P
return 0; return 0;
} }
U32 MmFindAvailablePagesBeforePage(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded, U32 LastPage)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 AvailablePagesSoFar;
U32 Index;
if (LastPage > TotalPageCount)
{
return MmFindAvailablePagesFromEnd(PageLookupTable, TotalPageCount, PagesNeeded);
}
AvailablePagesSoFar = 0;
for (Index=LastPage-1; Index>0; Index--)
{
if (RealPageLookupTable[Index].PageAllocated != 0)
{
AvailablePagesSoFar = 0;
continue;
}
else
{
AvailablePagesSoFar++;
}
if (AvailablePagesSoFar >= PagesNeeded)
{
return Index;
}
}
return 0;
}
VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount) VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount)
{ {
int Index; int Index;

View file

@ -138,6 +138,61 @@ PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress)
return MemPointer; return MemPointer;
} }
PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress)
{
U32 PagesNeeded;
U32 FirstFreePageFromEnd;
U32 DesiredAddressPageNumber;
PVOID MemPointer;
if (MemorySize == 0)
{
DbgPrint((DPRINT_MEMORY, "MmAllocateHighestMemoryBelowAddress() called for 0 bytes. Returning NULL.\n"));
UiMessageBoxCritical("Memory allocation failed: MmAllocateHighestMemoryBelowAddress() called for 0 bytes.");
return NULL;
}
// Find out how many blocks it will take to
// satisfy this allocation
PagesNeeded = ROUND_UP(MemorySize, MM_PAGE_SIZE) / MM_PAGE_SIZE;
// Get the page number for their desired address
DesiredAddressPageNumber = (U32)DesiredAddress / MM_PAGE_SIZE;
// If we don't have enough available mem
// then return NULL
if (FreePagesInLookupTable < PagesNeeded)
{
DbgPrint((DPRINT_MEMORY, "Memory allocation failed. Not enough free memory to allocate %d bytes. AllocationCount: %d\n", MemorySize, AllocationCount));
UiMessageBoxCritical("Memory allocation failed: out of memory.");
return NULL;
}
FirstFreePageFromEnd = MmFindAvailablePagesBeforePage(PageLookupTableAddress, TotalPagesInLookupTable, PagesNeeded, DesiredAddressPageNumber);
if (FirstFreePageFromEnd == 0)
{
DbgPrint((DPRINT_MEMORY, "Memory allocation failed. Not enough free memory to allocate %d bytes. AllocationCount: %d\n", MemorySize, AllocationCount));
UiMessageBoxCritical("Memory allocation failed: out of memory.");
return NULL;
}
MmAllocatePagesInLookupTable(PageLookupTableAddress, FirstFreePageFromEnd, PagesNeeded);
FreePagesInLookupTable -= PagesNeeded;
MemPointer = (PVOID)(FirstFreePageFromEnd * MM_PAGE_SIZE);
#ifdef DEBUG
IncrementAllocationCount();
DbgPrint((DPRINT_MEMORY, "Allocated %d bytes (%d pages) of memory starting at page %d. AllocCount: %d\n", MemorySize, PagesNeeded, FirstFreePageFromEnd, AllocationCount));
DbgPrint((DPRINT_MEMORY, "Memory allocation pointer: 0x%x\n", MemPointer));
//VerifyHeap();
#endif // DEBUG
// Now return the pointer
return MemPointer;
}
VOID MmFreeMemory(PVOID MemoryPointer) VOID MmFreeMemory(PVOID MemoryPointer)
{ {
U32 PageNumber; U32 PageNumber;