Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenarchwsup.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Boot Loader (FreeLDR) 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: boot/freeldr/freeldr/reactos/archwsup.c 00005 * PURPOSE: Routines for ARC Hardware Tree and Configuration Data 00006 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include <freeldr.h> 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 /* GLOBALS ********************************************************************/ 00016 00017 extern CHAR reactos_arc_hardware_data[]; 00018 SIZE_T FldrpHwHeapLocation; 00019 PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot; 00020 00021 BOOLEAN UseRealHeap = FALSE; 00022 00023 VOID 00024 NTAPI 00025 FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData, 00026 IN PCM_PARTIAL_RESOURCE_LIST ResourceList, 00027 IN ULONG Size); 00028 00029 /* FUNCTIONS ******************************************************************/ 00030 00031 PVOID 00032 NTAPI 00033 FldrpHwHeapAlloc(IN SIZE_T Size) 00034 { 00035 PVOID Buffer; 00036 00037 if (UseRealHeap) 00038 { 00039 /* Allocate memory from generic bootloader heap */ 00040 Buffer = MmHeapAlloc(Size); 00041 } 00042 else 00043 { 00044 /* Return a block of memory from the ARC Hardware Heap */ 00045 Buffer = &reactos_arc_hardware_data[FldrpHwHeapLocation]; 00046 00047 /* Increment the heap location */ 00048 FldrpHwHeapLocation += Size; 00049 if (FldrpHwHeapLocation > HW_MAX_ARC_HEAP_SIZE) Buffer = NULL; 00050 } 00051 00052 /* Clear it */ 00053 if (Buffer) 00054 RtlZeroMemory(Buffer, Size); 00055 00056 /* Return the buffer */ 00057 return Buffer; 00058 } 00059 00060 VOID 00061 NTAPI 00062 FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData, 00063 IN PCHAR IdentifierString) 00064 { 00065 SIZE_T IdentifierLength; 00066 PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry; 00067 PCHAR Identifier; 00068 00069 /* Allocate memory for the identifier */ 00070 IdentifierLength = strlen(IdentifierString) + 1; 00071 Identifier = FldrpHwHeapAlloc(IdentifierLength); 00072 if (!Identifier) return; 00073 00074 /* Copy the identifier */ 00075 RtlCopyMemory(Identifier, IdentifierString, IdentifierLength); 00076 00077 /* Set component information */ 00078 Component->IdentifierLength = (ULONG)IdentifierLength; 00079 Component->Identifier = Identifier; 00080 } 00081 00082 VOID 00083 NTAPI 00084 FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode) 00085 { 00086 PCONFIGURATION_COMPONENT Component; 00087 00088 /* Allocate the root */ 00089 FldrArcHwTreeRoot = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA)); 00090 if (!FldrArcHwTreeRoot) return; 00091 00092 /* Set it up */ 00093 Component = &FldrArcHwTreeRoot->ComponentEntry; 00094 Component->Class = SystemClass; 00095 Component->Type = MaximumType; 00096 Component->ConfigurationDataLength = 0; 00097 Component->Identifier = 0; 00098 Component->IdentifierLength = 0; 00099 Component->Flags = 0; 00100 Component->Version = 0; 00101 Component->Revision = 0; 00102 Component->Key = 0; 00103 Component->AffinityMask = 0xFFFFFFFF; 00104 00105 /* Return the node */ 00106 *SystemNode = FldrArcHwTreeRoot; 00107 } 00108 00109 VOID 00110 NTAPI 00111 FldrLinkToParent(IN PCONFIGURATION_COMPONENT_DATA Parent, 00112 IN PCONFIGURATION_COMPONENT_DATA Child) 00113 { 00114 PCONFIGURATION_COMPONENT_DATA Sibling; 00115 00116 /* Get the first sibling */ 00117 Sibling = Parent->Child; 00118 00119 /* If no sibling exists, then we are the first child */ 00120 if (!Sibling) 00121 { 00122 /* Link us in */ 00123 Parent->Child = Child; 00124 } 00125 else 00126 { 00127 /* Loop each sibling */ 00128 do 00129 { 00130 /* This is now the parent */ 00131 Parent = Sibling; 00132 } while ((Sibling = Sibling->Sibling)); 00133 00134 /* Found the lowest sibling; mark us as its sibling too */ 00135 Parent->Sibling = Child; 00136 } 00137 } 00138 00139 VOID 00140 NTAPI 00141 FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode, 00142 IN CONFIGURATION_CLASS Class, 00143 IN CONFIGURATION_TYPE Type, 00144 IN IDENTIFIER_FLAG Flags, 00145 IN ULONG Key, 00146 IN ULONG Affinity, 00147 IN PCHAR IdentifierString, 00148 IN PCM_PARTIAL_RESOURCE_LIST ResourceList, 00149 IN ULONG Size, 00150 OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey) 00151 { 00152 PCONFIGURATION_COMPONENT_DATA ComponentData; 00153 PCONFIGURATION_COMPONENT Component; 00154 00155 /* Allocate the node for this component */ 00156 ComponentData = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA)); 00157 if (!ComponentData) return; 00158 00159 /* Now save our parent */ 00160 ComponentData->Parent = SystemNode; 00161 00162 /* Link us to the parent */ 00163 if (SystemNode) 00164 FldrLinkToParent(SystemNode, ComponentData); 00165 00166 /* Set us up */ 00167 Component = &ComponentData->ComponentEntry; 00168 Component->Class = Class; 00169 Component->Type = Type; 00170 Component->Flags = Flags; 00171 Component->Key = Key; 00172 Component->AffinityMask = Affinity; 00173 00174 /* Set identifier */ 00175 if (IdentifierString) 00176 FldrSetIdentifier(ComponentData, IdentifierString); 00177 00178 /* Set configuration data */ 00179 if (ResourceList) 00180 FldrSetConfigurationData(ComponentData, ResourceList, Size); 00181 00182 /* Return the child */ 00183 *ComponentKey = ComponentData; 00184 } 00185 00186 VOID 00187 NTAPI 00188 FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData, 00189 IN PCM_PARTIAL_RESOURCE_LIST ResourceList, 00190 IN ULONG Size) 00191 { 00192 PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry; 00193 PVOID ConfigurationData; 00194 00195 /* Allocate a buffer from the hardware heap */ 00196 ConfigurationData = FldrpHwHeapAlloc(Size); 00197 if (!ConfigurationData) return; 00198 00199 /* Copy component information */ 00200 RtlCopyMemory(ConfigurationData, ResourceList, Size); 00201 00202 /* Set component information */ 00203 ComponentData->ConfigurationData = ConfigurationData; 00204 Component->ConfigurationDataLength = Size; 00205 } Generated on Sun May 27 2012 04:19:17 for ReactOS by
1.7.6.1
|