Author: fireball
Date: Mon Dec 10 01:57:40 2007
New Revision: 31116
URL: http://svn.reactos.org/svn/reactos?rev=31116&view=rev
Log:
- Because we'll need to pass the ARC hardware information to the kernel, we need to use the usual FreeLDR trick of using a static buffer where to store the data instead of allocating memory. But, unlike our other data, this kind of information is variably-sized, and it's not possible to make arrays of arrays and start assuming upper bounds. Therefore, give us a large 16KB stash buffer, and implement a very simple array-based heap allocator so that all the ARC hardware memory will be contiguous and static as the kernel will expect it.
- Copy all configuration data, identifiers and other data passed to the arc hardware routines into a new location. This is because the caller will free this information, and we want to keep it in memory. We also want it to be contiguous and part of our stash buffer, so allocate the copies from the stash buffer described above.
- Store the root of the hardware tree in the ArchExtra ReactOS Loader Parameter Block, the kernel's freeldr->ntldr conversion routines will later deal with this data.
Modified:
trunk/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h
trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c
trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h Mon Dec 10 01:57:40 2007
@@ -27,6 +27,13 @@
#define CONFIG_CMD(bus, dev_fn, where) \
(0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
+
+
+//
+// Static heap for ARC Hardware Component Tree
+// 16KB oughta be enough for anyone.
+//
+#define HW_MAX_ARC_HEAP_SIZE 16 * 1024
//
// ARC Component Configuration Routines
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c Mon Dec 10 01:57:40 2007
@@ -14,9 +14,28 @@
/* GLOBALS ********************************************************************/
+extern CHAR reactos_arc_hardware_data[];
+ULONG FldrpHwHeapLocation;
PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot;
/* FUNCTIONS ******************************************************************/
+
+PVOID
+NTAPI
+FldrpHwHeapAlloc(IN ULONG Size)
+{
+ PVOID Buffer;
+
+ /* Return a block of memory from the ARC Hardware Heap */
+ Buffer = &reactos_arc_hardware_data[FldrpHwHeapLocation];
+
+ /* Increment the heap location */
+ FldrpHwHeapLocation += Size;
+ if (FldrpHwHeapLocation > HW_MAX_ARC_HEAP_SIZE) Buffer = NULL;
+
+ /* Return the buffer */
+ return Buffer;
+}
VOID
NTAPI
@@ -51,21 +70,31 @@
VOID
NTAPI
FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
- IN PWCHAR Identifier)
-{
- LONG Error;
- ULONG IdentifierLength = (wcslen(Identifier) + 1) * sizeof(WCHAR);
+ IN PWCHAR IdentifierString)
+{
+ LONG Error;
+ ULONG IdentifierLength;
PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry;
+ PCHAR Identifier;
+
+ /* Allocate memory for the identifier */
+ /* WARNING: This should be ASCII data */
+ IdentifierLength = (wcslen(IdentifierString) + 1) * sizeof(WCHAR);
+ Identifier = FldrpHwHeapAlloc(IdentifierLength);
+ if (!Identifier) return;
+
+ /* Copy the identifier */
+ RtlCopyMemory(Identifier, IdentifierString, IdentifierLength);
/* Set component information */
Component->IdentifierLength = IdentifierLength;
- Component->Identifier = (PCHAR)Identifier; // We need to use ASCII instead
+ Component->Identifier = Identifier;
/* Set the key */
Error = RegSetValue((FRLDRHKEY)Component->Key,
L"Identifier",
REG_SZ,
- (PCHAR)Identifier,
+ (PCHAR)IdentifierString,
IdentifierLength);
if (Error != ERROR_SUCCESS)
{
@@ -82,7 +111,7 @@
PCONFIGURATION_COMPONENT Component;
/* Allocate the root */
- FldrArcHwTreeRoot = MmAllocateMemory(sizeof(CONFIGURATION_COMPONENT_DATA));
+ FldrArcHwTreeRoot = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA));
if (!FldrArcHwTreeRoot) return;
/* Set it up */
@@ -125,7 +154,7 @@
PCONFIGURATION_COMPONENT Component;
/* Allocate the node for this component */
- ComponentData = MmAllocateMemory(sizeof(CONFIGURATION_COMPONENT_DATA));
+ ComponentData = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA));
if (!ComponentData) return;
/* Now save our parent */
@@ -168,21 +197,29 @@
VOID
NTAPI
FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
- IN PVOID ConfigurationData,
+ IN PVOID Data,
IN ULONG Size)
{
LONG Error;
PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry;
-
+ PVOID ConfigurationData;
+
+ /* Allocate a buffer from the hardware heap */
+ ConfigurationData = FldrpHwHeapAlloc(Size);
+ if (!ConfigurationData) return;
+
+ /* Copy component information */
+ RtlCopyMemory(ConfigurationData, Data, Size);
+
/* Set component information */
ComponentData->ConfigurationData = ConfigurationData;
Component->ConfigurationDataLength = Size;
-
+
/* Set 'Configuration Data' value */
Error = RegSetValue((FRLDRHKEY)Component->Key,
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- ConfigurationData,
+ Data,
Size);
if (Error != ERROR_SUCCESS)
{
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c Mon Dec 10 01:57:40 2007
@@ -35,6 +35,8 @@
ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information
char reactos_arc_strings[32][256];
unsigned long reactos_disk_count = 0;
+char reactos_arc_hardware_data[HW_MAX_ARC_HEAP_SIZE] = {0};
+
CHAR szHalName[255];
CHAR szBootPath[255];
CHAR SystemRoot[255];
@@ -601,6 +603,7 @@
LoaderBlock.ModsCount = 0;
LoaderBlock.ModsAddr = reactos_modules;
LoaderBlock.DrivesAddr = reactos_arc_disk_info;
+ LoaderBlock.ArchExtra = (ULONG)reactos_arc_hardware_data;
LoaderBlock.MmapLength = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)reactos_memory_map, 32) * sizeof(memory_map_t);
if (LoaderBlock.MmapLength)
{
Author: fireball
Date: Sun Dec 9 22:36:04 2007
New Revision: 31112
URL: http://svn.reactos.org/svn/reactos?rev=31112&view=rev
Log:
- Our NtCreateKey currently allows building trees (which is incorrect) if the parent key is a symbolic link (which does exist), but if the target doesn't exist (Since the check 'does parent exist' is done Before the symlink is converted to its target. One side-effect is that although we create the CurrentControlSet symlink to ControlSet001, we never create ControlSet001. We end up creating it later during the boot by creating a sub-key, by exposing the bug in NtCreateKey. Since the new NtCreateKey uses the new parse routine code and doesn't exhibit this bug, we have to create ControlSet001 manually to avoid a failure. Other bugs of this nature may exist. Bug found and fixed by Alex.
- Implement the last bit of the new parse routine (creating children) and write a new version of NtCreateKey which uses the parse routine. Disable it for now until other latent bugs are fixed.
Modified:
trunk/reactos/ntoskrnl/config/cm.h
trunk/reactos/ntoskrnl/config/cmparse.c
trunk/reactos/ntoskrnl/config/cmsysini.c
trunk/reactos/ntoskrnl/config/ntapi.c
Modified: trunk/reactos/ntoskrnl/config/cm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cm.h (original)
+++ trunk/reactos/ntoskrnl/config/cm.h Sun Dec 9 22:36:04 2007
@@ -495,15 +495,6 @@
//
// BUGBUG Old Hive Stuff for Temporary Support
//
-NTSTATUS
-NTAPI
-CmFindObject(POBJECT_CREATE_INFORMATION ObjectCreateInfo,
- PUNICODE_STRING ObjectName,
- PVOID* ReturnedObject,
- PUNICODE_STRING RemainingPath,
- POBJECT_TYPE ObjectType,
- IN PACCESS_STATE AccessState,
- IN PVOID ParseContext);
NTSTATUS CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1, IN PVOID Argument2);
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/reactos/ntoskrnl/config/cmparse.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmparse.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmparse.c (original)
+++ trunk/reactos/ntoskrnl/config/cmparse.c Sun Dec 9 22:36:04 2007
@@ -1077,7 +1077,7 @@
while (TRUE)
{
/* Get the next component */
- Result = CmpGetNextName(&Current, &NextName, &Last);
+ Result = CmpGetNextName(&Current, &NextName, &Last);
if ((Result) && (NextName.Length))
{
/* See if this is a sym link */
@@ -1184,9 +1184,15 @@
}
else
{
- /* Create: should not see this (yet) */
- DPRINT1("Unexpected: Creating new child\n");
- while (TRUE);
+ /* Do the create */
+ Status = CmpDoCreate(Hive,
+ Cell,
+ AccessState,
+ &NextName,
+ AccessMode,
+ ParseContext,
+ ParentKcb,
+ Object);
}
/* Check for reparse (in this case, someone beat us) */
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c Sun Dec 9 22:36:04 2007
@@ -363,6 +363,26 @@
/* ReactOS Hack: Hard-code current to 001 for SetupLdr */
if (!LoaderBlock->RegistryBase)
{
+ /* Build the ControlSet001 key */
+ RtlInitUnicodeString(&KeyName,
+ L"\\Registry\\Machine\\System\\ControlSet001");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+ Status = NtCreateKey(&KeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ 0,
+ &Disposition);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /* Don't need the handle */
+ ZwClose(KeyHandle);
+
/* Use hard-coded setting */
ControlSet = 1;
goto UseSet;
@@ -396,7 +416,6 @@
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
-
Status = NtCreateKey(&KeyHandle,
KEY_CREATE_LINK,
&ObjectAttributes,
Modified: trunk/reactos/ntoskrnl/config/ntapi.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/ntapi.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/config/ntapi.c (original)
+++ trunk/reactos/ntoskrnl/config/ntapi.c Sun Dec 9 22:36:04 2007
@@ -17,6 +17,42 @@
BOOLEAN CmFirstTime = TRUE;
/* FUNCTIONS *****************************************************************/
+
+#if 0
+NTSTATUS
+NTAPI
+NtCreateKey(OUT PHANDLE KeyHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes,
+ IN ULONG TitleIndex,
+ IN PUNICODE_STRING Class,
+ IN ULONG CreateOptions,
+ OUT PULONG Disposition)
+{
+ NTSTATUS Status;
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ CM_PARSE_CONTEXT ParseContext = {0};
+ PAGED_CODE();
+
+ /* Setup the parse context */
+ ParseContext.CreateOperation = TRUE;
+ ParseContext.CreateOptions = CreateOptions;
+ if (Class) ParseContext.Class = *Class;
+
+ /* Do the create */
+ Status = ObOpenObjectByName(ObjectAttributes,
+ CmpKeyObjectType,
+ PreviousMode,
+ NULL,
+ DesiredAccess,
+ &ParseContext,
+ KeyHandle);
+
+ /* Return data to user */
+ if (Disposition) *Disposition = ParseContext.Disposition;
+ return Status;
+}
+#endif
NTSTATUS
NTAPI