From owner-p4-projects@FreeBSD.ORG Sat Sep 22 17:35:06 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DA42116A421; Sat, 22 Sep 2007 17:35:05 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BF4416A417 for ; Sat, 22 Sep 2007 17:35:05 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 5B66713C4B6 for ; Sat, 22 Sep 2007 17:35:05 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l8MHZ5Hu035574 for ; Sat, 22 Sep 2007 17:35:05 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l8MHZ5ut035571 for perforce@freebsd.org; Sat, 22 Sep 2007 17:35:05 GMT (envelope-from hselasky@FreeBSD.org) Date: Sat, 22 Sep 2007 17:35:05 GMT Message-Id: <200709221735.l8MHZ5ut035571@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 126697 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Sep 2007 17:35:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=126697 Change 126697 by hselasky@hselasky_laptop001 on 2007/09/22 17:34:22 - change UCOM layer to accept USB DMA buffers instead of linear buffers Affected files ... .. //depot/projects/usb/src/sys/dev/usb/ucom.c#17 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/ucom.c#17 (text+ko) ==== @@ -1060,12 +1060,14 @@ * 1 if data is available, else 0 */ -u_int8_t -ucom_get_data(struct ucom_softc *sc, u_int8_t *buf, u_int32_t len, - u_int32_t *actlen) +uint8_t +ucom_get_data(struct ucom_softc *sc, struct usbd_page_cache *pc, + uint32_t offset, uint32_t len, uint32_t *actlen) { + struct usbd_page_search res; struct tty *tp = sc->sc_tty; - u_int32_t cnt; + uint32_t cnt; + uint32_t offset_orig; mtx_assert(sc->sc_parent_mtx, MA_OWNED); @@ -1097,21 +1099,35 @@ goto done; } - cnt = q_to_b(&(tp->t_outq), buf, len); + offset_orig = offset; + + while (len > 0) { + + usbd_get_page(pc, offset, &res); + + if (res.length > len) { + res.length = len; + } + + cnt = q_to_b(&(tp->t_outq), res.buffer, res.length); + + offset += cnt; + len -= cnt; - if (cnt > len) { - DPRINTF(0, "invalid length, %d bytes\n", cnt); - goto done; + if (cnt < res.length) { + /* end of buffer */ + break; + } } - DPRINTF(0, "cnt=%d\n", cnt); + actlen[0] = offset - offset_orig; + + DPRINTF(0, "cnt=%d\n", actlen[0]); - if (cnt == 0) { + if (actlen[0] == 0) { goto done; } - actlen[0] = cnt; - ttwwakeup(tp); return 1; @@ -1125,10 +1141,12 @@ } void -ucom_put_data(struct ucom_softc *sc, u_int8_t *ptr, u_int16_t len) +ucom_put_data(struct ucom_softc *sc, struct usbd_page_cache *pc, + uint32_t offset, uint32_t len) { + struct usbd_page_search res; struct tty *tp = sc->sc_tty; - u_int16_t lostcc; + uint32_t cnt; mtx_assert(sc->sc_parent_mtx, MA_OWNED); @@ -1137,53 +1155,62 @@ return; /* multiport device polling */ } - /* set a flag to prevent recursation */ + /* set a flag to prevent recursation ? */ + + while (len > 0) { - if (len == 0) { - goto done; - } + usbd_get_page(pc, offset, &res); - if (tp->t_state & TS_CAN_BYPASS_L_RINT) { - if (((tp->t_rawq.c_cc + len) > tp->t_ihiwat) && - ((sc->sc_flag & UCOM_FLAG_RTS_IFLOW) || - (tp->t_iflag & IXOFF)) && - (!(tp->t_state & TS_TBLOCK))) { - ttyblock(tp); + if (res.length > len) { + res.length = len; } - lostcc = b_to_q(ptr, len, &(tp->t_rawq)); + len -= res.length; + offset += res.length; - tp->t_rawcc += len; + if (tp->t_state & TS_CAN_BYPASS_L_RINT) { - ttwakeup(tp); + if (((tp->t_rawq.c_cc + res.length) > tp->t_ihiwat) && + ((sc->sc_flag & UCOM_FLAG_RTS_IFLOW) || + (tp->t_iflag & IXOFF)) && + (!(tp->t_state & TS_TBLOCK))) { + ttyblock(tp); + } - if ((tp->t_state & TS_TTSTOP) && - ((tp->t_iflag & IXANY) || - (tp->t_cc[VSTART] == tp->t_cc[VSTOP]))) { - tp->t_state &= ~TS_TTSTOP; - tp->t_lflag &= ~FLUSHO; - ucom_start_write(tp); - } + cnt = b_to_q(res.buffer, res.length, &(tp->t_rawq)); - if (lostcc > 0) { - DPRINTF(0, "tp=%p, lost %d " - "chars\n", tp, lostcc); - } - } else { - /* pass characters to tty layer */ - while (len) { - DPRINTF(7, "char = 0x%02x\n", *ptr); + tp->t_rawcc += res.length; - if (ttyld_rint(tp, *ptr) == -1) { + ttwakeup(tp); - /* XXX what should we do? */ + if ((tp->t_state & TS_TTSTOP) && + ((tp->t_iflag & IXANY) || + (tp->t_cc[VSTART] == tp->t_cc[VSTOP]))) { + tp->t_state &= ~TS_TTSTOP; + tp->t_lflag &= ~FLUSHO; + ucom_start_write(tp); + } + if (cnt > 0) { DPRINTF(0, "tp=%p, lost %d " - "chars\n", tp, len); - break; + "chars\n", tp, cnt); + } + + } else { + + /* pass characters to tty layer */ + + for (cnt = 0; cnt < res.length; cnt++) { + + if (ttyld_rint(tp, ((uint8_t *)res.buffer)[cnt]) == -1) { + + /* XXX what should we do? */ + + DPRINTF(0, "tp=%p, lost %d " + "chars\n", tp, res.length - cnt); + break; + } } - len--; - ptr++; } }