From owner-freebsd-arm@FreeBSD.ORG Tue Mar 3 03:54:25 2015 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 74906697 for ; Tue, 3 Mar 2015 03:54:25 +0000 (UTC) Received: from mail-qa0-x231.google.com (mail-qa0-x231.google.com [IPv6:2607:f8b0:400d:c00::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 24BB91726 for ; Tue, 3 Mar 2015 03:54:25 +0000 (UTC) Received: by mail-qa0-f49.google.com with SMTP id w8so26223334qac.8 for ; Mon, 02 Mar 2015 19:54:24 -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=m4IYEWZ9gYnBQz17omXaDqpn/LMK9YiYoPAwc6w5BI8=; b=lInH3hpnzAOt7EFZbGAoCFUIjOe7p8DxGdoQv/8QY/KSHV4FZE+8V6OWZFiaS6w1bS LwGCghjveJsboBGN1MViwdybf6oatLi/HU9r8wzyxGLoYN8n81G75Jyn0InHex4L3ZTD lBGu5ESYiOfwGkJAoOrQnGOMNzsC634xue1hQNFK9crZQvRvN69H8jcJuZ7XYPOxRAjH I32Rc43KTmCHXIX0jFel6ZsT0d4jxRbL/94G1a5xjqf3QFU9x9BjUSg/Vgw0PPOI84bB F5rGV+0VdrO3y1j+khZ1cf4oRKs33RTBjDgyR9l1p91bABVAAqF040HfIpW+7Szl7JVI O8sg== MIME-Version: 1.0 X-Received: by 10.55.26.208 with SMTP id l77mr8876226qkh.62.1425354864226; Mon, 02 Mar 2015 19:54:24 -0800 (PST) Received: by 10.140.37.82 with HTTP; Mon, 2 Mar 2015 19:54:24 -0800 (PST) In-Reply-To: <8A6DDF8F-0BAA-40CE-8905-866C48BA6015@bsdimp.com> References: <8A6DDF8F-0BAA-40CE-8905-866C48BA6015@bsdimp.com> Date: Tue, 3 Mar 2015 00:54:24 -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 03:54:25 -0000 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 FPGA */ /* * 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 yo= u * 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 Los= h */ /* * 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 this * in the pci space, and then do stuff from tehre. However, it appears to * 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 recieved * 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 the * 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_ACTIVE= ); 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_chil= d > is > > not implemented" when I try to load it in my development board which is= 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 th= e > > 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" > >