Author: ion
Date: Sun Sep 6 03:24:30 2015
New Revision: 69044
URL:
http://svn.reactos.org/svn/reactos?rev=69044&view=rev
Log:
[BOOTMGFW]
- Begin carving out the rough edges of the memory manager. This will be the hardest part.
Added:
trunk/reactos/boot/environ/lib/mm/blkalloc.c (with props)
trunk/reactos/boot/environ/lib/mm/descriptor.c (with props)
trunk/reactos/boot/environ/lib/mm/heapalloc.c (with props)
trunk/reactos/boot/environ/lib/mm/i386/ (with props)
trunk/reactos/boot/environ/lib/mm/i386/mmx86.c (with props)
trunk/reactos/boot/environ/lib/mm/mm.c (with props)
trunk/reactos/boot/environ/lib/mm/pagealloc.c (with props)
Removed:
trunk/reactos/boot/environ/lib/mm/foo.c
Modified:
trunk/reactos/boot/environ/CMakeLists.txt
trunk/reactos/boot/environ/include/bl.h
trunk/reactos/boot/environ/lib/bootlib.c
Modified: trunk/reactos/boot/environ/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/CMakeLists.tx…
==============================================================================
--- trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -12,7 +12,12 @@
lib/bootlib.c
lib/misc/bcd.c
lib/misc/util.c
- lib/firmware/efi/firmware.c)
+ lib/firmware/efi/firmware.c
+ lib/mm/mm.c
+ lib/mm/pagealloc.c
+ lib/mm/heapalloc.c
+ lib/mm/blkalloc.c
+ lib/mm/descriptor.c)
if(ARCH STREQUAL "i386")
list(APPEND BOOTLIB_ASM_SOURCE
@@ -20,6 +25,7 @@
)
list(APPEND BOOTLIB_SOURCE
lib/arch/i386/arch.c
+ lib/mm/i386/mmx86.c
)
elseif(ARCH STREQUAL "amd64")
list(APPEND BOOTLIB_ASM_SOURCE
Modified: trunk/reactos/boot/environ/include/bl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
==============================================================================
--- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -1,9 +1,9 @@
/*
-* COPYRIGHT: See COPYING.ARM in the top level directory
-* PROJECT: ReactOS UEFI Boot Library
-* FILE: boot/environ/include/bl.h
-* PURPOSE: Main Boot Library Header
-* PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/include/bl.h
+ * PURPOSE: Main Boot Library Header
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
*/
#ifndef _BL_H
@@ -401,6 +401,13 @@
_In_ PBL_FIRMWARE_DESCRIPTOR FirmwareParameters
);
+NTSTATUS
+BlpMmInitialize (
+ _In_ PBL_MEMORY_DATA MemoryData,
+ _In_ BL_TRANSLATION_TYPE TranslationType,
+ _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
+ );
+
/* UTILITY ROUTINES **********************************************************/
EFI_STATUS
@@ -425,6 +432,39 @@
VOID
BlpArchSwitchContext (
_In_ BL_ARCH_MODE NewMode
+ );
+
+/* MEMORY MANAGER ROUTINES ***************************************************/
+
+NTSTATUS
+MmBaInitialize (
+ VOID
+ );
+
+NTSTATUS
+MmPaInitialize (
+ _In_ PBL_MEMORY_DATA MemoryData,
+ _In_ ULONG MinimumPages
+ );
+
+NTSTATUS
+MmArchInitialize (
+ _In_ ULONG Phase,
+ _In_ PBL_MEMORY_DATA MemoryData,
+ _In_ BL_TRANSLATION_TYPE TranslationType,
+ _In_ BL_TRANSLATION_TYPE LibraryTranslationType
+ );
+
+NTSTATUS
+MmHaInitialize (
+ _In_ ULONG HeapSize,
+ _In_ ULONG HeapAttributes
+ );
+
+NTSTATUS
+MmMdInitialize (
+ _In_ ULONG Phase,
+ _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
);
extern ULONG BlpApplicationFlags;
Modified: trunk/reactos/boot/environ/lib/bootlib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/bootlib.c…
==============================================================================
--- trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -18,9 +18,6 @@
PBOOT_APPLICATION_PARAMETER_BLOCK BlpApplicationParameters;
BL_APPLICATION_ENTRY BlpApplicationEntry;
BOOLEAN BlpLibraryParametersInitialized;
-
-/* temp */
-BL_TRANSLATION_TYPE MmTranslationType;
/* FUNCTIONS *****************************************************************/
@@ -68,7 +65,7 @@
)
{
NTSTATUS Status;
- //PBL_MEMORY_DATA MemoryData;
+ PBL_MEMORY_DATA MemoryData;
PBL_APPLICATION_ENTRY AppEntry;
PBL_FIRMWARE_DESCRIPTOR FirmwareDescriptor;
ULONG_PTR ParamPointer = (ULONG_PTR)BootAppParameters;
@@ -84,7 +81,7 @@
}
/* Get sub-structures */
- //MemoryData = (PBL_MEMORY_DATA)(ParamPointer +
BootAppParameters->MemoryDataOffset);
+ MemoryData = (PBL_MEMORY_DATA)(ParamPointer +
BootAppParameters->MemoryDataOffset);
FirmwareDescriptor = (PBL_FIRMWARE_DESCRIPTOR)(ParamPointer +
BootAppParameters->FirmwareParametersOffset);
AppEntry = (PBL_APPLICATION_ENTRY)(ParamPointer +
BootAppParameters->AppEntryOffset);
BlpBootDevice = (PBL_DEVICE_DESCRIPTOR)(ParamPointer +
BootAppParameters->BootDeviceOffset);
@@ -122,6 +119,16 @@
Status = BlpArchInitialize(0);
if (!NT_SUCCESS(Status))
{
+ goto Quickie;
+ }
+
+ /* Initialize the memory manager */
+ Status = BlpMmInitialize(MemoryData,
+ BootAppParameters->MemoryTranslationType,
+ LibraryParameters);
+ if (!NT_SUCCESS(Status))
+ {
+ EarlyPrint(L"MM init failed!\n");
goto Quickie;
}
Added: trunk/reactos/boot/environ/lib/mm/blkalloc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/blkall…
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/blkalloc.c (added)
+++ trunk/reactos/boot/environ/lib/mm/blkalloc.c [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -0,0 +1,24 @@
+/*
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/lib/mm/blkalloc.c
+ * PURPOSE: Boot Library Memory Manager Block Allocator
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+*/
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+MmBaInitialize (
+ VOID
+ )
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
Propchange: trunk/reactos/boot/environ/lib/mm/blkalloc.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/boot/environ/lib/mm/descriptor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/descri…
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/descriptor.c (added)
+++ trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -0,0 +1,26 @@
+/*
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/lib/mm/descriptor.c
+ * PURPOSE: Boot Library Memory Manager Descriptor Manager
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+*/
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+MmMdInitialize (
+ _In_ ULONG Phase,
+ _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
+ )
+{
+ EarlyPrint(L"Md init\n");
+ return STATUS_NOT_IMPLEMENTED;
+}
Propchange: trunk/reactos/boot/environ/lib/mm/descriptor.c
------------------------------------------------------------------------------
svn:eol-style = native
Removed: trunk/reactos/boot/environ/lib/mm/foo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/foo.c?…
==============================================================================
(empty)
Added: trunk/reactos/boot/environ/lib/mm/heapalloc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/heapal…
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/heapalloc.c (added)
+++ trunk/reactos/boot/environ/lib/mm/heapalloc.c [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -0,0 +1,25 @@
+/*
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/lib/mm/heapalloc.c
+ * PURPOSE: Boot Library Memory Manager Heap Allocator
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+MmHaInitialize (
+ _In_ ULONG HeapSize,
+ _In_ ULONG HeapAttributes
+ )
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
Propchange: trunk/reactos/boot/environ/lib/mm/heapalloc.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/boot/environ/lib/mm/i386/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sun Sep 6 03:24:30 2015
@@ -0,0 +1 @@
+((CORE|ROSTESTS|ROSAPPS)-\d+)(,? ?((CORE|ROSTESTS|ROSAPPS)-\d+))*(,? ?(and |or
)?((CORE|ROSTESTS|ROSAPPS)-\d+))?
Propchange: trunk/reactos/boot/environ/lib/mm/i386/
------------------------------------------------------------------------------
bugtraq:message = See issue %BUGID% for more details.
Propchange: trunk/reactos/boot/environ/lib/mm/i386/
------------------------------------------------------------------------------
bugtraq:url =
https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/boot/environ/lib/mm/i386/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Added: trunk/reactos/boot/environ/lib/mm/i386/mmx86.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/i386/m…
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/i386/mmx86.c (added)
+++ trunk/reactos/boot/environ/lib/mm/i386/mmx86.c [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -0,0 +1,26 @@
+/*
+* COPYRIGHT: See COPYING.ARM in the top level directory
+* PROJECT: ReactOS UEFI Boot Library
+* FILE: boot/environ/lib/mm/i386/mmx86.c
+* PURPOSE: Boot Library Memory Manager x86-Specific Code
+* PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+*/
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+MmArchInitialize (
+ _In_ ULONG Phase,
+ _In_ PBL_MEMORY_DATA MemoryData,
+ _In_ BL_TRANSLATION_TYPE TranslationType,
+ _In_ BL_TRANSLATION_TYPE LibraryTranslationType
+ )
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
Propchange: trunk/reactos/boot/environ/lib/mm/i386/mmx86.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/boot/environ/lib/mm/mm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/mm.c?r…
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/mm.c (added)
+++ trunk/reactos/boot/environ/lib/mm/mm.c [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -0,0 +1,148 @@
+/*
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/lib/mm/mm.c
+ * PURPOSE: Boot Library Memory Manager Core
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+*/
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+BL_TRANSLATION_TYPE MmTranslationType, MmOriginalTranslationType;
+ULONG MmDescriptorCallTreeCount;
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+MmTrInitialize (
+ VOID
+ )
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+
+NTSTATUS
+BlMmRemoveBadMemory (
+ VOID
+ )
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+BlpMmInitialize (
+ _In_ PBL_MEMORY_DATA MemoryData,
+ _In_ BL_TRANSLATION_TYPE TranslationType,
+ _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
+ )
+{
+ NTSTATUS Status;
+
+ /* Take a reference */
+ MmDescriptorCallTreeCount = 1;
+
+ /* Only support valid translation types */
+ if ((TranslationType > BlPae) || (LibraryParameters->TranslationType >
BlPae))
+ {
+ /* Bail out */
+ EarlyPrint(L"Invalid translation types present\n");
+ Status = STATUS_INVALID_PARAMETER;
+ goto Quickie;
+ }
+
+ /* Initialize memory descriptors */
+ MmMdInitialize(0, LibraryParameters);
+
+ /* Remember the page type we came in with */
+ MmOriginalTranslationType = TranslationType;
+
+ /* Initialize the physical page allocator */
+ Status = MmPaInitialize(MemoryData,
+ LibraryParameters->MinimumAllocationCount);
+ if (!NT_SUCCESS(Status))
+ {
+ goto Quickie;
+ }
+
+ /* Initialize the memory tracker */
+ Status = MmTrInitialize();
+ if (!NT_SUCCESS(Status))
+ {
+ //MmArchDestroy();
+ //MmPaDestroy(1);
+ goto Quickie;
+ }
+
+ /* Initialize paging, large pages, self-mapping, PAE, if needed */
+ Status = MmArchInitialize(1,
+ MemoryData,
+ TranslationType,
+ LibraryParameters->TranslationType);
+ if (NT_SUCCESS(Status))
+ {
+ /* Save the newly active transation type */
+ MmTranslationType = LibraryParameters->TranslationType;
+
+ /* Initialize the heap allocator now */
+ Status = MmHaInitialize(LibraryParameters->MinimumHeapSize,
+ LibraryParameters->HeapAllocationAttributes);
+ }
+
+ /* If Phase 1 init failed, bail out */
+ if (!NT_SUCCESS(Status))
+ {
+ /* Kill everything set setup so far */
+ //MmPaDestroy(0);
+ //MmTrDestroy();
+ //MmArchDestroy();
+ //MmPaDestroy(1);
+ goto Quickie;
+ }
+
+ /* Do we have too many descriptors? */
+ if (LibraryParameters->DescriptorCount > 512)
+ {
+ /* Switch to using a dynamic buffer instead */
+ //MmMdpSwitchToDynamicDescriptors(LibraryParameters->DescriptorCount);
+ }
+
+ /* Remove memory that the BCD says is bad */
+ BlMmRemoveBadMemory();
+
+ /* Now map all the memory regions as needed */
+ Status = MmArchInitialize(2,
+ MemoryData,
+ TranslationType,
+ LibraryParameters->TranslationType);
+ if (NT_SUCCESS(Status))
+ {
+ /* Initialize the block allocator */
+ Status = MmBaInitialize();
+ }
+
+ /* Check if anything in phase 2 failed */
+ if (!NT_SUCCESS(Status))
+ {
+ /* Go back to static descriptors and kill the heap */
+ //MmMdpSwitchToStaticDescriptors();
+ //HapInitializationStatus = 0;
+ ++MmDescriptorCallTreeCount;
+
+ /* Destroy the Phase 1 initialization */
+ //MmPaDestroy(0);
+ //MmTrDestroy();
+ //MmArchDestroy();
+ //MmPaDestroy(1);
+ }
+
+Quickie:
+ /* Free the memory descriptors and return the initialization state */
+ //MmMdFreeGlobalDescriptors();
+ --MmDescriptorCallTreeCount;
+ return Status;
+}
Propchange: trunk/reactos/boot/environ/lib/mm/mm.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/boot/environ/lib/mm/pagealloc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/pageal…
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/pagealloc.c (added)
+++ trunk/reactos/boot/environ/lib/mm/pagealloc.c [iso-8859-1] Sun Sep 6 03:24:30 2015
@@ -0,0 +1,25 @@
+/*
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/lib/mm/pagealloc.c
+ * PURPOSE: Boot Library Memory Manager Page Allocator
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+*/
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+MmPaInitialize (
+ _In_ PBL_MEMORY_DATA MemoryData,
+ _In_ ULONG MinimumPages
+ )
+{
+ return STATUS_NOT_IMPLEMENTED;
+}
Propchange: trunk/reactos/boot/environ/lib/mm/pagealloc.c
------------------------------------------------------------------------------
svn:eol-style = native