Skip to content
Snippets Groups Projects
Commit 3c78ebec authored by rtoy's avatar rtoy
Browse files

o Add a VOP that runs the cpuid instruction and returns the results.

o Add the function VM::CPUID to return the raw results.
parent b14ffba7
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman or slisp-group@cs.cmu.edu. ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/x86/system.lisp,v 1.13 2003/03/23 21:23:41 gerd Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/x86/system.lisp,v 1.14 2009/01/09 14:16:09 rtoy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -606,3 +606,57 @@ ...@@ -606,3 +606,57 @@
#+pentium #+pentium
(defun read-cycle-counter () (defun read-cycle-counter ()
(read-cycle-counter)) (read-cycle-counter))
(defknown cpuid ((unsigned-byte 32))
(values (unsigned-byte 32)
(unsigned-byte 32)
(unsigned-byte 32)
(unsigned-byte 32))
())
(define-vop (cpuid)
(:policy :fast-safe)
(:translate cpuid)
(:args (level :scs (unsigned-reg) :to :result))
(:arg-types unsigned-num)
(:results (a :scs (unsigned-reg))
(b :scs (unsigned-reg))
(c :scs (unsigned-reg))
(d :scs (unsigned-reg)))
(:result-types unsigned-num unsigned-num unsigned-num unsigned-num)
;; Not sure about these :from/:to values.
(:temporary (:sc unsigned-reg :offset eax-offset
:to (:result 0))
eax)
(:temporary (:sc unsigned-reg :offset ebx-offset
:to (:result 1))
ebx)
(:temporary (:sc unsigned-reg :offset ecx-offset
:to (:result 2))
ecx)
(:temporary (:sc unsigned-reg :offset edx-offset
:to (:result 3))
edx)
(:temporary (:sc unsigned-stack) eax-stack)
(:temporary (:sc unsigned-stack) ebx-stack)
(:temporary (:sc unsigned-stack) ecx-stack)
(:temporary (:sc unsigned-stack) edx-stack)
(:generator 10
(move eax level)
(inst cpuid)
;; Don't know where a, b, c, d are, so we save the results of
;; cpuid to the stack and then copy the stack values to the result
;; registers.
(move eax-stack eax)
(move ebx-stack ebx)
(move ecx-stack ecx)
(move edx-stack edx)
(move a eax-stack)
(move b ebx-stack)
(move c ecx-stack)
(move d edx-stack)))
(defun cpuid (level)
(declare (type (unsigned-byte 32) level))
(cpuid level))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment