|
;; $Id: cpuinit.inc,v 1.1 2007-09-01 22:44:04 niro Exp $ |
|
1 |
;; ----------------------------------------------------------------------- |
;; ----------------------------------------------------------------------- |
2 |
;; |
;; |
3 |
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved |
;; Copyright 1994-2008 H. Peter Anvin - All Rights Reserved |
4 |
|
;; Copyright 2010 Intel Corporation; author: H. Peter Anvin |
5 |
;; |
;; |
6 |
;; This program is free software; you can redistribute it and/or modify |
;; This program is free software; you can redistribute it and/or modify |
7 |
;; it under the terms of the GNU General Public License as published by |
;; it under the terms of the GNU General Public License as published by |
13 |
|
|
14 |
;; |
;; |
15 |
;; cpuinit.inc |
;; cpuinit.inc |
16 |
;; |
;; |
17 |
;; CPU-dependent initialization and related checks. |
;; CPU-dependent initialization and related checks. |
18 |
;; |
;; |
19 |
|
|
35 |
cmp ax,dosram_k |
cmp ax,dosram_k |
36 |
jae enough_ram |
jae enough_ram |
37 |
mov si,err_noram |
mov si,err_noram |
38 |
call writestr |
call writestr_early |
39 |
jmp kaboom |
jmp kaboom |
40 |
enough_ram: |
enough_ram: |
41 |
skip_checks: |
skip_checks: |
42 |
|
|
43 |
; |
; |
44 |
; Initialize the bcopy32 code in low memory |
; Detect old versions Xen HVM and disable halt |
45 |
; |
; Xen HVM older than version 3.3 might be using vmxassist, which breaks |
46 |
mov si,section..bcopy32.start |
; if HLT is executed in real mode. |
|
mov di,__bcopy_start |
|
|
mov cx,__bcopy_size >> 2 |
|
|
rep movsd |
|
|
|
|
|
; |
|
|
; Check if we're 386 (as opposed to 486+); if so we need to blank out |
|
|
; the WBINVD instruction |
|
47 |
; |
; |
48 |
; We check for 486 by setting EFLAGS.AC |
; Note: in Syslinux 4, we should probably just execute the HLT in |
49 |
|
; protected mode instead. |
50 |
; |
; |
51 |
%if DO_WBINVD |
check_xen: |
52 |
pushfd ; Save the good flags |
pushfd |
53 |
pushfd |
pushfd |
54 |
pop eax |
pop eax |
55 |
mov ebx,eax |
mov edx,eax |
56 |
xor eax,(1 << 18) ; AC bit |
xor eax,(1 << 21) ; ID flag |
57 |
push eax |
push eax |
58 |
popfd |
popfd |
59 |
pushfd |
pushfd |
60 |
pop eax |
pop eax |
61 |
popfd ; Restore the original flags |
popfd |
62 |
xor eax,ebx |
xor eax,edx |
63 |
jnz is_486 |
and eax,(1 << 21) |
64 |
; |
jz .not_xen ; No CPUID |
65 |
; 386 - Looks like we better blot out the WBINVD instruction |
|
66 |
; |
xor ebx,ebx |
67 |
mov byte [try_wbinvd],0c3h ; Near RET |
xor ecx,ecx |
68 |
is_486: |
xor edx,edx |
69 |
%endif ; DO_WBINVD |
mov eax,0x40000000 |
70 |
|
cpuid |
71 |
|
cmp ebx,"XenV" |
72 |
|
jne .not_xen |
73 |
|
cmp ecx,"MMXe" |
74 |
|
jne .not_xen |
75 |
|
cmp edx,"nVMM" |
76 |
|
jne .not_xen |
77 |
|
|
78 |
|
; We're on Xen... |
79 |
|
mov eax,0x40000001 |
80 |
|
cpuid |
81 |
|
cmp eax,0x00030003 |
82 |
|
jae .not_xen ; Xen >= 3.3, not affected |
83 |
|
|
84 |
|
; We may be using vmxassist, so disable HLT |
85 |
|
mov byte [ForceNoHalt],1 |
86 |
|
|
87 |
|
.not_xen: |
88 |
|
|
89 |
|
section .data |
90 |
|
err_noram db 'It appears your computer has less than ' |
91 |
|
asciidec dosram_k |
92 |
|
db 'K of low ("DOS")' |
93 |
|
db CR, LF |
94 |
|
db 'RAM. Linux needs at least this amount to boot. If you get' |
95 |
|
db CR, LF |
96 |
|
db 'this message in error, hold down the Ctrl key while' |
97 |
|
db CR, LF |
98 |
|
db 'booting, and I will take your word for it.', CR, LF, 0 |
99 |
|
section .text |