Implement MmAllocateProcessorStructures() routine as a temporary hack to get a buffer for AP initialization

This commit is contained in:
2024-05-07 23:30:11 +02:00
parent 8d6d27651c
commit b65ff2a767
6 changed files with 85 additions and 0 deletions

View File

@@ -26,3 +26,6 @@ LOADER_MEMORY_MAPPING MmOldFreeDescriptor;
/* Page Map Level */
ULONG MmPageMapLevel;
/* Processor structures data (THIS IS A TEMPORARY HACK) */
UCHAR MmProcessorStructuresData[MAXIMUM_PROCESSORS - 1][KPROCESSOR_STRUCTURES_SIZE] = {0};

View File

@@ -35,6 +35,51 @@ MmAllocateKernelStack(IN PVOID *Stack,
return STATUS_NOT_IMPLEMENTED;
}
/**
* Allocates a buffer for structures needed by a processor and assigns it to a corresponding CPU.
*
* @param CpuNumber
* Specifies the zero-indexed CPU number as an owner of the allocated structures.
*
* @param StructuresData
* Supplies a pointer to the memory area that will contain the allocated buffer.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTAPI
XTSTATUS
MmAllocateProcessorStructures(IN ULONG CpuNumber,
OUT PVOID *StructuresData)
{
PKPROCESSOR_BLOCK ProcessorBlock;
PVOID ProcessorStructures;
UINT_PTR Address;
/* Not implemented yet, this is just a hack */
UNIMPLEMENTED;
/* Assign memory for processor structures from preallocated buffer */
ProcessorStructures = &MmProcessorStructuresData[CpuNumber - 1];
/* Make sure all structures are zeroed */
RtlZeroMemory(ProcessorStructures, KPROCESSOR_STRUCTURES_SIZE);
/* Align address to page size boundary and find a space for processor block */
Address = ROUND_UP((UINT_PTR)ProcessorStructures, MM_PAGE_SIZE);
ProcessorBlock = (PKPROCESSOR_BLOCK)((PUCHAR)Address + (2 * KERNEL_STACK_SIZE) + sizeof(ArInitialGdt));
/* Store processor number in the processor block */
ProcessorBlock->CpuNumber = CpuNumber;
/* Return pointer to the processor structures */
*StructuresData = ProcessorStructures;
/* Return success */
return STATUS_SUCCESS;
}
/**
* Destroys a kernel stack and frees page table entry.
*
@@ -55,3 +100,20 @@ MmFreeKernelStack(IN PVOID Stack,
{
UNIMPLEMENTED;
}
/**
* Destroys an unused set of processor structures.
*
* @param StructuresData
* Supplies a pointer to the memory area containing the allocated buffer.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
MmFreeProcessorStructures(IN PVOID StructuresData)
{
UNIMPLEMENTED;
}