From owner-freebsd-arm@FreeBSD.ORG Tue Mar 3 04:18:16 2015 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DF5AC850 for ; Tue, 3 Mar 2015 04:18:16 +0000 (UTC) Received: from mail-qc0-x231.google.com (mail-qc0-x231.google.com [IPv6:2607:f8b0:400d:c01::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 90AA3190C for ; Tue, 3 Mar 2015 04:18:16 +0000 (UTC) Received: by qcrw7 with SMTP id w7so28431134qcr.4 for ; Mon, 02 Mar 2015 20:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=MF0olh7R0x5Tb2n0V7DvOihKNts5mJ9B3CyGPQ9PpzI=; b=zvTBDFu/FyOjXud/OsHs5DJZNP8z4363mOWCZqt5xPSm8KlsPxtyvb/4Y5EGH6gMeP E0MN7snaKB8bHyDt4JV74AVU2SPJxtUXHHIQUIISAWHxr6N4Av4XEZzbyEDx6qLSXixp AFBFDNOcwnpR1STu2Jt4Qe3FeNnSA0rhYyzKxpluSe+S/7kPwGMOIFq5lUHU/cn32+um neLGeiDdU2u54AZuJd3Xu6/HNJENO+vk1SY9lw1XCMilqkTc0tDBmI0jLNLBmjJImR7S TFbsD9AN2gtgzMuEBUYzBd9xlKLS5MXUbN0mj1HO2aJ9sv8cdnRJZW3/kau0SwSTRtI5 IFAQ== MIME-Version: 1.0 X-Received: by 10.55.26.208 with SMTP id l77mr8987032qkh.62.1425356295429; Mon, 02 Mar 2015 20:18:15 -0800 (PST) Received: by 10.140.37.82 with HTTP; Mon, 2 Mar 2015 20:18:15 -0800 (PST) In-Reply-To: References: <8A6DDF8F-0BAA-40CE-8905-866C48BA6015@bsdimp.com> Date: Tue, 3 Mar 2015 01:18:15 -0300 Message-ID: Subject: Re: panic: bus_add_child is not implemented From: =?UTF-8?Q?Mat=C3=ADas_Perret_Cantoni?= To: Warner Losh Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: freebsd-arm@freebsd.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Mar 2015 04:18:17 -0000 Oops! I found the error. In my system there's no simplebus node: root@zedboard: # devinfo nexus0 ofwbus0 simplebus0 zy7_slcr0 gic0 l2cache0 zy7_devcfg0 mp_tmr0 simplebus1 uart0 zy7_gpio0 gpioc0 gpiobus0 cgem0 miibus0 ukphy0 sdhci_fdt0 mmc0 mmcsd0 ehci0 usbus0 uhub0 --- I changed: DRIVER_MODULE(simple_register, simplebus, reg_driver, reg_devclass, 0, 0); for: DRIVER_MODULE(simple_register, simplebus0, reg_driver, reg_devclass, 0, 0); and now I can load it without a kernel panic. Now I have a new problem: after loading it I can't find the new node neither under /dev nor with devinfo. Thanks! 2015-03-03 0:54 GMT-03:00 Mat=C3=ADas Perret Cantoni : > Yes Warner, here it is. I think I got yours from here: > http://people.freebsd.org/~imp/led.tar.gz > > /* > * Prototipo 3 - Driver newbus simple para escribir un registro de la FPG= A > */ > > /* > * Copyright (c) 2000. M. Warner Losh. All Rights Reserved. > * > * "THE BEER-WARE LICENSE" (Revision 42): > * wrote this file. As long as you retain this notice > you > * can do whatever you want with this stuff. If we meet some day, and you > think > * this stuff is worth it, you can buy me a beer in return. M. Warner > Losh > */ > > /* > * Simple driver for the I-Opener LED, but likely could be adapted > * to any led driver. This is intended to be a thought excersize > * as well as a useful sample driver. Since I don't have a hackable > * iopener around to test it out on. > * > * The LED is located at 0x404c on the iopener. Likely we should find th= is > * in the pci space, and then do stuff from tehre. However, it appears t= o > * be controlled in some way by acpi, so I'm going to try to write this > driver > * to not interfere with that. > * > * the lower two bits of this register control the state of the LED. The > left > * led, with the mail ICON, is controlled by bit 0. The phone led is > * controlled by bit 1. > * > * This is a bog simple ISA driver... Would make a useful example, imho. > * > * Since I'm lazy, I have only a write interface. The characters recieve= d > * by the driver are masked and the results sent to these gpios. This > * allows things like '1' to turn on the led and '0' to turn off the led. > * There is a minor number for each led controlled. > * > * The read interface returns 1 character ('0' off '1' on) for the state > * of the led. > * > * thanks to "roastbeef" who posted technical information about this to t= he > * I-Opener BBS web site. > */ > > > #include > #include > #include > #include > > #include > #include > #include > > #include > #include > #include > > #define REG_IOADDR 0x67000000 > > struct reg_softc > { > struct cdev *dev0; > struct resource *res; > int rid; > }; > > static d_open_t reg_open; > static d_close_t reg_close; > static d_read_t reg_read; > static d_write_t reg_write; > > static struct cdevsw reg_cdevsw =3D { > .d_version =3D D_VERSION, > .d_open =3D reg_open, > .d_close =3D reg_close, > .d_read =3D reg_read, > .d_write =3D reg_write, > .d_name =3D "simple_register", > }; > > static devclass_t reg_devclass; > > static int reg_open(struct cdev *dev, int flags, int fmt, struct thread *= p) > { > uprintf("Open: simple_register.\n"); > return 0; > } > static int > reg_close(struct cdev *dev, int flags, int fmt, struct thread *p) > { > uprintf("Close: simple_register.\n"); > return 0; > } > > static int > reg_read(struct cdev *dev, struct uio *uio, int flag) > { > struct reg_softc *sc =3D dev->si_drv1; > int err; > u_int8_t ch; > > ch =3D bus_read_1(sc->res, 0); > err =3D uiomove(&ch, 1, uio); > > return err; > } > > static int > reg_write(struct cdev *dev, struct uio *uio, int flag) > { > > struct reg_softc *sc =3D dev->si_drv1; > int err; > u_int8_t ch; > > err =3D uiomove(&ch, 1, uio); > if (err !=3D 0) > return (err); > bus_write_1(sc->res, 0, ch); > return err; > } > static void > reg_identify (driver_t *driver, device_t parent) > { > device_t child; > child=3D device_find_child(parent, "simple_register", -1); > > if (!child) { > child =3D BUS_ADD_CHILD(parent, 0, "simple_register", -1); > bus_set_resource(child, SYS_RES_IOPORT, 0, REG_IOADDR, 1); > } > } > > static int > reg_probe(device_t dev) > { > if ( 0 =3D=3D bus_get_resource_start(dev, SYS_RES_IOPORT, 0) ) > return (ENXIO); > device_set_desc(dev, "simple_register_driver"); > return(BUS_PROBE_SPECIFIC); > } > > static int > reg_attach(device_t dev) > { > > struct reg_softc *sc; > sc =3D (struct reg_softc *) device_get_softc(dev); > sc->rid =3D 0; > /* Solicita el recurso */ > sc->res =3D bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->rid, RF_ACTI= VE); > if (sc->res =3D=3D NULL){ > device_printf(dev, "No se pudo obtener el puerto de E/S\n"); > return ENXIO; > } > /* Crea el nodo correspondiente en */ > sc->dev0 =3D make_dev(®_cdevsw, 0, UID_ROOT, GID_WHEEL, 0644, > "simple_reg"); > > return 0; > } > > static int > reg_detach(device_t dev) > { > struct reg_softc *sc; > sc =3D (struct reg_softc *) device_get_softc(dev); > /* Destruye el nodo */ > destroy_dev(sc->dev0); > > /* Devuelve los recursos */ > bus_release_resource(dev, SYS_RES_IOPORT, sc->rid, sc->res); > return 0; > } > > static device_method_t reg_methods[] =3D { > /* Device interface */ > DEVMETHOD(device_identify, reg_identify), > DEVMETHOD(device_probe, reg_probe), > DEVMETHOD(device_attach, reg_attach), > DEVMETHOD(device_detach, reg_detach), > > { 0, 0 } > }; > > /* Declaracion del driver */ > static driver_t reg_driver =3D { > "simple_register", > reg_methods, > sizeof(struct reg_softc), > }; > > DRIVER_MODULE(simple_register, simplebus, reg_driver, reg_devclass, 0, 0)= ; > > > 2015-03-02 22:48 GMT-03:00 Warner Losh : > > can you send me the source? >> >> Warner >> >> > On Mar 2, 2015, at 6:11 PM, Mat=C3=ADas Perret Cantoni < >> perretcantonim@gmail.com> wrote: >> > >> > Hello! >> > >> > I wrote a simple newbus driver for reading and writing a specific I/O >> port, >> > which is basically a copy of the Warner Losh example driver for the >> iOpener >> > Led. I compiled with no errors, but I get a kernel panic " >> bus_add_child is >> > not implemented" when I try to load it in my development board which i= s >> a >> > Zedboard with FreeBSD. >> > >> > >> > The way I compiled it: >> > >> > # cd /usr/src >> > root@matiBSD:/usr/src # make buildenv TARGET_ARCH=3Darmv6 >> > BUILDENV_SHELL=3D/usr/local/bin/bash >> > KERNBUILDDIR=3D/usr/obj/arm.armv6/usr/src/sys/ZEDBOARD >> > Entering world for armv6:arm >> > [root@matiBSD /usr/src]# cd /home/drivers/p3 >> > [root@matiBSD /home/drivers/p3]# make >> > >> > >> > The content of the Makefile I used: >> > >> > KMOD =3Dp3 >> > SRCS =3Dp3.c device_if.c bus_if.h >> > .include >> > >> > >> > The way I tried to load it: >> > >> > root@zedboard:/usr # kldload /boot/msdos/p3.ko >> > panic: bus_add_child is not implemented >> > cpuid =3D 1 >> > >> > >> > My only guess here is that I should compile the driver with the kernel >> so >> > that the linker can properly link the BUS_ADD_CHILD() method call in t= he >> > drivers identify() method. >> > >> > My host is: FreeBSD matiBSD 10.1-BETA2 FreeBSD 10.1-BETA2 >> > My target is: FreeBSD zedboard 10.1-BETA2 FreeBSD 10.1-BETA2 >> > >> > >> > I'm new at this, so any income is appreciated! >> > >> > Regards, >> > Matias. >> > _______________________________________________ >> > freebsd-arm@freebsd.org mailing list >> > http://lists.freebsd.org/mailman/listinfo/freebsd-arm >> > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" >> >> >