1/*-
2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 14 unchanged lines hidden (view full) ---
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/syscons/scterm-teken.c 186681 2009-01-01 13:26:53Z ed $");
32
33#include "opt_syscons.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/module.h>
39#include <sys/consio.h>
--- 4 unchanged lines hidden (view full) ---
44#include <machine/pc/display.h>
45#endif
46
47#include <dev/syscons/syscons.h>
48
49#include <dev/syscons/teken/teken.h>
50
51static void scteken_revattr(unsigned char, teken_attr_t *);
52
53static sc_term_init_t scteken_init;
54static sc_term_term_t scteken_term;
55static sc_term_puts_t scteken_puts;
56static sc_term_ioctl_t scteken_ioctl;
57static sc_term_default_attr_t scteken_default_attr;
58static sc_term_clear_t scteken_clear;
59static sc_term_input_t scteken_input;
--- 100 unchanged lines hidden (view full) ---
160 teken_input(&ts->ts_teken, buf, len);
161 scp->sc->write_in_progress--;
162}
163
164static int
165scteken_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data,
166 struct thread *td)
167{
168 vid_info_t *vi;
169
170 switch (cmd) {
171 case GIO_ATTR: /* get current attributes */
172 *(int*)data = SC_NORM_ATTR;
173 return (0);
174 case CONS_GETINFO: /* get current (virtual) console info */
175 /* XXX: INCORRECT! */
176 vi = (vid_info_t *)data;
177 if (vi->size != sizeof(struct vid_info))
178 return EINVAL;
179 vi->mv_norm.fore = SC_NORM_ATTR & 0x0f;
180 vi->mv_norm.back = (SC_NORM_ATTR >> 4) & 0x0f;
181 vi->mv_rev.fore = SC_NORM_ATTR & 0x0f;
182 vi->mv_rev.back = (SC_NORM_ATTR >> 4) & 0x0f;
183 /*
184 * The other fields are filled by the upper routine. XXX
185 */
186 return (ENOIOCTL);
187 }
188
189 return (ENOIOCTL);
190}
--- 84 unchanged lines hidden (view full) ---
275 a->ta_bgcolor = bg;
276 a->ta_format |= TF_BOLD;
277 return;
278 }
279 }
280 }
281}
282
283static inline unsigned int
284scteken_attr(const teken_attr_t *a)
285{
286 unsigned int attr = 0;
287
288 if (a->ta_format & TF_BOLD)
289 attr |= fgcolors_bold[a->ta_fgcolor];
290 else
291 attr |= fgcolors_normal[a->ta_fgcolor];
292 attr |= bgcolors[a->ta_bgcolor];
293
294#ifdef FG_UNDERLINE
295 if (a->ta_format & TF_UNDERLINE)
296 attr |= FG_UNDERLINE;
297#endif /* FG_UNDERLINE */
298#ifdef FG_BLINK
299 if (a->ta_format & TF_BLINK)
300 attr |= FG_BLINK;
301#endif /* FG_BLINK */
302
303 return (attr << 8);
304}
305
306static void
307scteken_bell(void *arg)
308{
309 scr_stat *scp = arg;
310
311 sc_bell(scp, scp->bell_pitch, scp->bell_duration);
--- 20 unchanged lines hidden (view full) ---
332#ifdef TEKEN_UTF8
333 if (c >= 0x80) {
334 /* XXX: Don't display UTF-8 yet. */
335 attr = (FG_YELLOW|BG_RED) << 8;
336 ch = '?';
337 } else
338#endif /* TEKEN_UTF8 */
339 {
340 attr = scteken_attr(a);
341 ch = c;
342 }
343
344 map = scp->sc->scr_map;
345
346 cursor = tp->tp_row * scp->xsize + tp->tp_col;
347 p = sc_vtb_pointer(&scp->vtb, cursor);
348 sc_vtb_putchar(&scp->vtb, p, map[ch], attr);
--- 19 unchanged lines hidden (view full) ---
368#ifdef TEKEN_UTF8
369 if (c >= 0x80) {
370 /* XXX: Don't display UTF-8 yet. */
371 attr = (FG_YELLOW|BG_RED) << 8;
372 ch = '?';
373 } else
374#endif /* TEKEN_UTF8 */
375 {
376 attr = scteken_attr(a);
377 ch = c;
378 }
379
380 map = scp->sc->scr_map;
381
382 if (r->tr_begin.tp_col == 0 && r->tr_end.tp_col == scp->xsize) {
383 /* Single contiguous region to fill. */
384 sc_vtb_erase(&scp->vtb, r->tr_begin.tp_row * scp->xsize,
--- 120 unchanged lines hidden ---
2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 14 unchanged lines hidden (view full) ---
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/syscons/scterm-teken.c 186681 2009-01-01 13:26:53Z ed $");
32
33#include "opt_syscons.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/module.h>
39#include <sys/consio.h>
--- 4 unchanged lines hidden (view full) ---
44#include <machine/pc/display.h>
45#endif
46
47#include <dev/syscons/syscons.h>
48
49#include <dev/syscons/teken/teken.h>
50
51static void scteken_revattr(unsigned char, teken_attr_t *);
52
53static sc_term_init_t scteken_init;
54static sc_term_term_t scteken_term;
55static sc_term_puts_t scteken_puts;
56static sc_term_ioctl_t scteken_ioctl;
57static sc_term_default_attr_t scteken_default_attr;
58static sc_term_clear_t scteken_clear;
59static sc_term_input_t scteken_input;
--- 100 unchanged lines hidden (view full) ---
160 teken_input(&ts->ts_teken, buf, len);
161 scp->sc->write_in_progress--;
162}
163
164static int
165scteken_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data,
166 struct thread *td)
167{
168 vid_info_t *vi;
169
170 switch (cmd) {
171 case GIO_ATTR: /* get current attributes */
172 *(int*)data = SC_NORM_ATTR;
173 return (0);
174 case CONS_GETINFO: /* get current (virtual) console info */
175 /* XXX: INCORRECT! */
176 vi = (vid_info_t *)data;
177 if (vi->size != sizeof(struct vid_info))
178 return EINVAL;
179 vi->mv_norm.fore = SC_NORM_ATTR & 0x0f;
180 vi->mv_norm.back = (SC_NORM_ATTR >> 4) & 0x0f;
181 vi->mv_rev.fore = SC_NORM_ATTR & 0x0f;
182 vi->mv_rev.back = (SC_NORM_ATTR >> 4) & 0x0f;
183 /*
184 * The other fields are filled by the upper routine. XXX
185 */
186 return (ENOIOCTL);
187 }
188
189 return (ENOIOCTL);
190}
--- 84 unchanged lines hidden (view full) ---
275 a->ta_bgcolor = bg;
276 a->ta_format |= TF_BOLD;
277 return;
278 }
279 }
280 }
281}
282
283static inline unsigned int
284scteken_attr(const teken_attr_t *a)
285{
286 unsigned int attr = 0;
287
288 if (a->ta_format & TF_BOLD)
289 attr |= fgcolors_bold[a->ta_fgcolor];
290 else
291 attr |= fgcolors_normal[a->ta_fgcolor];
292 attr |= bgcolors[a->ta_bgcolor];
293
294#ifdef FG_UNDERLINE
295 if (a->ta_format & TF_UNDERLINE)
296 attr |= FG_UNDERLINE;
297#endif /* FG_UNDERLINE */
298#ifdef FG_BLINK
299 if (a->ta_format & TF_BLINK)
300 attr |= FG_BLINK;
301#endif /* FG_BLINK */
302
303 return (attr << 8);
304}
305
306static void
307scteken_bell(void *arg)
308{
309 scr_stat *scp = arg;
310
311 sc_bell(scp, scp->bell_pitch, scp->bell_duration);
--- 20 unchanged lines hidden (view full) ---
332#ifdef TEKEN_UTF8
333 if (c >= 0x80) {
334 /* XXX: Don't display UTF-8 yet. */
335 attr = (FG_YELLOW|BG_RED) << 8;
336 ch = '?';
337 } else
338#endif /* TEKEN_UTF8 */
339 {
340 attr = scteken_attr(a);
341 ch = c;
342 }
343
344 map = scp->sc->scr_map;
345
346 cursor = tp->tp_row * scp->xsize + tp->tp_col;
347 p = sc_vtb_pointer(&scp->vtb, cursor);
348 sc_vtb_putchar(&scp->vtb, p, map[ch], attr);
--- 19 unchanged lines hidden (view full) ---
368#ifdef TEKEN_UTF8
369 if (c >= 0x80) {
370 /* XXX: Don't display UTF-8 yet. */
371 attr = (FG_YELLOW|BG_RED) << 8;
372 ch = '?';
373 } else
374#endif /* TEKEN_UTF8 */
375 {
376 attr = scteken_attr(a);
377 ch = c;
378 }
379
380 map = scp->sc->scr_map;
381
382 if (r->tr_begin.tp_col == 0 && r->tr_end.tp_col == scp->xsize) {
383 /* Single contiguous region to fill. */
384 sc_vtb_erase(&scp->vtb, r->tr_begin.tp_row * scp->xsize,
--- 120 unchanged lines hidden ---