Author: pschweitzer
Date: Sun Jun 14 15:52:28 2015
New Revision: 68136
URL:
http://svn.reactos.org/svn/reactos?rev=68136&view=rev
Log:
[KERNEL32]
Implement GetNumaHighestNodeNumber()
Implement GetNumaNodeProcessorMask()
Implement GetNumaProcessorNode()
Implement GetNumaAvailableMemoryNode()
They won't work yet though, given that the kernel mode counterpart is still
unimplemented.
CORE-9680
Modified:
trunk/reactos/dll/win32/kernel32/client/sysinfo.c
Modified: trunk/reactos/dll/win32/kernel32/client/sysinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/sysinfo.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/sysinfo.c [iso-8859-1] Sun Jun 14 15:52:28
2015
@@ -211,50 +211,160 @@
}
/*
- * @unimplemented
+ * @implemented
*/
BOOL
WINAPI
GetNumaHighestNodeNumber(OUT PULONG HighestNodeNumber)
{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
+ NTSTATUS Status;
+ ULONG Length;
+ ULONG PartialInfo[2]; // First two members of SYSTEM_NUMA_INFORMATION
+
+ /* Query partial NUMA info */
+ Status = NtQuerySystemInformation(SystemNumaProcessorMap,
+ PartialInfo,
+ sizeof(PartialInfo),
+ &Length);
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ if (Length < sizeof(ULONG))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ /* First member of the struct is the highest node number */
+ *HighestNodeNumber = PartialInfo[0];
+ return TRUE;
+}
+
+/*
+ * @implemented
*/
BOOL
WINAPI
GetNumaNodeProcessorMask(IN UCHAR Node,
OUT PULONGLONG ProcessorMask)
{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
+ NTSTATUS Status;
+ SYSTEM_NUMA_INFORMATION NumaInformation;
+ ULONG Length;
+
+ /* Query NUMA information */
+ Status = NtQuerySystemInformation(SystemNumaProcessorMap,
+ &NumaInformation,
+ sizeof(NumaInformation),
+ &Length);
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ /* Validate input node number */
+ if (Node > NumaInformation.HighestNodeNumber)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ /* Return mask for that node */
+ *ProcessorMask = NumaInformation.ActiveProcessorsAffinityMask[Node];
+ return TRUE;
+}
+
+/*
+ * @implemented
*/
BOOL
WINAPI
GetNumaProcessorNode(IN UCHAR Processor,
OUT PUCHAR NodeNumber)
{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
+ NTSTATUS Status;
+ SYSTEM_NUMA_INFORMATION NumaInformation;
+ ULONG Length;
+ ULONG Node;
+ ULONGLONG Proc;
+
+ /* Can't handle processor number >= 32 */
+ if (Processor >= 0x20)
+ {
+ *NodeNumber = -1;
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ /* Query NUMA information */
+ Status = NtQuerySystemInformation(SystemNumaProcessorMap,
+ &NumaInformation,
+ sizeof(NumaInformation),
+ &Length);
+ if (!NT_SUCCESS(Status))
+ {
+ *NodeNumber = -1;
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ /* Find ourselves */
+ Node = 0;
+ Proc = (1ULL << Processor) >> 0x20;
+ while ((Proc & NumaInformation.ActiveProcessorsAffinityMask[Node]) == 0ULL)
+ {
+ ++Node;
+ /* Out of options */
+ if (Node > NumaInformation.HighestNodeNumber)
+ {
+ *NodeNumber = -1;
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ }
+
+ /* Return found node */
+ *NodeNumber = Node;
+ return TRUE;
+}
+
+/*
+ * @implemented
*/
BOOL
WINAPI
GetNumaAvailableMemoryNode(IN UCHAR Node,
OUT PULONGLONG AvailableBytes)
{
- STUB;
- return FALSE;
+ NTSTATUS Status;
+ SYSTEM_NUMA_INFORMATION NumaInformation;
+ ULONG Length;
+
+ /* Query NUMA information */
+ Status = NtQuerySystemInformation(SystemNumaAvailableMemory,
+ &NumaInformation,
+ sizeof(NumaInformation),
+ &Length);
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ /* Validate input node number */
+ if (Node > NumaInformation.HighestNodeNumber)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ /* Return available memory for that node */
+ *AvailableBytes = NumaInformation.AvailableMemory[Node];
+ return TRUE;
}
/*