[movitz-cvs] CVS update: movitz/losp/x86-pc/pci.lisp

Frode Vatvedt Fjeld ffjeld at common-lisp.net
Sun Aug 14 12:15:06 UTC 2005


Update of /project/movitz/cvsroot/movitz/losp/x86-pc
In directory common-lisp.net:/tmp/cvs-serv24313

Modified Files:
	pci.lisp 
Log Message:
Added pci-device-address-maps.

Date: Sun Aug 14 14:15:05 2005
Author: ffjeld

Index: movitz/losp/x86-pc/pci.lisp
diff -u movitz/losp/x86-pc/pci.lisp:1.10 movitz/losp/x86-pc/pci.lisp:1.11
--- movitz/losp/x86-pc/pci.lisp:1.10	Fri Aug 12 08:34:35 2005
+++ movitz/losp/x86-pc/pci.lisp	Sun Aug 14 14:15:04 2005
@@ -10,7 +10,7 @@
 ;;;; Author:        Frode Vatvedt Fjeld <frodef at acm.org>
 ;;;; Created at:    Sun Dec 14 22:33:42 2003
 ;;;;                
-;;;; $Id: pci.lisp,v 1.10 2005/08/12 06:34:35 ffjeld Exp $
+;;;; $Id: pci.lisp,v 1.11 2005/08/14 12:15:04 ffjeld Exp $
 ;;;;                
 ;;;;------------------------------------------------------------------
 
@@ -281,6 +281,30 @@
   (setf (pci-bios-config-space bus device function register #xb10b 8)
     value))
 
+
+(defmacro pci-config (register)
+  (cdr (or (assoc register
+		  '((:interrupt-line . #x3c)
+		    (:interrupt-pin . #x3d)
+		    (:base-addr . #x10)
+		    (:memspace . #x00)
+		    (:iospace . #x01)
+		    (:type . #x06)
+		    (:memspace64 . #x01)))
+	   (error "Unknown pci-config register: ~S" register))))
+
+(defun pci-device-address-maps (bus device function)
+  (loop for i upfrom (pci-config :base-addr) by 4 repeat 6
+      as base = (pci-bios-config-space-dword bus device function i)
+      unless (= 0 base) collect
+	(cond
+	 ((logbitp 0 base)
+	  (cons :io (logand base -4)))
+	 ((= 1 (ldb (byte 2 1) base))
+	  (cons :mem64 (logand base -16)))
+	 (t
+	  (cons :mem32 (logand base -16))))))
+	    
 (defun scan-pci-bus (bus)
   (loop for device from 0 to 31
       do (multiple-value-bind (vendor-id return-code)
@@ -298,5 +322,6 @@
 		       (ldb (byte 8 0) class-rev)
 		       status)
 	       (format *query-io* "    Class:~{ ~@[~A~]~}"
-		       (multiple-value-list (pci-class (ldb (byte 24 8) class-rev))))))))
-  (values))
\ No newline at end of file
+		       (multiple-value-list (pci-class (ldb (byte 24 8) class-rev))))
+	       (format *query-io* "~S" (pci-device-address-maps bus device 0))))))
+  (values))




More information about the Movitz-cvs mailing list