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