also sprach Matan Ziv-Av:

> So does the driver work, after you replaced the apertures' meaning?

Ay Caramba! There is a problem with the combination
vga_setlinearaddressing and vga_getgraphmem. I think the linear array is
never memory mapped, and vga_getgraphmem returns the address of the VGA
aperture.

> I can see two more ways to distinguish:
> - Trying to write an address that is read only in mmio, and see if it
>   changes.
> - Checking the 1064 revision. (But I don't which revisions have which
>   mapping).

I have done the former. Attached is a patch to svgalib-1.9.10. It works
on my friend's card. Come to think of it, on some microprocessors a long
int will be 64 bits, so buf should be just int. You may remove the debug
messages. Register 1e10h is the bus FIFO status. It is read-only :-).

While I am at it, how are addresses kept on the PCI bus on systems which
have 64 bits physical addresses? And can someone who has the PCI
specifications send me a copy by e-mail?

Mihai
diff -urN svgalib-1.9.10/src/g400.c svgalib_mihai/src/g400.c
--- svgalib-1.9.10/src/g400.c   Tue Jul  3 08:25:01 2001
+++ svgalib_mihai/src/g400.c    Tue Jul  3 08:38:21 2001
@@ -790,8 +790,7 @@
 
 static int g400_init(int force, int par1, int par2)
 {
-    unsigned long buf[64];
-    int found=0;
+    unsigned int found=0, buf[64];
     int pci_id;
     char *ids[]={"Mystique", "G100", "G200", "G400", "G450"};
 
@@ -803,7 +802,7 @@
 
     found=__svgalib_pci_find_vendor_vga_pos(VENDOR_ID,buf,0);
     
-    if(found==-1) {
+       if(!found) {
         printf("Error: Must use Matrox driver, but no card found\n");
         exit(1);
     }
@@ -828,12 +827,30 @@
        default:
                id = ID_G100;
     }
-
-    g400_linear_base = buf[4]&0xffffff00;
-    g400_mmio_base = buf[5]&0xffffff00;
-
+       printf("linear base: %x\n", g400_linear_base = buf[4]&0xffffff00);
+       printf("mmio base: %x\n", g400_mmio_base = buf[5]&0xffffff00);
     
__svgalib_vgammbase=mmap(0,0x1000,PROT_READ|PROT_WRITE,MAP_SHARED,__svgalib_mem_fd,g400_mmio_base+0x1000)
 + 0xc00;
+       if(id == ID_1064){
+               /* For some mystique boards, the primary aperture is
+               for memory mapped registers. We detect this by writing
+               and reading from the bus FIFO status register, which is
+               read only and the upper 21 bits read 0. 
+               -- Mihai */
+               *((int *)(__svgalib_vgammbase + 0x210)) = 0x1234;
+               if(*((int *) (__svgalib_vgammbase + 0x210)) == 0x1234){
+                       printf("Changing configuration\n");
+                       munmap(__svgalib_vgammbase - 0xc00, 0x1000);
+                       g400_linear_base = buf[4]&0xffffff00;
+                       g400_mmio_base = buf[5]&0xffffff00;
+                       __svgalib_vgammbase=mmap(0,0x1000,
+                                       PROT_READ|PROT_WRITE,
+                                       MAP_SHARED,
+                                       __svgalib_mem_fd,
+                                       g400_mmio_base+0x1000) + 0xc00;
+               }       
+       }
     __svgalib_mm_io_mapio();
+
 
     __svgalib_inpal=inpal;
     __svgalib_outpal=outpal;    

Reply via email to