PERFORCE change 126697 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sat Sep 22 10:35:06 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=126697
Change 126697 by hselasky at 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++;
}
}
More information about the p4-projects
mailing list