Lines Matching +full:console +full:- +full:size
51 #include <xen/xen-os.h>
54 #include <contrib/xen/io/console.h>
71 unsigned int size);
73 unsigned int size);
77 * Called by the low-level driver during early boot.
78 * Only the minimal set up to get a console should be done here.
81 /* Prepare the console to be fully use */
104 #define WBUF_MASK(_i) ((_i)&(WBUF_SIZE-1))
109 #define RBUF_MASK(_i) ((_i)&(RBUF_SIZE-1))
113 /* Pointer to the console operations */
122 /* Console shared page */
127 * Data for the main console
128 * Necessary to support low-level console driver
134 /*----------------------------- Debug function ------------------------------*/
137 size_t size; member
142 xen_emergency_print(const char *str, size_t size) in xen_emergency_print() argument
145 HYPERVISOR_console_write(str, size); in xen_emergency_print()
155 if (pca->buf == NULL) { in putchar()
158 * console char by char. in putchar()
162 pca->buf[pca->n_next++] = c; in putchar()
163 if ((pca->size == pca->n_next) || (c = '\0')) { in putchar()
165 xen_emergency_print(pca->buf, pca->n_next); in putchar()
166 pca->n_next = 0; in putchar()
180 pca.size = sizeof(buf); in xc_printf()
184 pca.size = 0; in xc_printf()
197 /*---------------------- Helpers for the console lock -----------------------*/
206 mtx_lock_spin(&cons->mtx); in xencons_lock()
214 mtx_unlock_spin(&cons->mtx); in xencons_unlock()
217 #define xencons_lock_assert(cons) mtx_assert(&(cons)->mtx, MA_OWNED)
219 /*------------------ Helpers for the hypervisor console ---------------------*/
224 * Nothing to setup for the low-level console when using in xencons_early_init_hypervisor()
225 * the hypervisor console. in xencons_early_init_hypervisor()
239 intr_handler, tp, INTR_TYPE_TTY | INTR_MPSAFE, &cons->intr_handle); in xencons_init_hypervisor()
241 device_printf(dev, "Can't register console interrupt\n"); in xencons_init_hypervisor()
248 unsigned int size) in xencons_write_hypervisor() argument
251 HYPERVISOR_console_io(CONSOLEIO_write, size, buffer); in xencons_write_hypervisor()
253 return (size); in xencons_write_hypervisor()
258 unsigned int size) in xencons_read_hypervisor() argument
263 return (HYPERVISOR_console_io(CONSOLEIO_read, size, buffer)); in xencons_read_hypervisor()
273 /*------------------ Helpers for the ring console ---------------------------*/
277 cons->intf = pmap_mapdev_attr(ptoa(xen_get_console_mfn()), PAGE_SIZE, in xencons_early_init_ring()
279 cons->evtchn = xen_get_console_evtchn(); in xencons_early_init_ring()
290 if (cons->evtchn == 0) in xencons_init_ring()
293 err = xen_intr_bind_local_port(dev, cons->evtchn, NULL, in xencons_init_ring()
294 intr_handler, tp, INTR_TYPE_TTY | INTR_MPSAFE, &cons->intr_handle); in xencons_init_ring()
305 * The console may be used before the ring interrupt is properly in xencons_notify_ring()
309 if (__predict_true(cons->intr_handle != NULL)) in xencons_notify_ring()
310 xen_intr_signal(cons->intr_handle); in xencons_notify_ring()
313 .port = cons->evtchn in xencons_notify_ring()
322 unsigned int size) in xencons_write_ring() argument
328 intf = cons->intf; in xencons_write_ring()
332 wcons = intf->out_cons; in xencons_write_ring()
333 wprod = intf->out_prod; in xencons_write_ring()
336 KASSERT((wprod - wcons) <= sizeof(intf->out), in xencons_write_ring()
337 ("console send ring inconsistent")); in xencons_write_ring()
339 for (sent = 0; sent < size; sent++, wprod++) { in xencons_write_ring()
340 if ((wprod - wcons) >= sizeof(intf->out)) in xencons_write_ring()
342 intf->out[MASK_XENCONS_IDX(wprod, intf->out)] = buffer[sent]; in xencons_write_ring()
346 intf->out_prod = wprod; in xencons_write_ring()
354 xencons_read_ring(struct xencons_priv *cons, char *buffer, unsigned int size) in xencons_read_ring() argument
360 intf = cons->intf; in xencons_read_ring()
364 rcons = intf->in_cons; in xencons_read_ring()
365 rprod = intf->in_prod; in xencons_read_ring()
368 for (rsz = 0; rsz < size; rsz++, rcons++) { in xencons_read_ring()
371 buffer[rsz] = intf->in[MASK_XENCONS_IDX(rcons, intf->in)]; in xencons_read_ring()
375 intf->in_cons = rcons; in xencons_read_ring()
391 /*------------------ Common implementation of the console -------------------*/
394 * Called by the low-level driver during early boot to initialize the
395 * main console driver.
396 * Only the minimal set up to get a console should be done here.
409 main_cons.ops->early_init(&main_cons); in xencons_early_init()
413 * Receive character from the console and put them in the internal buffer
423 while ((sz = cons->ops->read(cons, buf, sizeof(buf))) > 0) { in xencons_rx()
427 cons->rbuf[RBUF_MASK(cons->rp++)] = buf[i]; in xencons_rx()
439 used = cons->wp - cons->wc; in xencons_tx_full()
451 while (cons->wc != cons->wp) { in xencons_tx_flush()
453 sz = cons->wp - cons->wc; in xencons_tx_flush()
454 if (sz > (WBUF_SIZE - WBUF_MASK(cons->wc))) in xencons_tx_flush()
455 sz = WBUF_SIZE - WBUF_MASK(cons->wc); in xencons_tx_flush()
456 sent = cons->ops->write(cons, &cons->wbuf[WBUF_MASK(cons->wc)], in xencons_tx_flush()
467 * If force is set, spin until the console data is in xencons_tx_flush()
473 cons->wc += sent; in xencons_tx_flush()
483 if ((cons->wp - cons->wc) < WBUF_SIZE) in xencons_putc()
484 cons->wbuf[WBUF_MASK(cons->wp++)] = c; in xencons_putc()
498 if (cons->rp != cons->rc) { in xencons_getc()
500 ret = (int)cons->rbuf[RBUF_MASK(cons->rc)]; in xencons_getc()
501 cons->rc++; in xencons_getc()
503 ret = -1; in xencons_getc()
547 * The input will be used by the low-level console when KDB is active in xencons_intr()
555 if (!cons->opened) in xencons_intr()
561 while ((ret = xencons_getc(cons)) != -1) { in xencons_intr()
563 kdb_alt_break(ret, &cons->altbrk); in xencons_intr()
576 * - Force flush all output
588 /*---------------------- Low-level console driver ---------------------------*/
596 cp->cn_pri = (boothowto & RB_SERIAL) ? CN_REMOTE : CN_NORMAL; in xencons_cnprobe()
597 sprintf(cp->cn_name, "%s0", driver_name); in xencons_cnprobe()
635 * The low-level console is used by KDB and panic. We have to ensure in xencons_cnputc()
643 /*----------------------------- TTY driver ---------------------------------*/
652 cons->opened = true; in xencons_tty_open()
664 cons->opened = false; in xencons_tty_close()
677 callout_reset(&cons->callout, XC_POLLTIME, in xencons_timeout()
688 callout_stop(&cons->callout); in xencons_tty_outwakeup()
691 callout_reset(&cons->callout, XC_POLLTIME, in xencons_tty_outwakeup()
702 /*------------------------ Main console driver ------------------------------*/
718 device_set_desc(dev, "Xen Console"); in xencons_probe()
727 * The main console is already allocated statically in order to in xencons_attach()
728 * support low-level console in xencons_attach()
739 callout_init_mtx(&cons->callout, tty_getlock(tp), 0); in xencons_attach()
741 err = cons->ops->init(dev, tp, xencons_intr); in xencons_attach()
743 device_printf(dev, "Unable to initialize the console (%d)\n", in xencons_attach()
748 /* register handler to flush console on shutdown */ in xencons_attach()
765 xen_intr_unbind(&cons->intr_handle); in xencons_resume()
767 err = cons->ops->init(dev, tp, xencons_intr); in xencons_resume()
769 device_printf(dev, "Unable to resume the console (%d)\n", err); in xencons_resume()