]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/syscons/syscons.h
MFV r325609: 7531 Assign correct flags to prefetched buffers
[FreeBSD/FreeBSD.git] / sys / dev / 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$
32  */
33
34 #ifndef _DEV_SYSCONS_SYSCONS_H_
35 #define _DEV_SYSCONS_SYSCONS_H_
36
37 #include <sys/kdb.h>            /* XXX */
38 #include <sys/_lock.h>
39 #include <sys/_mutex.h>
40
41 /* default values for configuration options */
42
43 #ifndef MAXCONS
44 #define MAXCONS         16
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  7
72 #endif
73
74 #ifndef SC_MOUSE_CHAR
75 #define SC_MOUSE_CHAR   8
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)) printf p
88
89 #ifndef __sparc64__
90 #define SC_DRIVER_NAME  "sc"
91 #else
92 /*
93  * Use a different driver name on sparc64 so it does not get confused
94  * with the system controller devices which are also termed 'sc' in OFW.
95  */
96 #define SC_DRIVER_NAME  "syscons"
97 #endif
98 #define SC_VTY(dev)     (((sc_ttysoftc *)tty_softc(tp))->st_index)
99 #define SC_DEV(sc, vty) ((sc)->dev[(vty) - (sc)->first_vty])
100 #define SC_STAT(tp)     (*((scr_stat **)&((sc_ttysoftc *)tty_softc(tp))->st_stat))
101
102 /* printable chars */
103 #ifndef PRINTABLE
104 #define PRINTABLE(ch)   ((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
105                          || (ch) < 0x07)
106 #endif
107
108 /* macros for "intelligent" screen update */
109 #define mark_for_update(scp, x) {\
110                                     if ((x) < scp->start) scp->start = (x);\
111                                     else if ((x) > scp->end) scp->end = (x);\
112                                 }
113 #define mark_all(scp)           {\
114                                     scp->start = 0;\
115                                     scp->end = scp->xsize * scp->ysize - 1;\
116                                 }
117
118 /* vty status flags (scp->status) */
119 #define UNKNOWN_MODE    0x00010         /* unknown video mode */
120 #define SWITCH_WAIT_REL 0x00080         /* waiting for vty release */
121 #define SWITCH_WAIT_ACQ 0x00100         /* waiting for vty ack */
122 #define BUFFER_SAVED    0x00200         /* vty buffer is saved */
123 #define CURSOR_ENABLED  0x00400         /* text cursor is enabled */
124 #define MOUSE_MOVED     0x01000         /* mouse cursor has moved */
125 #define MOUSE_CUTTING   0x02000         /* mouse cursor is cutting text */
126 #define MOUSE_VISIBLE   0x04000         /* mouse cursor is showing */
127 #define GRAPHICS_MODE   0x08000         /* vty is in a graphics mode */
128 #define PIXEL_MODE      0x10000         /* vty is in a raster text mode */
129 #define SAVER_RUNNING   0x20000         /* screen saver is running */
130 #define VR_CURSOR_BLINK 0x40000         /* blinking text cursor */
131 #define VR_CURSOR_ON    0x80000         /* text cursor is on */
132 #define MOUSE_HIDDEN    0x100000        /* mouse cursor is temporarily hidden */
133
134 /* misc defines */
135 #define FALSE           0
136 #define TRUE            1
137
138 /*
139    The following #defines are hard-coded for a maximum text
140    resolution corresponding to a maximum framebuffer
141    resolution of 1920x1200 with an 8x8 font...
142 */
143 #define COL             240
144 #define ROW             150
145
146 #define PCBURST         128
147
148 #ifndef BELL_DURATION
149 #define BELL_DURATION   ((5 * hz + 99) / 100)
150 #define BELL_PITCH      800
151 #endif
152
153 /* virtual terminal buffer */
154 typedef struct sc_vtb {
155         int             vtb_flags;
156 #define VTB_VALID       (1 << 0)
157 #define VTB_ALLOCED     (1 << 1)
158         int             vtb_type;
159 #define VTB_INVALID     0
160 #define VTB_MEMORY      1
161 #define VTB_FRAMEBUFFER 2
162 #define VTB_RINGBUFFER  3
163         int             vtb_cols;
164         int             vtb_rows;
165         int             vtb_size;
166         vm_offset_t     vtb_buffer;
167         int             vtb_tail;       /* valid for VTB_RINGBUFFER only */
168 } sc_vtb_t;
169
170 /* text and some mouse cursor attributes */
171 struct cursor_attr {
172         u_char          flags;
173         u_char          base;
174         u_char          height;
175         u_char          bg[3];
176         u_char          mouse_ba;
177         u_char          mouse_ia;
178 };
179
180 /* softc */
181
182 struct keyboard;
183 struct video_adapter;
184 struct scr_stat;
185 struct tty;
186
187 struct sc_cnstate {
188         u_char          kbd_locked;
189         u_char          kdb_locked;
190         u_char          mtx_locked;
191         u_char          kbd_opened;
192         u_char          scr_opened;
193 };
194
195 typedef struct sc_softc {
196         int             unit;                   /* unit # */
197         int             config;                 /* configuration flags */
198 #define SC_VESAMODE     (1 << 7)
199 #define SC_AUTODETECT_KBD (1 << 8)
200 #define SC_KERNEL_CONSOLE (1 << 9)
201
202         int             flags;                  /* status flags */
203 #define SC_VISUAL_BELL  (1 << 0)
204 #define SC_QUIET_BELL   (1 << 1)
205 #if 0 /* not used anymore */
206 #define SC_BLINK_CURSOR (1 << 2)
207 #define SC_CHAR_CURSOR  (1 << 3)
208 #endif
209 #define SC_MOUSE_ENABLED (1 << 4)
210 #define SC_SCRN_IDLE    (1 << 5)
211 #define SC_SCRN_BLANKED (1 << 6)
212 #define SC_SAVER_FAILED (1 << 7)
213 #define SC_SCRN_VTYLOCK (1 << 8)
214
215 #define SC_INIT_DONE    (1 << 16)
216 #define SC_SPLASH_SCRN  (1 << 17)
217
218         int             keyboard;               /* -1 if unavailable */
219         struct keyboard *kbd;
220
221         int             adapter;
222         struct video_adapter *adp;
223         int             initial_mode;           /* initial video mode */
224
225         int             first_vty;
226         int             vtys;
227         struct tty **dev;
228         struct scr_stat *cur_scp;
229         struct scr_stat *new_scp;
230         struct scr_stat *old_scp;
231         int             delayed_next_scr;
232
233         char            font_loading_in_progress;
234         char            switch_in_progress;
235         char            write_in_progress;
236         char            blink_in_progress;
237         int             grab_level;
238         /* 2 is just enough for kdb to grab for stepping normal grabbing: */
239         struct sc_cnstate grab_state[2];
240         int             kbd_open_level;
241         struct mtx      video_mtx;
242
243         long            scrn_time_stamp;
244
245         struct cursor_attr dflt_curs_attr;
246         struct cursor_attr curs_attr;
247
248         u_char          scr_map[256];
249         u_char          scr_rmap[256];
250
251 #ifdef _SC_MD_SOFTC_DECLARED_
252         sc_md_softc_t   md;                     /* machine dependent vars */
253 #endif
254
255 #ifndef SC_NO_PALETTE_LOADING
256         u_char          palette[256 * 3];
257 #ifdef SC_PIXEL_MODE
258         u_char          palette2[256 * 3];
259 #endif
260 #endif
261
262 #ifndef SC_NO_FONT_LOADING
263         int             fonts_loaded;
264 #define FONT_8          2
265 #define FONT_14         4
266 #define FONT_16         8
267 #define FONT_22         8
268         u_char          *font_8;
269         u_char          *font_14;
270         u_char          *font_16;
271         u_char          *font_22;
272 #endif
273
274         u_char          cursor_char;
275         u_char          mouse_char;
276
277 #ifdef KDB
278         int             sc_altbrk;
279 #endif
280         struct callout  ctimeout;
281         struct callout  cblink;
282 } sc_softc_t;
283
284 /* virtual screen */
285 typedef struct scr_stat {
286         int             index;                  /* index of this vty */
287         struct sc_softc *sc;                    /* pointer to softc */
288         struct sc_rndr_sw *rndr;                /* renderer */
289 #ifndef __sparc64__
290         sc_vtb_t        scr;
291 #endif
292         sc_vtb_t        vtb;
293
294         int             xpos;                   /* current X position */
295         int             ypos;                   /* current Y position */
296         int             xsize;                  /* X text size */
297         int             ysize;                  /* Y text size */
298         int             xpixel;                 /* X graphics size */
299         int             ypixel;                 /* Y graphics size */
300         int             xoff;                   /* X offset in pixel mode */
301         int             yoff;                   /* Y offset in pixel mode */
302
303         u_char          *font;                  /* current font */
304         int             font_size;              /* fontsize in Y direction */
305         int             font_width;             /* fontsize in X direction */
306
307         int             start;                  /* modified area start */
308         int             end;                    /* modified area end */
309
310         struct sc_term_sw *tsw;
311         void            *ts;
312
313         int             status;                 /* status (bitfield) */
314         int             kbd_mode;               /* keyboard I/O mode */
315
316         int             cursor_pos;             /* cursor buffer position */
317         int             cursor_oldpos;          /* cursor old buffer position */
318         struct cursor_attr dflt_curs_attr;
319         struct cursor_attr base_curs_attr;
320         struct cursor_attr curs_attr;
321
322         int             mouse_pos;              /* mouse buffer position */
323         int             mouse_oldpos;           /* mouse old buffer position */
324         short           mouse_xpos;             /* mouse x coordinate */
325         short           mouse_ypos;             /* mouse y coordinate */
326         short           mouse_oldxpos;          /* mouse previous x coordinate */
327         short           mouse_oldypos;          /* mouse previous y coordinate */
328         short           mouse_buttons;          /* mouse buttons */
329         int             mouse_cut_start;        /* mouse cut start pos */
330         int             mouse_cut_end;          /* mouse cut end pos */
331         int             mouse_level;            /* xterm mouse protocol */
332         struct proc     *mouse_proc;            /* proc* of controlling proc */
333         pid_t           mouse_pid;              /* pid of controlling proc */
334         int             mouse_signal;           /* signal # to report with */
335         const void      *mouse_data;            /* renderer (pixmap) data */
336
337         u_short         bell_duration;
338         u_short         bell_pitch;
339
340         u_char          border;                 /* border color */
341         int             mode;                   /* mode */
342         pid_t           pid;                    /* pid of controlling proc */
343         struct proc     *proc;                  /* proc* of controlling proc */
344         struct vt_mode  smode;                  /* switch mode */
345
346         sc_vtb_t        *history;               /* circular history buffer */
347         int             history_pos;            /* position shown on screen */
348         int             history_size;           /* size of history buffer */
349
350         int             splash_save_mode;       /* saved mode for splash screen */
351         int             splash_save_status;     /* saved status for splash screen */
352 #ifdef _SCR_MD_STAT_DECLARED_
353         scr_md_stat_t   md;                     /* machine dependent vars */
354 #endif
355 } scr_stat;
356
357 /* TTY softc. */
358 typedef struct sc_ttysoftc {
359         int             st_index;
360         scr_stat        *st_stat;
361 } sc_ttysoftc;
362
363 #ifndef SC_NORM_ATTR
364 #define SC_NORM_ATTR            (FG_LIGHTGREY | BG_BLACK)
365 #endif
366 #ifndef SC_NORM_REV_ATTR
367 #define SC_NORM_REV_ATTR        (FG_BLACK | BG_LIGHTGREY)
368 #endif
369 #ifndef SC_KERNEL_CONS_ATTR
370 #define SC_KERNEL_CONS_ATTR     (FG_WHITE | BG_BLACK)
371 #endif
372 #ifndef SC_KERNEL_CONS_REV_ATTR
373 #define SC_KERNEL_CONS_REV_ATTR (FG_BLACK | BG_LIGHTGREY)
374 #endif
375
376 /* terminal emulator */
377
378 #ifndef SC_DFLT_TERM
379 #define SC_DFLT_TERM    "*"                     /* any */
380 #endif
381
382 typedef int     sc_term_init_t(scr_stat *scp, void **tcp, int code);
383 #define SC_TE_COLD_INIT 0
384 #define SC_TE_WARM_INIT 1
385 typedef int     sc_term_term_t(scr_stat *scp, void **tcp);
386 typedef void    sc_term_puts_t(scr_stat *scp, u_char *buf, int len);
387 typedef int     sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd,
388                                 caddr_t data, struct thread *td);
389 typedef int     sc_term_reset_t(scr_stat *scp, int code);
390 #define SC_TE_HARD_RESET 0
391 #define SC_TE_SOFT_RESET 1
392 typedef void    sc_term_default_attr_t(scr_stat *scp, int norm, int rev);
393 typedef void    sc_term_clear_t(scr_stat *scp);
394 typedef void    sc_term_notify_t(scr_stat *scp, int event);
395 #define SC_TE_NOTIFY_VTSWITCH_IN        0
396 #define SC_TE_NOTIFY_VTSWITCH_OUT       1
397 typedef int     sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
398 typedef const char *sc_term_fkeystr_t(scr_stat *scp, int c);
399 typedef void sc_term_sync_t(scr_stat *scp);
400
401 typedef struct sc_term_sw {
402         LIST_ENTRY(sc_term_sw)  link;
403         char                    *te_name;       /* name of the emulator */
404         char                    *te_desc;       /* description */
405         char                    *te_renderer;   /* matching renderer */
406         size_t                  te_size;        /* size of internal buffer */
407         int                     te_refcount;    /* reference counter */
408         sc_term_init_t          *te_init;
409         sc_term_term_t          *te_term;
410         sc_term_puts_t          *te_puts;
411         sc_term_ioctl_t         *te_ioctl;
412         sc_term_reset_t         *te_reset;
413         sc_term_default_attr_t  *te_default_attr;
414         sc_term_clear_t         *te_clear;
415         sc_term_notify_t        *te_notify;
416         sc_term_input_t         *te_input;
417         sc_term_fkeystr_t       *te_fkeystr;
418         sc_term_sync_t          *te_sync;
419 } sc_term_sw_t;
420
421 #define SCTERM_MODULE(name, sw)                                 \
422         DATA_SET(scterm_set, sw);                               \
423         static int                                              \
424         scterm_##name##_event(module_t mod, int type, void *data) \
425         {                                                       \
426                 switch (type) {                                 \
427                 case MOD_LOAD:                                  \
428                         return sc_term_add(&sw);                \
429                 case MOD_UNLOAD:                                \
430                         if (sw.te_refcount > 0)                 \
431                                 return EBUSY;                   \
432                         return sc_term_remove(&sw);             \
433                 default:                                        \
434                         return EOPNOTSUPP;                      \
435                         break;                                  \
436                 }                                               \
437                 return 0;                                       \
438         }                                                       \
439         static moduledata_t scterm_##name##_mod = {             \
440                 "scterm-" #name,                                \
441                 scterm_##name##_event,                          \
442                 NULL,                                           \
443         };                                                      \
444         DECLARE_MODULE(scterm_##name, scterm_##name##_mod,      \
445                        SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
446
447 /* renderer function table */
448 typedef void    vr_init_t(scr_stat *scp);
449 typedef void    vr_clear_t(scr_stat *scp, int c, int attr);
450 typedef void    vr_draw_border_t(scr_stat *scp, int color);
451 typedef void    vr_draw_t(scr_stat *scp, int from, int count, int flip);
452 typedef void    vr_set_cursor_t(scr_stat *scp, int base, int height, int blink);
453 typedef void    vr_draw_cursor_t(scr_stat *scp, int at, int blink,
454                                  int on, int flip);
455 typedef void    vr_blink_cursor_t(scr_stat *scp, int at, int flip);
456 typedef void    vr_set_mouse_t(scr_stat *scp);
457 typedef void    vr_draw_mouse_t(scr_stat *scp, int x, int y, int on);
458
459 typedef struct sc_rndr_sw {
460         vr_init_t               *init;
461         vr_clear_t              *clear;
462         vr_draw_border_t        *draw_border;
463         vr_draw_t               *draw;
464         vr_set_cursor_t         *set_cursor;
465         vr_draw_cursor_t        *draw_cursor;
466         vr_blink_cursor_t       *blink_cursor;
467         vr_set_mouse_t          *set_mouse;
468         vr_draw_mouse_t         *draw_mouse;
469 } sc_rndr_sw_t;
470
471 typedef struct sc_renderer {
472         char                    *name;
473         int                     mode;
474         sc_rndr_sw_t            *rndrsw;
475         LIST_ENTRY(sc_renderer) link;
476 } sc_renderer_t;
477
478 #define RENDERER(name, mode, sw, set)                           \
479         static struct sc_renderer scrndr_##name##_##mode = {    \
480                 #name, mode, &sw                                \
481         };                                                      \
482         DATA_SET(scrndr_set, scrndr_##name##_##mode);           \
483         DATA_SET(set, scrndr_##name##_##mode)
484
485 #define RENDERER_MODULE(name, set)                              \
486         SET_DECLARE(set, sc_renderer_t);                        \
487         static int                                              \
488         scrndr_##name##_event(module_t mod, int type, void *data) \
489         {                                                       \
490                 sc_renderer_t **list;                           \
491                 int error = 0;                                  \
492                 switch (type) {                                 \
493                 case MOD_LOAD:                                  \
494                         SET_FOREACH(list, set) {                \
495                                 error = sc_render_add(*list);   \
496                                 if (error)                      \
497                                         break;                  \
498                         }                                       \
499                         break;                                  \
500                 case MOD_UNLOAD:                                \
501                         SET_FOREACH(list, set) {                \
502                                 error = sc_render_remove(*list);\
503                                 if (error)                      \
504                                         break;                  \
505                         }                                       \
506                         break;                                  \
507                 default:                                        \
508                         return EOPNOTSUPP;                      \
509                         break;                                  \
510                 }                                               \
511                 return error;                                   \
512         }                                                       \
513         static moduledata_t scrndr_##name##_mod = {             \
514                 "scrndr-" #name,                                \
515                 scrndr_##name##_event,                          \
516                 NULL,                                           \
517         };                                                      \
518         DECLARE_MODULE(scrndr_##name, scrndr_##name##_mod,      \
519                        SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
520
521 typedef struct {
522         int             shift_state;
523         int             bell_pitch;
524 } bios_values_t;
525
526 /* other macros */
527 #define ISTEXTSC(scp)   (!((scp)->status                                \
528                           & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
529 #define ISGRAPHSC(scp)  (((scp)->status                                 \
530                           & (UNKNOWN_MODE | GRAPHICS_MODE)))
531 #define ISPIXELSC(scp)  (((scp)->status                                 \
532                           & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
533                           == PIXEL_MODE)
534 #define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
535
536 #define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
537 #define ISFONTAVAIL(af) ((af) & V_ADP_FONT)
538 #define ISPALAVAIL(af)  ((af) & V_ADP_PALETTE)
539
540 #define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG)
541
542 #define SC_VIDEO_LOCKINIT(sc)                                           \
543                 mtx_init(&(sc)->video_mtx, "syscons video lock", NULL,  \
544                     MTX_SPIN | MTX_RECURSE);
545 #define SC_VIDEO_LOCK(sc)                                               \
546                 do {                                                    \
547                         if (!kdb_active)                                \
548                                 mtx_lock_spin(&(sc)->video_mtx);        \
549                 } while(0)
550 #define SC_VIDEO_UNLOCK(sc)                                             \
551                 do {                                                    \
552                         if (!kdb_active)                                \
553                                 mtx_unlock_spin(&(sc)->video_mtx);      \
554                 } while(0)
555
556 /* syscons.c */
557 extern int      (*sc_user_ioctl)(struct tty *tp, u_long cmd, caddr_t data,
558                                  struct thread *td);
559
560 int             sc_probe_unit(int unit, int flags);
561 int             sc_attach_unit(int unit, int flags);
562
563 int             set_mode(scr_stat *scp);
564
565 void            sc_set_border(scr_stat *scp, int color);
566 void            sc_load_font(scr_stat *scp, int page, int size, int width,
567                              u_char *font, int base, int count);
568 void            sc_save_font(scr_stat *scp, int page, int size, int width,
569                              u_char *font, int base, int count);
570 void            sc_show_font(scr_stat *scp, int page);
571
572 void            sc_touch_scrn_saver(void);
573 void            sc_draw_cursor_image(scr_stat *scp);
574 void            sc_remove_cursor_image(scr_stat *scp);
575 void            sc_set_cursor_image(scr_stat *scp);
576 void            sc_change_cursor_shape(scr_stat *scp, int flags,
577                                        int base, int height);
578 int             sc_clean_up(scr_stat *scp);
579 int             sc_switch_scr(sc_softc_t *sc, u_int next_scr);
580 void            sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard);
581 int             sc_init_emulator(scr_stat *scp, char *name);
582 void            sc_paste(scr_stat *scp, const u_char *p, int count);
583 void            sc_respond(scr_stat *scp, const u_char *p,
584                            int count, int wakeup);
585 void            sc_bell(scr_stat *scp, int pitch, int duration);
586
587 /* schistory.c */
588 #ifndef SC_NO_HISTORY
589 int             sc_alloc_history_buffer(scr_stat *scp, int lines,
590                                         int prev_ysize, int wait);
591 void            sc_free_history_buffer(scr_stat *scp, int prev_ysize);
592 void            sc_hist_save(scr_stat *scp);
593 #define         sc_hist_save_one_line(scp, from)        \
594                 sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize)
595 int             sc_hist_restore(scr_stat *scp);
596 void            sc_hist_home(scr_stat *scp);
597 void            sc_hist_end(scr_stat *scp);
598 int             sc_hist_up_line(scr_stat *scp);
599 int             sc_hist_down_line(scr_stat *scp);
600 int             sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data,
601                               struct thread *td);
602 #endif /* SC_NO_HISTORY */
603
604 /* scmouse.c */
605 #ifndef SC_NO_CUTPASTE
606 void            sc_alloc_cut_buffer(scr_stat *scp, int wait);
607 void            sc_draw_mouse_image(scr_stat *scp); 
608 void            sc_remove_mouse_image(scr_stat *scp); 
609 int             sc_inside_cutmark(scr_stat *scp, int pos);
610 void            sc_remove_cutmarking(scr_stat *scp);
611 void            sc_remove_all_cutmarkings(sc_softc_t *scp);
612 void            sc_remove_all_mouse(sc_softc_t *scp);
613 void            sc_mouse_paste(scr_stat *scp);
614 #else
615 #define         sc_draw_mouse_image(scp)
616 #define         sc_remove_mouse_image(scp)
617 #define         sc_inside_cutmark(scp, pos)     FALSE
618 #define         sc_remove_cutmarking(scp)
619 #define         sc_remove_all_cutmarkings(scp)
620 #define         sc_remove_all_mouse(scp)
621 #define         sc_mouse_paste(scp)
622 #endif /* SC_NO_CUTPASTE */
623 #ifndef SC_NO_SYSMOUSE
624 void            sc_mouse_move(scr_stat *scp, int x, int y);
625 int             sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
626                                struct thread *td);
627 #endif /* SC_NO_SYSMOUSE */
628
629 /* scvidctl.c */
630 int             sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
631                                  int xsize, int ysize, int fontsize,
632                                  int font_width);
633 int             sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
634 int             sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize,
635                                   int ysize, int fontsize, int font_width);
636 int             sc_support_pixel_mode(void *arg);
637 int             sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data,
638                              struct thread *td);
639
640 int             sc_render_add(sc_renderer_t *rndr);
641 int             sc_render_remove(sc_renderer_t *rndr);
642 sc_rndr_sw_t    *sc_render_match(scr_stat *scp, char *name, int mode);
643
644 /* scvtb.c */
645 void            sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows, 
646                             void *buffer, int wait);
647 void            sc_vtb_destroy(sc_vtb_t *vtb);
648 size_t          sc_vtb_size(int cols, int rows);
649 void            sc_vtb_clear(sc_vtb_t *vtb, int c, int attr);
650
651 int             sc_vtb_getc(sc_vtb_t *vtb, int at);
652 int             sc_vtb_geta(sc_vtb_t *vtb, int at);
653 void            sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a);
654 vm_offset_t     sc_vtb_putchar(sc_vtb_t *vtb, vm_offset_t p, int c, int a);
655 vm_offset_t     sc_vtb_pointer(sc_vtb_t *vtb, int at);
656 int             sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset);
657
658 #define         sc_vtb_tail(vtb)        ((vtb)->vtb_tail)
659 #define         sc_vtb_rows(vtb)        ((vtb)->vtb_rows)
660 #define         sc_vtb_cols(vtb)        ((vtb)->vtb_cols)
661
662 void            sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to,
663                             int count);
664 void            sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2,
665                               int count);
666 void            sc_vtb_seek(sc_vtb_t *vtb, int pos);
667 void            sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr);
668 void            sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count);
669 void            sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr);
670 void            sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr);
671
672 /* sysmouse.c */
673 int             sysmouse_event(mouse_info_t *info);
674
675 /* scterm.c */
676 void            sc_move_cursor(scr_stat *scp, int x, int y);
677 void            sc_clear_screen(scr_stat *scp);
678 int             sc_term_add(sc_term_sw_t *sw);
679 int             sc_term_remove(sc_term_sw_t *sw);
680 sc_term_sw_t    *sc_term_match(char *name);
681 sc_term_sw_t    *sc_term_match_by_number(int index);
682
683 /* machine dependent functions */
684 int             sc_max_unit(void);
685 sc_softc_t      *sc_get_softc(int unit, int flags);
686 sc_softc_t      *sc_find_softc(struct video_adapter *adp, struct keyboard *kbd);
687 int             sc_get_cons_priority(int *unit, int *flags);
688 void            sc_get_bios_values(bios_values_t *values);
689 int             sc_tone(int herz);
690
691 #endif /* !_DEV_SYSCONS_SYSCONS_H_ */