a3c57a6da5c6b9fbebae024afc4f93b38afc6767
[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  */
33
34 #ifndef _DEV_SYSCONS_SYSCONS_H_
35 #define _DEV_SYSCONS_SYSCONS_H_
36
37 #include <sys/malloc.h>
38
39 MALLOC_DECLARE(M_SYSCONS);
40
41 /* default values for configuration options */
42
43 #ifndef MAXCONS
44 #define MAXCONS         16      /* power of 2 */
45 #endif
46
47 #ifdef SC_NO_SYSMOUSE
48 #undef SC_NO_CUTPASTE
49 #define SC_NO_CUTPASTE  1
50 #endif
51
52 #ifdef SC_NO_MODE_CHANGE
53 #undef SC_PIXEL_MODE
54 #endif
55
56 /* Always load font data if the pixel (raster text) mode is to be used. */
57 #ifdef SC_PIXEL_MODE
58 #undef SC_NO_FONT_LOADING
59 #endif
60
61 /* 
62  * If font data is not available, the `arrow'-shaped mouse cursor cannot
63  * be drawn.  Use the alternative drawing method.
64  */
65 #ifdef SC_NO_FONT_LOADING
66 #undef SC_ALT_MOUSE_IMAGE
67 #define SC_ALT_MOUSE_IMAGE 1
68 #endif
69
70 #ifndef SC_CURSOR_CHAR
71 #define SC_CURSOR_CHAR  (0x07)
72 #endif
73
74 #ifndef SC_MOUSE_CHAR
75 #define SC_MOUSE_CHAR   (0xd0)
76 #endif
77
78 #if SC_MOUSE_CHAR <= SC_CURSOR_CHAR && SC_CURSOR_CHAR < (SC_MOUSE_CHAR + 4)
79 #undef SC_CURSOR_CHAR
80 #define SC_CURSOR_CHAR  (SC_MOUSE_CHAR + 4)
81 #endif
82
83 #ifndef SC_DEBUG_LEVEL
84 #define SC_DEBUG_LEVEL  0
85 #endif
86
87 #define DPRINTF(l, p)   if (SC_DEBUG_LEVEL >= (l)) kprintf p
88
89 #define SC_DRIVER_NAME  "sc"
90 #define SC_VTY(dev)     minor(dev)
91 #define SC_DEV(sc, vty) ((sc)->dev ? (sc)->dev[(vty) - (sc)->first_vty] : NULL)
92 #define SC_STAT(dev)    ((scr_stat *)(dev)->si_drv1)
93
94 /* printable chars */
95 #ifndef PRINTABLE
96 #define PRINTABLE(ch)   ((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
97                          || (ch) < 0x07)
98 #endif
99
100 /* macros for "intelligent" screen update */
101 #define mark_for_update(scp, x) {\
102                                     if ((x) < scp->start) scp->start = (x);\
103                                     else if ((x) > scp->end) scp->end = (x);\
104                                 }
105 #define mark_all(scp)           {\
106                                     scp->start = 0;\
107                                     scp->end = scp->xsize * scp->ysize - 1;\
108                                 }
109
110 /* macro for calculating the drawing position in video memory */
111 #ifdef SC_PIXEL_MODE
112 #define VIDEO_MEMORY_POS(scp, pos, x)                                   \
113         ((scp)->sc->adp->va_window +                                    \
114          (x) * (scp)->xoff +                                            \
115          (scp)->yoff * (scp)->font_height * (scp)->sc->adp->va_line_width +\
116          (x) * ((pos) % (scp)->xsize) +                                 \
117          (scp)->font_height * (scp)->sc->adp->va_line_width *           \
118          (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 struct dev_ioctl_args;
173
174 typedef struct sc_softc {
175         int             unit;                   /* unit # */
176         int             config;                 /* configuration flags */
177 #define SC_AUTODETECT_KBD (1 << 8)
178 #define SC_KERNEL_CONSOLE (1 << 9)
179 #define SC_EFI_FB       (1 << 10)
180
181         int             flags;                  /* status flags */
182 #define SC_VISUAL_BELL  (1 << 0)
183 #define SC_QUIET_BELL   (1 << 1)
184 #define SC_BLINK_CURSOR (1 << 2)
185 #define SC_CHAR_CURSOR  (1 << 3)
186 #define SC_MOUSE_ENABLED (1 << 4)
187 #define SC_SCRN_IDLE    (1 << 5)
188 #define SC_SCRN_BLANKED (1 << 6)
189 #define SC_SAVER_FAILED (1 << 7)
190 #define SC_SCRN_VTYLOCK (1 << 8)
191
192 #define SC_INIT_DONE    (1 << 16)
193 #define SC_SPLASH_SCRN  (1 << 17)
194
195         int             keyboard;               /* -1 if unavailable */
196         struct keyboard *kbd;
197
198         int             adapter;
199         struct video_adapter *adp;
200         int             initial_mode;           /* initial video mode */
201
202         uint64_t        fbi_generation;         /* increment on fbi update */
203         struct fb_info  *fbi;
204         struct fb_info  *dummy_fb_info;
205         struct task     *fb_set_par_task;
206         struct task     *fb_blank_task;
207         int             fb_blanked;
208
209         int             first_vty;
210         int             vtys;
211         cdev_t          *dev;
212         struct scr_stat *console_scp;
213         struct scr_stat *cur_scp;
214         struct scr_stat *new_scp;
215         struct scr_stat *old_scp;
216         int             delayed_next_scr;
217         int             videoio_in_progress;
218
219         char            font_loading_in_progress;
220         char            switch_in_progress;
221         char            write_in_progress;
222         char            blink_in_progress;
223
224         long            scrn_time_stamp;
225         struct callout  scrn_timer_ch;
226
227         char            cursor_base;
228         char            cursor_height;
229
230         u_char          scr_map[256];
231         u_char          scr_rmap[256];
232
233 #ifdef _SC_MD_SOFTC_DECLARED_
234         sc_md_softc_t   md;                     /* machine dependent vars */
235 #endif
236
237 #ifndef SC_NO_PALETTE_LOADING
238         u_char          palette[256*3];
239 #endif
240
241 #ifndef SC_NO_FONT_LOADING
242         int             fonts_loaded;
243 #define FONT_8          2
244 #define FONT_14         4
245 #define FONT_16         8
246         u_char          *font_8;
247         u_char          *font_14;
248         u_char          *font_16;
249 #endif
250
251         u_char          cursor_char;
252         u_char          mouse_char;
253
254 } sc_softc_t;
255
256 /* virtual screen */
257 typedef struct scr_stat {
258         int             index;                  /* index of this vty */
259         struct sc_softc *sc;                    /* pointer to softc */
260         struct sc_rndr_sw *rndr;                /* renderer */
261         sc_vtb_t        scr;
262         sc_vtb_t        vtb;
263         uint64_t        fbi_generation;         /* track fb_info updates */
264
265         int             xpos;                   /* current X position */
266         int             ypos;                   /* current Y position */
267         int             xsize;                  /* X text size */
268         int             ysize;                  /* Y text size */
269         int             xpixel;                 /* X graphics size */
270         int             ypixel;                 /* Y graphics size */
271         int             xoff;                   /* X offset in pixel mode */
272         int             yoff;                   /* Y offset in pixel mode */
273
274         u_char          *font;                  /* current font */
275         int             font_height;            /* font source Y pixels */
276         int             font_width;             /* font source X pixels */
277         int             blk_height;             /* fbtarget Y pixels */
278         int             blk_width;              /* fbtarget X pixels */
279
280         int             start;                  /* modified area start */
281         int             end;                    /* modified area end */
282         int             show_cursor;            /* used by async scrn_update */
283
284         struct sc_term_sw *tsw;
285         void            *ts;
286
287         int             status;                 /* status (bitfield) */
288         int             kbd_mode;               /* keyboard I/O mode */
289
290         int             cursor_pos;             /* cursor buffer position */
291         int             cursor_oldpos;          /* cursor old buffer position */
292         u_short         cursor_saveunder_char;  /* saved char under cursor */
293         u_short         cursor_saveunder_attr;  /* saved attr under cursor */
294         char            cursor_base;            /* cursor base line # */
295         char            cursor_height;          /* cursor height */
296
297         int             mouse_pos;              /* mouse buffer position */
298         int             mouse_oldpos;           /* mouse old buffer position */
299         short           mouse_xpos;             /* mouse x coordinate */
300         short           mouse_ypos;             /* mouse y coordinate */
301         short           mouse_oldxpos;          /* mouse previous x coordinate */
302         short           mouse_oldypos;          /* mouse previous y coordinate */
303         short           mouse_buttons;          /* mouse buttons */
304         int             mouse_cut_start;        /* mouse cut start pos */
305         int             mouse_cut_end;          /* mouse cut end pos */
306         struct proc     *mouse_proc;            /* proc* of controlling proc */
307         pid_t           mouse_pid;              /* pid of controlling proc */
308         int             mouse_signal;           /* signal # to report with */
309
310         u_short         bell_duration;
311         u_short         bell_pitch;
312
313         struct callout  blink_screen_ch;
314
315         uint32_t        ega_palette[16];        /* ega palette */
316         u_char          border;                 /* border color */
317         int             mode;                   /* mode */
318         int             model;                  /* memory model */
319         pid_t           pid;                    /* pid of controlling proc */
320         struct proc     *proc;                  /* proc* of controlling proc */
321         struct vt_mode  smode;                  /* switch mode */
322
323         sc_vtb_t        *history;               /* circular history buffer */
324         int             history_pos;            /* position shown on screen */
325         int             history_size;           /* size of history buffer */
326
327         int             splash_save_mode;       /* saved mode for splash scr */
328         int             splash_save_status;     /* saved status for splash scr*/
329         int             queue_update_td;
330         struct thread   *asynctd;
331 #ifdef _SCR_MD_STAT_DECLARED_
332         scr_md_stat_t   md;                     /* machine dependent vars */
333 #endif
334 } scr_stat;
335
336 #ifndef SC_NORM_ATTR
337 #define SC_NORM_ATTR            (FG_LIGHTGREY | BG_BLACK)
338 #endif
339 #ifndef SC_NORM_REV_ATTR
340 #define SC_NORM_REV_ATTR        (FG_BLACK | BG_LIGHTGREY)
341 #endif
342 #ifndef SC_KERNEL_CONS_ATTR
343 #define SC_KERNEL_CONS_ATTR     (FG_WHITE | BG_BLACK)
344 #endif
345 #ifndef SC_KERNEL_CONS_REV_ATTR
346 #define SC_KERNEL_CONS_REV_ATTR (FG_BLACK | BG_LIGHTGREY)
347 #endif
348 #ifndef SC_BORDER_COLOR
349 #define SC_BORDER_COLOR         FG_BLACK
350 #endif
351
352 /* terminal emulator */
353
354 #ifndef SC_DFLT_TERM
355 #define SC_DFLT_TERM    "*"                     /* any */
356 #endif
357
358 typedef int     sc_term_init_t(scr_stat *scp, void **tcp, int code);
359 #define SC_TE_COLD_INIT 0
360 #define SC_TE_WARM_INIT 1
361 typedef int     sc_term_term_t(scr_stat *scp, void **tcp);
362 typedef void    sc_term_puts_t(scr_stat *scp, u_char *buf, int len);
363 typedef int     sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd,
364                                 caddr_t data, int flag);
365 typedef int     sc_term_reset_t(scr_stat *scp, int code);
366 #define SC_TE_HARD_RESET 0
367 #define SC_TE_SOFT_RESET 1
368 typedef void    sc_term_default_attr_t(scr_stat *scp, int norm, int rev);
369 typedef void    sc_term_clear_t(scr_stat *scp);
370 typedef void    sc_term_notify_t(scr_stat *scp, int event);
371 #define SC_TE_NOTIFY_VTSWITCH_IN        0
372 #define SC_TE_NOTIFY_VTSWITCH_OUT       1
373 typedef int     sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
374
375 typedef struct sc_term_sw {
376         LIST_ENTRY(sc_term_sw)  link;
377         char                    *te_name;       /* name of the emulator */
378         char                    *te_desc;       /* description */
379         char                    *te_renderer;   /* matching renderer */
380         size_t                  te_size;        /* size of internal buffer */
381         int                     te_refcount;    /* reference counter */
382         sc_term_init_t          *te_init;
383         sc_term_term_t          *te_term;
384         sc_term_puts_t          *te_puts;
385         sc_term_ioctl_t         *te_ioctl;
386         sc_term_reset_t         *te_reset;
387         sc_term_default_attr_t  *te_default_attr;
388         sc_term_clear_t         *te_clear;
389         sc_term_notify_t        *te_notify;
390         sc_term_input_t         *te_input;
391 } sc_term_sw_t;
392
393 extern struct linker_set scterm_set;
394
395 #define SCTERM_MODULE(name, sw)                                 \
396         DATA_SET(scterm_set, sw);                               \
397         static int                                              \
398         scterm_##name##_event(module_t mod, int type, void *data) \
399         {                                                       \
400                 switch (type) {                                 \
401                 case MOD_LOAD:                                  \
402                         return sc_term_add(&sw);                \
403                 case MOD_UNLOAD:                                \
404                         if (sw.te_refcount > 0)                 \
405                                 return EBUSY;                   \
406                         return sc_term_remove(&sw);             \
407                 default:                                        \
408                         break;                                  \
409                 }                                               \
410                 return 0;                                       \
411         }                                                       \
412         static moduledata_t scterm_##name##_mod = {             \
413                 "scterm-" #name,                                \
414                 scterm_##name##_event,                          \
415                 NULL,                                           \
416         };                                                      \
417         DECLARE_MODULE(scterm_##name, scterm_##name##_mod,      \
418                        SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
419
420 /* renderer function table */
421 typedef void    vr_draw_border_t(scr_stat *scp, int color);
422 typedef void    vr_draw_t(scr_stat *scp, int from, int count, int flip);
423 typedef void    vr_set_cursor_t(scr_stat *scp, int base, int height, int blink);
424 typedef void    vr_draw_cursor_t(scr_stat *scp, int at, int blink,
425                                  int on, int flip);
426 typedef void    vr_blink_cursor_t(scr_stat *scp, int at, int flip);
427 typedef void    vr_set_mouse_t(scr_stat *scp);
428 typedef void    vr_draw_mouse_t(scr_stat *scp, int x, int y, int on);
429
430 typedef struct sc_rndr_sw {
431         vr_draw_border_t        *draw_border;
432         vr_draw_t               *draw;
433         vr_set_cursor_t         *set_cursor;
434         vr_draw_cursor_t        *draw_cursor;
435         vr_blink_cursor_t       *blink_cursor;
436         vr_draw_mouse_t         *draw_mouse;
437 } sc_rndr_sw_t;
438
439 typedef struct sc_renderer {
440         char                    *name;
441         int                     model;
442         sc_rndr_sw_t            *rndrsw;
443         LIST_ENTRY(sc_renderer) link;
444 } sc_renderer_t;
445
446 extern struct linker_set scrndr_set;
447
448 #define RENDERER(name, model, sw, set)                          \
449         static struct sc_renderer scrndr_##name##_##model = {   \
450                 #name, model, &sw                               \
451         };                                                      \
452         DATA_SET(scrndr_set, scrndr_##name##_##model);          \
453         DATA_SET(set, scrndr_##name##_##model)
454
455 #define RENDERER_MODULE(name, set)                              \
456         SET_DECLARE(set, sc_renderer_t);                        \
457         static int                                              \
458         scrndr_##name##_event(module_t mod, int type, void *data) \
459         {                                                       \
460                 sc_renderer_t **list;                           \
461                 int error = 0;                                  \
462                 switch (type) {                                 \
463                 case MOD_LOAD:                                  \
464                         SET_FOREACH(list, set) {                \
465                                 error = sc_render_add(*list);   \
466                                 if (error)                      \
467                                         break;                  \
468                         }                                       \
469                         break;                                  \
470                 case MOD_UNLOAD:                                \
471                         SET_FOREACH(list, set) {                \
472                                 error = sc_render_remove(*list);        \
473                                 if (error)                      \
474                                         break;                  \
475                         }                                       \
476                         break;                                  \
477                 default:                                        \
478                         break;                                  \
479                 }                                               \
480                 return error;                                   \
481         }                                                       \
482         static moduledata_t scrndr_##name##_mod = {             \
483                 "scrndr-" #name,                                \
484                 scrndr_##name##_event,                          \
485                 NULL,                                           \
486         };                                                      \
487         DECLARE_MODULE(scrndr_##name, scrndr_##name##_mod,      \
488                        SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
489
490 typedef struct {
491         int             cursor_start;
492         int             cursor_end;
493         int             shift_state;
494         int             bell_pitch;
495 } bios_values_t;
496
497 /* other macros */
498 #define ISTEXTSC(scp)   (!((scp)->status                                \
499                           & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
500 #define ISGRAPHSC(scp)  (((scp)->status                                 \
501                           & (UNKNOWN_MODE | GRAPHICS_MODE)))
502 #define ISPIXELSC(scp)  (((scp)->status                                 \
503                           & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
504                           == PIXEL_MODE)
505 #define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
506
507 #define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
508 #define ISFONTAVAIL(af) ((af) & V_ADP_FONT)
509 #define ISPALAVAIL(af)  ((af) & V_ADP_PALETTE)
510
511 #define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG)
512
513 /* syscons.c */
514 int             sc_probe_unit(int unit, int flags);
515 int             sc_attach_unit(int unit, int flags);
516
517 int             set_mode(scr_stat *scp);
518 void            refresh_ega_palette(scr_stat *scp);
519
520 void            sc_set_border(scr_stat *scp, int color);
521 void            sc_load_font(scr_stat *scp, int page, int size, u_char *font,
522                              int base, int count);
523 void            sc_save_font(scr_stat *scp, int page, int size, u_char *font,
524                              int base, int count);
525 void            sc_show_font(scr_stat *scp, int page);
526
527 void            sc_touch_scrn_saver(void);
528 void            sc_draw_cursor_image(scr_stat *scp);
529 void            sc_remove_cursor_image(scr_stat *scp);
530 void            sc_set_cursor_image(scr_stat *scp);
531 int             sc_clean_up(scr_stat *scp, int need_unlock);
532 int             sc_switch_scr(sc_softc_t *sc, u_int next_scr);
533 void            sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard);
534 int             sc_init_emulator(scr_stat *scp, char *name);
535 void            sc_paste(scr_stat *scp, u_char *p, int count);
536 void            sc_bell(scr_stat *scp, int pitch, int duration);
537 void            sc_font_scale(scr_stat *scp, int max_cols, int max_rows);
538
539 /* schistory.c */
540 #ifndef SC_NO_HISTORY
541 int             sc_alloc_history_buffer(scr_stat *scp, int lines,
542                                         int prev_ysize, int wait);
543 void            sc_free_history_buffer(scr_stat *scp, int prev_ysize);
544 void            sc_hist_save(scr_stat *scp);
545 #define         sc_hist_save_one_line(scp, from)        \
546                 sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize)
547 int             sc_hist_restore(scr_stat *scp);
548 void            sc_hist_home(scr_stat *scp);
549 void            sc_hist_getback(scr_stat *scp, int old_ysize);
550 void            sc_hist_end(scr_stat *scp);
551 int             sc_hist_up_line(scr_stat *scp);
552 int             sc_hist_down_line(scr_stat *scp);
553 int             sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data,
554                               int flag);
555 #endif /* SC_NO_HISTORY */
556
557 /* scmouse.c */
558 #ifndef SC_NO_CUTPASTE
559 void            sc_alloc_cut_buffer(scr_stat *scp, int wait);
560 void            sc_draw_mouse_image(scr_stat *scp); 
561 void            sc_remove_mouse_image(scr_stat *scp); 
562 int             sc_inside_cutmark(scr_stat *scp, int pos);
563 void            sc_remove_cutmarking(scr_stat *scp);
564 void            sc_remove_all_cutmarkings(sc_softc_t *scp);
565 void            sc_remove_all_mouse(sc_softc_t *scp);
566 #else
567 #define         sc_draw_mouse_image(scp)
568 #define         sc_remove_mouse_image(scp)
569 #define         sc_inside_cutmark(scp, pos)     FALSE
570 #define         sc_remove_cutmarking(scp)
571 #define         sc_remove_all_cutmarkings(scp)
572 #define         sc_remove_all_mouse(scp)
573 #endif /* SC_NO_CUTPASTE */
574 #ifndef SC_NO_SYSMOUSE
575 void            sc_mouse_move(scr_stat *scp, int x, int y);
576 int             sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
577                                int flag);
578 #endif /* SC_NO_SYSMOUSE */
579
580 /* scvidctl.c */
581 int             sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
582                                  int xsize, int ysize, int fontsize);
583 int             sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
584 int             sc_set_pixel_mode(scr_stat *scp, struct tty *tp,
585                                   int xsize, int ysize, int fontsize);
586 int             sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data,
587                                   int flag);
588
589 int             sc_render_add(sc_renderer_t *rndr);
590 int             sc_render_remove(sc_renderer_t *rndr);
591 sc_rndr_sw_t    *sc_render_match(scr_stat *scp, char *name, int model);
592 void            sc_update_render(scr_stat *scp);
593
594 /* scvtb.c */
595 void            sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows, 
596                             void *buffer, int wait);
597 void            sc_vtb_destroy(sc_vtb_t *vtb);
598 size_t          sc_vtb_size(int cols, int rows);
599 void            sc_vtb_clear(sc_vtb_t *vtb, int c, int attr);
600
601 int             sc_vtb_getc(sc_vtb_t *vtb, int at);
602 int             sc_vtb_geta(sc_vtb_t *vtb, int at);
603 void            sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a);
604 uint16_t        *sc_vtb_putchar(sc_vtb_t *vtb, uint16_t *p, int c, int a);
605 int             sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset);
606
607 #define         sc_vtb_tail(vtb)        ((vtb)->vtb_tail)
608 #define         sc_vtb_rows(vtb)        ((vtb)->vtb_rows)
609 #define         sc_vtb_cols(vtb)        ((vtb)->vtb_cols)
610
611 void            sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to,
612                             int count);
613 void            sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2,
614                               int count);
615 void            sc_vtb_seek(sc_vtb_t *vtb, int pos);
616 void            sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr);
617 void            sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count);
618 void            sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr);
619 void            sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr);
620
621 /* sysmouse.c */
622 int             sysmouse_event(mouse_info_t *info);
623
624 /* scterm.c */
625 void            sc_move_cursor(scr_stat *scp, int x, int y);
626 void            sc_clear_screen(scr_stat *scp);
627 int             sc_term_add(sc_term_sw_t *sw);
628 int             sc_term_remove(sc_term_sw_t *sw);
629 sc_term_sw_t    *sc_term_match(char *name);
630 sc_term_sw_t    *sc_term_match_by_number(int index);
631
632 /* machine dependent functions */
633 int             sc_max_unit(void);
634 sc_softc_t      *sc_get_softc(int unit, int flags);
635 sc_softc_t      *sc_find_softc(struct video_adapter *adp, struct keyboard *kbd);
636 int             sc_get_cons_priority(int *unit, int *flags);
637 void            sc_get_bios_values(bios_values_t *values);
638 int             sc_tone(int hertz);
639
640 #endif /* !_DEV_SYSCONS_SYSCONS_H_ */