On Tue, 2005-01-18 at 20:42 +0200, Michael S. Tsirkin wrote:
> What do you see with this:
> 
> ./mread 81:00.0 0x000f0014

tat:~# ./mread 81:00.0 0x000f0014
mopen: No such file or directory

tat:~# ./mread 0000:81:00.0 0x000f0014
mopen: No such file or directory

Now with my modified mfind:

tat:~# ./mread 0000:81:00.0 0x000f0014
Read 0x000f0014:0x00a15a44

-tduffy
Modify mfind to work with PCI domains on platforms such as sparc64.

Signed-off-by: Tom Duffy <[EMAIL PROTECTED]>

--- mtcr.h	2005-01-18 10:17:18.000000000 -0800
+++ mtcr.h.tduffy	2005-01-18 10:15:45.000000000 -0800
@@ -136,7 +136,8 @@
 
 /* Find the specific device by scanning /proc/bus/pci/devices */
 int mfind(const char* name, off_t* offset_p,
-		unsigned *bus_p, unsigned *dev_p, unsigned *func_p)
+		unsigned *bus_p, unsigned *dev_p, unsigned *func_p,
+		int *domain_p)
 {
   FILE* f;
 	unsigned     irq;
@@ -158,7 +159,7 @@
 
   unsigned long long offset;
 
-  unsigned my_domain = 0;
+  int my_domain = -1;
   unsigned my_bus;
   unsigned my_dev;
   unsigned my_func;
@@ -180,7 +181,7 @@
 
 name_parsed:
 
-  if (my_domain) {
+  if (my_domain > 0) {
     fprintf(stderr,"Device %s: domain number %#x detected.\n"
 		   "Only domain 0x0 supported for now, sorry.\n",
 		   name, my_domain);
@@ -266,6 +267,7 @@
   *bus_p=bus;
   *dev_p=dev;
   *func_p=func;
+  *domain_p=my_domain;
 
   fclose(f);
   return 0;
@@ -307,16 +309,22 @@
   {
 #if CONFIG_ENABLE_MMAP
     unsigned bus, dev, func;
-    if (mfind(name,&offset,&bus,&dev,&func)) goto find_failed;
+    int domain;
+    if (mfind(name,&offset,&bus,&dev,&func,&domain)) goto find_failed;
 
 #if CONFIG_USE_DEV_MEM
     mf->fd = open("/dev/mem", O_RDWR | O_SYNC);
     if (mf->fd<0) goto open_failed;
 #else
     {
-	    char file_name[]="/proc/bus/pci/00/00.0";
-	    sprintf(file_name,"/proc/bus/pci/%2.2x/%2.2x.%1.1x",
+	    char file_name[]="/proc/bus/pci/0000:00/00.0";
+	    if (domain >= 0) {
+	    	sprintf(file_name,"/proc/bus/pci/%4.4d:%2.2x/%2.2x.%1.1x",
+			    domain,bus,dev,func);
+	    } else {
+		sprintf(file_name,"/proc/bus/pci/%2.2x/%2.2x.%1.1x",
 			    bus,dev,func);
+	    }
 	    mf->fd = open(file_name, O_RDWR | O_SYNC);
 	    if (mf->fd<0) goto open_failed;
 

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to