]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] i386 head.S cleanup
authorBrian Gerst <bgerst@didntduck.org>
Tue, 28 May 2002 15:02:12 +0000 (08:02 -0700)
committerPatrick Mochel <mochel@osdl.org>
Tue, 28 May 2002 15:02:12 +0000 (08:02 -0700)
Cleans up some redundant code in head.S:
- Combine checking of AC and ID eflags.
- Streamline the setting of %cr0.

arch/i386/kernel/head.S

index b80c4753f97ef5f50c5aad7603e0bb6e67d170d9..94ec417ebbef089b3fece8f9ff0dde660398d7a5 100644 (file)
@@ -182,26 +182,19 @@ checkCPUtype:
        pushfl                  # push EFLAGS
        popl %eax               # get EFLAGS
        movl %eax,%ecx          # save original EFLAGS
-       xorl $0x40000,%eax      # flip AC bit in EFLAGS
+       xorl $0x240000,%eax     # flip AC and ID bits in EFLAGS
        pushl %eax              # copy to EFLAGS
        popfl                   # set EFLAGS
        pushfl                  # get new EFLAGS
        popl %eax               # put it in eax
        xorl %ecx,%eax          # change in flags
-       andl $0x40000,%eax      # check if AC bit changed
+       pushl %ecx              # restore original EFLAGS
+       popfl
+       testl $0x40000,%eax     # check if AC bit changed
        je is386
 
        movb $4,X86             # at least 486
-       movl %ecx,%eax
-       xorl $0x200000,%eax     # check ID flag
-       pushl %eax
-       popfl                   # if we are on a straight 486DX, SX, or
-       pushfl                  # 487SX we can't change it
-       popl %eax
-       xorl %ecx,%eax
-       pushl %ecx              # restore original EFLAGS
-       popfl
-       andl $0x200000,%eax
+       testl $0x200000,%eax    # check if ID bit changed
        je is486
 
        /* get vendor info */
@@ -227,18 +220,15 @@ checkCPUtype:
        movb %cl,X86_MASK
        movl %edx,X86_CAPABILITY
 
-is486:
-       movl %cr0,%eax          # 486 or better
-       andl $0x80000011,%eax   # Save PG,PE,ET
-       orl $0x50022,%eax       # set AM, WP, NE and MP
+is486: movl $0x50022,%ecx      # set AM, WP, NE and MP
        jmp 2f
 
-is386: pushl %ecx              # restore original EFLAGS
-       popfl
-       movl %cr0,%eax          # 386
+is386: movl $2,%ecx            # set MP
+2:     movl %cr0,%eax
        andl $0x80000011,%eax   # Save PG,PE,ET
-       orl $2,%eax             # set MP
-2:     movl %eax,%cr0
+       orl %ecx,%eax
+       movl %eax,%cr0
+
        call check_x87
        incb ready
        lgdt gdt_descr