Topic: Detection of ACPI PC HAL vs. ACPI Uniprocessor/Multiprocessor HAL

I was wondering if there has been any progress made on how to detect and automatically choose between the three main types of HALs--ACPI PC, Uniprocessor, and Multiprocessor--instead of just the latter two. This is for Windows XP SP3.

My current method for working around this issue is to use an image which allows Sysprep to choose Uniprocessor/Multiprocessor, and if the computer needs the older ACPI PC HAL, just manually overlay a "corrected" sysprep.inf on top of that image (which tells Sysprep to leave the default ACPI PC HAL unchanged). This works well, but I would prefer an automated solution.

I was hoping that OfflineSysprep would be the answer, but unfortunately it doesn't seem to be. The last information I can find from Galapo is this:

Galapo wrote:

OfflineSysPrep auto HAL detection on first boot only works with acpi uniprocessor and acpi multiprocessor machines. . . . I wish I had hardware to test and then I could improve it. I would like to know of a way to detect whether a system supports acpi but not acpi uniprocessor. Probably this would then solve most of your issues. Then I would like a way to detect whether a system supports acpi and if not default to standard.

So, in other words, it does the same thing the Sysprep is already doing for me.

I was hoping to perhaps modify OfflineSysprep's process myself to make it work for all three HALs. As of yet, I can't find a reliable way to do it. Currently, OSP just grabs the number of cores and/or hyperthreading capability from the CrystalCPUID dump. Is there a CPUID feature flag that could delineate support for ACPI Uniprocessor vs. ACPI PC (the older one)?

I'll keep poking around myself, but I thought I might ask the much smarter people on this forum to see if any progress has been made here. Thanks. smile

Re: Detection of ACPI PC HAL vs. ACPI Uniprocessor/Multiprocessor HAL

I think I may have figured it out. Here it is for anyone who is interested:

The primary CPUID feature flag that determines ACPI Uniprocessor HAL support (as opposed to the ACPI PC HAL) is the APIC flag. It is the 9th bit in the EDX register after calling the CPUID instruction with 0000_0001h in EAX (see: http://www.sandpile.org/ia32/cpuid.htm).

I added code to OfflineSysprep to check that bit and then determine the HAL based on its value. The original code looks like this:

$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Number (Total)", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Physical Core", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Hyper-Threading", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
If $cpu_count = "uni_processor" Then
	$Hal = "ACPIAPIC_UP"
ElseIf $cpu_count = "multi_processor" Then
	$Hal = "ACPIAPIC_MP"
EndIf

And the code which detects lack of APIC support (for the ACPI PC HAL) looks like this:

$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Number (Total)", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Physical Core", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Hyper-Threading", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "00000001", "not_found")
$apic_hex = Dec(StringMid($ini, 33, 1))
$apic_flag = Mod(BitShift($apic_hex, 1), 2)
If $cpu_count = "uni_processor" Then
	If $apic_flag = 0 Then
		$Hal = "ACPIPIC"
	Else
		$Hal = "ACPIAPIC_UP"
	EndIf
ElseIf $cpu_count = "multi_processor" Then
	$Hal = "ACPIAPIC_MP"
EndIf

I've done some initial testing, and the results are positive. I was able to get three different HALs on three different computers (each hardware type had its appropriate HAL) using a single image with no overlays. If anyone wants to try this, let me know how it works for you.

Last edited by bdurkee (2009-09-03 04:30:48)

Re: Detection of ACPI PC HAL vs. ACPI Uniprocessor/Multiprocessor HAL

Great, thanks for that.

Any idea about determining the setting of standard HAL vis-a-vis ACPI PC HAL?

Thanks,
Galapo.

Re: Detection of ACPI PC HAL vs. ACPI Uniprocessor/Multiprocessor HAL

Well, since ACPI has been out since 1996, I personally have no use for the Standard HAL (nor hardware to test it on). However, given the concept used to detect APIC, it should be trivial to add code to detect ACPI as well. It appears that the ACPI feature flag is the 22nd bit in the EDX register. So the code to check it would look like this:

$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Number (Total)", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Physical Core", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "Hyper-Threading", "not_found")
If $ini > 1 Then $cpu_count = "multi_processor"
$ini = IniRead($tempvariable & "\temp.txt", "CrystalCPUID", "00000001", "not_found")
$acpi_hex = Dec(StringMid($ini, 30, 1))
$acpi_flag = Mod(BitShift($acpi_hex, 2), 2)
$apic_hex = Dec(StringMid($ini, 33, 1))
$apic_flag = Mod(BitShift($apic_hex, 1), 2)
If $cpu_count = "uni_processor" Then
	If $acpi_flag = 0 Then
		$Hal = "STANDARD"
	ElseIf $apic_flag = 0 Then
		$Hal = "ACPIPIC"
	Else
		$Hal = "ACPIAPIC_UP"
	EndIf
ElseIf $cpu_count = "multi_processor" Then
	$Hal = "ACPIAPIC_MP"
EndIf

Also, you may notice that I changed my logic a little bit (for reading the bit values). I'm new to AutoIt, so I didn't think to look for a BitShift function until just now. tongue It should work the same, just be simpler and easier to understand. I edited my former post also to reflect this.

Again, I don't have the hardware to test the standard HAL detection, but I'm pretty confident that it would work, assuming that the CPUID flag is accurate.

Last edited by bdurkee (2009-09-03 04:54:39)

Re: Detection of ACPI PC HAL vs. ACPI Uniprocessor/Multiprocessor HAL

Thanks again. I'll add to the program. Hopefully issue of setting correct HAL at boot is now solved.

Regards,
Galapo.