Author: ion
Date: Sun Sep 6 21:29:41 2015
New Revision: 69073
URL:
http://svn.reactos.org/svn/reactos?rev=69073&view=rev
Log:
[BOOTMGFW]
- I/O Library initialization.
- A few more random initialization routines. Skip TPM, BitLocker, Network and non-FAT
filesystems for now.
Added:
trunk/reactos/boot/environ/lib/io/device.c (with props)
trunk/reactos/boot/environ/lib/io/fat.c (with props)
trunk/reactos/boot/environ/lib/io/file.c (with props)
trunk/reactos/boot/environ/lib/io/io.c (with props)
Modified:
trunk/reactos/boot/environ/CMakeLists.txt
trunk/reactos/boot/environ/include/bl.h
trunk/reactos/boot/environ/lib/bootlib.c
trunk/reactos/boot/environ/lib/misc/util.c
trunk/reactos/boot/environ/lib/platform/time.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 21:29:41 2015
@@ -18,7 +18,11 @@
lib/mm/heapalloc.c
lib/mm/blkalloc.c
lib/mm/descriptor.c
- lib/platform/time.c)
+ lib/platform/time.c
+ lib/io/io.c
+ lib/io/device.c
+ lib/io/file.c
+ lib/io/fat.c)
if(ARCH STREQUAL "i386")
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 21:29:41 2015
@@ -77,6 +77,8 @@
#define BL_LIBRARY_FLAG_REINITIALIZE_ALL 0x04
#define BL_LIBRARY_FLAG_ZERO_HEAP_ALLOCATIONS_ON_FREE 0x10
#define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED 0x20
+
+#define BL_FS_REGISTER_AT_HEAD_FLAG 1
#define BL_MEMORY_CLASS_SHIFT 28
@@ -200,6 +202,38 @@
BlMemoryRuntime = 0x1000000
} BL_MEMORY_ATTR;
+/* CALLBACKS *****************************************************************/
+
+typedef
+NTSTATUS
+(*PBL_FS_INIT_CALLBACK) (
+ VOID
+ );
+
+typedef
+NTSTATUS
+(*PBL_FS_DESTROY_CALLBACK) (
+ VOID
+ );
+
+typedef
+NTSTATUS
+(*PBL_FS_MOUNT_CALLBACK) (
+ VOID
+ );
+
+typedef
+NTSTATUS
+(*PBL_FS_PURGE_CALLBACK) (
+ VOID
+ );
+
+typedef
+NTSTATUS
+(*PBL_FILE_DESTROY_CALLBACK) (
+ _In_ PVOID Entry
+ );
+
/* DATA STRUCTURES ***********************************************************/
typedef struct _BL_LIBRARY_PARAMETERS
@@ -419,6 +453,34 @@
ULONGLONG Minimum;
ULONGLONG Maximum;
} BL_ADDRESS_RANGE, *PBL_ADDRESS_RANGE;
+
+typedef struct _BL_FILE_ENTRY
+{
+ ULONG DeviceIndex;
+ PBL_FILE_DESTROY_CALLBACK DestroyCallback;
+} BL_FILE_ENTRY, *PBL_FILE_ENTRY;
+
+typedef struct _BL_DEVICE_ENTRY
+{
+ ULONG ReferenceCount;
+} BL_DEVICE_ENTRY, *PBL_DEVICE_ENTRY;
+
+typedef struct _BL_FILE_SYSTEM_ENTRY
+{
+ LIST_ENTRY ListEntry;
+ PBL_FS_INIT_CALLBACK InitCallback;
+ PBL_FS_DESTROY_CALLBACK DestroyCallback;
+ PBL_FS_MOUNT_CALLBACK MountCallback;
+ PBL_FS_PURGE_CALLBACK PurgeCallback;
+} BL_FILE_SYSTEM_ENTRY, *PBL_FILE_SYSTEM_ENTRY;
+
+typedef struct _BL_FILE_SYSTEM_REGISTRATION_TABLE
+{
+ PBL_FS_INIT_CALLBACK Init;
+ PBL_FS_DESTROY_CALLBACK Destroy;
+ PBL_FS_MOUNT_CALLBACK Mount;
+ PBL_FS_PURGE_CALLBACK Purge;
+} BL_FILE_SYSTEM_REGISTRATION_TABLE;
/* INLINE ROUTINES ***********************************************************/
@@ -513,6 +575,26 @@
_In_ PBL_LIBRARY_PARAMETERS LibraryParameters
);
+NTSTATUS
+BlpDeviceInitialize (
+ VOID
+ );
+
+NTSTATUS
+BlpIoInitialize (
+ VOID
+ );
+
+NTSTATUS
+BlpFileInitialize (
+ VOID
+ );
+
+NTSTATUS
+FatInitialize (
+ VOID
+ );
+
/* FIRMWARE ROUTINES *********************************************************/
NTSTATUS
@@ -544,6 +626,11 @@
NTSTATUS
EfiGetNtStatusCode (
_In_ EFI_STATUS EfiStatus
+ );
+
+NTSTATUS
+BlUtlInitialize (
+ VOID
);
/* BCD ROUTINES **************************************************************/
@@ -647,6 +734,11 @@
_In_ ULONG Size
);
+NTSTATUS
+BlMmFreeHeap (
+ _In_ PVOID Buffer
+ );
+
extern ULONG MmDescriptorCallTreeCount;
extern ULONG BlpApplicationFlags;
extern BL_LIBRARY_PARAMETERS BlpLibraryParameters;
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 21:29:41 2015
@@ -18,6 +18,8 @@
PBOOT_APPLICATION_PARAMETER_BLOCK BlpApplicationParameters;
BL_APPLICATION_ENTRY BlpApplicationEntry;
BOOLEAN BlpLibraryParametersInitialized;
+BOOLEAN EnSubsystemInitialized;
+LIST_ENTRY EnEventNotificationList;
/* FUNCTIONS *****************************************************************/
@@ -176,6 +178,52 @@
return Status;
}
+#if 0
+ /* Initialize support for Trusted Platform Module v1.2 */
+ BlpTpmInitialize();
+#endif
+
+ /* Initialize the event manager */
+ EnSubsystemInitialized = 1;
+ InitializeListHead(&EnEventNotificationList);
+
+ /* Initialize the I/O Manager */
+ Status = BlpIoInitialize();
+ if (!NT_SUCCESS(Status))
+ {
+ /* Destroy memory manager in phase 1 and the event manager */
+ EarlyPrint(L"IO init failed\n");
+ //if (EnSubsystemInitialized) BlpEnDestroy();
+ //BlpMmDestroy(1);
+ return Status;
+ }
+
+#if 0
+ /* Initialize the network stack */
+ Status = BlNetInitialize();
+ if (!NT_SUCCESS(Status))
+ {
+ /* Destroy the I/O, event, and memory managers in phase 1 */
+ BlpIoDestroy();
+ if (EnSubsystemInitialized) BlpEnDestroy();
+ BlpMmDestroy(1);
+ return Status;
+ }
+#endif
+
+ /* Initialize the utility library */
+ Status = BlUtlInitialize();
+ if (!NT_SUCCESS(Status))
+ {
+ /* Destroy the network, I/O, event, and memory managers in phase 1 */
+ //BlNetDestroy();
+ //BlpIoDestroy();
+ //if (EnSubsystemInitialized) BlpEnDestroy();
+ //BlpMmDestroy(1);
+ EarlyPrint(L"Util init failed\n");
+ return Status;
+ }
+
EarlyPrint(L"TODO!\n");
Status = STATUS_NOT_IMPLEMENTED;
Added: trunk/reactos/boot/environ/lib/io/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/io/device…
==============================================================================
--- trunk/reactos/boot/environ/lib/io/device.c (added)
+++ trunk/reactos/boot/environ/lib/io/device.c [iso-8859-1] Sun Sep 6 21:29:41 2015
@@ -0,0 +1,72 @@
+/*
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/lib/io/device.c
+ * PURPOSE: Boot Library Device Management Routines
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+typedef struct _BL_DEVICE_INFORMATION
+{
+ ULONG Unknown0;
+ ULONG Unknown1;
+ ULONG Unknown2;
+ ULONG Unknown3;
+} BL_DEVICE_INFORMATION, *PBL_DEVICE_INFORMATION;
+
+LIST_ENTRY DmRegisteredDevices;
+ULONG DmTableEntries;
+LIST_ENTRY DmRegisteredDevices;
+PVOID* DmDeviceTable;
+
+BL_DEVICE_INFORMATION DmDeviceIoInformation;
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+BlpDeviceInitialize (
+ VOID
+ )
+{
+ NTSTATUS Status;
+
+ /* Initialize the table count and list of devices */
+ DmTableEntries = 8;
+ InitializeListHead(&DmRegisteredDevices);
+
+ /* Initialize device information */
+ DmDeviceIoInformation.Unknown0 = 0;
+ DmDeviceIoInformation.Unknown1 = 0;
+ DmDeviceIoInformation.Unknown2 = 0;
+ DmDeviceIoInformation.Unknown3 = 0;
+
+ /* Allocate the device table */
+ DmDeviceTable = BlMmAllocateHeap(DmTableEntries * sizeof(PVOID));
+ if (DmDeviceTable)
+ {
+ /* Clear it */
+ RtlZeroMemory(DmDeviceTable, DmTableEntries * sizeof(PVOID));
+
+#if 0
+ /* Initialize BitLocker support */
+ Status = FvebInitialize();
+#else
+ Status = STATUS_SUCCESS;
+#endif
+ }
+ else
+ {
+ /* No memory, we'll fail */
+ Status = STATUS_NO_MEMORY;
+ }
+
+ /* Return initialization state */
+ return Status;
+}
+
Propchange: trunk/reactos/boot/environ/lib/io/device.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/boot/environ/lib/io/fat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/io/fat.c?…
==============================================================================
--- trunk/reactos/boot/environ/lib/io/fat.c (added)
+++ trunk/reactos/boot/environ/lib/io/fat.c [iso-8859-1] Sun Sep 6 21:29:41 2015
@@ -0,0 +1,51 @@
+/*
+* COPYRIGHT: See COPYING.ARM in the top level directory
+* PROJECT: ReactOS UEFI Boot Library
+* FILE: boot/environ/lib/io/fat.c
+* PURPOSE: Boot Library FAT File System Management Routines
+* PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+*/
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+PVOID* FatDeviceTable;
+ULONG FatDeviceTableEntries;
+PWCHAR FatpLongFileName;
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+FatInitialize (
+ VOID
+ )
+{
+ NTSTATUS Status;
+
+ /* Allocate the device table with 2 entries*/
+ FatDeviceTableEntries = 2;
+ FatDeviceTable = BlMmAllocateHeap(sizeof(PBL_FILE_ENTRY) *
+ FatDeviceTableEntries);
+ if (FatDeviceTable)
+ {
+ /* Zero it out */
+ RtlZeroMemory(FatDeviceTable,
+ sizeof(PBL_FILE_ENTRY) * FatDeviceTableEntries);
+
+ /* Allocate a 512 byte buffer for long file name conversion */
+ FatpLongFileName = BlMmAllocateHeap(512);
+ Status = FatpLongFileName != NULL ? STATUS_SUCCESS : STATUS_NO_MEMORY;
+ }
+ else
+ {
+ /* No memory, fail */
+ Status = STATUS_NO_MEMORY;
+ }
+
+ /* Return back to caller */
+ return Status;
+}
+
Propchange: trunk/reactos/boot/environ/lib/io/fat.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/boot/environ/lib/io/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/io/file.c…
==============================================================================
--- trunk/reactos/boot/environ/lib/io/file.c (added)
+++ trunk/reactos/boot/environ/lib/io/file.c [iso-8859-1] Sun Sep 6 21:29:41 2015
@@ -0,0 +1,174 @@
+/*
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/lib/io/file.c
+ * PURPOSE: Boot Library File Management Routines
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+PVOID* FileTable;
+ULONG FileEntries;
+
+LIST_ENTRY RegisteredFileSystems;
+BL_FILE_SYSTEM_REGISTRATION_TABLE FatRegisterFunctionTable =
+{
+ FatInitialize,
+#if 0
+ FatDestroy,
+ FatMount,
+ NULL
+#endif
+};
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+BlpFileRegisterFileSystem (
+ _In_ PBL_FS_INIT_CALLBACK InitCallback,
+ _In_ PBL_FS_DESTROY_CALLBACK DestroyCallback,
+ _In_ PBL_FS_MOUNT_CALLBACK MountCallback,
+ _In_ PBL_FS_PURGE_CALLBACK PurgeCallback,
+ _In_ ULONG Flags
+ )
+{
+ PBL_FILE_SYSTEM_ENTRY FsEntry;
+ NTSTATUS Status;
+
+ FsEntry = BlMmAllocateHeap(sizeof(*FsEntry));
+ if (!FsEntry)
+ {
+ return STATUS_NO_MEMORY;
+ }
+
+ Status = InitCallback();
+ if (NT_SUCCESS(Status))
+ {
+ BlMmFreeHeap(FsEntry);
+ return Status;
+ }
+
+ /* Register the callbacks */
+ FsEntry->MountCallback = MountCallback;
+ FsEntry->DestroyCallback = DestroyCallback;
+ FsEntry->InitCallback = InitCallback;
+ FsEntry->PurgeCallback = PurgeCallback;
+
+ /* Insert in the right location in the list */
+ if (Flags & BL_FS_REGISTER_AT_HEAD_FLAG)
+ {
+ InsertHeadList(&RegisteredFileSystems, &FsEntry->ListEntry);
+ }
+ else
+ {
+ InsertTailList(&RegisteredFileSystems, &FsEntry->ListEntry);
+ }
+
+ /* Return */
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+BlpFileInitialize (
+ VOID
+ )
+{
+ NTSTATUS Status;
+
+ /* Allocate the file table */
+ FileEntries = 16;
+ FileTable = BlMmAllocateHeap(sizeof(PBL_FILE_ENTRY) * FileEntries);
+ if (!FileTable)
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Initialize it */
+ RtlZeroMemory(FileTable, sizeof(PBL_FILE_ENTRY) * FileEntries);
+ InitializeListHead(&RegisteredFileSystems);
+
+#if 0
+ /* Initialize the network file system */
+ Status = BlpFileRegisterFileSystem(NetRegisterFunctionTable.Init,
+ NetRegisterFunctionTable.Destroy,
+ NetRegisterFunctionTable.Mount,
+ NetRegisterFunctionTable.Purge,
+ 1);
+ if (NT_SUCCESS(Status))
+ {
+ /* Initialize NTFS */
+ Status = BlpFileRegisterFileSystem(NtfsRegisterFunctionTable.Init,
+ NtfsRegisterFunctionTable.Destroy,
+ NtfsRegisterFunctionTable.Mount,
+ NtfsRegisterFunctionTable.Purge,
+ 0);
+ }
+
+ if (NT_SUCCESS(Status))
+#endif
+ {
+ /* Initialize FAT */
+ Status = BlpFileRegisterFileSystem(FatRegisterFunctionTable.Init,
+ FatRegisterFunctionTable.Destroy,
+ FatRegisterFunctionTable.Mount,
+ FatRegisterFunctionTable.Purge,
+ 0);
+ }
+
+#if 0
+ if (NT_SUCCESS(Status))
+ {
+ /* Initialize EXFAT (FatPlus) */
+ Status = BlpFileRegisterFileSystem(FppRegisterFunctionTable.Init,
+ FppRegisterFunctionTable.Destroy,
+ FppRegisterFunctionTable.Mount,
+ FppRegisterFunctionTable.Purge,
+ 0);
+ }
+
+ if (NT_SUCCESS(Status))
+ {
+ /* Initialize WIM */
+ Status = BlpFileRegisterFileSystem(WimRegisterFunctionTable.Init,
+ WimRegisterFunctionTable.Destroy,
+ WimRegisterFunctionTable.Mount,
+ WimRegisterFunctionTable.Purge,
+ 0);
+ }
+
+ if (NT_SUCCESS(Status))
+ {
+ /* Initialize UDFS */
+ Status = BlpFileRegisterFileSystem(UdfsRegisterFunctionTable.Init,
+ UdfsRegisterFunctionTable.Destroy,
+ UdfsRegisterFunctionTable.Mount,
+ UdfsRegisterFunctionTable.Purge,
+ 0);
+ }
+
+ if (NT_SUCCESS(Status))
+ {
+ /* Initialize El-Torito CDFS */
+ Status = BlpFileRegisterFileSystem(EtfsRegisterFunctionTable.Init,
+ EtfsRegisterFunctionTable.Destroy,
+ EtfsRegisterFunctionTable.Mount,
+ EtfsRegisterFunctionTable.Purge,
+ 0);
+ }
+#endif
+
+ /* Destroy the file manager if any of the file systems didn't initialize */
+ if (!NT_SUCCESS(Status))
+ {
+ if (FileTable)
+ {
+ //BlpFileDestroy();
+ }
+ }
+ return Status;
+}
Propchange: trunk/reactos/boot/environ/lib/io/file.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/boot/environ/lib/io/io.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/io/io.c?r…
==============================================================================
--- trunk/reactos/boot/environ/lib/io/io.c (added)
+++ trunk/reactos/boot/environ/lib/io/io.c [iso-8859-1] Sun Sep 6 21:29:41 2015
@@ -0,0 +1,56 @@
+/*
+ * COPYRIGHT: See COPYING.ARM in the top level directory
+ * PROJECT: ReactOS UEFI Boot Library
+ * FILE: boot/environ/lib/io/io.c
+ * PURPOSE: Boot Library I/O Management Routines
+ * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+ULONG IoMgrRoutineEntries;
+PVOID* IoMgrDestroyRoutineTable;
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+BlpIoInitialize (
+ VOID
+ )
+{
+ NTSTATUS Status;
+ ULONG Size;
+
+ /* Allocate the I/O table */
+ IoMgrRoutineEntries = 4;
+ Size = IoMgrRoutineEntries * sizeof(PVOID);
+ IoMgrDestroyRoutineTable = BlMmAllocateHeap(Size);
+ if (IoMgrDestroyRoutineTable)
+ {
+ /* Zero it out */
+ RtlZeroMemory(IoMgrDestroyRoutineTable, Size);
+
+ /* Initialize the device manager */
+ Status = BlpDeviceInitialize();
+
+ /* Initialize the file manager */
+ if (NT_SUCCESS(Status))
+ {
+ Status = BlpFileInitialize();
+ }
+ }
+ else
+ {
+ /* No memory */
+ Status = STATUS_NO_MEMORY;
+ }
+
+ /* Return initialization status */
+ return Status;
+}
+
+
Propchange: trunk/reactos/boot/environ/lib/io/io.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/boot/environ/lib/misc/util.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/util…
==============================================================================
--- trunk/reactos/boot/environ/lib/misc/util.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/misc/util.c [iso-8859-1] Sun Sep 6 21:29:41 2015
@@ -9,6 +9,24 @@
/* INCLUDES ******************************************************************/
#include "bl.h"
+
+/* DATA VARIABLES ************************************************************/
+
+PVOID UtlRsdt;
+PVOID UtlXsdt;
+
+PVOID UtlMcContext;
+PVOID UtlMcDisplayMessageRoutine;
+PVOID UtlMcUpdateMessageRoutine;
+
+PVOID UtlProgressRoutine;
+PVOID UtlProgressContext;
+PVOID UtlProgressInfoRoutine;
+ULONG UtlProgressGranularity;
+ULONG UtlCurrentPercentComplete;
+ULONG UtlNextUpdatePercentage;
+BOOLEAN UtlProgressNeedsInfoUpdate;
+PVOID UtlProgressInfo;
/* FUNCTIONS *****************************************************************/
@@ -146,3 +164,26 @@
}
}
+NTSTATUS
+BlUtlInitialize (
+ VOID
+ )
+{
+ UtlRsdt = 0;
+ UtlXsdt = 0;
+
+ UtlMcContext = 0;
+ UtlMcDisplayMessageRoutine = 0;
+ UtlMcUpdateMessageRoutine = 0;
+
+ UtlProgressRoutine = 0;
+ UtlProgressContext = 0;
+ UtlProgressInfoRoutine = 0;
+ UtlProgressGranularity = 0;
+ UtlCurrentPercentComplete = 0;
+ UtlNextUpdatePercentage = 0;
+ UtlProgressNeedsInfoUpdate = 0;
+ UtlProgressInfo = 0;
+
+ return STATUS_SUCCESS;
+}
Modified: trunk/reactos/boot/environ/lib/platform/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/platform/…
==============================================================================
--- trunk/reactos/boot/environ/lib/platform/time.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/platform/time.c [iso-8859-1] Sun Sep 6 21:29:41 2015
@@ -13,6 +13,8 @@
/* DATA VARIABLES ************************************************************/
ULONGLONG BlpTimePerformanceFrequency;
+
+/* FUNCTIONS *****************************************************************/
NTSTATUS
BlpTimeMeasureTscFrequency (