[FREELDR]

- Move cleaning the shared user data to after WinLdrSetProcessorContext, as we need the new page tables to be active
- Fix indentation/coding style in registry.c
- Fix a few 64 bit warnings
- delete <arch>/ntsetup.c and rename <arch>/wlmemory.c to <arch>/winldr.c

svn path=/trunk/; revision=53526
This commit is contained in:
Timo Kreuzer 2011-09-01 19:01:19 +00:00
parent e6fe154eef
commit 6d62252f5a
19 changed files with 547 additions and 761 deletions

View file

@ -112,8 +112,7 @@ if(ARCH MATCHES i386)
arch/i386/xboxmem.c
arch/i386/xboxrtc.c
arch/i386/xboxvideo.c
arch/i386/ntsetup.c
arch/i386/wlmemory.c
arch/i386/winldr.c
windows/headless.c
disk/scsiport.c)
if(NOT MSVC)
@ -141,8 +140,7 @@ elseif(ARCH MATCHES amd64)
arch/i386/pcmem.c
arch/i386/pcrtc.c
arch/i386/pcvideo.c
arch/amd64/ntsetup.c
arch/amd64/wlmemory.c)
arch/amd64/winldr.c)
else()
#TBD
endif()

View file

@ -1,84 +0,0 @@
/*
* PROJECT: EFI Windows Loader
* LICENSE: GPL - See COPYING in the top level directory
* FILE: freeldr/windows/i386/ntsetup.c
* PURPOSE: i386-specific setup for Windows boot
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
*/
/* INCLUDES ***************************************************************/
#include <freeldr.h>
#include <debug.h>
// this is needed for new IDT filling
#if 0
extern ULONG_PTR i386DivideByZero;
extern ULONG_PTR i386DebugException;
extern ULONG_PTR i386NMIException;
extern ULONG_PTR i386Breakpoint;
extern ULONG_PTR i386Overflow;
extern ULONG_PTR i386BoundException;
extern ULONG_PTR i386InvalidOpcode;
extern ULONG_PTR i386FPUNotAvailable;
extern ULONG_PTR i386DoubleFault;
extern ULONG_PTR i386CoprocessorSegment;
extern ULONG_PTR i386InvalidTSS;
extern ULONG_PTR i386SegmentNotPresent;
extern ULONG_PTR i386StackException;
extern ULONG_PTR i386GeneralProtectionFault;
extern ULONG_PTR i386PageFault; // exc 14
extern ULONG_PTR i386CoprocessorError; // exc 16
extern ULONG_PTR i386AlignmentCheck; // exc 17
#endif
/* FUNCTIONS **************************************************************/
// Last step before going virtual
void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
PVOID *GdtIdt,
ULONG *PcrBasePage,
ULONG *TssBasePage)
{
ULONG TssSize;
ULONG TssPages;
ULONG_PTR Pcr = 0;
ULONG_PTR Tss = 0;
ULONG BlockSize, NumPages;
LoaderBlock->u.I386.CommonDataArea = (PVOID)DbgPrint; // HACK
LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
/* Allocate 2 pages for PCR */
Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
*PcrBasePage = Pcr >> MM_PAGE_SHIFT;
RtlZeroMemory((PVOID)Pcr, 2 * MM_PAGE_SIZE);
if (Pcr == 0)
{
UiMessageBox("Can't allocate PCR\n");
return;
}
/* Allocate TSS */
TssSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
TssPages = TssSize / MM_PAGE_SIZE;
Tss = (ULONG_PTR)MmAllocateMemoryWithType(TssSize, LoaderMemoryData);
*TssBasePage = Tss >> MM_PAGE_SHIFT;
/* Allocate space for new GDT + IDT */
BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT limits here?
NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
*GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
if (*GdtIdt == NULL)
{
UiMessageBox("Can't allocate pages for GDT+IDT!\n");
return;
}
/* Zero newly prepared GDT+IDT */
RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
}

View file

@ -23,8 +23,8 @@ PHARDWARE_PTE PxeBase;
//PHARDWARE_PTE HalPageTable;
PVOID GdtIdt;
ULONG PcrBasePage;
ULONG TssBasePage;
ULONG_PTR PcrBasePage;
ULONG_PTR TssBasePage;
/* FUNCTIONS **************************************************************/
@ -152,6 +152,8 @@ MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, ULONG cPage
{
if (!MempMapSinglePage(VirtualAddress, PhysicalAddress))
{
DPRINTM(DPRINT_WINDOWS, "Failed to map page %ld from %p to %p\n",
i, (PVOID)VirtualAddress, (PVOID)PhysicalAddress);
return i;
}
VirtualAddress += PAGE_SIZE;
@ -172,7 +174,8 @@ MempSetupPaging(IN ULONG StartPage,
StartPage * PAGE_SIZE,
NumberOfPages) != NumberOfPages)
{
DPRINTM(DPRINT_WINDOWS,"Failed to map pages 1\n");
DPRINTM(DPRINT_WINDOWS,"Failed to map pages %ld, %ld\n",
StartPage, NumberOfPages);
return FALSE;
}
@ -181,7 +184,8 @@ MempSetupPaging(IN ULONG StartPage,
StartPage * PAGE_SIZE,
NumberOfPages) != NumberOfPages)
{
DPRINTM(DPRINT_WINDOWS,"Failed to map pages 2\n");
DPRINTM(DPRINT_WINDOWS,"Failed to map pages %ld, %ld\n",
StartPage, NumberOfPages);
return FALSE;
}
@ -227,7 +231,7 @@ WinLdrpMapApic()
}
BOOLEAN
WinLdrMapSpecialPages(ULONG PcrBasePage)
WinLdrMapSpecialPages()
{
/* Map the PCR page */
if (!MempMapSinglePage(KIP0PCRADDRESS, PcrBasePage * PAGE_SIZE))
@ -350,10 +354,8 @@ WinLdrSetProcessorContext(void)
DPRINTM(DPRINT_WINDOWS, "leave WinLdrSetProcessorContext\n");
}
WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
{
ULONG TssSize;
ULONG_PTR KernelStack;
ULONG_PTR Pcr = 0;
ULONG_PTR Tss = 0;
ULONG BlockSize, NumPages;
@ -382,24 +384,25 @@ WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
/* Allocate space for new GDT + IDT */
BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT limits here?
NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
*GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
if (*GdtIdt == NULL)
GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
if (GdtIdt == NULL)
{
UiMessageBox("Can't allocate pages for GDT+IDT!\n");
return;
}
/* Zero newly prepared GDT+IDT */
RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
RtlZeroMemory(GdtIdt, NumPages << MM_PAGE_SHIFT);
/* Write initial context information */
LoaderBlock->KernelStack = (ULONG_PTR)KernelStack;
LoaderBlock->KernelStack += KERNEL_STACK_SIZE;
LoaderBlock->Prcb = (ULONG_PTR)&Pcr->Prcb;
LoaderBlock->Process = (ULONG_PTR)PdrPage->InitialProcess;
LoaderBlock->Thread = (ULONG_PTR)PdrPage->InitialThread;
// Before we start mapping pages, create a block of memory, which will contain
// PDE and PTEs
if (MempAllocatePageTables() == FALSE)
{
// FIXME: bugcheck
}
/* Map stuff like PCR, KI_USER_SHARED_DATA and Apic */
WinLdrMapSpecialPages();
}

View file

@ -1,84 +0,0 @@
/*
* PROJECT: EFI Windows Loader
* LICENSE: GPL - See COPYING in the top level directory
* FILE: freeldr/windows/i386/ntsetup.c
* PURPOSE: i386-specific setup for Windows boot
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
*/
/* INCLUDES ***************************************************************/
#include <freeldr.h>
#include <debug.h>
// this is needed for new IDT filling
#if 0
extern ULONG_PTR i386DivideByZero;
extern ULONG_PTR i386DebugException;
extern ULONG_PTR i386NMIException;
extern ULONG_PTR i386Breakpoint;
extern ULONG_PTR i386Overflow;
extern ULONG_PTR i386BoundException;
extern ULONG_PTR i386InvalidOpcode;
extern ULONG_PTR i386FPUNotAvailable;
extern ULONG_PTR i386DoubleFault;
extern ULONG_PTR i386CoprocessorSegment;
extern ULONG_PTR i386InvalidTSS;
extern ULONG_PTR i386SegmentNotPresent;
extern ULONG_PTR i386StackException;
extern ULONG_PTR i386GeneralProtectionFault;
extern ULONG_PTR i386PageFault; // exc 14
extern ULONG_PTR i386CoprocessorError; // exc 16
extern ULONG_PTR i386AlignmentCheck; // exc 17
#endif
/* FUNCTIONS **************************************************************/
#if 0
// Last step before going virtual
void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
PVOID *GdtIdt,
ULONG *PcrBasePage,
ULONG *TssBasePage)
{
ULONG TssSize;
//ULONG TssPages;
ULONG_PTR Pcr = 0;
ULONG_PTR Tss = 0;
ULONG BlockSize, NumPages;
LoaderBlock->u.I386.CommonDataArea = NULL; // Force No ABIOS support
LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
/* Allocate 2 pages for PCR */
Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
*PcrBasePage = Pcr >> MM_PAGE_SHIFT;
if (Pcr == 0)
{
UiMessageBox("Can't allocate PCR\n");
return;
}
/* Allocate TSS */
TssSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
//TssPages = TssSize / MM_PAGE_SIZE;
Tss = (ULONG_PTR)MmAllocateMemoryWithType(TssSize, LoaderMemoryData);
*TssBasePage = Tss >> MM_PAGE_SHIFT;
/* Allocate space for new GDT + IDT */
BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT limits here?
NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
*GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
if (*GdtIdt == NULL)
{
UiMessageBox("Can't allocate pages for GDT+IDT!\n");
return;
}
/* Zero newly prepared GDT+IDT */
RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
}
#endif

View file

@ -21,14 +21,14 @@ VOID
CmdLineParse(IN PCHAR CmdLine)
{
PCHAR End, Setting;
ULONG Length, Offset = 0;
ULONG_PTR Length, Offset = 0;
//
// Set defaults
//
CmdLineInfo.DefaultOperatingSystem = NULL;
CmdLineInfo.TimeOut = -1;
//
// Get timeout
//
@ -49,14 +49,14 @@ CmdLineParse(IN PCHAR CmdLine)
Setting += sizeof("defaultos=") + sizeof(ANSI_NULL);
End = strstr(Setting, " ");
if (End) Length = End - Setting; else Length = sizeof(DefaultOs);
//
// Copy the default OS
//
strncpy(DefaultOs, Setting, Length);
CmdLineInfo.DefaultOperatingSystem = DefaultOs;
}
//
// Get ramdisk base address
//
@ -66,7 +66,7 @@ CmdLineParse(IN PCHAR CmdLine)
sizeof(ANSI_NULL),
NULL,
0);
//
// Get ramdisk size
//

View file

@ -32,15 +32,13 @@
#if defined (DEBUG_ALL)
ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
DPRINT_UI | DPRINT_DISK | DPRINT_CACHE | DPRINT_REACTOS |
DPRINT_LINUX | DPRINT_HWDETECT | DPRINT_PELOADER;
DPRINT_LINUX | DPRINT_HWDETECT | DPRINT_PELOADER | DPRINT_WINDOWS;
#elif defined (DEBUG_INIFILE)
ULONG DebugPrintMask = DPRINT_INIFILE;
#elif defined (DEBUG_REACTOS)
ULONG DebugPrintMask = DPRINT_REACTOS | DPRINT_REGISTRY;
#elif defined (DEBUG_CUSTOM)
ULONG DebugPrintMask = DPRINT_WARNING |
DPRINT_UI | DPRINT_CACHE | DPRINT_REACTOS |
DPRINT_LINUX;
ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_WINDOWS;
#else //#elif defined (DEBUG_NONE)
ULONG DebugPrintMask = 0;
#endif

View file

@ -41,8 +41,7 @@
<file>xboxmem.c</file>
<file>xboxrtc.c</file>
<file>xboxvideo.c</file>
<file>ntsetup.c</file>
<file>wlmemory.c</file>
<file>winldr.c</file>
</if>
</directory>
<directory name="powerpc">
@ -71,8 +70,7 @@
<if property="ARCH" value="amd64">
<directory name="amd64">
<file>loader.c</file>
<file>ntsetup.c</file>
<file>wlmemory.c</file>
<file>winldr.c</file>
</directory>
<directory name="i386">
<file>hardware.c</file>
@ -93,7 +91,7 @@
<if property="ARCH" value="arm">
<directory name="arm">
<file>wlmemory.c</file>
<file>winldr.c</file>
</directory>
</if>
</directory>

View file

@ -118,7 +118,7 @@ PEXT2_FILE_INFO Ext2OpenFile(PCSTR FileName)
PEXT2_FILE_INFO FileHandle;
CHAR SymLinkPath[EXT2_NAME_LEN];
CHAR FullPath[EXT2_NAME_LEN * 2];
ULONG Index;
ULONG_PTR Index;
DPRINTM(DPRINT_FILESYSTEM, "Ext2OpenFile() FileName = %s\n", FileName);

View file

@ -650,7 +650,7 @@ static BOOLEAN FatXSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID D
{
ULONG EntryCount;
ULONG CurrentEntry;
ULONG FileNameLen;
SIZE_T FileNameLen;
FATX_DIRENTRY OurDirEntry;
PFATX_DIRENTRY DirEntry = &OurDirEntry;

View file

@ -183,7 +183,7 @@ typedef struct ext2_dirent EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
#define LOG2_BLOCK_SIZE(sb) (sb->log2_block_size + 10)
/* The size of an ext2 block in bytes. */
#define EXT2_BLOCK_SIZE(sb) (1 << LOG2_BLOCK_SIZE(sb))
#define EXT2_BLOCK_SIZE(sb) (((SIZE_T)1) << LOG2_BLOCK_SIZE(sb))
/* The revision level. */
#define EXT2_REVISION(sb) (sb->revision_level)

View file

@ -117,7 +117,7 @@ VOID MmFreeMemory(PVOID MemoryPointer);
PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType);
PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType);
PVOID MmHeapAlloc(ULONG MemorySize);
PVOID MmHeapAlloc(SIZE_T MemorySize);
VOID MmHeapFree(PVOID MemoryPointer);
#define ExAllocatePool(pool, size) MmHeapAlloc(size)

View file

@ -320,7 +320,7 @@ InfpAddKeyToLine (PINFCACHELINE Line,
if (Line->Key != NULL)
return NULL;
Line->Key = (PCHAR)MmHeapAlloc (strlen (Key) + 1);
Line->Key = MmHeapAlloc(strlen(Key) + 1);
if (Line->Key == NULL)
return NULL;
@ -431,7 +431,7 @@ __inline static int is_eol( struct parser *parser, const CHAR *ptr )
/* push data from current token start up to pos into the current token */
static int push_token( struct parser *parser, const CHAR *pos )
{
unsigned int len = pos - parser->start;
SIZE_T len = pos - parser->start;
const CHAR *src = parser->start;
CHAR *dst = parser->token + parser->token_len;

View file

@ -93,7 +93,7 @@ ULONG IniGetSectionSettingNameSize(ULONG_PTR SectionId, ULONG SettingIndex)
return 0;
// Return the size of the string plus 1 for the null-terminator
return (strlen(SectionItem->ItemName) + 1);
return (ULONG)(strlen(SectionItem->ItemName) + 1);
}
ULONG IniGetSectionSettingValueSize(ULONG_PTR SectionId, ULONG SettingIndex)
@ -106,7 +106,7 @@ ULONG IniGetSectionSettingValueSize(ULONG_PTR SectionId, ULONG SettingIndex)
return 0;
// Return the size of the string plus 1 for the null-terminator
return (strlen(SectionItem->ItemValue) + 1);
return (ULONG)(strlen(SectionItem->ItemValue) + 1);
}
BOOLEAN IniReadSettingByNumber(ULONG_PTR SectionId, ULONG SettingNumber, PCHAR SettingName, ULONG NameSize, PCHAR SettingValue, ULONG ValueSize)

File diff suppressed because it is too large Load diff

View file

@ -628,7 +628,7 @@ LoadAndBootWindowsCommon(
/* Do the machine specific initialization */
WinLdrSetupMachineDependent(LoaderBlock);
/* Turn on paging mode of CPU */
/* Map pages and create memory descriptors */
WinLdrSetupMemoryLayout(LoaderBlock);
/* Save final value of LoaderPagesSpanned */
@ -640,6 +640,9 @@ LoadAndBootWindowsCommon(
DPRINTM(DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
KiSystemStartup, LoaderBlockVA);
// Zero KI_USER_SHARED_DATA page
memset((PVOID)KI_USER_SHARED_DATA, 0, MM_PAGE_SIZE);
WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
WinLdrpDumpBootDriver(LoaderBlockVA);
WinLdrpDumpArcDisks(LoaderBlockVA);

View file

@ -324,9 +324,6 @@ WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
MempDump();
#endif
// Zero KI_USER_SHARED_DATA page
memset((PVOID)KI_USER_SHARED_DATA, 0, MM_PAGE_SIZE);
return TRUE;
}

View file

@ -11,7 +11,7 @@
#include <freeldr.h>
#include <debug.h>
// The only global var here, used to mark mem pages as NLS in WinLdrTurnOnPaging()
// The only global var here, used to mark mem pages as NLS in WinLdrSetupMemoryLayout()
ULONG TotalNLSSize = 0;
BOOLEAN WinLdrGetNLSNames(LPSTR AnsiName,