Author: hbelusca
Date: Wed Feb 3 15:20:37 2016
New Revision: 70683
URL:
http://svn.reactos.org/svn/reactos?rev=70683&view=rev
Log:
[FREELDR]
- Move the NTOS loader files that were scattered in many places into their own directory
(now all that stuff is inside freeldr/windows).
- Split arch/arm/winldr.c into the real winldr code (going into freeldr/windows) and entry
point code (going into arch/arm/entry.c).
Added:
trunk/reactos/boot/freeldr/freeldr/arch/arm/entry.c
- copied, changed from r70682, trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c
trunk/reactos/boot/freeldr/freeldr/windows/arch/
trunk/reactos/boot/freeldr/freeldr/windows/arch/amd64/
trunk/reactos/boot/freeldr/freeldr/windows/arch/amd64/winldr.c
- copied, changed from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c
trunk/reactos/boot/freeldr/freeldr/windows/arch/arm/
trunk/reactos/boot/freeldr/freeldr/windows/arch/arm/winldr.c
- copied, changed from r70676, trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c
trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/
trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/halstub.c
- copied, changed from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/i386/halstub.c
trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.c
- copied, changed from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c
trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.h
- copied unchanged from r70682,
trunk/reactos/boot/freeldr/freeldr/include/ntoskrnl.h
trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/winldr.c
- copied, changed from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/i386/winldr.c
Removed:
trunk/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c
trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/halstub.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/winldr.c
trunk/reactos/boot/freeldr/freeldr/include/ntoskrnl.h
Modified:
trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c
trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
trunk/reactos/boot/freeldr/freeldr/include/winldr.h
Modified: trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/CMake…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] Wed Feb 3 15:20:37
2016
@@ -91,7 +91,6 @@
fs/pxe.c
arch/i386/archmach.c
arch/i386/drivemap.c
- arch/i386/halstub.c
arch/i386/hardware.c
arch/i386/hwacpi.c
arch/i386/hwapm.c
@@ -103,7 +102,6 @@
arch/i386/i386rtl.c
arch/i386/i386vid.c
arch/i386/machpc.c
- arch/i386/ntoskrnl.c
arch/i386/pccons.c
arch/i386/pcdisk.c
arch/i386/pcmem.c
@@ -118,7 +116,9 @@
arch/i386/xboxmem.c
arch/i386/xboxrtc.c
arch/i386/xboxvideo.c
- arch/i386/winldr.c
+ windows/arch/i386/halstub.c
+ windows/arch/i386/ntoskrnl.c
+ windows/arch/i386/winldr.c
windows/headless.c
disk/scsiport.c)
if(NOT MSVC)
@@ -142,19 +142,20 @@
arch/i386/i386disk.c
arch/i386/i386vid.c
arch/i386/machpc.c
- arch/i386/ntoskrnl.c
arch/i386/pccons.c
arch/i386/pcdisk.c
arch/i386/pcmem.c
arch/i386/pcrtc.c
arch/i386/pcvideo.c
- arch/amd64/winldr.c)
+ windows/arch/i386/ntoskrnl.c
+ windows/arch/amd64/winldr.c)
elseif(ARCH STREQUAL "arm")
list(APPEND FREELDR_COMMON_ASM_SOURCE
arch/arm/boot.S)
list(APPEND FREELDR_COMMON_SOURCE
+ arch/arm/entry.c
arch/arm/macharm.c
- arch/arm/winldr.c)
+ windows/arch/arm/winldr.c)
else()
#TBD
endif()
@@ -193,7 +194,7 @@
add_target_link_flags(freeldr_pe "/ignore:4078 /ignore:4254 /DRIVER")
add_target_link_flags(freeldr_pe_dbg "/ignore:4078 /ignore:4254
/DRIVER")
else()
- add_target_link_flags(freeldr_pe "/ignore:4078 /ignore:4254 /DRIVER /FIXED
/ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text
/MERGE:.rdata=.text /MERGE:.bss=.text ")
+ add_target_link_flags(freeldr_pe "/ignore:4078 /ignore:4254 /DRIVER /FIXED
/ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text
/MERGE:.rdata=.text /MERGE:.bss=.text")
add_target_link_flags(freeldr_pe_dbg "/ignore:4078 /ignore:4254 /DRIVER
/FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text
/MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text")
endif()
else()
Removed: trunk/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c (removed)
@@ -1,424 +0,0 @@
-/*
- * PROJECT: EFI Windows Loader
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: boot/freeldr/freeldr/arch/amd64/winldr.c
- * PURPOSE: Memory related routines
- * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org)
- */
-
-/* INCLUDES ***************************************************************/
-
-#include <freeldr.h>
-
-#include <ndk/asm.h>
-#include <debug.h>
-
-//extern ULONG LoaderPagesSpanned;
-
-DBG_DEFAULT_CHANNEL(WINDOWS);
-
-/* GLOBALS ***************************************************************/
-
-PHARDWARE_PTE PxeBase;
-//PHARDWARE_PTE HalPageTable;
-
-PVOID GdtIdt;
-ULONG_PTR PcrBasePage;
-ULONG_PTR TssBasePage;
-
-/* FUNCTIONS **************************************************************/
-
-BOOLEAN
-MempAllocatePageTables(VOID)
-{
- TRACE(">>> MempAllocatePageTables\n");
-
- /* Allocate a page for the PML4 */
- PxeBase = MmAllocateMemoryWithType(PAGE_SIZE, LoaderMemoryData);
- if (!PxeBase)
- {
- ERR("failed to allocate PML4\n");
- return FALSE;
- }
-
- // FIXME: Physical PTEs = FirmwareTemporary ?
-
- /* Zero the PML4 */
- RtlZeroMemory(PxeBase, PAGE_SIZE);
-
- /* The page tables are located at 0xfffff68000000000
- * We create a recursive self mapping through all 4 levels at
- * virtual address 0xfffff6fb7dbedf68 */
- PxeBase[VAtoPXI(PXE_BASE)].Valid = 1;
- PxeBase[VAtoPXI(PXE_BASE)].Write = 1;
- PxeBase[VAtoPXI(PXE_BASE)].PageFrameNumber = PtrToPfn(PxeBase);
-
- // FIXME: map PDE's for hals memory mapping
-
- TRACE(">>> leave MempAllocatePageTables\n");
-
- return TRUE;
-}
-
-PHARDWARE_PTE
-MempGetOrCreatePageDir(PHARDWARE_PTE PdeBase, ULONG Index)
-{
- PHARDWARE_PTE SubDir;
-
- if (!PdeBase)
- return NULL;
-
- if (!PdeBase[Index].Valid)
- {
- SubDir = MmAllocateMemoryWithType(PAGE_SIZE, LoaderMemoryData);
- if (!SubDir)
- return NULL;
- RtlZeroMemory(SubDir, PAGE_SIZE);
- PdeBase[Index].PageFrameNumber = PtrToPfn(SubDir);
- PdeBase[Index].Valid = 1;
- PdeBase[Index].Write = 1;
- }
- else
- {
- SubDir = (PVOID)((ULONG64)(PdeBase[Index].PageFrameNumber) * PAGE_SIZE);
- }
- return SubDir;
-}
-
-BOOLEAN
-MempMapSinglePage(ULONG64 VirtualAddress, ULONG64 PhysicalAddress)
-{
- PHARDWARE_PTE PpeBase, PdeBase, PteBase;
- ULONG Index;
-
- PpeBase = MempGetOrCreatePageDir(PxeBase, VAtoPXI(VirtualAddress));
- PdeBase = MempGetOrCreatePageDir(PpeBase, VAtoPPI(VirtualAddress));
- PteBase = MempGetOrCreatePageDir(PdeBase, VAtoPDI(VirtualAddress));
-
- if (!PteBase)
- {
- ERR("!!!No Dir %p, %p, %p, %p\n", PxeBase, PpeBase, PdeBase, PteBase);
- return FALSE;
- }
-
- Index = VAtoPTI(VirtualAddress);
- if (PteBase[Index].Valid)
- {
- ERR("!!!Already mapped %ld\n", Index);
- return FALSE;
- }
-
- PteBase[Index].Valid = 1;
- PteBase[Index].Write = 1;
- PteBase[Index].PageFrameNumber = PhysicalAddress / PAGE_SIZE;
-
- return TRUE;
-}
-
-BOOLEAN
-MempIsPageMapped(PVOID VirtualAddress)
-{
- PHARDWARE_PTE PpeBase, PdeBase, PteBase;
- ULONG Index;
-
- Index = VAtoPXI(VirtualAddress);
- if (!PxeBase[Index].Valid)
- return FALSE;
-
- PpeBase = (PVOID)((ULONG64)(PxeBase[Index].PageFrameNumber) * PAGE_SIZE);
- Index = VAtoPPI(VirtualAddress);
- if (!PpeBase[Index].Valid)
- return FALSE;
-
- PdeBase = (PVOID)((ULONG64)(PpeBase[Index].PageFrameNumber) * PAGE_SIZE);
- Index = VAtoPDI(VirtualAddress);
- if (!PdeBase[Index].Valid)
- return FALSE;
-
- PteBase = (PVOID)((ULONG64)(PdeBase[Index].PageFrameNumber) * PAGE_SIZE);
- Index = VAtoPTI(VirtualAddress);
- if (!PteBase[Index].Valid)
- return FALSE;
-
- return TRUE;
-}
-
-PFN_NUMBER
-MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, PFN_NUMBER cPages)
-{
- PFN_NUMBER i;
-
- for (i = 0; i < cPages; i++)
- {
- if (!MempMapSinglePage(VirtualAddress, PhysicalAddress))
- {
- ERR("Failed to map page %ld from %p to %p\n",
- i, (PVOID)VirtualAddress, (PVOID)PhysicalAddress);
- return i;
- }
- VirtualAddress += PAGE_SIZE;
- PhysicalAddress += PAGE_SIZE;
- }
- return i;
-}
-
-BOOLEAN
-MempSetupPaging(IN PFN_NUMBER StartPage,
- IN PFN_NUMBER NumberOfPages,
- IN BOOLEAN KernelMapping)
-{
- TRACE(">>> MempSetupPaging(0x%lx, %ld, %p)\n",
- StartPage, NumberOfPages, StartPage * PAGE_SIZE + KSEG0_BASE);
-
- /* Identity mapping */
- if (MempMapRangeOfPages(StartPage * PAGE_SIZE,
- StartPage * PAGE_SIZE,
- NumberOfPages) != NumberOfPages)
- {
- ERR("Failed to map pages %ld, %ld\n",
- StartPage, NumberOfPages);
- return FALSE;
- }
-
- /* Kernel mapping */
- if (KernelMapping)
- {
- if (MempMapRangeOfPages(StartPage * PAGE_SIZE + KSEG0_BASE,
- StartPage * PAGE_SIZE,
- NumberOfPages) != NumberOfPages)
- {
- ERR("Failed to map pages %ld, %ld\n",
- StartPage, NumberOfPages);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-VOID
-MempUnmapPage(PFN_NUMBER Page)
-{
- // TRACE(">>> MempUnmapPage\n");
-}
-
-VOID
-WinLdrpMapApic(VOID)
-{
- BOOLEAN LocalAPIC;
- LARGE_INTEGER MsrValue;
- ULONG CpuInfo[4];
- ULONG64 APICAddress;
-
- TRACE(">>> WinLdrpMapApic\n");
-
- /* Check if we have a local APIC */
- __cpuid((int*)CpuInfo, 1);
- LocalAPIC = (((CpuInfo[3] >> 9) & 1) != 0);
-
- /* If there is no APIC, just return */
- if (!LocalAPIC)
- {
- WARN("No APIC found.\n");
- return;
- }
-
- /* Read the APIC Address */
- MsrValue.QuadPart = __readmsr(0x1B);
- APICAddress = (MsrValue.LowPart & 0xFFFFF000);
-
- TRACE("Local APIC detected at address 0x%x\n",
- APICAddress);
-
- /* Map it */
- MempMapSinglePage(APIC_BASE, APICAddress);
-}
-
-BOOLEAN
-WinLdrMapSpecialPages(VOID)
-{
- PHARDWARE_PTE PpeBase, PdeBase;
-
- /* Map the PCR page */
- if (!MempMapSinglePage(KIP0PCRADDRESS, PcrBasePage * PAGE_SIZE))
- {
- ERR("Could not map PCR @ %lx\n", PcrBasePage);
- return FALSE;
- }
-
- /* Map KI_USER_SHARED_DATA */
- if (!MempMapSinglePage(KI_USER_SHARED_DATA, (PcrBasePage+1) * PAGE_SIZE))
- {
- ERR("Could not map KI_USER_SHARED_DATA\n");
- return FALSE;
- }
-
- /* Map the APIC page */
- WinLdrpMapApic();
-
- /* Map the page tables for 4 MB HAL address space. */
- PpeBase = MempGetOrCreatePageDir(PxeBase, VAtoPXI(MM_HAL_VA_START));
- PdeBase = MempGetOrCreatePageDir(PpeBase, VAtoPPI(MM_HAL_VA_START));
- MempGetOrCreatePageDir(PdeBase, VAtoPDI(MM_HAL_VA_START));
- MempGetOrCreatePageDir(PdeBase, VAtoPDI(MM_HAL_VA_START + 2 * 1024 * 1024));
-
- return TRUE;
-}
-
-VOID
-Amd64SetupGdt(PVOID GdtBase, ULONG64 TssBase)
-{
- PKGDTENTRY64 Entry;
- KDESCRIPTOR GdtDesc;
- TRACE("Amd64SetupGdt(GdtBase = %p, TssBase = %p)\n", GdtBase, TssBase);
-
- /* Setup KGDT64_NULL */
- Entry = KiGetGdtEntry(GdtBase, KGDT64_NULL);
- *(PULONG64)Entry = 0x0000000000000000ULL;
-
- /* Setup KGDT64_R0_CODE */
- Entry = KiGetGdtEntry(GdtBase, KGDT64_R0_CODE);
- *(PULONG64)Entry = 0x00209b0000000000ULL;
-
- /* Setup KGDT64_R0_DATA */
- Entry = KiGetGdtEntry(GdtBase, KGDT64_R0_DATA);
- *(PULONG64)Entry = 0x00cf93000000ffffULL;
-
- /* Setup KGDT64_R3_CMCODE */
- Entry = KiGetGdtEntry(GdtBase, KGDT64_R3_CMCODE);
- *(PULONG64)Entry = 0x00cffb000000ffffULL;
-
- /* Setup KGDT64_R3_DATA */
- Entry = KiGetGdtEntry(GdtBase, KGDT64_R3_DATA);
- *(PULONG64)Entry = 0x00cff3000000ffffULL;
-
- /* Setup KGDT64_R3_CODE */
- Entry = KiGetGdtEntry(GdtBase, KGDT64_R3_CODE);
- *(PULONG64)Entry = 0x0020fb0000000000ULL;
-
- /* Setup KGDT64_R3_CMTEB */
- Entry = KiGetGdtEntry(GdtBase, KGDT64_R3_CMTEB);
- *(PULONG64)Entry = 0xff40f3fd50003c00ULL;
-
- /* Setup TSS entry */
- Entry = KiGetGdtEntry(GdtBase, KGDT64_SYS_TSS);
- KiInitGdtEntry(Entry, TssBase, sizeof(KTSS), I386_TSS, 0);
-
- /* Setup GDT descriptor */
- GdtDesc.Base = GdtBase;
- GdtDesc.Limit = NUM_GDT * sizeof(KGDTENTRY) - 1;
-
- /* Set the new Gdt */
- __lgdt(&GdtDesc.Limit);
- TRACE("Leave Amd64SetupGdt()\n");
-}
-
-VOID
-Amd64SetupIdt(PVOID IdtBase)
-{
- KDESCRIPTOR IdtDesc, OldIdt;
- ULONG Size;
- TRACE("Amd64SetupIdt(IdtBase = %p)\n", IdtBase);
-
- /* Get old IDT */
- __sidt(&OldIdt.Limit);
-
- /* Copy the old IDT */
- Size = min(OldIdt.Limit + 1, NUM_IDT * sizeof(KIDTENTRY));
- //RtlCopyMemory(IdtBase, (PVOID)OldIdt.Base, Size);
-
- /* Setup the new IDT descriptor */
- IdtDesc.Base = IdtBase;
- IdtDesc.Limit = NUM_IDT * sizeof(KIDTENTRY) - 1;
-
- /* Set the new IDT */
- __lidt(&IdtDesc.Limit);
- TRACE("Leave Amd64SetupIdt()\n");
-}
-
-VOID
-WinLdrSetProcessorContext(void)
-{
- TRACE("WinLdrSetProcessorContext\n");
-
- /* Disable Interrupts */
- _disable();
-
- /* Re-initialize EFLAGS */
- __writeeflags(0);
-
- /* Set the new PML4 */
- __writecr3((ULONG64)PxeBase);
-
- /* Get kernel mode address of gdt / idt */
- GdtIdt = (PVOID)((ULONG64)GdtIdt + KSEG0_BASE);
-
- /* Create gdt entries and load gdtr */
- Amd64SetupGdt(GdtIdt, KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT));
-
- /* Copy old Idt and set idtr */
- Amd64SetupIdt((PVOID)((ULONG64)GdtIdt + NUM_GDT * sizeof(KGDTENTRY)));
-
- /* LDT is unused */
-// __lldt(0);
-
- /* Load TSR */
- __ltr(KGDT64_SYS_TSS);
-
- TRACE("leave WinLdrSetProcessorContext\n");
-}
-
-void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
- 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;
- if (Pcr == 0)
- {
- UiMessageBox("Can't allocate PCR.");
- return;
- }
- RtlZeroMemory((PVOID)Pcr, 2 * MM_PAGE_SIZE);
-
- /* Allocate TSS */
- BlockSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
- Tss = (ULONG_PTR)MmAllocateMemoryWithType(BlockSize, LoaderMemoryData);
- TssBasePage = Tss >> MM_PAGE_SHIFT;
-
- /* Allocate space for new GDT + IDT */
- BlockSize = NUM_GDT * sizeof(KGDTENTRY) + NUM_IDT * sizeof(KIDTENTRY);
- 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!");
- return;
- }
-
- /* Zero newly prepared GDT+IDT */
- RtlZeroMemory(GdtIdt, NumPages << MM_PAGE_SHIFT);
-
- // 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();
-}
-
-
-VOID
-MempDump(VOID)
-{
-}
-
Copied: trunk/reactos/boot/freeldr/freeldr/arch/arm/entry.c (from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/entry.c [iso-8859-1] Wed Feb 3 15:20:37
2016
@@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Boot Loader
* LICENSE: BSD - See COPYING.ARM in the top level directory
- * FILE: boot/freeldr/freeldr/arch/arm/winldr.c
- * PURPOSE: ARM Kernel Loader
+ * FILE: boot/freeldr/freeldr/arch/arm/entry.c
+ * PURPOSE: Implements the entry point for ARM machines (see also boot.S)
* PROGRAMMERS: ReactOS Portable Systems Group
*/
@@ -10,277 +10,8 @@
#include <freeldr.h>
#include <debug.h>
-#include <internal/arm/mm.h>
-#include <internal/arm/intrin_i.h>
-
-#define PFN_SHIFT 12
-#define LARGE_PFN_SHIFT 20
-
-#define PTE_BASE 0xC0000000
-#define PDE_BASE 0xC0400000
-#define PDR_BASE 0xFFD00000
-#define VECTOR_BASE 0xFFFF0000
-
-#ifdef _ZOOM2_
-#define IDMAP_BASE 0x81000000
-#define MMIO_BASE 0x10000000
-#else
-#define IDMAP_BASE 0x00000000
-#define MMIO_BASE 0x10000000
-#endif
-
-#define LowMemPageTableIndex (IDMAP_BASE >> PDE_SHIFT)
-#define MmioPageTableIndex (MMIO_BASE >> PDE_SHIFT)
-#define KernelPageTableIndex (KSEG0_BASE >> PDE_SHIFT)
-#define StartupPtePageTableIndex (PTE_BASE >> PDE_SHIFT)
-#define StartupPdePageTableIndex (PDE_BASE >> PDE_SHIFT)
-#define PdrPageTableIndex (PDR_BASE >> PDE_SHIFT)
-#define VectorPageTableIndex (VECTOR_BASE >> PDE_SHIFT)
-
-#ifndef _ZOOM2_
-PVOID MempPdrBaseAddress = (PVOID)0x70000;
-PVOID MempKernelBaseAddress = (PVOID)0;
-#else
-PVOID MempPdrBaseAddress = (PVOID)0x81100000;
-PVOID MempKernelBaseAddress = (PVOID)0x80000000;
-#endif
-
-/* Converts a Physical Address into a Page Frame Number */
-#define PaToPfn(p) ((p) >> PFN_SHIFT)
-#define PaToLargePfn(p) ((p) >> LARGE_PFN_SHIFT)
-#define PaPtrToPfn(p) (((ULONG_PTR)(p)) >> PFN_SHIFT)
-
-/* Converts a Physical Address into a Coarse Page Table PFN */
-#define PaPtrToPdePfn(p) (((ULONG_PTR)(p)) >> CPT_SHIFT)
-
-typedef struct _KPDR_PAGE
-{
- PAGE_DIRECTORY_ARM PageDir; // 0xC0400000 [0xFFD00000]
- CHAR HyperSpace[233 * PAGE_SIZE]; // 0xC0404000 [0xFFD04000]
- PAGE_TABLE_ARM KernelPageTable[3]; // 0xC04ED000 [0xFFDED000]
- CHAR SharedData[PAGE_SIZE]; // 0xC04F0000 [0xFFDF0000]
- CHAR KernelStack[KERNEL_STACK_SIZE]; // 0xC04F1000 [0xFFDF1000]
- CHAR PanicStack[KERNEL_STACK_SIZE]; // 0xC04F4000 [0xFFDF4000]
- CHAR InterruptStack[KERNEL_STACK_SIZE]; // 0xC04F7000 [0xFFDF7000]
- CHAR InitialProcess[PAGE_SIZE]; // 0xC04FA000 [0xFFDFA000]
- CHAR InitialThread[PAGE_SIZE]; // 0xC04FB000 [0xFFDFB000]
- CHAR Prcb[PAGE_SIZE]; // 0xC04FC000 [0xFFDFC000]
- PAGE_TABLE_ARM PageDirPageTable; // 0xC04FD000 [0xFFDFD000]
- PAGE_TABLE_ARM VectorPageTable; // 0xC04FE000 [0xFFDFE000]
- CHAR Pcr[PAGE_SIZE]; // 0xC04FF000 [0xFFDFF000]
-} KPDR_PAGE, *PKPDR_PAGE;
-
-C_ASSERT(sizeof(KPDR_PAGE) == (1 * 1024 * 1024));
-
-HARDWARE_PTE_ARMV6 TempPte;
-HARDWARE_LARGE_PTE_ARMV6 TempLargePte;
-HARDWARE_PDE_ARMV6 TempPde;
-PKPDR_PAGE PdrPage;
/* FUNCTIONS **************************************************************/
-
-BOOLEAN
-MempSetupPaging(IN PFN_NUMBER StartPage,
- IN PFN_NUMBER NumberOfPages,
- IN BOOLEAN KernelMapping)
-{
- return TRUE;
-}
-
-VOID
-MempUnmapPage(IN PFN_NUMBER Page)
-{
- return;
-}
-
-VOID
-MempDump(VOID)
-{
- return;
-}
-
-BOOLEAN
-WinLdrMapSpecialPages(ULONG PcrBasePage)
-{
- ULONG i;
- PHARDWARE_PTE_ARMV6 PointerPte;
- PHARDWARE_PDE_ARMV6 PointerPde;
- PHARDWARE_LARGE_PTE_ARMV6 LargePte;
- PFN_NUMBER Pfn;
-
- /* Setup the Startup PDE */
- LargePte = &PdrPage->PageDir.Pte[StartupPdePageTableIndex];
- TempLargePte.PageFrameNumber = PaToLargePfn((ULONG_PTR)&PdrPage->PageDir);
- *LargePte = TempLargePte;
-
- /* Map-in the PDR */
- LargePte = &PdrPage->PageDir.Pte[PdrPageTableIndex];
- *LargePte = TempLargePte;
-
- /* After this point, any MiAddressToPde is guaranteed not to fault */
-
- /*
- * Link them in the Startup PDE.
- * Note these are the entries in the PD at (MiAddressToPde(PTE_BASE)).
- */
- PointerPde = &PdrPage->PageDir.Pde[StartupPtePageTableIndex];
- Pfn = PaPtrToPdePfn(&PdrPage->PageDirPageTable);
- for (i = 0; i < 4; i++)
- {
- TempPde.PageFrameNumber = Pfn++;
- *PointerPde++ = TempPde;
- }
-
- /*
- * Now map these page tables in PTE space (MiAddressToPte(PTE_BASE)).
- * Note that they all live on a single page, since each is 1KB.
- */
- PointerPte = &PdrPage->PageDirPageTable.Pte[0x300];
- TempPte.PageFrameNumber = PaPtrToPfn(&PdrPage->PageDirPageTable);
- *PointerPte = TempPte;
-
- /*
- * After this point, MiAddressToPte((PDE_BASE) to MiAddressToPte(PDE_TOP))
- * is guaranteed not to fault.
- * Any subsequent page allocation will first need its page table created
- * and mapped in the PTE_BASE first, then the page table itself will be
- * editable through its flat PTE address.
- */
-
- /* Setup the Vector PDE */
- PointerPde = &PdrPage->PageDir.Pde[VectorPageTableIndex];
- TempPde.PageFrameNumber = PaPtrToPdePfn(&PdrPage->VectorPageTable);
- *PointerPde = TempPde;
-
- /* Setup the Vector PTEs */
- PointerPte = &PdrPage->VectorPageTable.Pte[0xF0];
- TempPte.PageFrameNumber = 0;
- *PointerPte = TempPte;
-
- /* TODO: Map in the kernel CPTs */
- return TRUE;
-}
-
-VOID
-WinLdrSetupForNt(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
- IN PVOID *GdtIdt,
- IN ULONG *PcrBasePage,
- IN ULONG *TssBasePage)
-{
- PKPDR_PAGE PdrPage = (PVOID)0xFFD00000;
-
- /* Load cache information */
- LoaderBlock->u.Arm.FirstLevelDcacheSize = FirstLevelDcacheSize;
- LoaderBlock->u.Arm.FirstLevelDcacheFillSize = FirstLevelDcacheFillSize;
- LoaderBlock->u.Arm.FirstLevelIcacheSize = FirstLevelIcacheSize;
- LoaderBlock->u.Arm.FirstLevelIcacheFillSize = FirstLevelIcacheFillSize;
- LoaderBlock->u.Arm.SecondLevelDcacheSize = SecondLevelDcacheSize;
- LoaderBlock->u.Arm.SecondLevelDcacheFillSize = SecondLevelDcacheFillSize;
- LoaderBlock->u.Arm.SecondLevelIcacheSize = SecondLevelIcacheSize;
- LoaderBlock->u.Arm.SecondLevelIcacheFillSize = SecondLevelIcacheSize;
-
- /* Write initial context information */
- LoaderBlock->KernelStack = (ULONG_PTR)PdrPage->KernelStack;
- LoaderBlock->KernelStack += KERNEL_STACK_SIZE;
- LoaderBlock->u.Arm.PanicStack = (ULONG_PTR)PdrPage->PanicStack;
- LoaderBlock->u.Arm.PanicStack += KERNEL_STACK_SIZE;
- LoaderBlock->u.Arm.InterruptStack = (ULONG_PTR)PdrPage->InterruptStack;
- LoaderBlock->u.Arm.InterruptStack += KERNEL_STACK_SIZE;
- LoaderBlock->Prcb = (ULONG_PTR)PdrPage->Prcb;
- LoaderBlock->Process = (ULONG_PTR)PdrPage->InitialProcess;
- LoaderBlock->Thread = (ULONG_PTR)PdrPage->InitialThread;
-}
-
-BOOLEAN
-MempAllocatePageTables(VOID)
-{
- ULONG i;
- PHARDWARE_PTE_ARMV6 PointerPte;
- PHARDWARE_PDE_ARMV6 PointerPde;
- PHARDWARE_LARGE_PTE_ARMV6 LargePte;
- PFN_NUMBER Pfn;
-
- /* Setup templates */
- TempPte.Sbo = TempPte.Valid = TempLargePte.LargePage = TempLargePte.Sbo =
TempPde.Valid = 1;
-
- /* Allocate the 1MB "PDR" (Processor Data Region). Must be 1MB aligned */
- PdrPage = MmAllocateMemoryAtAddress(sizeof(KPDR_PAGE),
- MempPdrBaseAddress,
- LoaderMemoryData);
-
- /* Setup the Low Memory PDE as an identity-mapped Large Page (1MB) */
- LargePte = &PdrPage->PageDir.Pte[LowMemPageTableIndex];
- TempLargePte.PageFrameNumber = PaToLargePfn(IDMAP_BASE);
- *LargePte = TempLargePte;
-
- /* Setup the MMIO PDE as two identity mapped large pages -- the kernel will blow
these away later */
- LargePte = &PdrPage->PageDir.Pte[MmioPageTableIndex];
- Pfn = PaToLargePfn(MMIO_BASE);
- for (i = 0; i < 2; i++)
- {
- TempLargePte.PageFrameNumber = Pfn++;
- *LargePte++ = TempLargePte;
- }
-
- /* Setup the Kernel PDEs */
- PointerPde = &PdrPage->PageDir.Pde[KernelPageTableIndex];
- Pfn = PaPtrToPdePfn(PdrPage->KernelPageTable);
- for (i = 0; i < 12; i++)
- {
- TempPde.PageFrameNumber = Pfn;
- *PointerPde++ = TempPde;
- Pfn++;
- }
-
- /* Setup the Kernel PTEs */
- PointerPte = PdrPage->KernelPageTable[0].Pte;
- Pfn = PaPtrToPfn(MempKernelBaseAddress);
- for (i = 0; i < 3072; i++)
- {
- TempPte.PageFrameNumber = Pfn++;
- *PointerPte++ = TempPte;
- }
-
- /* Done */
- return TRUE;
-}
-
-VOID
-WinLdrSetProcessorContext(VOID)
-{
- ARM_CONTROL_REGISTER ControlRegister;
- ARM_TTB_REGISTER TtbRegister;
- ARM_DOMAIN_REGISTER DomainRegister;
-
- /* Set the TTBR */
- TtbRegister.AsUlong = (ULONG_PTR)&PdrPage->PageDir;
- ASSERT(TtbRegister.Reserved == 0);
- KeArmTranslationTableRegisterSet(TtbRegister);
-
- /* Disable domains and simply use access bits on PTEs */
- DomainRegister.AsUlong = 0;
- DomainRegister.Domain0 = ClientDomain;
- KeArmDomainRegisterSet(DomainRegister);
-
- /* Enable ARMv6+ paging (MMU), caches and the access bit */
- ControlRegister = KeArmControlRegisterGet();
- ControlRegister.MmuEnabled = TRUE;
- ControlRegister.ICacheEnabled = TRUE;
- ControlRegister.DCacheEnabled = TRUE;
- ControlRegister.ForceAp = TRUE;
- ControlRegister.ExtendedPageTables = TRUE;
- KeArmControlRegisterSet(ControlRegister);
-}
-
-VOID
-WinLdrSetupMachineDependent(
- PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
-}
-
-VOID DiskStopFloppyMotor(VOID)
-{
-}
VOID
RealEntryPoint(VOID)
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c [iso-8859-1] Wed Feb 3 15:20:37
2016
@@ -60,6 +60,10 @@
};
/* FUNCTIONS ******************************************************************/
+
+VOID DiskStopFloppyMotor(VOID)
+{
+}
VOID
FrLdrCheckCpuCompatiblity(VOID)
Removed: trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c (removed)
@@ -1,300 +0,0 @@
-/*
- * PROJECT: ReactOS Boot Loader
- * LICENSE: BSD - See COPYING.ARM in the top level directory
- * FILE: boot/freeldr/freeldr/arch/arm/winldr.c
- * PURPOSE: ARM Kernel Loader
- * PROGRAMMERS: ReactOS Portable Systems Group
- */
-
-/* INCLUDES ***************************************************************/
-
-#include <freeldr.h>
-#include <debug.h>
-#include <internal/arm/mm.h>
-#include <internal/arm/intrin_i.h>
-
-#define PFN_SHIFT 12
-#define LARGE_PFN_SHIFT 20
-
-#define PTE_BASE 0xC0000000
-#define PDE_BASE 0xC0400000
-#define PDR_BASE 0xFFD00000
-#define VECTOR_BASE 0xFFFF0000
-
-#ifdef _ZOOM2_
-#define IDMAP_BASE 0x81000000
-#define MMIO_BASE 0x10000000
-#else
-#define IDMAP_BASE 0x00000000
-#define MMIO_BASE 0x10000000
-#endif
-
-#define LowMemPageTableIndex (IDMAP_BASE >> PDE_SHIFT)
-#define MmioPageTableIndex (MMIO_BASE >> PDE_SHIFT)
-#define KernelPageTableIndex (KSEG0_BASE >> PDE_SHIFT)
-#define StartupPtePageTableIndex (PTE_BASE >> PDE_SHIFT)
-#define StartupPdePageTableIndex (PDE_BASE >> PDE_SHIFT)
-#define PdrPageTableIndex (PDR_BASE >> PDE_SHIFT)
-#define VectorPageTableIndex (VECTOR_BASE >> PDE_SHIFT)
-
-#ifndef _ZOOM2_
-PVOID MempPdrBaseAddress = (PVOID)0x70000;
-PVOID MempKernelBaseAddress = (PVOID)0;
-#else
-PVOID MempPdrBaseAddress = (PVOID)0x81100000;
-PVOID MempKernelBaseAddress = (PVOID)0x80000000;
-#endif
-
-/* Converts a Physical Address into a Page Frame Number */
-#define PaToPfn(p) ((p) >> PFN_SHIFT)
-#define PaToLargePfn(p) ((p) >> LARGE_PFN_SHIFT)
-#define PaPtrToPfn(p) (((ULONG_PTR)(p)) >> PFN_SHIFT)
-
-/* Converts a Physical Address into a Coarse Page Table PFN */
-#define PaPtrToPdePfn(p) (((ULONG_PTR)(p)) >> CPT_SHIFT)
-
-typedef struct _KPDR_PAGE
-{
- PAGE_DIRECTORY_ARM PageDir; // 0xC0400000 [0xFFD00000]
- CHAR HyperSpace[233 * PAGE_SIZE]; // 0xC0404000 [0xFFD04000]
- PAGE_TABLE_ARM KernelPageTable[3]; // 0xC04ED000 [0xFFDED000]
- CHAR SharedData[PAGE_SIZE]; // 0xC04F0000 [0xFFDF0000]
- CHAR KernelStack[KERNEL_STACK_SIZE]; // 0xC04F1000 [0xFFDF1000]
- CHAR PanicStack[KERNEL_STACK_SIZE]; // 0xC04F4000 [0xFFDF4000]
- CHAR InterruptStack[KERNEL_STACK_SIZE]; // 0xC04F7000 [0xFFDF7000]
- CHAR InitialProcess[PAGE_SIZE]; // 0xC04FA000 [0xFFDFA000]
- CHAR InitialThread[PAGE_SIZE]; // 0xC04FB000 [0xFFDFB000]
- CHAR Prcb[PAGE_SIZE]; // 0xC04FC000 [0xFFDFC000]
- PAGE_TABLE_ARM PageDirPageTable; // 0xC04FD000 [0xFFDFD000]
- PAGE_TABLE_ARM VectorPageTable; // 0xC04FE000 [0xFFDFE000]
- CHAR Pcr[PAGE_SIZE]; // 0xC04FF000 [0xFFDFF000]
-} KPDR_PAGE, *PKPDR_PAGE;
-
-C_ASSERT(sizeof(KPDR_PAGE) == (1 * 1024 * 1024));
-
-HARDWARE_PTE_ARMV6 TempPte;
-HARDWARE_LARGE_PTE_ARMV6 TempLargePte;
-HARDWARE_PDE_ARMV6 TempPde;
-PKPDR_PAGE PdrPage;
-
-/* FUNCTIONS **************************************************************/
-
-BOOLEAN
-MempSetupPaging(IN PFN_NUMBER StartPage,
- IN PFN_NUMBER NumberOfPages,
- IN BOOLEAN KernelMapping)
-{
- return TRUE;
-}
-
-VOID
-MempUnmapPage(IN PFN_NUMBER Page)
-{
- return;
-}
-
-VOID
-MempDump(VOID)
-{
- return;
-}
-
-BOOLEAN
-WinLdrMapSpecialPages(ULONG PcrBasePage)
-{
- ULONG i;
- PHARDWARE_PTE_ARMV6 PointerPte;
- PHARDWARE_PDE_ARMV6 PointerPde;
- PHARDWARE_LARGE_PTE_ARMV6 LargePte;
- PFN_NUMBER Pfn;
-
- /* Setup the Startup PDE */
- LargePte = &PdrPage->PageDir.Pte[StartupPdePageTableIndex];
- TempLargePte.PageFrameNumber = PaToLargePfn((ULONG_PTR)&PdrPage->PageDir);
- *LargePte = TempLargePte;
-
- /* Map-in the PDR */
- LargePte = &PdrPage->PageDir.Pte[PdrPageTableIndex];
- *LargePte = TempLargePte;
-
- /* After this point, any MiAddressToPde is guaranteed not to fault */
-
- /*
- * Link them in the Startup PDE.
- * Note these are the entries in the PD at (MiAddressToPde(PTE_BASE)).
- */
- PointerPde = &PdrPage->PageDir.Pde[StartupPtePageTableIndex];
- Pfn = PaPtrToPdePfn(&PdrPage->PageDirPageTable);
- for (i = 0; i < 4; i++)
- {
- TempPde.PageFrameNumber = Pfn++;
- *PointerPde++ = TempPde;
- }
-
- /*
- * Now map these page tables in PTE space (MiAddressToPte(PTE_BASE)).
- * Note that they all live on a single page, since each is 1KB.
- */
- PointerPte = &PdrPage->PageDirPageTable.Pte[0x300];
- TempPte.PageFrameNumber = PaPtrToPfn(&PdrPage->PageDirPageTable);
- *PointerPte = TempPte;
-
- /*
- * After this point, MiAddressToPte((PDE_BASE) to MiAddressToPte(PDE_TOP))
- * is guaranteed not to fault.
- * Any subsequent page allocation will first need its page table created
- * and mapped in the PTE_BASE first, then the page table itself will be
- * editable through its flat PTE address.
- */
-
- /* Setup the Vector PDE */
- PointerPde = &PdrPage->PageDir.Pde[VectorPageTableIndex];
- TempPde.PageFrameNumber = PaPtrToPdePfn(&PdrPage->VectorPageTable);
- *PointerPde = TempPde;
-
- /* Setup the Vector PTEs */
- PointerPte = &PdrPage->VectorPageTable.Pte[0xF0];
- TempPte.PageFrameNumber = 0;
- *PointerPte = TempPte;
-
- /* TODO: Map in the kernel CPTs */
- return TRUE;
-}
-
-VOID
-WinLdrSetupForNt(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
- IN PVOID *GdtIdt,
- IN ULONG *PcrBasePage,
- IN ULONG *TssBasePage)
-{
- PKPDR_PAGE PdrPage = (PVOID)0xFFD00000;
-
- /* Load cache information */
- LoaderBlock->u.Arm.FirstLevelDcacheSize = FirstLevelDcacheSize;
- LoaderBlock->u.Arm.FirstLevelDcacheFillSize = FirstLevelDcacheFillSize;
- LoaderBlock->u.Arm.FirstLevelIcacheSize = FirstLevelIcacheSize;
- LoaderBlock->u.Arm.FirstLevelIcacheFillSize = FirstLevelIcacheFillSize;
- LoaderBlock->u.Arm.SecondLevelDcacheSize = SecondLevelDcacheSize;
- LoaderBlock->u.Arm.SecondLevelDcacheFillSize = SecondLevelDcacheFillSize;
- LoaderBlock->u.Arm.SecondLevelIcacheSize = SecondLevelIcacheSize;
- LoaderBlock->u.Arm.SecondLevelIcacheFillSize = SecondLevelIcacheSize;
-
- /* Write initial context information */
- LoaderBlock->KernelStack = (ULONG_PTR)PdrPage->KernelStack;
- LoaderBlock->KernelStack += KERNEL_STACK_SIZE;
- LoaderBlock->u.Arm.PanicStack = (ULONG_PTR)PdrPage->PanicStack;
- LoaderBlock->u.Arm.PanicStack += KERNEL_STACK_SIZE;
- LoaderBlock->u.Arm.InterruptStack = (ULONG_PTR)PdrPage->InterruptStack;
- LoaderBlock->u.Arm.InterruptStack += KERNEL_STACK_SIZE;
- LoaderBlock->Prcb = (ULONG_PTR)PdrPage->Prcb;
- LoaderBlock->Process = (ULONG_PTR)PdrPage->InitialProcess;
- LoaderBlock->Thread = (ULONG_PTR)PdrPage->InitialThread;
-}
-
-BOOLEAN
-MempAllocatePageTables(VOID)
-{
- ULONG i;
- PHARDWARE_PTE_ARMV6 PointerPte;
- PHARDWARE_PDE_ARMV6 PointerPde;
- PHARDWARE_LARGE_PTE_ARMV6 LargePte;
- PFN_NUMBER Pfn;
-
- /* Setup templates */
- TempPte.Sbo = TempPte.Valid = TempLargePte.LargePage = TempLargePte.Sbo =
TempPde.Valid = 1;
-
- /* Allocate the 1MB "PDR" (Processor Data Region). Must be 1MB aligned */
- PdrPage = MmAllocateMemoryAtAddress(sizeof(KPDR_PAGE),
- MempPdrBaseAddress,
- LoaderMemoryData);
-
- /* Setup the Low Memory PDE as an identity-mapped Large Page (1MB) */
- LargePte = &PdrPage->PageDir.Pte[LowMemPageTableIndex];
- TempLargePte.PageFrameNumber = PaToLargePfn(IDMAP_BASE);
- *LargePte = TempLargePte;
-
- /* Setup the MMIO PDE as two identity mapped large pages -- the kernel will blow
these away later */
- LargePte = &PdrPage->PageDir.Pte[MmioPageTableIndex];
- Pfn = PaToLargePfn(MMIO_BASE);
- for (i = 0; i < 2; i++)
- {
- TempLargePte.PageFrameNumber = Pfn++;
- *LargePte++ = TempLargePte;
- }
-
- /* Setup the Kernel PDEs */
- PointerPde = &PdrPage->PageDir.Pde[KernelPageTableIndex];
- Pfn = PaPtrToPdePfn(PdrPage->KernelPageTable);
- for (i = 0; i < 12; i++)
- {
- TempPde.PageFrameNumber = Pfn;
- *PointerPde++ = TempPde;
- Pfn++;
- }
-
- /* Setup the Kernel PTEs */
- PointerPte = PdrPage->KernelPageTable[0].Pte;
- Pfn = PaPtrToPfn(MempKernelBaseAddress);
- for (i = 0; i < 3072; i++)
- {
- TempPte.PageFrameNumber = Pfn++;
- *PointerPte++ = TempPte;
- }
-
- /* Done */
- return TRUE;
-}
-
-VOID
-WinLdrSetProcessorContext(VOID)
-{
- ARM_CONTROL_REGISTER ControlRegister;
- ARM_TTB_REGISTER TtbRegister;
- ARM_DOMAIN_REGISTER DomainRegister;
-
- /* Set the TTBR */
- TtbRegister.AsUlong = (ULONG_PTR)&PdrPage->PageDir;
- ASSERT(TtbRegister.Reserved == 0);
- KeArmTranslationTableRegisterSet(TtbRegister);
-
- /* Disable domains and simply use access bits on PTEs */
- DomainRegister.AsUlong = 0;
- DomainRegister.Domain0 = ClientDomain;
- KeArmDomainRegisterSet(DomainRegister);
-
- /* Enable ARMv6+ paging (MMU), caches and the access bit */
- ControlRegister = KeArmControlRegisterGet();
- ControlRegister.MmuEnabled = TRUE;
- ControlRegister.ICacheEnabled = TRUE;
- ControlRegister.DCacheEnabled = TRUE;
- ControlRegister.ForceAp = TRUE;
- ControlRegister.ExtendedPageTables = TRUE;
- KeArmControlRegisterSet(ControlRegister);
-}
-
-VOID
-WinLdrSetupMachineDependent(
- PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
-}
-
-VOID DiskStopFloppyMotor(VOID)
-{
-}
-
-VOID
-RealEntryPoint(VOID)
-{
- BootMain("");
-}
-
-VOID
-FrLdrBugCheckWithMessage(
- ULONG BugCode,
- PCHAR File,
- ULONG Line,
- PSTR Format,
- ...)
-{
-
-}
Removed: trunk/reactos/boot/freeldr/freeldr/arch/i386/halstub.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/halstub.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/halstub.c (removed)
@@ -1,99 +0,0 @@
-/*
- * PROJECT: ReactOS Kernel
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: boot/freeldr/freeldr/arch/i386/halstub.c
- * PURPOSE: I/O Stub HAL Routines
- * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-NTSTATUS
-FASTCALL
-xHalIoReadPartitionTable(
- IN PDEVICE_OBJECT DeviceObject,
- IN ULONG SectorSize,
- IN BOOLEAN ReturnRecognizedPartitions,
- OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer)
-{
- return IoReadPartitionTable(DeviceObject,
- SectorSize,
- ReturnRecognizedPartitions,
- PartitionBuffer);
-}
-
-UCHAR
-NTAPI
-xHalVectorToIDTEntry(IN ULONG Vector)
-{
- /* Return the vector */
- return (UCHAR)Vector;
-}
-
-VOID
-NTAPI
-xHalHaltSystem(VOID)
-{
- /* Halt execution */
- while (TRUE);
-}
-
-/* GLOBALS *******************************************************************/
-
-HAL_DISPATCH HalDispatchTable =
-{
- HAL_DISPATCH_VERSION,
- (pHalQuerySystemInformation)NULL,
- (pHalSetSystemInformation)NULL,
- (pHalQueryBusSlots)NULL,
- 0,
- (pHalExamineMBR)NULL,
- (pHalIoAssignDriveLetters)NULL,
- (pHalIoReadPartitionTable)xHalIoReadPartitionTable,
- (pHalIoSetPartitionInformation)NULL,
- (pHalIoWritePartitionTable)NULL,
- (pHalHandlerForBus)NULL,
- (pHalReferenceBusHandler)NULL,
- (pHalReferenceBusHandler)NULL,
- (pHalInitPnpDriver)NULL,
- (pHalInitPowerManagement)NULL,
- (pHalGetDmaAdapter)NULL,
- (pHalGetInterruptTranslator)NULL,
- (pHalStartMirroring)NULL,
- (pHalEndMirroring)NULL,
- (pHalMirrorPhysicalMemory)NULL,
- (pHalEndOfBoot)NULL,
- (pHalMirrorVerify)NULL,
- (pHalGetAcpiTable)NULL,
- (pHalSetPciErrorHandlerCallback)NULL
-};
-
-HAL_PRIVATE_DISPATCH HalPrivateDispatchTable =
-{
- HAL_PRIVATE_DISPATCH_VERSION,
- (pHalHandlerForBus)NULL,
- (pHalHandlerForConfigSpace)NULL,
- (pHalLocateHiberRanges)NULL,
- (pHalRegisterBusHandler)NULL,
- (pHalSetWakeEnable)NULL,
- (pHalSetWakeAlarm)NULL,
- (pHalTranslateBusAddress)NULL,
- (pHalAssignSlotResources)NULL,
- (pHalHaltSystem)xHalHaltSystem,
- (pHalFindBusAddressTranslation)NULL,
- (pHalResetDisplay)NULL,
- (pHalAllocateMapRegisters)NULL,
- (pKdSetupPciDeviceForDebugging)NULL,
- (pKdReleasePciDeviceForDebugging)NULL,
- (pKdGetAcpiTablePhase0)NULL,
- (pKdCheckPowerButton)NULL,
- (pHalVectorToIDTEntry)xHalVectorToIDTEntry,
- (pKdMapPhysicalMemory64)NULL,
- (pKdUnmapVirtualAddress)NULL
-};
Removed: trunk/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c (removed)
@@ -1,142 +0,0 @@
-/*
- * PROJECT: ReactOS Kernel
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: boot/freeldr/freeldr/arch/i386/ntoskrnl.c
- * PURPOSE: NTOS glue routines for the MINIHAL library
- * PROGRAMMERS: Hervé Poussineau <hpoussin(a)reactos.org>
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <ntoskrnl.h>
-
-/* For KeStallExecutionProcessor */
-#if defined(_M_IX86) || defined(_M_AMD64)
-#include <arch/pc/pcbios.h>
-#endif
-
-/* FUNCTIONS *****************************************************************/
-
-VOID
-NTAPI
-KeInitializeEvent(
- IN PRKEVENT Event,
- IN EVENT_TYPE Type,
- IN BOOLEAN State)
-{
- memset(Event, 0, sizeof(*Event));
-}
-
-VOID
-FASTCALL
-KiAcquireSpinLock(
- IN PKSPIN_LOCK SpinLock)
-{
-}
-
-VOID
-FASTCALL
-KiReleaseSpinLock(
- IN PKSPIN_LOCK SpinLock)
-{
-}
-
-VOID
-NTAPI
-KeSetTimeIncrement(
- IN ULONG MaxIncrement,
- IN ULONG MinIncrement)
-{
-}
-
-VOID
-FASTCALL
-IoAssignDriveLetters(
- IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
- IN PSTRING NtDeviceName,
- OUT PUCHAR NtSystemPath,
- OUT PSTRING NtSystemPathString)
-{
-}
-
-NTSTATUS
-FASTCALL
-IoSetPartitionInformation(
- IN PDEVICE_OBJECT DeviceObject,
- IN ULONG SectorSize,
- IN ULONG PartitionNumber,
- IN ULONG PartitionType)
-{
- return STATUS_NOT_IMPLEMENTED;
-}
-
-/*
- * NTSTATUS
- * FASTCALL
- * IoReadPartitionTable(
- * IN PDEVICE_OBJECT DeviceObject,
- * IN ULONG SectorSize,
- * IN BOOLEAN ReturnRecognizedPartitions,
- * OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer);
- *
- * See boot/freeldr/freeldr/disk/partition.c
- */
-
-NTSTATUS
-FASTCALL
-IoWritePartitionTable(
- IN PDEVICE_OBJECT DeviceObject,
- IN ULONG SectorSize,
- IN ULONG SectorsPerTrack,
- IN ULONG NumberOfHeads,
- IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer)
-{
- return STATUS_NOT_IMPLEMENTED;
-}
-
-VOID
-NTAPI
-KeStallExecutionProcessor(
- IN ULONG MicroSeconds)
-{
-#if defined(_M_IX86) || defined(_M_AMD64)
- REGS Regs;
- ULONG usec_this;
-
- // Int 15h AH=86h
- // BIOS - WAIT (AT,PS)
- //
- // AH = 86h
- // CX:DX = interval in microseconds
- // Return:
- // CF clear if successful (wait interval elapsed)
- // CF set on error or AH=83h wait already in progress
- // AH = status (see #00496)
-
- // Note: The resolution of the wait period is 977 microseconds on
- // many systems because many BIOSes use the 1/1024 second fast
- // interrupt from the AT real-time clock chip which is available on INT 70;
- // because newer BIOSes may have much more precise timers available, it is
- // not possible to use this function accurately for very short delays unless
- // the precise behavior of the BIOS is known (or found through testing)
-
- while (MicroSeconds)
- {
- usec_this = MicroSeconds;
-
- if (usec_this > 4000000)
- {
- usec_this = 4000000;
- }
-
- Regs.b.ah = 0x86;
- Regs.w.cx = usec_this >> 16;
- Regs.w.dx = usec_this & 0xffff;
- Int386(0x15, &Regs, &Regs);
-
- MicroSeconds -= usec_this;
- }
-#else
- #error unimplemented
-#endif
-}
Removed: trunk/reactos/boot/freeldr/freeldr/arch/i386/winldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/winldr.c (removed)
@@ -1,693 +0,0 @@
-/*
- * PROJECT: EFI Windows Loader
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: boot/freeldr/freeldr/arch/i386/winldr.c
- * PURPOSE: Memory related routines
- * PROGRAMMERS: Aleksey Bragin (aleksey(a)reactos.org)
- */
-
-/* INCLUDES ***************************************************************/
-
-#include <freeldr.h>
-
-#include <ndk/asm.h>
-#include <debug.h>
-
-// This is needed because headers define wrong one for ReactOS
-#undef KIP0PCRADDRESS
-#define KIP0PCRADDRESS 0xffdff000
-
-#define SELFMAP_ENTRY 0x300
-
-// This is needed only for SetProcessorContext routine
-#pragma pack(2)
- typedef struct
- {
- USHORT Limit;
- ULONG Base;
- } GDTIDT;
-#pragma pack(4)
-
-DBG_DEFAULT_CHANNEL(WINDOWS);
-
-/* GLOBALS ***************************************************************/
-
-PHARDWARE_PTE PDE;
-PHARDWARE_PTE HalPageTable;
-
-PUCHAR PhysicalPageTablesBuffer;
-PUCHAR KernelPageTablesBuffer;
-ULONG PhysicalPageTables;
-ULONG KernelPageTables;
-
-ULONG PcrBasePage;
-ULONG TssBasePage;
-PVOID GdtIdt;
-
-/* FUNCTIONS **************************************************************/
-
-BOOLEAN
-MempAllocatePageTables(VOID)
-{
- ULONG NumPageTables, TotalSize;
- PUCHAR Buffer;
- // It's better to allocate PDE + PTEs contigiuos
-
- // Max number of entries = MaxPageNum >> 10
- // FIXME: This is a number to describe ALL physical memory
- // and windows doesn't expect ALL memory mapped...
- NumPageTables = TotalPagesInLookupTable >> 10;
-
- TRACE("NumPageTables = %d\n", NumPageTables);
-
- // Allocate memory block for all these things:
- // PDE, HAL mapping page table, physical mapping, kernel mapping
- TotalSize = (1 + 1 + NumPageTables * 2) * MM_PAGE_SIZE;
-
- // PDE+HAL+KernelPTEs == MemoryData
- Buffer = MmAllocateMemoryWithType(TotalSize, LoaderMemoryData);
-
- // Physical PTEs = FirmwareTemporary
- PhysicalPageTablesBuffer = (PUCHAR)Buffer + TotalSize - NumPageTables*MM_PAGE_SIZE;
- MmSetMemoryType(PhysicalPageTablesBuffer,
- NumPageTables*MM_PAGE_SIZE,
- LoaderFirmwareTemporary);
-
- // This check is now redundant
- if (Buffer + (TotalSize - NumPageTables*MM_PAGE_SIZE) !=
- PhysicalPageTablesBuffer)
- {
- TRACE("There was a problem allocating two adjacent blocks of
memory!");
- }
-
- if (Buffer == NULL || PhysicalPageTablesBuffer == NULL)
- {
- UiMessageBox("Impossible to allocate memory block for page tables!");
- return FALSE;
- }
-
- // Zero all this memory block
- RtlZeroMemory(Buffer, TotalSize);
-
- // Set up pointers correctly now
- PDE = (PHARDWARE_PTE)Buffer;
-
- // Map the page directory at 0xC0000000 (maps itself)
- PDE[SELFMAP_ENTRY].PageFrameNumber = (ULONG)PDE >> MM_PAGE_SHIFT;
- PDE[SELFMAP_ENTRY].Valid = 1;
- PDE[SELFMAP_ENTRY].Write = 1;
-
- // The last PDE slot is allocated for HAL's memory mapping (Virtual Addresses
0xFFC00000 - 0xFFFFFFFF)
- HalPageTable = (PHARDWARE_PTE)&Buffer[MM_PAGE_SIZE*1];
-
- // Map it
- PDE[1023].PageFrameNumber = (ULONG)HalPageTable >> MM_PAGE_SHIFT;
- PDE[1023].Valid = 1;
- PDE[1023].Write = 1;
-
- // Store pointer to the table for easier access
- KernelPageTablesBuffer = &Buffer[MM_PAGE_SIZE*2];
-
- // Zero counters of page tables used
- PhysicalPageTables = 0;
- KernelPageTables = 0;
-
- return TRUE;
-}
-
-VOID
-MempAllocatePTE(ULONG Entry, PHARDWARE_PTE *PhysicalPT, PHARDWARE_PTE *KernelPT)
-{
- //Print(L"Creating PDE Entry %X\n", Entry);
-
- // Identity mapping
- *PhysicalPT =
(PHARDWARE_PTE)&PhysicalPageTablesBuffer[PhysicalPageTables*MM_PAGE_SIZE];
- PhysicalPageTables++;
-
- PDE[Entry].PageFrameNumber = (ULONG)*PhysicalPT >> MM_PAGE_SHIFT;
- PDE[Entry].Valid = 1;
- PDE[Entry].Write = 1;
-
- if (Entry+(KSEG0_BASE >> 22) > 1023)
- {
- TRACE("WARNING! Entry: %X > 1023\n", Entry+(KSEG0_BASE >>
22));
- }
-
- // Kernel-mode mapping
- *KernelPT =
(PHARDWARE_PTE)&KernelPageTablesBuffer[KernelPageTables*MM_PAGE_SIZE];
- KernelPageTables++;
-
- PDE[Entry+(KSEG0_BASE >> 22)].PageFrameNumber = ((ULONG)*KernelPT >>
MM_PAGE_SHIFT);
- PDE[Entry+(KSEG0_BASE >> 22)].Valid = 1;
- PDE[Entry+(KSEG0_BASE >> 22)].Write = 1;
-}
-
-BOOLEAN
-MempSetupPaging(IN PFN_NUMBER StartPage,
- IN PFN_COUNT NumberOfPages,
- IN BOOLEAN KernelMapping)
-{
- PHARDWARE_PTE PhysicalPT;
- PHARDWARE_PTE KernelPT;
- PFN_COUNT Entry, Page;
-
- TRACE("MempSetupPaging: SP 0x%X, Number: 0x%X, Kernel: %s\n",
- StartPage, NumberOfPages, KernelMapping ? "yes" : "no");
-
- // HACK
- if (StartPage+NumberOfPages >= 0x80000)
- {
- //
- // We can't map this as it requires more than 1 PDE
- // and in fact it's not possible at all ;)
- //
- //Print(L"skipping...\n");
- return TRUE;
- }
-
- //
- // Now actually set up the page tables for identity mapping
- //
- for (Page = StartPage; Page < StartPage + NumberOfPages; Page++)
- {
- Entry = Page >> 10;
-
- if (((PULONG)PDE)[Entry] == 0)
- {
- MempAllocatePTE(Entry, &PhysicalPT, &KernelPT);
- }
- else
- {
- PhysicalPT = (PHARDWARE_PTE)(PDE[Entry].PageFrameNumber <<
MM_PAGE_SHIFT);
- KernelPT = (PHARDWARE_PTE)(PDE[Entry+(KSEG0_BASE >>
22)].PageFrameNumber << MM_PAGE_SHIFT);
- }
-
- PhysicalPT[Page & 0x3ff].PageFrameNumber = Page;
- PhysicalPT[Page & 0x3ff].Valid = (Page != 0);
- PhysicalPT[Page & 0x3ff].Write = (Page != 0);
-
- if (KernelMapping)
- {
- if (KernelPT[Page & 0x3ff].Valid) WARN("xxx already mapped
\n");
- KernelPT[Page & 0x3ff].PageFrameNumber = Page;
- KernelPT[Page & 0x3ff].Valid = (Page != 0);
- KernelPT[Page & 0x3ff].Write = (Page != 0);
- }
- }
-
- return TRUE;
-}
-
-VOID
-MempUnmapPage(PFN_NUMBER Page)
-{
- PHARDWARE_PTE KernelPT;
- PFN_NUMBER Entry = (Page >> 10) + (KSEG0_BASE >> 22);
-
- /* Don't unmap page directory or HAL entries */
- if (Entry == SELFMAP_ENTRY || Entry == 1023)
- return;
-
- if (PDE[Entry].Valid)
- {
- KernelPT = (PHARDWARE_PTE)(PDE[Entry].PageFrameNumber << MM_PAGE_SHIFT);
-
- if (KernelPT)
- {
- KernelPT[Page & 0x3ff].PageFrameNumber = 0;
- KernelPT[Page & 0x3ff].Valid = 0;
- KernelPT[Page & 0x3ff].Write = 0;
- }
- }
-}
-
-VOID
-WinLdrpMapApic(VOID)
-{
- BOOLEAN LocalAPIC;
- LARGE_INTEGER MsrValue;
- ULONG APICAddress, CpuInfo[4];
-
- /* Check if we have a local APIC */
- __cpuid((int*)CpuInfo, 1);
- LocalAPIC = (((CpuInfo[3] >> 9) & 1) != 0);
-
- /* If there is no APIC, just return */
- if (!LocalAPIC)
- return;
-
- /* Read the APIC Address */
- MsrValue.QuadPart = __readmsr(0x1B);
- APICAddress = (MsrValue.LowPart & 0xFFFFF000);
-
- TRACE("Local APIC detected at address 0x%x\n",
- APICAddress);
-
- /* Map it */
- HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber
- = APICAddress >> MM_PAGE_SHIFT;
- HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1;
- HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1;
- HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].WriteThrough = 1;
- HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].CacheDisable = 1;
-}
-
-BOOLEAN
-WinLdrMapSpecialPages(void)
-{
-
- //VideoDisplayString(L"Hello from VGA, going into the kernel\n");
- TRACE("HalPageTable: 0x%X\n", HalPageTable);
-
- // Page Tables have been setup, make special handling for PCR and TSS
- // (which is done in BlSetupFotNt in usual ntldr)
- HalPageTable[(KI_USER_SHARED_DATA - 0xFFC00000) >>
MM_PAGE_SHIFT].PageFrameNumber = PcrBasePage+1;
- HalPageTable[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1;
- HalPageTable[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1;
-
- HalPageTable[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber =
PcrBasePage;
- HalPageTable[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1;
- HalPageTable[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1;
-
- // Map APIC
- WinLdrpMapApic();
-
- // Map VGA memory
- //VideoMemoryBase = MmMapIoSpace(0xb8000, 4000, MmNonCached);
- //TRACE("VideoMemoryBase: 0x%X\n", VideoMemoryBase);
-
- return TRUE;
-}
-
-#define ExtendedBIOSDataArea ((PULONG)0x740)
-#define ExtendedBIOSDataSize ((PULONG)0x744)
-#define RomFontPointers ((PULONG)0x700)
-
-enum
-{
- INT1FhFont = 0x00,
- INT43hFont = 0x01,
- ROM_8x14CharacterFont = 0x02,
- ROM_8x8DoubleDotFontLo = 0x03,
- ROM_8x8DoubleDotFontHi = 0x04,
- ROM_AlphaAlternate = 0x05,
- ROM_8x16Font = 0x06,
- ROM_Alternate9x16Font = 0x07,
- UltraVision_8x20Font = 0x11,
- UltraVision_8x10Font = 0x12,
-};
-
-void WinLdrSetupSpecialDataPointers(VOID)
-{
- REGS BiosRegs;
-
- /* Get the address of the bios rom fonts. Win 2003 videoprt reads these
- values from address 0x700 .. 0x718 and store them in the registry
- in HKLM\System\CurrentControlSet\Control\Wow\RomFontPointers
- Int 10h, AX=1130h, BH = pointer specifier
- returns: es:bp = address */
- BiosRegs.d.eax = 0x1130;
- BiosRegs.b.bh = ROM_8x14CharacterFont;
- Int386(0x10, &BiosRegs, &BiosRegs);
- RomFontPointers[0] = BiosRegs.w.es << 4 | BiosRegs.w.bp;
-
- BiosRegs.b.bh = ROM_8x8DoubleDotFontLo;
- Int386(0x10, &BiosRegs, &BiosRegs);
- RomFontPointers[1] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
-
- BiosRegs.b.bh = ROM_8x8DoubleDotFontHi;
- Int386(0x10, &BiosRegs, &BiosRegs);
- RomFontPointers[2] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
-
- BiosRegs.b.bh = ROM_AlphaAlternate;
- Int386(0x10, &BiosRegs, &BiosRegs);
- RomFontPointers[3] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
-
- BiosRegs.b.bh = ROM_8x16Font;
- Int386(0x10, &BiosRegs, &BiosRegs);
- RomFontPointers[4] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
-
- BiosRegs.b.bh = ROM_Alternate9x16Font;
- Int386(0x10, &BiosRegs, &BiosRegs);
- RomFontPointers[5] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
-
- /* Store address of the extended bios data area in 0x740 */
- BiosRegs.d.eax = 0xC100;
- Int386(0x15, &BiosRegs, &BiosRegs);
- if (INT386_SUCCESS(BiosRegs))
- {
- *ExtendedBIOSDataArea = BiosRegs.w.es << 4;
- *ExtendedBIOSDataSize = 1024;
- TRACE("*ExtendedBIOSDataArea = 0x%lx\n", *ExtendedBIOSDataArea);
- }
- else
- {
- WARN("Couldn't get address of extended BIOS data area\n");
- *ExtendedBIOSDataArea = 0;
- *ExtendedBIOSDataSize = 0;
- }
-}
-
-void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
- 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.");
- 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!");
- return;
- }
-
- /* Zero newly prepared GDT+IDT */
- RtlZeroMemory(GdtIdt, NumPages << MM_PAGE_SHIFT);
-
- // Before we start mapping pages, create a block of memory, which will contain
- // PDE and PTEs
- if (MempAllocatePageTables() == FALSE)
- {
- BugCheck("MempAllocatePageTables failed!\n");
- }
-
- /* Map stuff like PCR, KI_USER_SHARED_DATA and Apic */
- WinLdrMapSpecialPages();
-
- /* Set some special fields */
- WinLdrSetupSpecialDataPointers();
-}
-
-
-VOID
-WinLdrSetProcessorContext(void)
-{
- GDTIDT GdtDesc, IdtDesc, OldIdt;
- PKGDTENTRY pGdt;
- PKIDTENTRY pIdt;
- USHORT Ldt = 0;
- ULONG Pcr;
- ULONG Tss;
- //ULONG i;
-
- Pcr = KIP0PCRADDRESS;
- Tss = KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT);
-
- TRACE("GDtIdt %p, Pcr %p, Tss 0x%08X\n",
- GdtIdt, Pcr, Tss);
-
- // Enable paging
- //BS->ExitBootServices(ImageHandle,MapKey);
-
- // Disable Interrupts
- _disable();
-
- // Re-initialize EFLAGS
- __writeeflags(0);
-
- // Set the PDBR
- __writecr3((ULONG_PTR)PDE);
-
- // Enable paging by modifying CR0
- __writecr0(__readcr0() | CR0_PG);
-
- // Kernel expects the PCR to be zero-filled on startup
- // FIXME: Why zero it here when we can zero it right after allocation?
- RtlZeroMemory((PVOID)Pcr, MM_PAGE_SIZE); //FIXME: Why zero only 1 page when we
allocate 2?
-
- // Get old values of GDT and IDT
- Ke386GetGlobalDescriptorTable(&GdtDesc);
- __sidt(&IdtDesc);
-
- // Save old IDT
- OldIdt.Base = IdtDesc.Base;
- OldIdt.Limit = IdtDesc.Limit;
-
- // Prepare new IDT+GDT
- GdtDesc.Base = KSEG0_BASE | (ULONG_PTR)GdtIdt;
- GdtDesc.Limit = NUM_GDT * sizeof(KGDTENTRY) - 1;
- IdtDesc.Base = (ULONG)((PUCHAR)GdtDesc.Base + GdtDesc.Limit + 1);
- IdtDesc.Limit = NUM_IDT * sizeof(KIDTENTRY) - 1;
-
- // ========================
- // Fill all descriptors now
- // ========================
-
- pGdt = (PKGDTENTRY)GdtDesc.Base;
- pIdt = (PKIDTENTRY)IdtDesc.Base;
-
- //
- // Code selector (0x8)
- // Flat 4Gb
- //
- pGdt[1].LimitLow = 0xFFFF;
- pGdt[1].BaseLow = 0;
- pGdt[1].HighWord.Bytes.BaseMid = 0;
- pGdt[1].HighWord.Bytes.Flags1 = 0x9A;
- pGdt[1].HighWord.Bytes.Flags2 = 0xCF;
- pGdt[1].HighWord.Bytes.BaseHi = 0;
-
- //
- // Data selector (0x10)
- // Flat 4Gb
- //
- pGdt[2].LimitLow = 0xFFFF;
- pGdt[2].BaseLow = 0;
- pGdt[2].HighWord.Bytes.BaseMid = 0;
- pGdt[2].HighWord.Bytes.Flags1 = 0x92;
- pGdt[2].HighWord.Bytes.Flags2 = 0xCF;
- pGdt[2].HighWord.Bytes.BaseHi = 0;
-
- //
- // Selector (0x18)
- // Flat 2Gb
- //
- pGdt[3].LimitLow = 0xFFFF;
- pGdt[3].BaseLow = 0;
- pGdt[3].HighWord.Bytes.BaseMid = 0;
- pGdt[3].HighWord.Bytes.Flags1 = 0xFA;
- pGdt[3].HighWord.Bytes.Flags2 = 0xCF;
- pGdt[3].HighWord.Bytes.BaseHi = 0;
-
- //
- // Selector (0x20)
- // Flat 2Gb
- //
- pGdt[4].LimitLow = 0xFFFF;
- pGdt[4].BaseLow = 0;
- pGdt[4].HighWord.Bytes.BaseMid = 0;
- pGdt[4].HighWord.Bytes.Flags1 = 0xF2;
- pGdt[4].HighWord.Bytes.Flags2 = 0xCF;
- pGdt[4].HighWord.Bytes.BaseHi = 0;
-
- //
- // TSS Selector (0x28)
- //
- pGdt[5].LimitLow = 0x78-1; //FIXME: Check this
- pGdt[5].BaseLow = (USHORT)(Tss & 0xffff);
- pGdt[5].HighWord.Bytes.BaseMid = (UCHAR)((Tss >> 16) & 0xff);
- pGdt[5].HighWord.Bytes.Flags1 = 0x89;
- pGdt[5].HighWord.Bytes.Flags2 = 0x00;
- pGdt[5].HighWord.Bytes.BaseHi = (UCHAR)((Tss >> 24) & 0xff);
-
- //
- // PCR Selector (0x30)
- //
- pGdt[6].LimitLow = 0x01;
- pGdt[6].BaseLow = (USHORT)(Pcr & 0xffff);
- pGdt[6].HighWord.Bytes.BaseMid = (UCHAR)((Pcr >> 16) & 0xff);
- pGdt[6].HighWord.Bytes.Flags1 = 0x92;
- pGdt[6].HighWord.Bytes.Flags2 = 0xC0;
- pGdt[6].HighWord.Bytes.BaseHi = (UCHAR)((Pcr >> 24) & 0xff);
-
- //
- // Selector (0x38)
- //
- pGdt[7].LimitLow = 0xFFFF;
- pGdt[7].BaseLow = 0;
- pGdt[7].HighWord.Bytes.BaseMid = 0;
- pGdt[7].HighWord.Bytes.Flags1 = 0xF3;
- pGdt[7].HighWord.Bytes.Flags2 = 0x40;
- pGdt[7].HighWord.Bytes.BaseHi = 0;
-
- //
- // Some BIOS stuff (0x40)
- //
- pGdt[8].LimitLow = 0xFFFF;
- pGdt[8].BaseLow = 0x400;
- pGdt[8].HighWord.Bytes.BaseMid = 0;
- pGdt[8].HighWord.Bytes.Flags1 = 0xF2;
- pGdt[8].HighWord.Bytes.Flags2 = 0x0;
- pGdt[8].HighWord.Bytes.BaseHi = 0;
-
- //
- // Selector (0x48)
- //
- pGdt[9].LimitLow = 0;
- pGdt[9].BaseLow = 0;
- pGdt[9].HighWord.Bytes.BaseMid = 0;
- pGdt[9].HighWord.Bytes.Flags1 = 0;
- pGdt[9].HighWord.Bytes.Flags2 = 0;
- pGdt[9].HighWord.Bytes.BaseHi = 0;
-
- //
- // Selector (0x50)
- //
- pGdt[10].LimitLow = 0xFFFF; //FIXME: Not correct!
- pGdt[10].BaseLow = 0;
- pGdt[10].HighWord.Bytes.BaseMid = 0x2;
- pGdt[10].HighWord.Bytes.Flags1 = 0x89;
- pGdt[10].HighWord.Bytes.Flags2 = 0;
- pGdt[10].HighWord.Bytes.BaseHi = 0;
-
- //
- // Selector (0x58)
- //
- pGdt[11].LimitLow = 0xFFFF;
- pGdt[11].BaseLow = 0;
- pGdt[11].HighWord.Bytes.BaseMid = 0x2;
- pGdt[11].HighWord.Bytes.Flags1 = 0x9A;
- pGdt[11].HighWord.Bytes.Flags2 = 0;
- pGdt[11].HighWord.Bytes.BaseHi = 0;
-
- //
- // Selector (0x60)
- //
- pGdt[12].LimitLow = 0xFFFF;
- pGdt[12].BaseLow = 0; //FIXME: Maybe not correct, but noone cares
- pGdt[12].HighWord.Bytes.BaseMid = 0x2;
- pGdt[12].HighWord.Bytes.Flags1 = 0x92;
- pGdt[12].HighWord.Bytes.Flags2 = 0;
- pGdt[12].HighWord.Bytes.BaseHi = 0;
-
- //
- // Video buffer Selector (0x68)
- //
- pGdt[13].LimitLow = 0x3FFF;
- pGdt[13].BaseLow = 0x8000;
- pGdt[13].HighWord.Bytes.BaseMid = 0x0B;
- pGdt[13].HighWord.Bytes.Flags1 = 0x92;
- pGdt[13].HighWord.Bytes.Flags2 = 0;
- pGdt[13].HighWord.Bytes.BaseHi = 0;
-
- //
- // Points to GDT (0x70)
- //
- pGdt[14].LimitLow = NUM_GDT*sizeof(KGDTENTRY) - 1;
- pGdt[14].BaseLow = 0x7000;
- pGdt[14].HighWord.Bytes.BaseMid = 0xFF;
- pGdt[14].HighWord.Bytes.Flags1 = 0x92;
- pGdt[14].HighWord.Bytes.Flags2 = 0;
- pGdt[14].HighWord.Bytes.BaseHi = 0xFF;
-
- //
- // Some unused descriptors should go here
- //
-
- // Copy the old IDT
- RtlCopyMemory(pIdt, (PVOID)OldIdt.Base, OldIdt.Limit + 1);
-
- // Mask interrupts
- //asm("cli\n"); // they are already masked before enabling paged mode
-
- // Load GDT+IDT
- Ke386SetGlobalDescriptorTable(&GdtDesc);
- __lidt(&IdtDesc);
-
- // Jump to proper CS and clear prefetch queue
-#if defined(__GNUC__)
- asm("ljmp $0x08, $1f\n"
- "1:\n");
-#elif defined(_MSC_VER)
- /* We can't express the above in MASM so we use this far return instead */
- __asm
- {
- push 8
- push offset resume
- retf
- resume:
- };
-#else
-#error
-#endif
-
- // Set SS selector
- Ke386SetSs(0x10); // DataSelector=0x10
-
- // Set DS and ES selectors
- Ke386SetDs(0x10);
- Ke386SetEs(0x10); // this is vital for rep stosd
-
- // LDT = not used ever, thus set to 0
- Ke386SetLocalDescriptorTable(Ldt);
-
- // Load TSR
- Ke386SetTr(KGDT_TSS);
-
- // Clear GS
- Ke386SetGs(0);
-
- // Set FS to PCR
- Ke386SetFs(0x30);
-
- // Real end of the function, just for information
- /* do not uncomment!
- pop edi;
- pop esi;
- pop ebx;
- mov esp, ebp;
- pop ebp;
- ret
- */
-}
-
-#if DBG
-VOID
-MempDump(VOID)
-{
- ULONG *PDE_Addr=(ULONG *)PDE;//0xC0300000;
- int i, j;
-
- TRACE("\nPDE\n");
-
- for (i=0; i<128; i++)
- {
- TRACE("0x%04X | ", i*8);
-
- for (j=0; j<8; j++)
- {
- TRACE("0x%08X ", PDE_Addr[i*8+j]);
- }
-
- TRACE("\n");
- }
-}
-#endif
-
Modified: trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] Wed Feb 3 15:20:37
2016
@@ -79,6 +79,8 @@
#include <ui.h>
#include <ver.h>
#include <video.h>
+
+/* NTOS loader */
#include <winldr.h>
/* File system headers */
Removed: trunk/reactos/boot/freeldr/freeldr/include/ntoskrnl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/ntoskrnl.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/ntoskrnl.h (removed)
@@ -1,25 +0,0 @@
-/*
- * PROJECT: ReactOS Kernel
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: boot/freeldr/freeldr/include/ntoskrnl.h
- * PURPOSE: NTOS glue routines for the MINIHAL library
- * PROGRAMMERS: Hervé Poussineau <hpoussin(a)reactos.org>
- */
-
-#include <ntdef.h>
-#undef _NTHAL_
-//#undef DECLSPEC_IMPORT
-//#define DECLSPEC_IMPORT
-#undef NTSYSAPI
-#define NTSYSAPI
-
-/* Windows Device Driver Kit */
-#include <ntddk.h>
-#include <ndk/haltypes.h>
-
-//typedef GUID UUID;
-
-/* Disk stuff */
-#include <arc/arc.h>
-#include <ntdddisk.h>
-#include <internal/hal.h>
Modified: trunk/reactos/boot/freeldr/freeldr/include/winldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/winldr.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/winldr.h [iso-8859-1] Wed Feb 3 15:20:37
2016
@@ -161,9 +161,6 @@
WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
BOOLEAN
-MempAllocatePageTables();
-
-BOOLEAN
MempSetupPaging(IN PFN_NUMBER StartPage,
IN PFN_NUMBER NumberOfPages,
IN BOOLEAN KernelMapping);
Copied: trunk/reactos/boot/freeldr/freeldr/windows/arch/amd64/winldr.c (from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/arch/amd64/winldr.c [iso-8859-1] Wed Feb 3
15:20:37 2016
@@ -28,6 +28,7 @@
/* FUNCTIONS **************************************************************/
+static
BOOLEAN
MempAllocatePageTables(VOID)
{
@@ -60,6 +61,7 @@
return TRUE;
}
+static
PHARDWARE_PTE
MempGetOrCreatePageDir(PHARDWARE_PTE PdeBase, ULONG Index)
{
@@ -85,6 +87,7 @@
return SubDir;
}
+static
BOOLEAN
MempMapSinglePage(ULONG64 VirtualAddress, ULONG64 PhysicalAddress)
{
@@ -143,6 +146,7 @@
return TRUE;
}
+static
PFN_NUMBER
MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, PFN_NUMBER cPages)
{
@@ -202,6 +206,7 @@
// TRACE(">>> MempUnmapPage\n");
}
+static
VOID
WinLdrpMapApic(VOID)
{
@@ -234,6 +239,7 @@
MempMapSinglePage(APIC_BASE, APICAddress);
}
+static
BOOLEAN
WinLdrMapSpecialPages(VOID)
{
@@ -265,6 +271,7 @@
return TRUE;
}
+static
VOID
Amd64SetupGdt(PVOID GdtBase, ULONG64 TssBase)
{
@@ -313,6 +320,7 @@
TRACE("Leave Amd64SetupGdt()\n");
}
+static
VOID
Amd64SetupIdt(PVOID IdtBase)
{
@@ -421,4 +429,3 @@
MempDump(VOID)
{
}
-
Copied: trunk/reactos/boot/freeldr/freeldr/windows/arch/arm/winldr.c (from r70676,
trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/arch/arm/winldr.c [iso-8859-1] Wed Feb 3
15:20:37 2016
@@ -99,6 +99,7 @@
return;
}
+static
BOOLEAN
WinLdrMapSpecialPages(ULONG PcrBasePage)
{
@@ -191,6 +192,7 @@
LoaderBlock->Thread = (ULONG_PTR)PdrPage->InitialThread;
}
+static
BOOLEAN
MempAllocatePageTables(VOID)
{
@@ -277,24 +279,3 @@
PLOADER_PARAMETER_BLOCK LoaderBlock)
{
}
-
-VOID DiskStopFloppyMotor(VOID)
-{
-}
-
-VOID
-RealEntryPoint(VOID)
-{
- BootMain("");
-}
-
-VOID
-FrLdrBugCheckWithMessage(
- ULONG BugCode,
- PCHAR File,
- ULONG Line,
- PSTR Format,
- ...)
-{
-
-}
Copied: trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/halstub.c (from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/i386/halstub.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/halstub.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/halstub.c [iso-8859-1] Wed Feb 3
15:20:37 2016
@@ -8,7 +8,7 @@
/* INCLUDES ******************************************************************/
-#include <ntoskrnl.h>
+#include "ntoskrnl.h"
#define NDEBUG
#include <debug.h>
Copied: trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.c (from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.c [iso-8859-1] Wed Feb
3 15:20:37 2016
@@ -8,7 +8,7 @@
/* INCLUDES ******************************************************************/
-#include <ntoskrnl.h>
+#include "ntoskrnl.h"
/* For KeStallExecutionProcessor */
#if defined(_M_IX86) || defined(_M_AMD64)
Copied: trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/winldr.c (from r70682,
trunk/reactos/boot/freeldr/freeldr/arch/i386/winldr.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/arch/i386/winldr.c [iso-8859-1] Wed Feb 3
15:20:37 2016
@@ -46,6 +46,7 @@
/* FUNCTIONS **************************************************************/
+static
BOOLEAN
MempAllocatePageTables(VOID)
{
@@ -115,6 +116,7 @@
return TRUE;
}
+static
VOID
MempAllocatePTE(ULONG Entry, PHARDWARE_PTE *PhysicalPT, PHARDWARE_PTE *KernelPT)
{
@@ -144,8 +146,8 @@
BOOLEAN
MempSetupPaging(IN PFN_NUMBER StartPage,
- IN PFN_COUNT NumberOfPages,
- IN BOOLEAN KernelMapping)
+ IN PFN_COUNT NumberOfPages,
+ IN BOOLEAN KernelMapping)
{
PHARDWARE_PTE PhysicalPT;
PHARDWARE_PTE KernelPT;
@@ -221,6 +223,7 @@
}
}
+static
VOID
WinLdrpMapApic(VOID)
{
@@ -252,6 +255,7 @@
HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].CacheDisable = 1;
}
+static
BOOLEAN
WinLdrMapSpecialPages(void)
{
@@ -297,6 +301,7 @@
UltraVision_8x10Font = 0x12,
};
+static
void WinLdrSetupSpecialDataPointers(VOID)
{
REGS BiosRegs;
@@ -690,4 +695,3 @@
}
}
#endif
-