Mike Smith <[EMAIL PROTECTED]> writes:
> If you're working on a single, fixed platform, this should be pretty 
> simple; they just lop the top bit off the base address they use for PCI 
> address allocation.
> 
> Here's an evil trick you can pull though, if you're *really* desperate 
> and if you're *certain* that you're in control of your platform, and 
> *certain* that you'll never have more than ~1.9GB of physical memory.
> 
> In sys/pci/pci.c:pci_readmaps(), fix the loop that reads maps to knock the
> high bit off memory ranges and write them back:
> 
>         for (i = 0; i < maxmaps; i++) {
>                 int reg = PCIR_MAPS + i*4;
>                 u_int32_t base;
>                 u_int32_t ln2range;
>  
>                 base = pci_cfgread(cfg, reg, 4);
>                 ln2range = pci_maprange(base);
>  
>                 if (base == 0 || ln2range == 0 || base == 0xffffffff)
>                         continue; /* skip invalid entry */
>                 else {
>                       /* remap below 2GB */
>                       if (pci_maptype(base) == PCI_MAPMEM) {
>                               base &= ~0x80000000;
>                               pci_cfgwrite(cfg, reg, base, 4);
>                               ln2range = pci_maprange(base);
>                       }
>                         j++;
>                         if (ln2range > 32) {
>                                 i++;
>                                 j++;
>                         }
>                 }
>         }
> 
> This is, of course, only a solution if you have total control over the 
> system as well; if you plan to ship the product for inclusion in general 
> FreeBSD systems, you're prettymuch hosed.

This is actually only needed for an internal use project, and this
hack is exactly what I was looking for!  It works wonderfully,
although I had to change the code slightly:

                if ((pci_maptype(base) & PCI_MAPMEM) == PCI_MAPMEM) {
                        base &= ~0x80000000;
                        printf("0x%x)\n", base);
                        pci_cfgwrite(cfg, reg, base, 4);
                        ln2range = pci_maprange(base);
                }

to handle prefetchable memory as well.

Thank you very much for the suggestion -- I'd read through that code,
but didn't think about the simple fix you've suggested!

DaveG           o_,    o,     o_      o_     o'         
Programmer      )-'   /|'     ),`     ) '   (\    ^o          Gymnast
Dancer          >\    / >     >\      >^'   >\    >>'           Hiker
[EMAIL PROTECTED]                   www.mit.edu/~daveg/     (617)216-4705
[EMAIL PROTECTED]      www.conexant.com        (508)621-0658
                


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to