Adding debian version 3.40~pre9-1.
[syslinux-debian/hramrach.git] / debian / patches / 02-64bit-autodetection.dpatch
blob39b5c64b2427a603904dd6e43aabe73271973b33
1 #!/bin/sh /usr/share/dpatch/dpatch-run
2 ## 02-64bit-autodetection.dpatch by Byron Stanoszek <gandalf@winds.org>
3 ##
4 ## DP: Allows auto-detection of 64bit CPUs (Closes: #408138), see
5 ## DP: http://syslinux.zytor.com/archives/2007-January/007832.html
7 @DPATCH@
9 diff -Naur syslinux-3.36.orig/cpuinit.inc syslinux-3.36/cpuinit.inc
10 --- syslinux-3.36.orig/cpuinit.inc 2007-02-10 20:47:08.000000000 +0000
11 +++ syslinux-3.36/cpuinit.inc 2007-03-05 00:45:25.000000000 +0000
12 @@ -48,12 +48,10 @@
13 rep movsd
16 -; Check if we're 386 (as opposed to 486+); if so we need to blank out
17 -; the WBINVD instruction
18 +; Determine if we're running on a 64-bit CPU
20 -; We check for 486 by setting EFLAGS.AC
21 +; First, check if we're 386. If so, we need to blank out the WBINVD instruction
23 -%if DO_WBINVD
24 pushfd ; Save the good flags
25 pushfd
26 pop eax
27 @@ -69,6 +67,37 @@
29 ; 386 - Looks like we better blot out the WBINVD instruction
31 +%if DO_WBINVD
32 mov byte [try_wbinvd],0c3h ; Near RET
33 -is_486:
34 %endif ; DO_WBINVD
35 + jmp is_32bit
36 +is_486:
38 +; Check if this CPU supports the CPUID command
40 + pushfd ; Save the flags again
41 + pushfd
42 + pop eax
43 + mov ebx,eax
44 + xor eax,(1 << 21) ; CPUID bit
45 + push eax
46 + popfd
47 + pushfd
48 + pop eax
49 + popfd ; Restore the original flags
50 + xor eax,ebx
51 + jz is_32bit
53 +; Now check for the 64-bit flag (bit 29) in the CPU extended features byte ($8000_0001, edx)
55 + mov eax, 80000000h ; Find last AMD cpuid #
56 + cpuid
57 + cmp eax, 80000000h
58 + jbe is_32bit
59 + mov eax, 80000001h ; Read AMD CPU flags
60 + cpuid
61 + bt edx, 29 ; 64-bit if bit 29 is set
62 + jnc is_32bit
64 +is_64bit: mov byte [Is64Bit],1 ; Flag that we're 64-bit
65 +is_32bit:
66 diff -Naur syslinux-3.36.orig/keywords syslinux-3.36/keywords
67 --- syslinux-3.36.orig/keywords 2007-02-10 20:47:08.000000000 +0000
68 +++ syslinux-3.36/keywords 2007-03-05 00:45:38.000000000 +0000
69 @@ -2,6 +2,7 @@
70 text
71 append
72 default
73 +default64
74 display
75 font
76 implicit
77 diff -Naur syslinux-3.36.orig/keywords.inc syslinux-3.36/keywords.inc
78 --- syslinux-3.36.orig/keywords.inc 2007-02-10 20:47:08.000000000 +0000
79 +++ syslinux-3.36/keywords.inc 2007-03-05 00:46:05.000000000 +0000
80 @@ -49,6 +49,7 @@
81 keyword text, pc_text
82 keyword append, pc_append
83 keyword default, pc_default
84 + keyword default64, pc_default64
85 keyword display, pc_filecmd, get_msg_file
86 keyword font, pc_filecmd, loadfont
87 keyword implicit, pc_setint16, AllowImplicit
88 diff -Naur syslinux-3.36.orig/kwdhash.gen syslinux-3.36/kwdhash.gen
89 --- syslinux-3.36.orig/kwdhash.gen 2007-02-10 20:47:13.000000000 +0000
90 +++ syslinux-3.36/kwdhash.gen 2007-03-05 00:46:23.000000000 +0000
91 @@ -2,6 +2,7 @@
92 hash_text equ 0x003b9b74
93 hash_append equ 0xc53999a4
94 hash_default equ 0xcc5159ed
95 +hash_default64 equ 0x4567b1c5
96 hash_display equ 0xd509bc40
97 hash_font equ 0x0032b1b4
98 hash_implicit equ 0xa6f50207
99 diff -Naur syslinux-3.36.orig/parseconfig.inc syslinux-3.36/parseconfig.inc
100 --- syslinux-3.36.orig/parseconfig.inc 2007-02-10 20:47:08.000000000 +0000
101 +++ syslinux-3.36/parseconfig.inc 2007-03-05 00:50:12.000000000 +0000
102 @@ -20,7 +20,20 @@
104 ; "default" command
106 -pc_default: mov di,default_cmd
107 +pc_default: cmp byte [HasDefault64],0 ; Check if we accepted 'default64'
108 + ja pc_getline ; If so, do nothing
109 + mov di,default_cmd
110 + call getline
111 + mov byte [di-1],0 ; null-terminate
112 + ret
115 +; "default64" command
117 +pc_default64: cmp byte [Is64Bit],0 ; Make sure cpu is 64-bit
118 + je pc_getline
119 + mov byte [HasDefault64],1 ; Note that we saw a default64
120 + mov di,default_cmd
121 call getline
122 mov byte [di-1],0 ; null-terminate
124 @@ -414,6 +427,8 @@
125 SerialPort dw 0 ; Serial port base (or 0 for no serial port)
126 VKernelBytes dw 0 ; Number of bytes used by vkernels
127 VKernel db 0 ; Have we seen any "label" statements?
128 +Is64Bit db 0 ; Is this CPU 64-bit?
129 +HasDefault64 db 0 ; We've seen a 'default64' statement
131 section .latebss
132 alignb 4 ; For the good of REP MOVSD