Hi,

        I'm trying to use an PCI SUN-GEM gigabit ethernet adapter on
        x86 based server with FreeBSD.

        It seems that the module if_gem actually exists but it relies
        on OpenFirmware to read board data (such as mac-address), thus
        it doesn't work on X86 FreeBSD.

        To my comprension this is because the x86 platform lacks support
        for openfirmware.

        Nonetheless, it seems that the same board is supported on other O.S.
        like OpenBSD or Linux using specific code that bypass openfirmware
        reading directly the data from PCI Expansion ROM.

        Actually, even FreeBSD uses the same trick but it does so for
        another SUN board (if_hme), so I thought that it was worth the
        try to add the missing code on if_gem device.

        After a few(!!) tries I managed to access the PCI Expansion ROM
        but I found out that it was empty, or at least full of 0xFF...

        At the beginning I thought that something was wrong with my code
        but when I finally managed to dump the ROM contents using the
        tool 'pciroms' I found out that actually the ROM content was
        '1'-filled.

        So what I'm wondering what I'm doing wrong.

        This is the code that should read the Expansion ROM reg:

#define PCI_ROM_REG 0x30
#define PCI_ROM_ENABLE                  0x00000001
#define PCI_ROM_ADDR_MASK               0xfffff800
#define PCI_ROM_ADDR(mr)                                                \
            ((mr) & PCI_ROM_ADDR_MASK)
#define PCI_ROM_SIZE(mr)                                                \
            (PCI_ROM_ADDR(mr) & -PCI_ROM_ADDR(mr))


        rrid=PCI_ROM_REG;
        address = pci_read_config(dev, PCI_ROM_REG,4);
        device_printf(dev,"valore dell'address %08x\n",address);
        pci_write_config(dev, PCI_ROM_REG, 0xfffffffe,4);
        mask = pci_read_config(dev, PCI_ROM_REG,4);
        address |= PCI_ROM_ENABLE;
        pci_write_config(dev, PCI_ROM_REG, address,4);

        size = PCI_ROM_SIZE(mask);
        bus_set_resource(dev, SYS_RES_MEMORY, rrid,(u_long )&rrid,size);
        rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rrid, RF_ACTIVE);

        if ( rres == NULL) {
                device_printf(dev, "could not map PROM registers\n");
                error = ENXIO;
                goto fail_sres;
        }

        romt = rman_get_bustag(rres);
        romh = rman_get_bushandle(rres);

        /* Read PCI expansion PROM header. */
        bus_space_read_region_1(romt, romh, 0, buf, sizeof(buf));
        for (i=0; i<1048576 ; i++ ) {
                if ( buf[i] != 0xff ) {
                device_printf(dev,"Memory address %d = %x \n",i,buf[i]);
                }
        }

        
        Should I look elsewhere for the VPD to be found ?
        There's some particular init sequence to do in order to
        have the Expansion ROM loaded with the correct code?

        
        Any advice or suggestion is more than welcome :)

Thanks
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hardware
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to