From owner-freebsd-hackers@FreeBSD.ORG Fri May 20 03:23:17 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3F41316A4CE for ; Fri, 20 May 2005 03:23:17 +0000 (GMT) Received: from smtp1.matrix.com.br (smtp1.matrix.com.br [200.196.28.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id E3FC943DA5 for ; Fri, 20 May 2005 03:23:15 +0000 (GMT) (envelope-from cargnini@cargnini.trix.net) Received: from portalbl1.matrix.net.br (unknown [200.201.192.31]) by smtp1.matrix.com.br (Postfix) with SMTP id EB2E4379E8 for ; Fri, 20 May 2005 00:23:12 -0300 (BRST) Received: (qmail 32053 invoked from network); 20 May 2005 03:23:12 -0000 Received: from unknown (HELO shark.hopto.org) (cargnini@cargnini.trix.net@[200.175.74.246]) (envelope-sender ) by portalbl1.matrix.net.br (qmail-ldap-1.03) with SMTP for ; 20 May 2005 03:23:12 -0000 From: =?ISO-8859-1?Q?Lu=EDs_Vit=F3rio?= Cargnini To: freebsd-hackers@freebsd.org Content-Type: text/plain Date: Fri, 20 May 2005 00:23:46 -0300 Message-Id: <1116559426.27848.7.camel@shark.hopto.org> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Subject: PCI Device Driver X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2005 03:23:17 -0000 Hi i need to write a device driver for a PCI board. I read the developers book see the exemples and i'm starting to write the device driver. I'm writeing a device driver for a board with SAA713X TV chipset from Phillips. I did theskeleton example, but whe i catch the example of PCI driver from developers book and tried to compilate i receive the following: (forgive me for the long paste, but i need some answers and i need to give the details) PASTE of ERORS: @/sys/bus.h:455:23: device_if.h: No such file or directory @/sys/bus.h:456:20: bus_if.h: No such file or directory In file included from saa713x.c:23: @/dev/pci/pcivar.h:170:20: pci_if.h: No such file or directory In file included from saa713x.c:23: @/dev/pci/pcivar.h: In function `pci_get_subvendor': @/dev/pci/pcivar.h:203: warning: implicit declaration of function `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h: In function `pci_set_subvendor': @/dev/pci/pcivar.h:203: warning: implicit declaration of function `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h: In function `pci_get_subdevice': @/dev/pci/pcivar.h:204: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_subdevice': @/dev/pci/pcivar.h:204: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_vendor': @/dev/pci/pcivar.h:205: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_vendor': @/dev/pci/pcivar.h:205: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_device': @/dev/pci/pcivar.h:206: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_device': @/dev/pci/pcivar.h:206: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_devid': @/dev/pci/pcivar.h:207: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_devid': @/dev/pci/pcivar.h:207: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_class': @/dev/pci/pcivar.h:208: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_class': @/dev/pci/pcivar.h:208: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_subclass': @/dev/pci/pcivar.h:209: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_subclass': @/dev/pci/pcivar.h:209: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_progif': @/dev/pci/pcivar.h:210: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_progif': @/dev/pci/pcivar.h:210: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_revid': @/dev/pci/pcivar.h:211: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_revid': @/dev/pci/pcivar.h:211: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_intpin': @/dev/pci/pcivar.h:212: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_intpin': @/dev/pci/pcivar.h:212: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_irq': @/dev/pci/pcivar.h:213: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_irq': @/dev/pci/pcivar.h:213: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_bus': @/dev/pci/pcivar.h:214: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_bus': @/dev/pci/pcivar.h:214: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_slot': @/dev/pci/pcivar.h:215: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_slot': @/dev/pci/pcivar.h:215: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_function': @/dev/pci/pcivar.h:216: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_function': @/dev/pci/pcivar.h:216: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_get_ether': @/dev/pci/pcivar.h:217: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pci_set_ether': @/dev/pci/pcivar.h:217: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_read_config': @/dev/pci/pcivar.h:227: warning: implicit declaration of function `PCI_READ_CONFIG' @/dev/pci/pcivar.h:227: warning: nested extern declaration of `PCI_READ_CONFIG' @/dev/pci/pcivar.h: In function `pci_write_config': @/dev/pci/pcivar.h:233: warning: implicit declaration of function `PCI_WRITE_CONFIG' @/dev/pci/pcivar.h:233: warning: nested extern declaration of `PCI_WRITE_CONFIG' @/dev/pci/pcivar.h: In function `pcib_get_bus': @/dev/pci/pcivar.h:248: warning: nested extern declaration of `BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_READ_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_READ_IVAR' was here @/dev/pci/pcivar.h: In function `pcib_set_bus': @/dev/pci/pcivar.h:248: warning: nested extern declaration of `BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: redundant redeclaration of 'BUS_WRITE_IVAR' @/dev/pci/pcivar.h:203: warning: previous implicit declaration of 'BUS_WRITE_IVAR' was here @/dev/pci/pcivar.h: In function `pci_enable_busmaster': @/dev/pci/pcivar.h:269: warning: implicit declaration of function `PCI_ENABLE_BUSMASTER' @/dev/pci/pcivar.h:269: warning: nested extern declaration of `PCI_ENABLE_BUSMASTER' @/dev/pci/pcivar.h: In function `pci_disable_busmaster': @/dev/pci/pcivar.h:275: warning: implicit declaration of function `PCI_DISABLE_BUSMASTER' @/dev/pci/pcivar.h:275: warning: nested extern declaration of `PCI_DISABLE_BUSMASTER' @/dev/pci/pcivar.h: In function `pci_enable_io': @/dev/pci/pcivar.h:281: warning: implicit declaration of function `PCI_ENABLE_IO' @/dev/pci/pcivar.h:281: warning: nested extern declaration of `PCI_ENABLE_IO' @/dev/pci/pcivar.h: In function `pci_disable_io': @/dev/pci/pcivar.h:287: warning: implicit declaration of function `PCI_DISABLE_IO' @/dev/pci/pcivar.h:287: warning: nested extern declaration of `PCI_DISABLE_IO' @/dev/pci/pcivar.h: In function `pci_set_powerstate': @/dev/pci/pcivar.h:314: warning: implicit declaration of function `PCI_SET_POWERSTATE' @/dev/pci/pcivar.h:314: warning: nested extern declaration of `PCI_SET_POWERSTATE' @/dev/pci/pcivar.h: In function `pci_get_powerstate': @/dev/pci/pcivar.h:320: warning: implicit declaration of function `PCI_GET_POWERSTATE' @/dev/pci/pcivar.h:320: warning: nested extern declaration of `PCI_GET_POWERSTATE' saa713x.c: At top level: saa713x.c:50: error: conflicting types for 'saa713x_open' saa713x.c:27: error: previous declaration of 'saa713x_open' was here saa713x.c:50: error: conflicting types for 'saa713x_open' saa713x.c:27: error: previous declaration of 'saa713x_open' was here saa713x.c:59: error: conflicting types for 'saa713x_close' saa713x.c:28: error: previous declaration of 'saa713x_close' was here saa713x.c:59: error: conflicting types for 'saa713x_close' saa713x.c:28: error: previous declaration of 'saa713x_close' was here saa713x.c:68: error: conflicting types for 'saa713x_read' saa713x.c:29: error: previous declaration of 'saa713x_read' was here saa713x.c:68: error: conflicting types for 'saa713x_read' saa713x.c:29: error: previous declaration of 'saa713x_read' was here saa713x.c:77: error: conflicting types for 'saa713x_write' saa713x.c:30: error: previous declaration of 'saa713x_write' was here saa713x.c:77: error: conflicting types for 'saa713x_write' saa713x.c:30: error: previous declaration of 'saa713x_write' was here saa713x.c: In function `saa713x_attach': saa713x.c:111: warning: assignment makes integer from pointer without a cast saa713x.c: At top level: saa713x.c:161: error: `device_probe_desc' undeclared here (not in a function) saa713x.c:161: error: initializer element is not constant saa713x.c:161: error: (near initialization for `saa713x_methods[0].desc') saa713x.c:161: error: initializer element is not constant saa713x.c:161: error: (near initialization for `saa713x_methods[0]') saa713x.c:162: error: `device_attach_desc' undeclared here (not in a function) saa713x.c:162: error: initializer element is not constant saa713x.c:162: error: (near initialization for `saa713x_methods[1].desc') saa713x.c:162: error: initializer element is not constant saa713x.c:162: error: (near initialization for `saa713x_methods[1]') saa713x.c:163: error: `device_detach_desc' undeclared here (not in a function) saa713x.c:163: error: initializer element is not constant saa713x.c:163: error: (near initialization for `saa713x_methods[2].desc') saa713x.c:163: error: initializer element is not constant saa713x.c:163: error: (near initialization for `saa713x_methods[2]') saa713x.c:164: error: `device_shutdown_desc' undeclared here (not in a function) saa713x.c:164: error: initializer element is not constant saa713x.c:164: error: (near initialization for `saa713x_methods[3].desc') saa713x.c:164: error: initializer element is not constant saa713x.c:164: error: (near initialization for `saa713x_methods[3]') saa713x.c:165: error: `device_suspend_desc' undeclared here (not in a function) saa713x.c:165: error: initializer element is not constant saa713x.c:165: error: (near initialization for `saa713x_methods[4].desc') saa713x.c:165: error: initializer element is not constant saa713x.c:165: error: (near initialization for `saa713x_methods[4]') saa713x.c:166: error: `device_resume_desc' undeclared here (not in a function) saa713x.c:166: error: initializer element is not constant saa713x.c:166: error: (near initialization for `saa713x_methods[5].desc') saa713x.c:166: error: initializer element is not constant saa713x.c:166: error: (near initialization for `saa713x_methods[5]') saa713x.c:168: error: initializer element is not constant saa713x.c:168: error: (near initialization for `saa713x_methods[6]') *** Error code 1 Stop in /usr/home/.../projects/FreeBSD/device_drivers/saa713X. The source code is this:START STAGE /* * SAA713X Phillips Chipset * * Murray Stokely */ //#define MIN(a,b) (((a) < (b)) ? (a) : (b)) #include /* defines used in kernel.h */ #include #include #include #include /* types used in module initialization */ #include /* cdevsw struct */ #include /* uio struct */ #include #include /* structs, prototypes for pci bus stuff */ #include #include #include #include /* For get_pci macros! */ #include /* Function prototypes */ d_open_t saa713x_open; d_close_t saa713x_close; d_read_t saa713x_read; d_write_t saa713x_write; /* Character device entry points */ static struct cdevsw saa713x_cdevsw = { .d_open = saa713x_open, .d_close = saa713x_close, .d_read = saa713x_read, .d_write = saa713x_write, .d_name = "saa713x", }; /* vars */ static dev_t sdev; /* We're more interested in probe/attach than with open/close/read/write at this point */ int saa713x_open(dev_t dev, int oflags, int devtype, d_thread_t *td) { int err = 0; printf("Opened device \"saa713x\" successfully.\n"); return (err); } int saa713x_close(dev_t dev, int fflag, int devtype, d_thread_t *td) { int err = 0; printf("Closing device \"saa713x.\"\n"); return (err); } int saa713x_read(dev_t dev, struct uio *uio, int ioflag) { int err = 0; printf("saa713x read!\n"); return (err); } int saa713x_write(dev_t dev, struct uio *uio, int ioflag) { int err = 0; printf("saa713x write!\n"); return (err); } /* PCI Support Functions */ /* * Return identification string if this is device is ours. */ static int saa713x_probe(device_t dev) { device_printf(dev, "Saa713x Probe\nVendor ID : 0x%x\nDevice ID : 0x% x\n", pci_get_vendor(dev), pci_get_device(dev)); if (pci_get_vendor(dev) == 0x11c1) { printf("We've got the Winmodem, probe successful!\n"); return (0); } return (ENXIO); } /* Attach function is only called if the probe is successful */ static int saa713x_attach(device_t dev) { printf("Saa713x Attach for : deviceID : 0x%x \n",pci_get_vendor(dev)); sdev = make_dev(&saa713x_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "saa713x"); printf("Saa713x device loaded.\n"); return (ENXIO); } /* Detach device. */ static int saa713x_detach(device_t dev) { printf("Saa713x detach!\n"); return (0); } /* Called during system shutdown after sync. */ static int saa713x_shutdown(device_t dev) { printf("Saa713x shutdown!\n"); return (0); } /* * Device suspend routine. */ static int saa713x_suspend(device_t dev) { printf("Saa713x suspend!\n"); return (0); } /* * Device resume routine. */ static int saa713x_resume(device_t dev) { printf("Saa713x resume!\n"); return (0); } static device_method_t saa713x_methods[] = { /* Device interface */ DEVMETHOD(device_probe, saa713x_probe), DEVMETHOD(device_attach, saa713x_attach), DEVMETHOD(device_detach, saa713x_detach), DEVMETHOD(device_shutdown, saa713x_shutdown), DEVMETHOD(device_suspend, saa713x_suspend), DEVMETHOD(device_resume, saa713x_resume), { 0, 0 } }; static driver_t saa713x_driver = { "saa713x", saa713x_methods, 0, /* sizeof(struct saa713x_softc), */ }; static devclass_t saa713x_devclass; DRIVER_MODULE(saa713x, pci, saa713x_driver, saa713x_devclass, 0, 0); thanks for any help