mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
Automagically select computer type (UP/MP) during first stage setup
svn path=/trunk/; revision=17929
This commit is contained in:
parent
f1ee99f91a
commit
243b1fc88f
2 changed files with 134 additions and 3 deletions
|
@ -52,6 +52,11 @@ DefaultLayout = 00000409
|
||||||
pci_up = "Standard-PC"
|
pci_up = "Standard-PC"
|
||||||
pci_mp = "Standard-PC Multiprocessor"
|
pci_mp = "Standard-PC Multiprocessor"
|
||||||
|
|
||||||
|
[Map.Computer]
|
||||||
|
;<id> = <pnp id string>
|
||||||
|
pci_up = "PC UP"
|
||||||
|
pci_mp = "PC MP"
|
||||||
|
|
||||||
[Files.pci_up]
|
[Files.pci_up]
|
||||||
; <filename> = <directory_id>,<new name>
|
; <filename> = <directory_id>,<new name>
|
||||||
hal.dll = 2
|
hal.dll = 2
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id$
|
/* COPYRIGHT: See COPYING in the top level directory
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS text-mode setup
|
* PROJECT: ReactOS text-mode setup
|
||||||
* FILE: subsys/system/usetup/settings.c
|
* FILE: subsys/system/usetup/settings.c
|
||||||
* PURPOSE: Device settings support functions
|
* PURPOSE: Device settings support functions
|
||||||
|
@ -33,6 +32,90 @@
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
static BOOLEAN
|
||||||
|
GetComputerIdentifier(PWSTR Identifier,
|
||||||
|
ULONG IdentifierLength)
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
UNICODE_STRING KeyName;
|
||||||
|
LPCWSTR ComputerIdentifier;
|
||||||
|
HANDLE ProcessorsKey;
|
||||||
|
PKEY_FULL_INFORMATION pFullInfo;
|
||||||
|
ULONG Size, SizeNeeded;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("GetComputerIdentifier() called\n");
|
||||||
|
|
||||||
|
Size = sizeof(KEY_FULL_INFORMATION);
|
||||||
|
pFullInfo = (PKEY_FULL_INFORMATION)RtlAllocateHeap(RtlGetProcessHeap(), 0, Size);
|
||||||
|
if (!pFullInfo)
|
||||||
|
{
|
||||||
|
DPRINT("RtlAllocateHeap() failed\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open the processors key */
|
||||||
|
RtlInitUnicodeString(&KeyName,
|
||||||
|
L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor");
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = NtOpenKey(&ProcessorsKey,
|
||||||
|
KEY_QUERY_VALUE ,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("NtOpenKey() failed (Status 0x%lx)\n", Status);
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pFullInfo);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get number of subkeys */
|
||||||
|
Status = NtQueryKey(
|
||||||
|
ProcessorsKey,
|
||||||
|
KeyFullInformation,
|
||||||
|
pFullInfo,
|
||||||
|
Size,
|
||||||
|
&Size);
|
||||||
|
NtClose(ProcessorsKey);
|
||||||
|
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW)
|
||||||
|
{
|
||||||
|
DPRINT("NtQueryKey() failed (Status 0x%lx)\n", Status);
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pFullInfo);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find computer identifier */
|
||||||
|
if (pFullInfo->SubKeys == 0)
|
||||||
|
{
|
||||||
|
/* Something strange happened. No processor detected */
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pFullInfo);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pFullInfo->SubKeys == 1)
|
||||||
|
{
|
||||||
|
/* Computer is mono-CPU */
|
||||||
|
ComputerIdentifier = L"PC UP";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Computer is multi-CPUs */
|
||||||
|
ComputerIdentifier = L"PC MP";
|
||||||
|
}
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pFullInfo);
|
||||||
|
|
||||||
|
/* Copy computer identifier to return buffer */
|
||||||
|
SizeNeeded = (wcslen(ComputerIdentifier) + 1) * sizeof(WCHAR);
|
||||||
|
if (SizeNeeded > IdentifierLength)
|
||||||
|
return FALSE;
|
||||||
|
RtlCopyMemory(Identifier, ComputerIdentifier, SizeNeeded);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PGENERIC_LIST
|
PGENERIC_LIST
|
||||||
CreateComputerTypeList(HINF InfFile)
|
CreateComputerTypeList(HINF InfFile)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +125,48 @@ CreateComputerTypeList(HINF InfFile)
|
||||||
PWCHAR KeyName;
|
PWCHAR KeyName;
|
||||||
PWCHAR KeyValue;
|
PWCHAR KeyValue;
|
||||||
PWCHAR UserData;
|
PWCHAR UserData;
|
||||||
|
WCHAR ComputerIdentifier[128];
|
||||||
|
WCHAR ComputerKey[32];
|
||||||
|
|
||||||
|
/* Get the computer identification */
|
||||||
|
if (!GetComputerIdentifier(ComputerIdentifier, 128))
|
||||||
|
{
|
||||||
|
ComputerIdentifier[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("Computer identifier: '%S'\n", ComputerIdentifier);
|
||||||
|
|
||||||
|
/* Search for matching device identifier */
|
||||||
|
if (!InfFindFirstLine(InfFile, L"Map.Computer", NULL, &Context))
|
||||||
|
{
|
||||||
|
/* FIXME: error message */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!InfGetDataField(&Context, 1, &KeyValue))
|
||||||
|
{
|
||||||
|
/* FIXME: Handle error! */
|
||||||
|
DPRINT("InfGetDataField() failed\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("KeyValue: %S\n", KeyValue);
|
||||||
|
if (wcsstr(ComputerIdentifier, KeyValue))
|
||||||
|
{
|
||||||
|
if (!InfGetDataField(&Context, 0, &KeyName))
|
||||||
|
{
|
||||||
|
/* FIXME: Handle error! */
|
||||||
|
DPRINT("InfGetDataField() failed\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("Computer key: %S\n", KeyName);
|
||||||
|
wcscpy(ComputerKey, KeyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (InfFindNextLine(&Context, &Context));
|
||||||
|
|
||||||
List = CreateGenericList();
|
List = CreateGenericList();
|
||||||
if (List == NULL)
|
if (List == NULL)
|
||||||
|
@ -73,7 +198,8 @@ CreateComputerTypeList(HINF InfFile)
|
||||||
wcscpy(UserData, KeyName);
|
wcscpy(UserData, KeyName);
|
||||||
|
|
||||||
sprintf(Buffer, "%S", KeyValue);
|
sprintf(Buffer, "%S", KeyValue);
|
||||||
AppendGenericListEntry(List, Buffer, UserData, FALSE);
|
AppendGenericListEntry(List, Buffer, UserData,
|
||||||
|
_wcsicmp(KeyName, ComputerKey) ? FALSE : TRUE);
|
||||||
}
|
}
|
||||||
while (InfFindNextLine(&Context, &Context));
|
while (InfFindNextLine(&Context, &Context));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue