From owner-freebsd-hardware@FreeBSD.ORG Wed Aug 1 19:31:30 2007 Return-Path: Delivered-To: freebsd-hardware@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43E3D16A418 for ; Wed, 1 Aug 2007 19:31:30 +0000 (UTC) (envelope-from andrea.franceschini@postecom.it) Received: from relay-pt2.poste.it (relay-pt2.poste.it [62.241.5.253]) by mx1.freebsd.org (Postfix) with ESMTP id 006AF13C465 for ; Wed, 1 Aug 2007 19:31:29 +0000 (UTC) (envelope-from andrea.franceschini@postecom.it) Received: from knute.cs.poste.it (192.168.44.52) by relay-pt2.poste.it (7.3.122) id 46AFBF480001388E for freebsd-hardware@FreeBSD.ORG; Wed, 1 Aug 2007 21:11:21 +0200 Received: from knute.cs.poste.it (localhost [127.0.0.1]) by knute.cs.poste.it (8.14.1/8.12.10) with ESMTP id l71JBLu3038172 for ; Wed, 1 Aug 2007 21:11:21 +0200 (CEST) (envelope-from andrea.franceschini@postecom.it) Received: (from andrea@localhost) by knute.cs.poste.it (8.14.1/8.12.10/Submit) id l71JBK7T038171 for freebsd-hardware@FreeBSD.ORG; Wed, 1 Aug 2007 21:11:20 +0200 (CEST) (envelope-from andrea.franceschini@postecom.it) X-Authentication-Warning: knute.cs.poste.it: andrea set sender to andrea.franceschini@postecom.it using -f Date: Wed, 1 Aug 2007 21:11:20 +0200 From: Andrea Franceschini To: freebsd-hardware@FreeBSD.ORG Message-ID: <20070801191120.GB81152@postecom.it> Mail-Followup-To: freebsd-hardware@FreeBSD.ORG Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: Subject: Sun GEM Gigabit Ethernet support on x86 FreeBSD X-BeenThere: freebsd-hardware@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General discussion of FreeBSD hardware List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2007 19:31:30 -0000 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