/* INCLUDES *****************************************************************/
+#if !defined(_X86_)
+
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
#if defined(_PPC_)
#include <ppcmmu/mmu.h>
#define KERNEL_RVA(x) RVA(x,0x80800000)
-#define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)(x) + KernelBase) >> PAGE_SHIFT)
+#define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x + KernelBase) >> PAGE_SHIFT)
#else
#define KERNEL_RVA(x) RVA(x,KSEG0_BASE)
-#define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)(x) & ~KSEG0_BASE) >> PAGE_SHIFT)
+#define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x &~ KSEG0_BASE) >> PAGE_SHIFT)
#endif
typedef struct _BIOS_MEMORY_DESCRIPTOR
/* GLOBALS *******************************************************************/
-/* Function pointer for early debug prints */
-ULONG (*FrLdrDbgPrint)(const char *Format, ...);
-
/* FreeLDR Loader Data */
PROS_LOADER_PARAMETER_BLOCK KeRosLoaderBlock;
ADDRESS_RANGE KeMemoryMap[64];
VOID
NTAPI
KiRosFixupComponentTree(IN PCONFIGURATION_COMPONENT_DATA p,
- IN ULONG_PTR i)
+ IN ULONG i)
{
PCONFIGURATION_COMPONENT pp;
WCHAR PathSetup[] = L"\\SystemRoot\\";
CHAR DriverNameLow[256];
ULONG Base;
+ size_t Remaining;
+ WCHAR *StringEnd;
#if defined(_PPC_)
ULONG KernelBase = RosLoaderBlock->ModsAddr[0].ModStart;
#endif
/* Build entries for ReactOS memory ranges, which uses ARC Descriptors */
KiRosBuildOsMemoryMap();
-#if defined(_X86_) || defined(_M_AMD64)
+#if defined(_X86_)
/* Build entries for the reserved map, which uses ARC Descriptors */
KiRosBuildReservedMemoryMap();
#endif
/* Construct a correct full name */
BldrModuleStringsFull[i][0] = 0;
- LdrEntry->FullDllName.MaximumLength = 260 * sizeof(WCHAR);
+ LdrEntry->FullDllName.MaximumLength = sizeof(BldrModuleStringsFull[i]);
LdrEntry->FullDllName.Length = 0;
LdrEntry->FullDllName.Buffer = BldrModuleStringsFull[i];
/* Now mark the remainder of the FreeLDR 6MB area as "in use" */
KiRosAllocateNtDescriptor(LoaderMemoryData,
KERNEL_DESCRIPTOR_PAGE(RosEntry->ModEnd),
- KERNEL_DESCRIPTOR_PAGE((RosLoaderBlock->KernelBase + 0x600000)) -
+ KERNEL_DESCRIPTOR_PAGE((0x80800000 + 0x600000)) -
KERNEL_DESCRIPTOR_PAGE(RosEntry->ModEnd),
0,
&Base);
- //
- // Check if we have a ramdisk
- //
+ /* Check if we have a ramdisk */
if ((RosLoaderBlock->RdAddr) && (RosLoaderBlock->RdLength))
{
- //
- // Build a descriptor for it
- //
+ /* Build a descriptor for it */
KiRosAllocateNtDescriptor(LoaderXIPRom,
KERNEL_DESCRIPTOR_PAGE(RosLoaderBlock->RdAddr),
(RosLoaderBlock->RdLength + PAGE_SIZE - 1) >> PAGE_SHIFT,
LoaderBlock->Extension->MajorVersion = 5;
LoaderBlock->Extension->MinorVersion = 2;
-
-// FIXME FIXME FIXME NOW!!!!
-
/* FreeLDR hackllocates 1536 static pages for the initial boot images */
LoaderBlock->Extension->LoaderPagesSpanned = 1536 * PAGE_SIZE;
/* Find the first \, separating the ARC path from NT path */
BootPath = strchr(CommandLine, '\\');
*BootPath = ANSI_NULL;
- strncpy(BldrArcBootPath, CommandLine, 63);
+ RtlStringCbCopyA(BldrArcBootPath, sizeof(BldrArcBootPath), CommandLine);
LoaderBlock->ArcBootDeviceName = BldrArcBootPath;
/* The rest of the string is the NT path */
HalPath = strchr(BootPath + 1, ' ');
*HalPath = ANSI_NULL;
- BldrNtBootPath[0] = '\\';
- strncat(BldrNtBootPath, BootPath + 1, 63);
- strcat(BldrNtBootPath,"\\");
+ Remaining = sizeof(BldrNtBootPath);
+ RtlStringCbCopyExA(BldrNtBootPath, Remaining, "\\", &StringEnd, &Remaining, 0);
+ RtlStringCbCopyExA(StringEnd, Remaining, BootPath + 1, &StringEnd, &Remaining, 0);
+ RtlStringCbCopyA(StringEnd, Remaining, "\\");
LoaderBlock->NtBootPathName = BldrNtBootPath;
/* Set the HAL paths */
- strncpy(BldrArcHalPath, BldrArcBootPath, 63);
+ RtlStringCbCopyA(BldrArcHalPath, sizeof(BldrArcHalPath), BldrArcBootPath);
LoaderBlock->ArcHalDeviceName = BldrArcHalPath;
strcpy(BldrNtHalPath, "\\");
LoaderBlock->NtHalPathName = BldrNtHalPath;
/* Use this new command line */
- strncpy(LoaderBlock->LoadOptions, HalPath + 2, 255);
+ RtlStringCbCopyA(LoaderBlock->LoadOptions, 255, HalPath + 2);
/* Parse it and change every slash to a space */
BootPath = LoaderBlock->LoadOptions;
/* Save pointer to ROS Block */
KeRosLoaderBlock = LoaderBlock;
- /* Get debugging function */
- FrLdrDbgPrint = LoaderBlock->FrLdrDbgPrint;
-
/* Save memory manager data */
KeMemoryMapRangeCount = 0;
if (LoaderBlock->Flags & MB_FLAGS_MMAP_INFO)
{
/* We have a memory map from the nice BIOS */
- ent = ((PULONG)(LoaderBlock->MmapAddr - sizeof(ULONG))); // FIXME: this is ugly
+ ent = ((PULONG)(LoaderBlock->MmapAddr - sizeof(ULONG)));
size = *ent;
i = 0;
/* Save data */
LoaderBlock->MmapLength = KeMemoryMapRangeCount * sizeof(ADDRESS_RANGE);
- LoaderBlock->MmapAddr = (ULONG_PTR)KeMemoryMap;
+ LoaderBlock->MmapAddr = (ULONG)KeMemoryMap;
}
else
{
/* Nothing from BIOS */
LoaderBlock->MmapLength = 0;
- LoaderBlock->MmapAddr = (ULONG_PTR)KeMemoryMap;
+ LoaderBlock->MmapAddr = (ULONG)KeMemoryMap;
}
/* Convert the loader block */
/* Do general System Startup */
KiSystemStartup(NtLoaderBlock);
}
+#endif