xref: /reactos/boot/environ/lib/io/io.c (revision c2c66aff)
1 /*
2  * COPYRIGHT:       See COPYING.ARM in the top level directory
3  * PROJECT:         ReactOS UEFI Boot Library
4  * FILE:            boot/environ/lib/io/io.c
5  * PURPOSE:         Boot Library I/O Management Routines
6  * PROGRAMMER:      Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include "bl.h"
12 
13 /* DATA VARIABLES ************************************************************/
14 
15 ULONG IoMgrRoutineEntries;
16 PVOID* IoMgrDestroyRoutineTable;
17 
18 /* FUNCTIONS *****************************************************************/
19 
20 NTSTATUS
BlpIoRegisterDestroyRoutine(_In_ PBL_IO_DESTROY_ROUTINE DestroyRoutine)21 BlpIoRegisterDestroyRoutine (
22     _In_ PBL_IO_DESTROY_ROUTINE DestroyRoutine
23     )
24 {
25     ULONG Id;
26 
27     return BlTblSetEntry(&IoMgrDestroyRoutineTable,
28                          &IoMgrRoutineEntries,
29                          DestroyRoutine,
30                          &Id,
31                          TblDoNotPurgeEntry);
32 }
33 
34 NTSTATUS
BlpIoInitialize(VOID)35 BlpIoInitialize (
36     VOID
37     )
38 {
39     NTSTATUS Status;
40     ULONG Size;
41 
42     /* Allocate the I/O table */
43     IoMgrRoutineEntries = 4;
44     Size = IoMgrRoutineEntries * sizeof(PVOID);
45     IoMgrDestroyRoutineTable = BlMmAllocateHeap(Size);
46     if (IoMgrDestroyRoutineTable)
47     {
48         /* Zero it out */
49         RtlZeroMemory(IoMgrDestroyRoutineTable, Size);
50 
51         /* Initialize the device manager */
52         Status = BlpDeviceInitialize();
53 
54         /* Initialize the file manager */
55         if (NT_SUCCESS(Status))
56         {
57             Status = BlpFileInitialize();
58         }
59     }
60     else
61     {
62         /* No memory */
63         Status = STATUS_NO_MEMORY;
64     }
65 
66     /* Return initialization status */
67     return Status;
68 }
69 
70 
71