Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Dec 2001 16:27:09 +0100
From:      "Petr Holub" <hopet@ics.muni.cz>
To:        <imp@harmony.village.org>, <akimichi@sfc.wide.ad.jp>
Cc:        <freebsd-hackers@FreeBSD.ORG>, <firewire-bsd@marahute.cc.uec.ac.jp>
Subject:   firewire driver
Message-ID:  <000201c18a33$f4cee710$2603fb93@kloboucek>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

------=_NextPart_000_0003_01C18A3C.56934F10
Content-Type: text/plain;
	charset="iso-8859-2"
Content-Transfer-Encoding: 7bit

Hi all!

I've patched the fwohci driver from the DVTS suite
(http://www.sfc.wide.ad.jp/DVTS/) to do the memory
allocation for the card on it's own in the case BIOS
is too lazy to do it (my case). Patch is in
the attachement. I'd like to thank Warner Losh for
his help with this problem and for his PCCBB code
in the -CURRENT. My patch runs for me on FreeBSD 4.4.
So if somebody is interested, here you are...

With best regards and best wishes for the year 2002,

Petr

================================================================
                            Petr Holub
CESNET z.s.p.o.                       Supercomputing Center Brno
Zikova 2                             Institute of Compt. Science
10200 Praha, CZ                               Masaryk University
Czech Republic                     Botanicka 68a, 60200 Brno, CZ 
e-mail: Petr.Holub@cesnet.cz              phone: +420-5-41512278
                                       e-mail: hopet@ics.muni.cz  
 
------=_NextPart_000_0003_01C18A3C.56934F10
Content-Type: application/octet-stream;
	name="fwohci.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="fwohci.diff"

--- fwohci.c.orig	Tue Dec 18 20:44:14 2001=0A=
+++ fwohci.c	Fri Dec 21 15:55:49 2001=0A=
@@ -357,6 +357,8 @@=0A=
 	volatile u_int32_t	cmd, fun, latency, cache_line;=0A=
 	u_int 		ch, i;=0A=
 	int rid;=0A=
+	u_int32_t sockbase;=0A=
+=0A=
 #ifdef __FreeBSD__=0A=
 #if 0=0A=
 	sc =3D &fwohci[unit];=0A=
@@ -398,10 +400,42 @@=0A=
 	rid =3D PCI_MAP_REG_START;=0A=
 	sc->fc.mem =3D bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,=0A=
 			          0, ~0, 1, RF_ACTIVE);=0A=
+=0A=
+/* This self-allocation is done using code by Warner Losh in -CURRENT =
(5.0)=0A=
+   from PCCBB code. Thanks Warner!=0A=
+   Petr Holub (hopet@ics.muni.cz) */=0A=
+=0A=
 	if (!sc->fc.mem) {=0A=
-		device_printf(dev, "could not map memory\n");=0A=
-		error =3D ENXIO;=0A=
-		goto fail;=0A=
+		device_printf(dev, "could not map memory - trying allocation on my =
own\n");=0A=
+		/* According to Windows 2000 */=0A=
+		#define FWOHCI_START_MEM 0xFFAFC000=0A=
+		/* According to Warner Losh's PCCBB */=0A=
+		/* #define FWOHCI_START_MEM 0x84000000 */=0A=
+		sockbase =3D pci_read_config(dev, rid, 4);=0A=
+		if (sockbase < 0x100000 || sockbase >=3D 0xfffffff0) {=0A=
+			pci_write_config(dev, rid, 0xffffffff, 4);=0A=
+			sockbase =3D pci_read_config(dev, rid, 4);=0A=
+			sockbase =3D (sockbase & 0xfffffff0) &=0A=
+			    -(sockbase & 0xfffffff0);=0A=
+			sc->fc.mem =3D bus_generic_alloc_resource(=0A=
+			    device_get_parent(dev), dev, SYS_RES_MEMORY,=0A=
+			    &rid, FWOHCI_START_MEM, ~0, sockbase,=0A=
+			    RF_ACTIVE|rman_make_alignment_flags(sockbase));=0A=
+			if (!sc->fc.mem){=0A=
+				device_printf(dev,=0A=
+				    "Could not grab register memory\n");=0A=
+				error =3D ENXIO;=0A=
+				goto fail;=0A=
+			}=0A=
+			pci_write_config(dev, PCI_MAP_REG_START,=0A=
+			    rman_get_start(sc->fc.mem), 4);=0A=
+			device_printf(dev, "PCI Memory allocated: %08lx\n",=0A=
+			    rman_get_start(sc->fc.mem));=0A=
+		} else {=0A=
+			device_printf(dev, "Could not map register memory\n");=0A=
+			error =3D ENXIO;=0A=
+			goto fail;=0A=
+		}=0A=
 	}=0A=
 	sc->base =3D rman_get_virtual(sc->fc.mem);=0A=
 #endif  /* __FreeBSD__ */=0A=

------=_NextPart_000_0003_01C18A3C.56934F10--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000201c18a33$f4cee710$2603fb93>