Update commentary in ape.S

This commit is contained in:
Justine Tunney 2023-03-05 16:11:03 -08:00
parent c5de653b98
commit c8a9d3458e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -1406,12 +1406,12 @@ longmodeloader:
.endfn longmodeloader .endfn longmodeloader
// Long Mode Hardware Check // Long Mode Hardware Check
lcheck: pushf # check for i8086 / i8088 / i80186 lcheck: pushf # checks for i8086 / i8088 / i80186
pop %ax pop %ax # see intel manual volume 1 §20.1.2
test $0x80,%ah # see intel manual volume 1 20.1.2 test $0x80,%ah
jnz 10f # we now assume 32 bit is supported jnz 10f # we now assume 32 bit is supported
pushfl # now check for i386 or early i486 pushfl # now check for i386, or early i486
pop %eax # test ability to change cpuid bit pop %eax # tests ability to change cpuid bit
mov %eax,%ecx mov %eax,%ecx
mov $1<<21,%ebx mov $1<<21,%ebx
xor %ebx,%eax xor %ebx,%eax
@ -1424,16 +1424,16 @@ lcheck: pushf # check for i8086 / i8088 / i80186
or %ebx,%eax # puts cpuid bit in the on position or %ebx,%eax # puts cpuid bit in the on position
push %eax push %eax
popfl popfl
mov $0x80000000,%edi # get amd ext cpuid thingy length mov $0x80000000,%edi # get amd64 ext cpuid thingy length
mov %edi,%eax mov %edi,%eax
inc %edi inc %edi
cpuid # clobbers eax, ebx, ecx, and edx cpuid # leaf 0x80000000, clob ax/bx/cx/dx
cmp %edi,%eax cmp %edi,%eax
jl 10f jl 10f
mov %edi,%eax mov %edi,%eax
cpuid cpuid # leaf 0x80000001, clob ax/bx/cx/dx
mov $1<<29|1<<20,%edi # need nexgen32e long mode support mov $1<<29|1<<20,%edi # 29 = LM (long), 20 = NX (no exec)
and %edi,%edx # & nx support and %edi,%edx # we need to both, or we won't work
cmp %edi,%edx cmp %edi,%edx
jne 10f jne 10f
xor %ax,%ax xor %ax,%ax