Merge from vendor branch ZLIB:
[dragonfly.git] / sys / dev / misc / syscons / syscons.h
1 /*-
2  * Copyright (c) 1995-1998 Søren Schmidt
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The DragonFly Project
6  * by Sascha Wildner <saw@online.de>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer,
13  *    without modification, immediately at the beginning of the file.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * $FreeBSD: src/sys/dev/syscons/syscons.h,v 1.60.2.6 2002/09/15 22:30:45 dd Exp $
32  * $DragonFly: src/sys/dev/misc/syscons/syscons.h,v 1.15 2005/05/26 16:24:33 swildner Exp $
33  */
34
35 #ifndef _DEV_SYSCONS_SYSCONS_H_
36 #define _DEV_SYSCONS_SYSCONS_H_
37
38 #include <sys/malloc.h>
39
40 MALLOC_DECLARE(M_SYSCONS);
41
42 /* default values for configuration options */
43
44 #ifndef MAXCONS
45 #define MAXCONS         16      /* power of 2 */
46 #endif
47
48 #ifdef SC_NO_SYSMOUSE
49 #undef SC_NO_CUTPASTE
50 #define SC_NO_CUTPASTE  1
51 #endif
52
53 #ifdef SC_NO_MODE_CHANGE
54 #undef SC_PIXEL_MODE
55 #endif
56
57 /* Always load font data if the pixel (raster text) mode is to be used. */
58 #ifdef SC_PIXEL_MODE
59 #undef SC_NO_FONT_LOADING
60 #endif
61
62 /* 
63  * If font data is not available, the `arrow'-shaped mouse cursor cannot
64  * be drawn.  Use the alternative drawing method.
65  */
66 #ifdef SC_NO_FONT_LOADING
67 #undef SC_ALT_MOUSE_IMAGE
68 #define SC_ALT_MOUSE_IMAGE 1
69 #endif
70
71 #ifndef SC_CURSOR_CHAR
72 #define SC_CURSOR_CHAR  (0x07)
73 #endif
74
75 #ifndef SC_MOUSE_CHAR
76 #define SC_MOUSE_CHAR   (0xd0)
77 #endif
78
79 #if SC_MOUSE_CHAR <= SC_CURSOR_CHAR && SC_CURSOR_CHAR < (SC_MOUSE_CHAR + 4)
80 #undef SC_CURSOR_CHAR
81 #define SC_CURSOR_CHAR  (SC_MOUSE_CHAR + 4)
82 #endif
83
84 #ifndef SC_DEBUG_LEVEL
85 #define SC_DEBUG_LEVEL  0
86 #endif
87
88 #define DPRINTF(l, p)   if (SC_DEBUG_LEVEL >= (l)) printf p
89
90 #define SC_DRIVER_NAME  "sc"
91 #define SC_VTY(dev)     minor(dev)
92 #define SC_DEV(sc, vty) ((sc)->dev[(vty) - (sc)->first_vty])
93 #define SC_STAT(dev)    ((scr_stat *)(dev)->si_drv1)
94
95 /* printable chars */
96 #ifndef PRINTABLE
97 #define PRINTABLE(ch)   ((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
98                          || (ch) < 0x07)
99 #endif
100
101 /* macros for "intelligent" screen update */
102 #define mark_for_update(scp, x) {\
103                                     if ((x) < scp->start) scp->start = (x);\
104                                     else if ((x) > scp->end) scp->end = (x);\
105                                 }
106 #define mark_all(scp)           {\
107                                     scp->start = 0;\
108                                     scp->end = scp->xsize * scp->ysize - 1;\
109                                 }
110
111 /* macro for calculating the drawing position in video memory */
112 #ifdef SC_PIXEL_MODE
113 #define VIDEO_MEMORY_POS(scp, pos, x)                                   \
114         ((scp)->sc->adp->va_window +                                    \
115          (x) * (scp)->xoff +                                            \
116          (scp)->yoff * (scp)->font_size * (scp)->sc->adp->va_line_width +\
117          (x) * ((pos) % (scp)->xsize) +                                 \
118          (scp)->font_size * (scp)->sc->adp->va_line_width * (pos / (scp)->xsize))
119 #endif
120
121 /* vty status flags (scp->status) */
122 #define UNKNOWN_MODE    0x00010         /* unknown video mode */
123 #define SWITCH_WAIT_REL 0x00080         /* waiting for vty release */
124 #define SWITCH_WAIT_ACQ 0x00100         /* waiting for vty ack */
125 #define BUFFER_SAVED    0x00200         /* vty buffer is saved */
126 #define CURSOR_ENABLED  0x00400         /* text cursor is enabled */
127 #define MOUSE_MOVED     0x01000         /* mouse cursor has moved */
128 #define MOUSE_CUTTING   0x02000         /* mouse cursor is cutting text */
129 #define MOUSE_VISIBLE   0x04000         /* mouse cursor is showing */
130 #define GRAPHICS_MODE   0x08000         /* vty is in a graphics mode */
131 #define PIXEL_MODE      0x10000         /* vty is in a raster text mode */
132 #define SAVER_RUNNING   0x20000         /* screen saver is running */
133 #define VR_CURSOR_BLINK 0x40000         /* blinking text cursor */
134 #define VR_CURSOR_ON    0x80000         /* text cursor is on */
135 #define MOUSE_HIDDEN    0x100000        /* mouse cursor is temporarily hidden */
136
137 /* misc defines */
138 #define FALSE           0
139 #define TRUE            1
140 #define COL             80
141 #define ROW             25
142 #define PCBURST         128
143
144 #ifndef BELL_DURATION
145 #define BELL_DURATION   ((5 * hz + 99) / 100)
146 #define BELL_PITCH      800
147 #endif
148
149 /* virtual terminal buffer */
150 typedef struct sc_vtb {
151         int             vtb_flags;
152 #define VTB_VALID       (1 << 0)
153 #define VTB_ALLOCED     (1 << 1)
154         int             vtb_type;
155 #define VTB_INVALID     0
156 #define VTB_MEMORY      1
157 #define VTB_FRAMEBUFFER 2
158 #define VTB_RINGBUFFER  3
159         int             vtb_cols;
160         int             vtb_rows;
161         int             vtb_size;
162         uint16_t        *vtb_buffer;
163         int             vtb_tail;       /* valid for VTB_RINGBUFFER only */
164 } sc_vtb_t;
165
166 /* softc */
167
168 struct keyboard;
169 struct video_adapter;
170 struct scr_stat;
171 struct tty;
172
173 typedef struct sc_softc {
174         int             unit;                   /* unit # */
175         int             config;                 /* configuration flags */
176 #define SC_VESA800X600  (1 << 7)
177 #define SC_AUTODETECT_KBD (1 << 8)
178 #define SC_KERNEL_CONSOLE (1 << 9)
179
180         int             flags;                  /* status flags */
181 #define SC_VISUAL_BELL  (1 << 0)
182 #define SC_QUIET_BELL   (1 << 1)
183 #define SC_BLINK_CURSOR (1 << 2)
184 #define SC_CHAR_CURSOR  (1 << 3)
185 #define SC_MOUSE_ENABLED (1 << 4)
186 #define SC_SCRN_IDLE    (1 << 5)
187 #define SC_SCRN_BLANKED (1 << 6)
188 #define SC_SAVER_FAILED (1 << 7)
189 #define SC_SCRN_VTYLOCK (1 << 8)
190
191 #define SC_INIT_DONE    (1 << 16)
192 #define SC_SPLASH_SCRN  (1 << 17)
193
194         int             keyboard;               /* -1 if unavailable */
195         struct keyboard *kbd;
196
197         int             adapter;
198         struct video_adapter *adp;
199         int             initial_mode;           /* initial video mode */
200
201         int             first_vty;
202         int             vtys;
203         dev_t           *dev;
204         struct scr_stat *cur_scp;
205         struct scr_stat *new_scp;
206         struct scr_stat *old_scp;
207         int             delayed_next_scr;
208
209         char            font_loading_in_progress;
210         char            switch_in_progress;
211         char            videoio_in_progress;
212         char            write_in_progress;
213         char            blink_in_progress;
214
215         long            scrn_time_stamp;
216         struct callout  scrn_timer_ch;
217
218         char            cursor_base;
219         char            cursor_height;
220
221         u_char          scr_map[256];
222         u_char          scr_rmap[256];
223
224 #ifdef _SC_MD_SOFTC_DECLARED_
225         sc_md_softc_t   md;                     /* machine dependent vars */
226 #endif
227
228 #ifndef SC_NO_PALETTE_LOADING
229         u_char          palette[256*3];
230 #endif
231
232 #ifndef SC_NO_FONT_LOADING
233         int             fonts_loaded;
234 #define FONT_8          2
235 #define FONT_14         4
236 #define FONT_16         8
237         u_char          *font_8;
238         u_char          *font_14;
239         u_char          *font_16;
240 #endif
241
242         u_char          cursor_char;
243         u_char          mouse_char;
244
245 } sc_softc_t;
246
247 /* virtual screen */
248 typedef struct scr_stat {
249         int             index;                  /* index of this vty */
250         struct sc_softc *sc;                    /* pointer to softc */
251         struct sc_rndr_sw *rndr;                /* renderer */
252         sc_vtb_t        scr;
253         sc_vtb_t        vtb;
254
255         int             xpos;                   /* current X position */
256         int             ypos;                   /* current Y position */
257         int             xsize;                  /* X text size */
258         int             ysize;                  /* Y text size */
259         int             xpixel;                 /* X graphics size */
260         int             ypixel;                 /* Y graphics size */
261         int             xoff;                   /* X offset in pixel mode */
262         int             yoff;                   /* Y offset in pixel mode */
263
264         u_char          *font;                  /* current font */
265         int             font_size;              /* fontsize in Y direction */
266
267         int             start;                  /* modified area start */
268         int             end;                    /* modified area end */
269
270         struct sc_term_sw *tsw;
271         void            *ts;
272
273         int             status;                 /* status (bitfield) */
274         int             kbd_mode;               /* keyboard I/O mode */
275
276         int             cursor_pos;             /* cursor buffer position */
277         int             cursor_oldpos;          /* cursor old buffer position */
278         u_short         cursor_saveunder_char;  /* saved char under cursor */
279         u_short         cursor_saveunder_attr;  /* saved attr under cursor */
280         char            cursor_base;            /* cursor base line # */
281         char            cursor_height;          /* cursor height */
282
283         int             mouse_pos;              /* mouse buffer position */
284         int             mouse_oldpos;           /* mouse old buffer position */
285         short           mouse_xpos;             /* mouse x coordinate */
286         short           mouse_ypos;             /* mouse y coordinate */
287         short           mouse_oldxpos;          /* mouse previous x coordinate */
288         short           mouse_oldypos;          /* mouse previous y coordinate */
289         short           mouse_buttons;          /* mouse buttons */
290         int             mouse_cut_start;        /* mouse cut start pos */
291         int             mouse_cut_end;          /* mouse cut end pos */
292         struct proc     *mouse_proc;            /* proc* of controlling proc */
293         pid_t           mouse_pid;              /* pid of controlling proc */
294         int             mouse_signal;           /* signal # to report with */
295
296         u_short         bell_duration;
297         u_short         bell_pitch;
298
299         struct callout  blink_screen_ch;
300
301         uint32_t        ega_palette[16];        /* ega palette */
302         u_char          border;                 /* border color */
303         int             mode;                   /* mode */
304         pid_t           pid;                    /* pid of controlling proc */
305         struct proc     *proc;                  /* proc* of controlling proc */
306         struct vt_mode  smode;                  /* switch mode */
307
308         sc_vtb_t        *history;               /* circular history buffer */
309         int             history_pos;            /* position shown on screen */
310         int             history_size;           /* size of history buffer */
311
312         int             splash_save_mode;       /* saved mode for splash screen */
313         int             splash_save_status;     /* saved status for splash screen */
314 #ifdef _SCR_MD_STAT_DECLARED_
315         scr_md_stat_t   md;                     /* machine dependent vars */
316 #endif
317 } scr_stat;
318
319 #ifndef SC_NORM_ATTR
320 #define SC_NORM_ATTR            (FG_LIGHTGREY | BG_BLACK)
321 #endif
322 #ifndef SC_NORM_REV_ATTR
323 #define SC_NORM_REV_ATTR        (FG_BLACK | BG_LIGHTGREY)
324 #endif
325 #ifndef SC_KERNEL_CONS_ATTR
326 #define SC_KERNEL_CONS_ATTR     (FG_WHITE | BG_BLACK)
327 #endif
328 #ifndef SC_KERNEL_CONS_REV_ATTR
329 #define SC_KERNEL_CONS_REV_ATTR (FG_BLACK | BG_LIGHTGREY)
330 #endif
331
332 /* terminal emulator */
333
334 #ifndef SC_DFLT_TERM
335 #define SC_DFLT_TERM    "*"                     /* any */
336 #endif
337
338 typedef int     sc_term_init_t(scr_stat *scp, void **tcp, int code);
339 #define SC_TE_COLD_INIT 0
340 #define SC_TE_WARM_INIT 1
341 typedef int     sc_term_term_t(scr_stat *scp, void **tcp);
342 typedef void    sc_term_puts_t(scr_stat *scp, u_char *buf, int len);
343 typedef int     sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd,
344                                 caddr_t data, int flag, struct thread *td);
345 typedef int     sc_term_reset_t(scr_stat *scp, int code);
346 #define SC_TE_HARD_RESET 0
347 #define SC_TE_SOFT_RESET 1
348 typedef void    sc_term_default_attr_t(scr_stat *scp, int norm, int rev);
349 typedef void    sc_term_clear_t(scr_stat *scp);
350 typedef void    sc_term_notify_t(scr_stat *scp, int event);
351 #define SC_TE_NOTIFY_VTSWITCH_IN        0
352 #define SC_TE_NOTIFY_VTSWITCH_OUT       1
353 typedef int     sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
354
355 typedef struct sc_term_sw {
356         LIST_ENTRY(sc_term_sw)  link;
357         char                    *te_name;       /* name of the emulator */
358         char                    *te_desc;       /* description */
359         char                    *te_renderer;   /* matching renderer */
360         size_t                  te_size;        /* size of internal buffer */
361         int                     te_refcount;    /* reference counter */
362         sc_term_init_t          *te_init;
363         sc_term_term_t          *te_term;
364         sc_term_puts_t          *te_puts;
365         sc_term_ioctl_t         *te_ioctl;
366         sc_term_reset_t         *te_reset;
367         sc_term_default_attr_t  *te_default_attr;
368         sc_term_clear_t         *te_clear;
369         sc_term_notify_t        *te_notify;
370         sc_term_input_t         *te_input;
371 } sc_term_sw_t;
372
373 extern struct linker_set scterm_set;
374
375 #define SCTERM_MODULE(name, sw)                                 \
376         DATA_SET(scterm_set, sw);                               \
377         static int                                              \
378         scterm_##name##_event(module_t mod, int type, void *data) \
379         {                                                       \
380                 switch (type) {                                 \
381                 case MOD_LOAD:                                  \
382                         return sc_term_add(&sw);                \
383                 case MOD_UNLOAD:                                \
384                         if (sw.te_refcount > 0)                 \
385                                 return EBUSY;                   \
386                         return sc_term_remove(&sw);             \
387                 default:                                        \
388                         break;                                  \
389                 }                                               \
390                 return 0;                                       \
391         }                                                       \
392         static moduledata_t scterm_##name##_mod = {             \
393                 "scterm-" #name,                                \
394                 scterm_##name##_event,                          \
395                 NULL,                                           \
396         };                                                      \
397         DECLARE_MODULE(scterm_##name, scterm_##name##_mod,      \
398                        SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
399
400 /* renderer function table */
401 typedef void    vr_init_t(scr_stat *scp);
402 typedef void    vr_draw_border_t(scr_stat *scp, int color);
403 typedef void    vr_draw_t(scr_stat *scp, int from, int count, int flip);
404 typedef void    vr_set_cursor_t(scr_stat *scp, int base, int height, int blink);
405 typedef void    vr_draw_cursor_t(scr_stat *scp, int at, int blink,
406                                  int on, int flip);
407 typedef void    vr_blink_cursor_t(scr_stat *scp, int at, int flip);
408 typedef void    vr_set_mouse_t(scr_stat *scp);
409 typedef void    vr_draw_mouse_t(scr_stat *scp, int x, int y, int on);
410
411 typedef struct sc_rndr_sw {
412         vr_init_t               *init;
413         vr_draw_border_t        *draw_border;
414         vr_draw_t               *draw;
415         vr_set_cursor_t         *set_cursor;
416         vr_draw_cursor_t        *draw_cursor;
417         vr_blink_cursor_t       *blink_cursor;
418         vr_set_mouse_t          *set_mouse;
419         vr_draw_mouse_t         *draw_mouse;
420 } sc_rndr_sw_t;
421
422 typedef struct sc_renderer {
423         char                    *name;
424         int                     mode;
425         sc_rndr_sw_t            *rndrsw;
426         LIST_ENTRY(sc_renderer) link;
427 } sc_renderer_t;
428
429 extern struct linker_set scrndr_set;
430
431 #define RENDERER(name, mode, sw, set)                           \
432         static struct sc_renderer scrndr_##name##_##mode = {    \
433                 #name, mode, &sw                                \
434         };                                                      \
435         DATA_SET(scrndr_set, scrndr_##name##_##mode);           \
436         DATA_SET(set, scrndr_##name##_##mode)
437
438 #define RENDERER_MODULE(name, set)                              \
439         SET_DECLARE(set, sc_renderer_t);                        \
440         static int                                              \
441         scrndr_##name##_event(module_t mod, int type, void *data) \
442         {                                                       \
443                 sc_renderer_t **list;                           \
444                 int error = 0;                                  \
445                 switch (type) {                                 \
446                 case MOD_LOAD:                                  \
447                         SET_FOREACH(list, set) {                \
448                                 error = sc_render_add(*list);   \
449                                 if (error)                      \
450                                         break;                  \
451                         }                                       \
452                         break;                                  \
453                 case MOD_UNLOAD:                                \
454                         SET_FOREACH(list, set) {                \
455                                 error = sc_render_remove(*list);        \
456                                 if (error)                      \
457                                         break;                  \
458                         }                                       \
459                         break;                                  \
460                 default:                                        \
461                         break;                                  \
462                 }                                               \
463                 return error;                                   \
464         }                                                       \
465         static moduledata_t scrndr_##name##_mod = {             \
466                 "scrndr-" #name,                                \
467                 scrndr_##name##_event,                          \
468                 NULL,                                           \
469         };                                                      \
470         DECLARE_MODULE(scrndr_##name, scrndr_##name##_mod,      \
471                        SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
472
473 typedef struct {
474         int             cursor_start;
475         int             cursor_end;
476         int             shift_state;
477         int             bell_pitch;
478 } bios_values_t;
479
480 /* other macros */
481 #define ISTEXTSC(scp)   (!((scp)->status                                \
482                           & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
483 #define ISGRAPHSC(scp)  (((scp)->status                                 \
484                           & (UNKNOWN_MODE | GRAPHICS_MODE)))
485 #define ISPIXELSC(scp)  (((scp)->status                                 \
486                           & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
487                           == PIXEL_MODE)
488 #define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
489
490 #define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
491 #define ISFONTAVAIL(af) ((af) & V_ADP_FONT)
492 #define ISPALAVAIL(af)  ((af) & V_ADP_PALETTE)
493
494 #define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG)
495
496 #define kbd_read_char(kbd, wait)                                        \
497                 (*kbdsw[(kbd)->kb_index]->read_char)((kbd), (wait))
498 #define kbd_check_char(kbd)                                             \
499                 (*kbdsw[(kbd)->kb_index]->check_char)((kbd))
500 #define kbd_enable(kbd)                                                 \
501                 (*kbdsw[(kbd)->kb_index]->enable)((kbd))
502 #define kbd_disable(kbd)                                                \
503                 (*kbdsw[(kbd)->kb_index]->disable)((kbd))
504 #define kbd_lock(kbd, lockf)                                            \
505                 (*kbdsw[(kbd)->kb_index]->lock)((kbd), (lockf))
506 #define kbd_ioctl(kbd, cmd, arg)                                        \
507             (((kbd) == NULL) ?                                          \
508                 ENODEV : (*kbdsw[(kbd)->kb_index]->ioctl)((kbd), (cmd), (arg)))
509 #define kbd_clear_state(kbd)                                            \
510                 (*kbdsw[(kbd)->kb_index]->clear_state)((kbd))
511 #define kbd_get_fkeystr(kbd, fkey, len)                                 \
512                 (*kbdsw[(kbd)->kb_index]->get_fkeystr)((kbd), (fkey), (len))
513 #define kbd_poll(kbd, on)                                               \
514                 (*kbdsw[(kbd)->kb_index]->poll)((kbd), (on))
515
516 /* syscons.c */
517 extern int      (*sc_user_ioctl)(dev_t dev, u_long cmd, caddr_t data,
518                                  int flag, struct thread *td);
519
520 int             sc_probe_unit(int unit, int flags);
521 int             sc_attach_unit(int unit, int flags);
522
523 int             set_mode(scr_stat *scp);
524 void            refresh_ega_palette(scr_stat *scp);
525
526 void            sc_set_border(scr_stat *scp, int color);
527 void            sc_load_font(scr_stat *scp, int page, int size, u_char *font,
528                              int base, int count);
529 void            sc_save_font(scr_stat *scp, int page, int size, u_char *font,
530                              int base, int count);
531 void            sc_show_font(scr_stat *scp, int page);
532
533 void            sc_touch_scrn_saver(void);
534 void            sc_puts(scr_stat *scp, u_char *buf, int len);
535 void            sc_draw_cursor_image(scr_stat *scp);
536 void            sc_remove_cursor_image(scr_stat *scp);
537 void            sc_set_cursor_image(scr_stat *scp);
538 int             sc_clean_up(scr_stat *scp);
539 int             sc_switch_scr(sc_softc_t *sc, u_int next_scr);
540 void            sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard);
541 int             sc_init_emulator(scr_stat *scp, char *name);
542 void            sc_paste(scr_stat *scp, u_char *p, int count);
543 void            sc_bell(scr_stat *scp, int pitch, int duration);
544
545 /* schistory.c */
546 #ifndef SC_NO_HISTORY
547 int             sc_alloc_history_buffer(scr_stat *scp, int lines,
548                                         int prev_ysize, int wait);
549 void            sc_free_history_buffer(scr_stat *scp, int prev_ysize);
550 void            sc_hist_save(scr_stat *scp);
551 #define         sc_hist_save_one_line(scp, from)        \
552                 sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize)
553 int             sc_hist_restore(scr_stat *scp);
554 void            sc_hist_home(scr_stat *scp);
555 void            sc_hist_end(scr_stat *scp);
556 int             sc_hist_up_line(scr_stat *scp);
557 int             sc_hist_down_line(scr_stat *scp);
558 int             sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data,
559                               int flag, struct thread *td);
560 #endif /* SC_NO_HISTORY */
561
562 /* scmouse.c */
563 #ifndef SC_NO_CUTPASTE
564 void            sc_alloc_cut_buffer(scr_stat *scp, int wait);
565 void            sc_draw_mouse_image(scr_stat *scp); 
566 void            sc_remove_mouse_image(scr_stat *scp); 
567 int             sc_inside_cutmark(scr_stat *scp, int pos);
568 void            sc_remove_cutmarking(scr_stat *scp);
569 void            sc_remove_all_cutmarkings(sc_softc_t *scp);
570 void            sc_remove_all_mouse(sc_softc_t *scp);
571 #else
572 #define         sc_draw_mouse_image(scp)
573 #define         sc_remove_mouse_image(scp)
574 #define         sc_inside_cutmark(scp, pos)     FALSE
575 #define         sc_remove_cutmarking(scp)
576 #define         sc_remove_all_cutmarkings(scp)
577 #define         sc_remove_all_mouse(scp)
578 #endif /* SC_NO_CUTPASTE */
579 #ifndef SC_NO_SYSMOUSE
580 void            sc_mouse_move(scr_stat *scp, int x, int y);
581 int             sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
582                                int flag, struct thread *td);
583 #endif /* SC_NO_SYSMOUSE */
584
585 /* scvidctl.c */
586 int             sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
587                                  int xsize, int ysize, int fontsize);
588 int             sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
589 int             sc_set_pixel_mode(scr_stat *scp, struct tty *tp,
590                                   int xsize, int ysize, int fontsize);
591 int             sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
592                              struct thread *td);
593
594 int             sc_render_add(sc_renderer_t *rndr);
595 int             sc_render_remove(sc_renderer_t *rndr);
596 sc_rndr_sw_t    *sc_render_match(scr_stat *scp, char *name, int mode);
597
598 /* scvtb.c */
599 void            sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows, 
600                             void *buffer, int wait);
601 void            sc_vtb_destroy(sc_vtb_t *vtb);
602 size_t          sc_vtb_size(int cols, int rows);
603 void            sc_vtb_clear(sc_vtb_t *vtb, int c, int attr);
604
605 int             sc_vtb_getc(sc_vtb_t *vtb, int at);
606 int             sc_vtb_geta(sc_vtb_t *vtb, int at);
607 void            sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a);
608 uint16_t        *sc_vtb_putchar(sc_vtb_t *vtb, uint16_t *p, int c, int a);
609 int             sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset);
610
611 #define         sc_vtb_tail(vtb)        ((vtb)->vtb_tail)
612 #define         sc_vtb_rows(vtb)        ((vtb)->vtb_rows)
613 #define         sc_vtb_cols(vtb)        ((vtb)->vtb_cols)
614
615 void            sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to,
616                             int count);
617 void            sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2,
618                               int count);
619 void            sc_vtb_seek(sc_vtb_t *vtb, int pos);
620 void            sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr);
621 void            sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count);
622 void            sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr);
623 void            sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr);
624
625 /* sysmouse.c */
626 int             sysmouse_event(mouse_info_t *info);
627
628 /* scterm.c */
629 void            sc_move_cursor(scr_stat *scp, int x, int y);
630 void            sc_clear_screen(scr_stat *scp);
631 int             sc_term_add(sc_term_sw_t *sw);
632 int             sc_term_remove(sc_term_sw_t *sw);
633 sc_term_sw_t    *sc_term_match(char *name);
634 sc_term_sw_t    *sc_term_match_by_number(int index);
635
636 /* machine dependent functions */
637 int             sc_max_unit(void);
638 sc_softc_t      *sc_get_softc(int unit, int flags);
639 sc_softc_t      *sc_find_softc(struct video_adapter *adp, struct keyboard *kbd);
640 int             sc_get_cons_priority(int *unit, int *flags);
641 void            sc_get_bios_values(bios_values_t *values);
642 int             sc_tone(int hertz);
643
644 #endif /* !_DEV_SYSCONS_SYSCONS_H_ */