From owner-p4-projects@FreeBSD.ORG Sun Nov 7 05:50:10 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A369716A4D2; Sun, 7 Nov 2004 05:50:09 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2D89216A4CE for ; Sun, 7 Nov 2004 05:50:09 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 000F343D31 for ; Sun, 7 Nov 2004 05:50:08 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id iA75o850060245 for ; Sun, 7 Nov 2004 05:50:08 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id iA75o8Uq060242 for perforce@freebsd.org; Sun, 7 Nov 2004 05:50:08 GMT (envelope-from marcel@freebsd.org) Date: Sun, 7 Nov 2004 05:50:08 GMT Message-Id: <200411070550.iA75o8Uq060242@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 64481 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Nov 2004 05:50:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=64481 Change 64481 by marcel@marcel_nfs on 2004/11/07 05:49:23 Add resource allocation and release related code. With this, uart(4) probes as a child of scc(4). Next, IRQ handling so that we can do something other than wait for the interrupt storm to pass over... Affected files ... .. //depot/projects/uart/dev/scc/scc_core.c#4 edit Differences ... ==== //depot/projects/uart/dev/scc/scc_core.c#4 (text+ko) ==== @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD$"); +#define __RMAN_RESOURCE_VISIBLE /* XXX shouldn't be needed. */ + #include #include #include @@ -55,10 +57,12 @@ int scc_bfe_attach(device_t dev) { + struct resource_list_entry *rle; struct scc_chan *ch; struct scc_class *cl; struct scc_mode *m; struct scc_softc *sc; + bus_space_handle_t bh; u_long size, start; int c, error, i, mode; @@ -102,14 +106,29 @@ for (c = 1; c <= cl->cl_channels; c++) { ch = malloc(sizeof(struct scc_chan), M_SCC, M_WAITOK | M_ZERO); STAILQ_INSERT_TAIL(&sc->sc_chan, ch, ch_link); + resource_list_init(&ch->ch_rlist); ch->ch_nr = c; - resource_list_init(&ch->ch_rlist); resource_list_add(&ch->ch_rlist, sc->sc_rtype, sc->sc_rrid, start, start + size - 1, size); + rle = resource_list_find(&ch->ch_rlist, sc->sc_rtype, + sc->sc_rrid); + rle->res = malloc(sizeof(struct resource), M_SCC, + M_WAITOK | M_ZERO); + rman_set_start(rle->res, rle->start); + rman_set_end(rle->res, rle->end); + bus_space_subregion(rman_get_bustag(sc->sc_rres), + rman_get_bushandle(sc->sc_rres), + start - rman_get_start(sc->sc_rres), size, &bh); + rman_set_bushandle(rle->res, bh); + rman_set_bustag(rle->res, rman_get_bustag(sc->sc_rres)); + resource_list_add(&ch->ch_rlist, SYS_RES_IRQ, sc->sc_irid, rman_get_start(sc->sc_ires), rman_get_end(sc->sc_ires), 1); - + rle = resource_list_find(&ch->ch_rlist, SYS_RES_IRQ, + sc->sc_irid); + rle->res = sc->sc_ires; + STAILQ_INIT(&ch->ch_mode); mode = cl->cl_modes; while (mode != 0) { @@ -184,16 +203,49 @@ scc_bus_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { - device_printf(dev, "%s\n", __func__); - return (NULL); + struct resource_list_entry *rle; + struct scc_chan *ch; + struct scc_mode *m; + + /* We only support default allocations. */ + if (start != 0UL || end != ~0UL) + return (NULL); + + /* We don't support any grandchildren or children thereof. */ + if (device_get_parent(child) != dev) + return (NULL); + + m = device_get_ivars(child); + ch = m->m_chan; + rle = resource_list_find(&ch->ch_rlist, type, *rid); + if (rle == NULL) + return (NULL); + return (rle->res); } int scc_bus_get_resource(device_t dev, device_t child, int type, int rid, u_long *startp, u_long *countp) { + struct resource_list_entry *rle; + struct scc_chan *ch; + struct scc_mode *m; + + /* We don't support any grandchildren or children thereof. */ + if (device_get_parent(child) != dev) + return (EINVAL); + + m = device_get_ivars(child); + ch = m->m_chan; + rle = resource_list_find(&ch->ch_rlist, type, rid); + if (rle == NULL) + return (EINVAL); - return (ENXIO); + if (startp != NULL) + *startp = rle->start; + if (countp != NULL) + *countp = rle->count; + return (0); } int @@ -235,8 +287,18 @@ scc_bus_release_resource(device_t dev, device_t child, int type, int rid, struct resource *res) { + struct resource_list_entry *rle; + struct scc_chan *ch; + struct scc_mode *m; - return (ENXIO); + /* We don't support any grandchildren or children thereof. */ + if (device_get_parent(child) != dev) + return (EINVAL); + + m = device_get_ivars(child); + ch = m->m_chan; + rle = resource_list_find(&ch->ch_rlist, type, rid); + return ((rle == NULL) ? EINVAL : 0); } int