#include "ppcmmu/mmu.h"
#include "compat.h"
-#define NDEBUG
#include <debug.h>
/* We'll check this to see if we're in OFW land */
* FrLdrGetPaeMode
* INTERNAL
*
- * Determines whether PAE mode shoudl be enabled or not.
+ * Determines whether PAE mode should be enabled or not.
*
* Params:
* None.
* None.
*
* Remarks:
- * We are setting PDEs, but using the equvivalent (for our purpose) PTE structure.
+ * We are setting PDEs, but using the equivalent (for our purpose) PTE structure.
* As such, please note that PageFrameNumber == PageEntryNumber.
*
*--*/
PCHAR sptr;
Elf32_Ehdr ehdr;
Elf32_Shdr *shdr;
+ LARGE_INTEGER Position;
LPSTR TempName;
TempName = strrchr(ImageName, '\\');
//printf("Loading file (elf at %x)\n", KernelAddr);
/* Load the first 1024 bytes of the kernel image so we can read the PE header */
- if (!FsReadFile(KernelImage, sizeof(ehdr), NULL, &ehdr)) {
+ if (ArcRead(KernelImage, &ehdr, sizeof(ehdr), NULL) != ESUCCESS) {
/* Fail if we couldn't read */
printf("Couldn't read the elf header\n");
sptr = (PCHAR)FrLdrTempAlloc(shnum * shsize, TAG_MBOOT);
/* Read section headers */
- FsSetFilePointer(KernelImage, ehdr.e_shoff);
- FsReadFile(KernelImage, shsize * shnum, NULL, sptr);
+ Position.QuadPart = ehdr.e_shoff;
+ ArcSeek(KernelImage, &Position, SeekAbsolute);
+ ArcRead(KernelImage, sptr, shsize * shnum, NULL);
/* Now we'll get the PE Header */
for( i = 0; i < shnum; i++ )
/* Find the PE Header */
if (shdr->sh_type == TYPE_PEHEADER)
{
- FsSetFilePointer(KernelImage, shdr->sh_offset);
- FsReadFile(KernelImage, shdr->sh_size, NULL, MemLoadAddr);
+ Position.QuadPart = shdr->sh_offset;
+ ArcSeek(KernelImage, &Position, SeekAbsolute);
+ ArcRead(KernelImage, MemLoadAddr, shdr->sh_size, NULL);
ImageHeader = (PIMAGE_DOS_HEADER)MemLoadAddr;
NtHeader = (PIMAGE_NT_HEADERS)((PCHAR)MemLoadAddr + SWAPD(ImageHeader->e_lfanew));
#if 0
{
/* Content area */
printf("Loading section %d at %x (real: %x:%d)\n", i, KernelAddr + SectionAddr, MemLoadAddr+SectionAddr, shdr->sh_size);
- FsSetFilePointer(KernelImage, shdr->sh_offset);
- FsReadFile(KernelImage, shdr->sh_size, NULL, MemLoadAddr + SectionAddr);
+ Position.QuadPart = shdr->sh_offset;
+ ArcSeek(KernelImage, &Position, SeekAbsolute);
+ ArcRead(KernelImage, MemLoadAddr + SectionAddr, shdr->sh_size, NULL);
}
else
{
if (!ELF_SECTION(targetSection)->sh_addr) continue;
RelocSection = FrLdrTempAlloc(shdr->sh_size, TAG_MBOOT);
- FsSetFilePointer(KernelImage, relstart);
- FsReadFile(KernelImage, shdr->sh_size, NULL, RelocSection);
+ Position.QuadPart = relstart;
+ ArcSeek(KernelImage, &Position, SeekAbsolute);
+ ArcRead(KernelImage, RelocSection, shdr->sh_size, NULL);
/* Get the symbol section */
shdr = ELF_SECTION(shdr->sh_link);
SymbolSection = FrLdrTempAlloc(shdr->sh_size, TAG_MBOOT);
- FsSetFilePointer(KernelImage, shdr->sh_offset);
- FsReadFile(KernelImage, shdr->sh_size, NULL, SymbolSection);
+ Position.QuadPart = shdr->sh_offset;
+ ArcSeek(KernelImage, &Position, SeekAbsolute);
+ ArcRead(KernelImage, SymbolSection, shdr->sh_size, NULL);
for(j = 0; j < numreloc; j++)
{
LPCSTR ModuleName,
PULONG ModuleSize)
{
+ ARC_STATUS Status;
+ FILEINFORMATION FileInfo;
ULONG LocalModuleSize;
ULONG_PTR ThisModuleBase = NextModuleBase;
PLOADER_MODULE ModuleData;
} while(TempName);
NameBuffer = reactos_module_strings[LoaderBlock.ModsCount];
-
/* Get Module Size */
- LocalModuleSize = FsGetFileSize(ModuleImage);
+ Status = ArcGetFileInformation(ModuleImage, &FileInfo);
+ if (Status != ESUCCESS || FileInfo.EndingAddress.HighPart != 0)
+ LocalModuleSize = 0;
+ else
+ LocalModuleSize = FileInfo.EndingAddress.LowPart;
/* Fill out Module Data Structure */
ModuleData->ModStart = NextModuleBase;
ModuleData->String = (ULONG_PTR)NameBuffer;
/* Load the file image */
- FsReadFile(ModuleImage, LocalModuleSize, NULL, (PVOID)NextModuleBase);
+ ArcRead(ModuleImage, (PVOID)NextModuleBase, LocalModuleSize, NULL);
/* Move to next memory block and increase Module Count */
NextModuleBase = ROUND_UP(ModuleData->ModEnd, PAGE_SIZE);