syscons.c (42748) | syscons.c (42831) |
---|---|
1/*- 2 * Copyright (c) 1992-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 --- 11 unchanged lines hidden (view full) --- 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 * | 1/*- 2 * Copyright (c) 1992-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 --- 11 unchanged lines hidden (view full) --- 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 * $Id: syscons.c,v 1.291 1999/01/13 01:14:26 yokota Exp $ | 28 * $Id: syscons.c,v 1.292 1999/01/17 14:23:15 yokota Exp $ |
29 */ 30 31#include "sc.h" 32#include "splash.h" | 29 */ 30 31#include "sc.h" 32#include "splash.h" |
33#ifdef __i386__ |
|
33#include "apm.h" | 34#include "apm.h" |
35#endif |
|
34#include "opt_ddb.h" 35#include "opt_devfs.h" | 36#include "opt_ddb.h" 37#include "opt_devfs.h" |
38#ifdef __i386__ |
|
36#include "opt_vesa.h" 37#include "opt_vm86.h" | 39#include "opt_vesa.h" 40#include "opt_vm86.h" |
41#endif |
|
38#include "opt_syscons.h" 39 40#if NSC > 0 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/reboot.h> 44#include <sys/conf.h> 45#include <sys/proc.h> --- 9 unchanged lines hidden (view full) --- 55#include <machine/clock.h> 56#include <machine/cons.h> 57#include <machine/console.h> 58#include <machine/mouse.h> 59#include <machine/md_var.h> 60#include <machine/psl.h> 61#include <machine/frame.h> 62#include <machine/pc/display.h> | 42#include "opt_syscons.h" 43 44#if NSC > 0 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/reboot.h> 48#include <sys/conf.h> 49#include <sys/proc.h> --- 9 unchanged lines hidden (view full) --- 59#include <machine/clock.h> 60#include <machine/cons.h> 61#include <machine/console.h> 62#include <machine/mouse.h> 63#include <machine/md_var.h> 64#include <machine/psl.h> 65#include <machine/frame.h> 66#include <machine/pc/display.h> |
67#ifdef __i386__ |
|
63#include <machine/pc/vesa.h> 64#include <machine/apm_bios.h> 65#include <machine/random.h> | 68#include <machine/pc/vesa.h> 69#include <machine/apm_bios.h> 70#include <machine/random.h> |
71#endif |
|
66 67#include <vm/vm.h> 68#include <vm/vm_param.h> 69#include <vm/pmap.h> 70 71#include <dev/kbd/kbdreg.h> 72#include <dev/fb/fbreg.h> 73#include <dev/fb/vgareg.h> 74#include <dev/fb/splashreg.h> 75#include <dev/syscons/syscons.h> 76 | 72 73#include <vm/vm.h> 74#include <vm/vm_param.h> 75#include <vm/pmap.h> 76 77#include <dev/kbd/kbdreg.h> 78#include <dev/fb/fbreg.h> 79#include <dev/fb/vgareg.h> 80#include <dev/fb/splashreg.h> 81#include <dev/syscons/syscons.h> 82 |
83#ifndef __i386__ 84#include <isa/isareg.h> 85#else |
|
77#include <i386/isa/isa.h> 78#include <i386/isa/isa_device.h> 79#include <i386/isa/timerreg.h> | 86#include <i386/isa/isa.h> 87#include <i386/isa/isa_device.h> 88#include <i386/isa/timerreg.h> |
89#endif |
|
80 81#if !defined(MAXCONS) 82#define MAXCONS 16 83#endif 84 85#if !defined(SC_MAX_HISTORY_SIZE) 86#define SC_MAX_HISTORY_SIZE (1000 * MAXCONS) 87#endif --- 112 unchanged lines hidden (view full) --- 200static int extra_history_size = 201 SC_MAX_HISTORY_SIZE - SC_HISTORY_SIZE * MAXCONS; 202 203static void none_saver(int blank) { } 204static void (*current_saver)(int blank) = none_saver; 205 d_ioctl_t *sc_user_ioctl; 206 207static int sticky_splash = FALSE; | 90 91#if !defined(MAXCONS) 92#define MAXCONS 16 93#endif 94 95#if !defined(SC_MAX_HISTORY_SIZE) 96#define SC_MAX_HISTORY_SIZE (1000 * MAXCONS) 97#endif --- 112 unchanged lines hidden (view full) --- 210static int extra_history_size = 211 SC_MAX_HISTORY_SIZE - SC_HISTORY_SIZE * MAXCONS; 212 213static void none_saver(int blank) { } 214static void (*current_saver)(int blank) = none_saver; 215 d_ioctl_t *sc_user_ioctl; 216 217static int sticky_splash = FALSE; |
218static struct { 219 u_int8_t cursor_start; 220 u_int8_t cursor_end; 221 u_int8_t shift_state; 222 } bios_value; |
|
208 209/* OS specific stuff */ 210#ifdef not_yet_done 211#define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x])) 212struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS])) 213struct MOUSE_TTY (sccons[MAXCONS+1] = ttymalloc(sccons[MAXCONS+1])) 214struct tty *sccons[MAXCONS+2]; 215#else 216#define VIRTUAL_TTY(x) &sccons[x] 217#define CONSOLE_TTY &sccons[MAXCONS] 218#define MOUSE_TTY &sccons[MAXCONS+1] 219static struct tty sccons[MAXCONS+2]; 220#endif 221#define SC_MOUSE 128 222#define SC_CONSOLE 255 | 223 224/* OS specific stuff */ 225#ifdef not_yet_done 226#define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x])) 227struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS])) 228struct MOUSE_TTY (sccons[MAXCONS+1] = ttymalloc(sccons[MAXCONS+1])) 229struct tty *sccons[MAXCONS+2]; 230#else 231#define VIRTUAL_TTY(x) &sccons[x] 232#define CONSOLE_TTY &sccons[MAXCONS] 233#define MOUSE_TTY &sccons[MAXCONS+1] 234static struct tty sccons[MAXCONS+2]; 235#endif 236#define SC_MOUSE 128 237#define SC_CONSOLE 255 |
223u_short *Crtat; | 238vm_offset_t Crtat; |
224static const int nsccons = MAXCONS+2; 225 226#define WRAPHIST(scp, pointer, offset)\ 227 ((scp)->history + ((((pointer) - (scp)->history) + (scp)->history_size \ 228 + (offset)) % (scp)->history_size)) 229#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) 230 231/* some useful macros */ --- 11 unchanged lines hidden (view full) --- 243 (((kbd) == NULL) ? \ 244 ENODEV : (*kbdsw[(kbd)->kb_index]->ioctl)((kbd), (cmd), (arg))) 245#define kbd_clear_state(kbd) \ 246 (*kbdsw[(kbd)->kb_index]->clear_state)((kbd)) 247#define kbd_get_fkeystr(kbd, fkey, len) \ 248 (*kbdsw[(kbd)->kb_index]->get_fkeystr)((kbd), (fkey), (len)) 249 250/* prototypes */ | 239static const int nsccons = MAXCONS+2; 240 241#define WRAPHIST(scp, pointer, offset)\ 242 ((scp)->history + ((((pointer) - (scp)->history) + (scp)->history_size \ 243 + (offset)) % (scp)->history_size)) 244#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) 245 246/* some useful macros */ --- 11 unchanged lines hidden (view full) --- 258 (((kbd) == NULL) ? \ 259 ENODEV : (*kbdsw[(kbd)->kb_index]->ioctl)((kbd), (cmd), (arg))) 260#define kbd_clear_state(kbd) \ 261 (*kbdsw[(kbd)->kb_index]->clear_state)((kbd)) 262#define kbd_get_fkeystr(kbd, fkey, len) \ 263 (*kbdsw[(kbd)->kb_index]->get_fkeystr)((kbd), (fkey), (len)) 264 265/* prototypes */ |
251static int scattach(struct isa_device *dev); | |
252static kbd_callback_func_t sckbdevent; 253static int scparam(struct tty *tp, struct termios *t); | 266static kbd_callback_func_t sckbdevent; 267static int scparam(struct tty *tp, struct termios *t); |
254static int scprobe(struct isa_device *dev); | |
255static int scvidprobe(int unit, int flags, int cons); 256static int sckbdprobe(int unit, int flags, int cons); 257static void scstart(struct tty *tp); 258static void scmousestart(struct tty *tp); 259static void scinit(void); 260static void scshutdown(int howto, void *arg); 261static u_int scgetc(keyboard_t *kbd, u_int flags); 262#define SCGETC_CN 1 263#define SCGETC_NONBLOCK 2 264static int sccngetch(int flags); 265static void sccnupdate(scr_stat *scp); 266static scr_stat *alloc_scp(void); 267static void init_scp(scr_stat *scp); | 268static int scvidprobe(int unit, int flags, int cons); 269static int sckbdprobe(int unit, int flags, int cons); 270static void scstart(struct tty *tp); 271static void scmousestart(struct tty *tp); 272static void scinit(void); 273static void scshutdown(int howto, void *arg); 274static u_int scgetc(keyboard_t *kbd, u_int flags); 275#define SCGETC_CN 1 276#define SCGETC_NONBLOCK 2 277static int sccngetch(int flags); 278static void sccnupdate(scr_stat *scp); 279static scr_stat *alloc_scp(void); 280static void init_scp(scr_stat *scp); |
281static void get_bios_values(void); |
|
268static void sc_bcopy(scr_stat *scp, u_short *p, int from, int to, int mark); 269static int get_scr_num(void); 270static timeout_t scrn_timer; 271static void scrn_update(scr_stat *scp, int show_cursor); 272#if NSPLASH > 0 273static int scsplash_callback(int); 274static void scsplash_saver(int show); 275static int add_scrn_saver(void (*this_saver)(int)); --- 35 unchanged lines hidden (view full) --- 311static void mouse_paste(scr_stat *scp); 312static void draw_mouse_image(scr_stat *scp); 313static void remove_mouse_image(scr_stat *scp); 314static void draw_cutmarking(scr_stat *scp); 315static void remove_cutmarking(scr_stat *scp); 316static void do_bell(scr_stat *scp, int pitch, int duration); 317static timeout_t blink_screen; 318 | 282static void sc_bcopy(scr_stat *scp, u_short *p, int from, int to, int mark); 283static int get_scr_num(void); 284static timeout_t scrn_timer; 285static void scrn_update(scr_stat *scp, int show_cursor); 286#if NSPLASH > 0 287static int scsplash_callback(int); 288static void scsplash_saver(int show); 289static int add_scrn_saver(void (*this_saver)(int)); --- 35 unchanged lines hidden (view full) --- 325static void mouse_paste(scr_stat *scp); 326static void draw_mouse_image(scr_stat *scp); 327static void remove_mouse_image(scr_stat *scp); 328static void draw_cutmarking(scr_stat *scp); 329static void remove_cutmarking(scr_stat *scp); 330static void do_bell(scr_stat *scp, int pitch, int duration); 331static timeout_t blink_screen; 332 |
333#define CDEV_MAJOR 12 334 335#ifdef __i386__ 336 |
|
319static cn_probe_t sccnprobe; 320static cn_init_t sccninit; 321static cn_getc_t sccngetc; 322static cn_checkc_t sccncheckc; 323static cn_putc_t sccnputc; 324 325CONS_DRIVER(sc, sccnprobe, sccninit, sccngetc, sccncheckc, sccnputc); 326 | 337static cn_probe_t sccnprobe; 338static cn_init_t sccninit; 339static cn_getc_t sccngetc; 340static cn_checkc_t sccncheckc; 341static cn_putc_t sccnputc; 342 343CONS_DRIVER(sc, sccnprobe, sccninit, sccngetc, sccncheckc, sccnputc); 344 |
327struct isa_driver scdriver = { 328 scprobe, scattach, "sc", 1 | 345#else /* !__i386__ */ 346 347static cn_getc_t sccngetc; 348static cn_checkc_t sccncheckc; 349static cn_putc_t sccnputc; 350 351struct consdev sc_cons = { 352 NULL, NULL, sccngetc, sccncheckc, sccnputc, 353 NULL, makedev(CDEV_MAJOR, 0), CN_NORMAL, |
329}; 330 | 354}; 355 |
356#endif /* __i386__ */ 357 |
|
331static d_open_t scopen; 332static d_close_t scclose; 333static d_read_t scread; 334static d_write_t scwrite; 335static d_ioctl_t scioctl; 336static d_mmap_t scmmap; 337 | 358static d_open_t scopen; 359static d_close_t scclose; 360static d_read_t scread; 361static d_write_t scwrite; 362static d_ioctl_t scioctl; 363static d_mmap_t scmmap; 364 |
338#define CDEV_MAJOR 12 339static struct cdevsw sc_cdevsw = { | 365struct cdevsw sc_cdevsw = { |
340 scopen, scclose, scread, scwrite, 341 scioctl, nullstop, noreset, scdevtotty, 342 ttpoll, scmmap, nostrategy, "sc", 343 NULL, -1, nodump, nopsize, 344 D_TTY, 345}; 346 | 366 scopen, scclose, scread, scwrite, 367 scioctl, nullstop, noreset, scdevtotty, 368 ttpoll, scmmap, nostrategy, "sc", 369 NULL, -1, nodump, nopsize, 370 D_TTY, 371}; 372 |
373#ifdef __i386__ 374 375#define fillw_io(p, b, c) fillw((p), (void *)(b), (c)) 376 377#endif 378 379#ifdef __alpha__ 380 |
|
347static void | 381static void |
382fillw(int pat, void *base, size_t cnt) 383{ 384 u_short *sp = base; 385 while (cnt--) 386 *sp++ = pat; 387} 388 389static void 390fillw_io(int pat, u_int32_t base, size_t cnt) 391{ 392 while (cnt--) { 393 writew(base, pat); 394 base += 2; 395 } 396} 397 398#endif 399 400static void |
|
348draw_cursor_image(scr_stat *scp) 349{ 350 u_short cursor_image; | 401draw_cursor_image(scr_stat *scp) 402{ 403 u_short cursor_image; |
351 u_short *ptr; | 404 vm_offset_t ptr; |
352 u_short prev_image; 353 354 if (ISPIXELSC(scp)) { 355 sc_bcopy(scp, scp->scr_buf, scp->cursor_pos - scp->scr_buf, 356 scp->cursor_pos - scp->scr_buf, 1); 357 return; 358 } 359 | 405 u_short prev_image; 406 407 if (ISPIXELSC(scp)) { 408 sc_bcopy(scp, scp->scr_buf, scp->cursor_pos - scp->scr_buf, 409 scp->cursor_pos - scp->scr_buf, 1); 410 return; 411 } 412 |
360 ptr = (u_short *)(scp->adp->va_window) 361 + (scp->cursor_pos - scp->scr_buf); | 413 ptr = scp->adp->va_window + 2*(scp->cursor_pos - scp->scr_buf); |
362 363 /* do we have a destructive cursor ? */ 364 if (sc_flags & CHAR_CURSOR) { 365 prev_image = scp->cursor_saveunder; | 414 415 /* do we have a destructive cursor ? */ 416 if (sc_flags & CHAR_CURSOR) { 417 prev_image = scp->cursor_saveunder; |
366 cursor_image = *ptr & 0x00ff; | 418 cursor_image = readw(ptr) & 0x00ff; |
367 if (cursor_image == DEAD_CHAR) 368 cursor_image = prev_image & 0x00ff; 369 cursor_image |= *(scp->cursor_pos) & 0xff00; 370 scp->cursor_saveunder = cursor_image; 371 /* update the cursor bitmap if the char under the cursor has changed */ 372 if (prev_image != cursor_image) 373 set_destructive_cursor(scp); 374 /* modify cursor_image */ --- 6 unchanged lines hidden (view full) --- 381 */ 382 if ((prev_image == cursor_image) 383 && (cursor_image != *(scp->cursor_pos))) 384 set_destructive_cursor(scp); 385 cursor_image &= 0xff00; 386 cursor_image |= DEAD_CHAR; 387 } 388 } else { | 419 if (cursor_image == DEAD_CHAR) 420 cursor_image = prev_image & 0x00ff; 421 cursor_image |= *(scp->cursor_pos) & 0xff00; 422 scp->cursor_saveunder = cursor_image; 423 /* update the cursor bitmap if the char under the cursor has changed */ 424 if (prev_image != cursor_image) 425 set_destructive_cursor(scp); 426 /* modify cursor_image */ --- 6 unchanged lines hidden (view full) --- 433 */ 434 if ((prev_image == cursor_image) 435 && (cursor_image != *(scp->cursor_pos))) 436 set_destructive_cursor(scp); 437 cursor_image &= 0xff00; 438 cursor_image |= DEAD_CHAR; 439 } 440 } else { |
389 cursor_image = (*(ptr) & 0x00ff) | *(scp->cursor_pos) & 0xff00; | 441 cursor_image = (readw(ptr) & 0x00ff) | *(scp->cursor_pos) & 0xff00; |
390 scp->cursor_saveunder = cursor_image; 391 if (!(sc_flags & BLINK_CURSOR)||((sc_flags & BLINK_CURSOR)&&(blinkrate & 4))){ 392 if ((cursor_image & 0x7000) == 0x7000) { 393 cursor_image &= 0x8fff; 394 if(!(cursor_image & 0x0700)) 395 cursor_image |= 0x0700; 396 } else { 397 cursor_image |= 0x7000; 398 if ((cursor_image & 0x0700) == 0x0700) 399 cursor_image &= 0xf0ff; 400 } 401 } 402 } | 442 scp->cursor_saveunder = cursor_image; 443 if (!(sc_flags & BLINK_CURSOR)||((sc_flags & BLINK_CURSOR)&&(blinkrate & 4))){ 444 if ((cursor_image & 0x7000) == 0x7000) { 445 cursor_image &= 0x8fff; 446 if(!(cursor_image & 0x0700)) 447 cursor_image |= 0x0700; 448 } else { 449 cursor_image |= 0x7000; 450 if ((cursor_image & 0x0700) == 0x0700) 451 cursor_image &= 0xf0ff; 452 } 453 } 454 } |
403 *ptr = cursor_image; | 455 writew(ptr, cursor_image); |
404} 405 406static void 407remove_cursor_image(scr_stat *scp) 408{ 409 if (ISPIXELSC(scp)) 410 sc_bcopy(scp, scp->scr_buf, scp->cursor_oldpos - scp->scr_buf, 411 scp->cursor_oldpos - scp->scr_buf, 0); 412 else | 456} 457 458static void 459remove_cursor_image(scr_stat *scp) 460{ 461 if (ISPIXELSC(scp)) 462 sc_bcopy(scp, scp->scr_buf, scp->cursor_oldpos - scp->scr_buf, 463 scp->cursor_oldpos - scp->scr_buf, 0); 464 else |
413 *((u_short *)(scp->adp->va_window) 414 + (scp->cursor_oldpos - scp->scr_buf)) 415 = scp->cursor_saveunder; | 465 writew(scp->adp->va_window + 2*(scp->cursor_oldpos - scp->scr_buf), 466 scp->cursor_saveunder); |
416} 417 418static void 419move_crsr(scr_stat *scp, int x, int y) 420{ 421 if (x < 0) 422 x = 0; 423 if (y < 0) 424 y = 0; 425 if (x >= scp->xsize) 426 x = scp->xsize-1; 427 if (y >= scp->ysize) 428 y = scp->ysize-1; 429 scp->xpos = x; 430 scp->ypos = y; 431 scp->cursor_pos = scp->scr_buf + scp->ypos * scp->xsize + scp->xpos; 432} 433 | 467} 468 469static void 470move_crsr(scr_stat *scp, int x, int y) 471{ 472 if (x < 0) 473 x = 0; 474 if (y < 0) 475 y = 0; 476 if (x >= scp->xsize) 477 x = scp->xsize-1; 478 if (y >= scp->ysize) 479 y = scp->ysize-1; 480 scp->xpos = x; 481 scp->ypos = y; 482 scp->cursor_pos = scp->scr_buf + scp->ypos * scp->xsize + scp->xpos; 483} 484 |
434static int 435scprobe(struct isa_device *dev) | 485int 486sc_probe_unit(int unit, int flags) |
436{ | 487{ |
437 if (!scvidprobe(dev->id_unit, dev->id_flags, FALSE)) { | 488 if (!scvidprobe(unit, flags, FALSE)) { |
438 if (bootverbose) | 489 if (bootverbose) |
439 printf("sc%d: no video adapter is found.\n", dev->id_unit); 440 return (0); | 490 printf("sc%d: no video adapter is found.\n", unit); 491 return ENXIO; |
441 } 442 | 492 } 493 |
443 return ((sckbdprobe(dev->id_unit, dev->id_flags, FALSE)) ? -1 : 0); | 494 return ((sckbdprobe(unit, flags, FALSE)) ? 0 : ENXIO); |
444} 445 446/* probe video adapters, return TRUE if found */ 447static int 448scvidprobe(int unit, int flags, int cons) 449{ 450 video_adapter_t *adp; 451 --- 9 unchanged lines hidden (view full) --- 461 /* allocate a frame buffer */ 462 if (adapter < 0) { 463 adapter = vid_allocate("*", -1, (void *)&adapter); 464 if (adapter < 0) 465 return FALSE; 466 } 467 adp = vid_get_adapter(adapter); /* shouldn't fail */ 468 | 495} 496 497/* probe video adapters, return TRUE if found */ 498static int 499scvidprobe(int unit, int flags, int cons) 500{ 501 video_adapter_t *adp; 502 --- 9 unchanged lines hidden (view full) --- 512 /* allocate a frame buffer */ 513 if (adapter < 0) { 514 adapter = vid_allocate("*", -1, (void *)&adapter); 515 if (adapter < 0) 516 return FALSE; 517 } 518 adp = vid_get_adapter(adapter); /* shouldn't fail */ 519 |
469 Crtat = (u_short *)adp->va_window; | 520 Crtat = adp->va_window; |
470 initial_video_mode = adp->va_initial_mode; 471 472 return TRUE; 473} 474 475/* probe the keyboard, return TRUE if found */ 476static int 477sckbdprobe(int unit, int flags, int cons) --- 17 unchanged lines hidden (view full) --- 495scresume(void *dummy) 496{ 497 if (kbd != NULL) 498 kbd_clear_state(kbd); 499 return 0; 500} 501#endif 502 | 521 initial_video_mode = adp->va_initial_mode; 522 523 return TRUE; 524} 525 526/* probe the keyboard, return TRUE if found */ 527static int 528sckbdprobe(int unit, int flags, int cons) --- 17 unchanged lines hidden (view full) --- 546scresume(void *dummy) 547{ 548 if (kbd != NULL) 549 kbd_clear_state(kbd); 550 return 0; 551} 552#endif 553 |
503static int 504scattach(struct isa_device *dev) | 554int 555sc_attach_unit(int unit, int flags) |
505{ 506 scr_stat *scp; 507#if defined(VESA) && defined(VM86) 508 video_info_t info; 509#endif 510 dev_t cdev = makedev(CDEV_MAJOR, 0); 511#ifdef DEVFS 512 int vc; 513#endif 514 515 scinit(); 516 scp = console[0]; | 556{ 557 scr_stat *scp; 558#if defined(VESA) && defined(VM86) 559 video_info_t info; 560#endif 561 dev_t cdev = makedev(CDEV_MAJOR, 0); 562#ifdef DEVFS 563 int vc; 564#endif 565 566 scinit(); 567 scp = console[0]; |
517 sc_flags = dev->id_flags; | 568 sc_flags = flags; |
518 if (!ISFONTAVAIL(scp->adp->va_flags)) 519 sc_flags &= ~CHAR_CURSOR; 520 521 /* copy temporary buffer to final buffer */ 522 scp->scr_buf = NULL; 523 sc_alloc_scr_buffer(scp, FALSE, FALSE); 524 bcopy(sc_buffer, scp->scr_buf, scp->xsize*scp->ysize*sizeof(u_short)); 525 --- 27 unchanged lines hidden (view full) --- 553 /* get screen update going */ 554 scrn_timer((void *)TRUE); 555 556 /* set up the keyboard */ 557 kbd_ioctl(kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); 558 update_kbd_state(scp->status, LOCK_MASK); 559 560 if (bootverbose) { | 569 if (!ISFONTAVAIL(scp->adp->va_flags)) 570 sc_flags &= ~CHAR_CURSOR; 571 572 /* copy temporary buffer to final buffer */ 573 scp->scr_buf = NULL; 574 sc_alloc_scr_buffer(scp, FALSE, FALSE); 575 bcopy(sc_buffer, scp->scr_buf, scp->xsize*scp->ysize*sizeof(u_short)); 576 --- 27 unchanged lines hidden (view full) --- 604 /* get screen update going */ 605 scrn_timer((void *)TRUE); 606 607 /* set up the keyboard */ 608 kbd_ioctl(kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); 609 update_kbd_state(scp->status, LOCK_MASK); 610 611 if (bootverbose) { |
561 printf("sc%d:", dev->id_unit); | 612 printf("sc%d:", unit); |
562 if (adapter >= 0) 563 printf(" fb%d", adapter); 564 if (keyboard >= 0) 565 printf(" kbd%d", keyboard); 566 printf("\n"); 567 } | 613 if (adapter >= 0) 614 printf(" fb%d", adapter); 615 if (keyboard >= 0) 616 printf(" kbd%d", keyboard); 617 printf("\n"); 618 } |
568 printf("sc%d: ", dev->id_unit); | 619 printf("sc%d: ", unit); |
569 switch(scp->adp->va_type) { 570 case KD_VGA: 571 printf("VGA %s", (scp->adp->va_flags & V_ADP_COLOR) ? "color" : "mono"); 572 break; 573 case KD_EGA: 574 printf("EGA %s", (scp->adp->va_flags & V_ADP_COLOR) ? "color" : "mono"); 575 break; 576 case KD_CGA: --- 47 unchanged lines hidden (view full) --- 624 return VIRTUAL_TTY(unit); 625} 626 627int 628scopen(dev_t dev, int flag, int mode, struct proc *p) 629{ 630 struct tty *tp = scdevtotty(dev); 631 keyarg_t key; | 620 switch(scp->adp->va_type) { 621 case KD_VGA: 622 printf("VGA %s", (scp->adp->va_flags & V_ADP_COLOR) ? "color" : "mono"); 623 break; 624 case KD_EGA: 625 printf("EGA %s", (scp->adp->va_flags & V_ADP_COLOR) ? "color" : "mono"); 626 break; 627 case KD_CGA: --- 47 unchanged lines hidden (view full) --- 675 return VIRTUAL_TTY(unit); 676} 677 678int 679scopen(dev_t dev, int flag, int mode, struct proc *p) 680{ 681 struct tty *tp = scdevtotty(dev); 682 keyarg_t key; |
683 int s; |
|
632 633 if (!tp) 634 return(ENXIO); 635 636 tp->t_oproc = (minor(dev) == SC_MOUSE) ? scmousestart : scstart; 637 tp->t_param = scparam; 638 tp->t_dev = dev; 639 if (!(tp->t_state & TS_ISOPEN)) { --- 7 unchanged lines hidden (view full) --- 647 tp->t_oflag = TTYDEF_OFLAG; 648 tp->t_cflag = TTYDEF_CFLAG; 649 tp->t_lflag = TTYDEF_LFLAG; 650 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; 651 scparam(tp, &tp->t_termios); 652 (*linesw[tp->t_line].l_modem)(tp, 1); 653 if (minor(dev) == SC_MOUSE) 654 mouse_level = 0; /* XXX */ | 684 685 if (!tp) 686 return(ENXIO); 687 688 tp->t_oproc = (minor(dev) == SC_MOUSE) ? scmousestart : scstart; 689 tp->t_param = scparam; 690 tp->t_dev = dev; 691 if (!(tp->t_state & TS_ISOPEN)) { --- 7 unchanged lines hidden (view full) --- 699 tp->t_oflag = TTYDEF_OFLAG; 700 tp->t_cflag = TTYDEF_CFLAG; 701 tp->t_lflag = TTYDEF_LFLAG; 702 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; 703 scparam(tp, &tp->t_termios); 704 (*linesw[tp->t_line].l_modem)(tp, 1); 705 if (minor(dev) == SC_MOUSE) 706 mouse_level = 0; /* XXX */ |
707 if (minor(dev) < MAXCONS && console[minor(dev)]) { 708 s = spltty(); 709 sc_clean_up(console[minor(dev)]); 710 splx(s); 711 } |
|
655 } 656 else 657 if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) 658 return(EBUSY); 659 if (minor(dev) < MAXCONS && !console[minor(dev)]) { 660 console[minor(dev)] = alloc_scp(); 661 if (ISGRAPHSC(console[minor(dev)])) 662 sc_set_pixel_mode(console[minor(dev)], NULL, COL, ROW, 16); --- 78 unchanged lines hidden (view full) --- 741 742 /* assert(thiskbd == kbd) */ 743 744 switch (event) { 745 case KBDIO_KEYINPUT: 746 break; 747 case KBDIO_UNLOADING: 748 kbd = NULL; | 712 } 713 else 714 if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) 715 return(EBUSY); 716 if (minor(dev) < MAXCONS && !console[minor(dev)]) { 717 console[minor(dev)] = alloc_scp(); 718 if (ISGRAPHSC(console[minor(dev)])) 719 sc_set_pixel_mode(console[minor(dev)], NULL, COL, ROW, 16); --- 78 unchanged lines hidden (view full) --- 798 799 /* assert(thiskbd == kbd) */ 800 801 switch (event) { 802 case KBDIO_KEYINPUT: 803 break; 804 case KBDIO_UNLOADING: 805 kbd = NULL; |
749 kbd_release(thiskbd, (void *)keyboard); | 806 kbd_release(thiskbd, (void *)&keyboard); |
750 return 0; 751 default: 752 return EINVAL; 753 } 754 755 /* 756 * Loop while there is still input to get from the keyboard. 757 * I don't think this is nessesary, and it doesn't fix --- 688 unchanged lines hidden (view full) --- 1446 if (!(tp->t_state & TS_ISOPEN)) { 1447 *(int *)data = i + 1; 1448 return 0; 1449 } 1450 } 1451 return EINVAL; 1452 1453 case VT_ACTIVATE: /* switch to screen *data */ | 807 return 0; 808 default: 809 return EINVAL; 810 } 811 812 /* 813 * Loop while there is still input to get from the keyboard. 814 * I don't think this is nessesary, and it doesn't fix --- 688 unchanged lines hidden (view full) --- 1503 if (!(tp->t_state & TS_ISOPEN)) { 1504 *(int *)data = i + 1; 1505 return 0; 1506 } 1507 } 1508 return EINVAL; 1509 1510 case VT_ACTIVATE: /* switch to screen *data */ |
1511 s = spltty(); 1512 sc_clean_up(cur_console); 1513 splx(s); |
|
1454 return switch_scr(scp, *(int *)data - 1); 1455 1456 case VT_WAITACTIVE: /* wait for switch to occur */ 1457 if (*(int *)data > MAXCONS || *(int *)data < 0) 1458 return EINVAL; | 1514 return switch_scr(scp, *(int *)data - 1); 1515 1516 case VT_WAITACTIVE: /* wait for switch to occur */ 1517 if (*(int *)data > MAXCONS || *(int *)data < 0) 1518 return EINVAL; |
1519 s = spltty(); 1520 error = sc_clean_up(cur_console); 1521 splx(s); 1522 if (error) 1523 return error; |
|
1459 if (minor(dev) == *(int *)data - 1) 1460 return 0; 1461 if (*(int *)data == 0) { 1462 if (scp == cur_console) 1463 return 0; 1464 } 1465 else 1466 scp = console[*(int *)data - 1]; --- 6 unchanged lines hidden (view full) --- 1473 return 0; 1474 1475 case KDENABIO: /* allow io operations */ 1476 error = suser(p->p_ucred, &p->p_acflag); 1477 if (error != 0) 1478 return error; 1479 if (securelevel > 0) 1480 return EPERM; | 1524 if (minor(dev) == *(int *)data - 1) 1525 return 0; 1526 if (*(int *)data == 0) { 1527 if (scp == cur_console) 1528 return 0; 1529 } 1530 else 1531 scp = console[*(int *)data - 1]; --- 6 unchanged lines hidden (view full) --- 1538 return 0; 1539 1540 case KDENABIO: /* allow io operations */ 1541 error = suser(p->p_ucred, &p->p_acflag); 1542 if (error != 0) 1543 return error; 1544 if (securelevel > 0) 1545 return EPERM; |
1546#ifdef __i386__ |
|
1481 p->p_md.md_regs->tf_eflags |= PSL_IOPL; | 1547 p->p_md.md_regs->tf_eflags |= PSL_IOPL; |
1548#endif |
|
1482 return 0; 1483 1484 case KDDISABIO: /* disallow io operations (default) */ | 1549 return 0; 1550 1551 case KDDISABIO: /* disallow io operations (default) */ |
1552#ifdef __i386__ |
|
1485 p->p_md.md_regs->tf_eflags &= ~PSL_IOPL; | 1553 p->p_md.md_regs->tf_eflags &= ~PSL_IOPL; |
1554#endif |
|
1486 return 0; 1487 1488 case KDSKBSTATE: /* set keyboard state (locks) */ 1489 if (*(int *)data & ~LOCK_MASK) 1490 return EINVAL; 1491 scp->status &= ~LOCK_MASK; 1492 scp->status |= *(int *)data; 1493 if (scp == cur_console) --- 42 unchanged lines hidden (view full) --- 1536 if (*(int*)data) 1537 do_bell(scp, (*(int*)data)&0xffff, 1538 (((*(int*)data)>>16)&0xffff)*hz/1000); 1539 else 1540 do_bell(scp, scp->bell_pitch, scp->bell_duration); 1541 return 0; 1542 1543 case KIOCSOUND: /* make tone (*data) hz */ | 1555 return 0; 1556 1557 case KDSKBSTATE: /* set keyboard state (locks) */ 1558 if (*(int *)data & ~LOCK_MASK) 1559 return EINVAL; 1560 scp->status &= ~LOCK_MASK; 1561 scp->status |= *(int *)data; 1562 if (scp == cur_console) --- 42 unchanged lines hidden (view full) --- 1605 if (*(int*)data) 1606 do_bell(scp, (*(int*)data)&0xffff, 1607 (((*(int*)data)>>16)&0xffff)*hz/1000); 1608 else 1609 do_bell(scp, scp->bell_pitch, scp->bell_duration); 1610 return 0; 1611 1612 case KIOCSOUND: /* make tone (*data) hz */ |
1613#ifdef __i386__ |
|
1544 if (scp == cur_console) { 1545 if (*(int*)data) { 1546 int pitch = timer_freq / *(int*)data; 1547 1548 /* set command for counter 2, 2 byte write */ 1549 if (acquire_timer2(TIMER_16BIT|TIMER_SQWAVE)) 1550 return EBUSY; 1551 --- 5 unchanged lines hidden (view full) --- 1557 outb(IO_PPI, inb(IO_PPI) | 3); 1558 } 1559 else { 1560 /* disable counter 2 output to speaker */ 1561 outb(IO_PPI, inb(IO_PPI) & 0xFC); 1562 release_timer2(); 1563 } 1564 } | 1614 if (scp == cur_console) { 1615 if (*(int*)data) { 1616 int pitch = timer_freq / *(int*)data; 1617 1618 /* set command for counter 2, 2 byte write */ 1619 if (acquire_timer2(TIMER_16BIT|TIMER_SQWAVE)) 1620 return EBUSY; 1621 --- 5 unchanged lines hidden (view full) --- 1627 outb(IO_PPI, inb(IO_PPI) | 3); 1628 } 1629 else { 1630 /* disable counter 2 output to speaker */ 1631 outb(IO_PPI, inb(IO_PPI) & 0xFC); 1632 release_timer2(); 1633 } 1634 } |
1635#endif /* __i386__ */ |
|
1565 return 0; 1566 1567 case KDGKBTYPE: /* get keyboard type */ 1568 error = kbd_ioctl(kbd, cmd, data); 1569 if (error == ENOIOCTL) { 1570 /* always return something? XXX */ 1571 *(int *)data = 0; 1572 } --- 207 unchanged lines hidden (view full) --- 1780 q_to_b(rbp, buf, PCBURST); 1781 } 1782 tp->t_state &= ~TS_BUSY; 1783 ttwwakeup(tp); 1784 } 1785 splx(s); 1786} 1787 | 1636 return 0; 1637 1638 case KDGKBTYPE: /* get keyboard type */ 1639 error = kbd_ioctl(kbd, cmd, data); 1640 if (error == ENOIOCTL) { 1641 /* always return something? XXX */ 1642 *(int *)data = 0; 1643 } --- 207 unchanged lines hidden (view full) --- 1851 q_to_b(rbp, buf, PCBURST); 1852 } 1853 tp->t_state &= ~TS_BUSY; 1854 ttwwakeup(tp); 1855 } 1856 splx(s); 1857} 1858 |
1859#if __i386__ 1860 1861/* XXX kludge! */ 1862extern struct isa_driver scdriver; 1863 |
|
1788static void 1789sccnprobe(struct consdev *cp) 1790{ 1791 struct isa_device *dvp; 1792 1793 /* 1794 * Take control if we are the highest priority enabled display device. 1795 */ --- 15 unchanged lines hidden (view full) --- 1811} 1812 1813static void 1814sccninit(struct consdev *cp) 1815{ 1816 scinit(); 1817} 1818 | 1864static void 1865sccnprobe(struct consdev *cp) 1866{ 1867 struct isa_device *dvp; 1868 1869 /* 1870 * Take control if we are the highest priority enabled display device. 1871 */ --- 15 unchanged lines hidden (view full) --- 1887} 1888 1889static void 1890sccninit(struct consdev *cp) 1891{ 1892 scinit(); 1893} 1894 |
1895#else /* !__i386__ */ 1896 1897extern struct consdev *cn_tab; 1898 1899void 1900sccnattach(void) 1901{ 1902 if (!scvidprobe(0, 0, TRUE) || !sckbdprobe(0, 0, TRUE)) { 1903 return; 1904 } 1905 1906 scinit(); 1907 cn_tab = &sc_cons; 1908} 1909 1910#endif /* __i386__ */ 1911 |
|
1819static void 1820sccnputc(dev_t dev, int c) 1821{ 1822 u_char buf[1]; 1823 scr_stat *scp = console[0]; 1824 term_stat save = scp->term; 1825 u_short *p; 1826 int s; --- 1272 unchanged lines hidden (view full) --- 3099 int col; 3100 int row; 3101 u_int i; 3102 3103 if (init_done != COLD) 3104 return; 3105 init_done = WARM; 3106 | 1912static void 1913sccnputc(dev_t dev, int c) 1914{ 1915 u_char buf[1]; 1916 scr_stat *scp = console[0]; 1917 term_stat save = scp->term; 1918 u_short *p; 1919 int s; --- 1272 unchanged lines hidden (view full) --- 3192 int col; 3193 int row; 3194 u_int i; 3195 3196 if (init_done != COLD) 3197 return; 3198 init_done = WARM; 3199 |
3200 get_bios_values(); 3201 |
|
3107 /* extract the hardware cursor location and hide the cursor for now */ 3108 adp = vid_get_adapter(adapter); 3109 (*vidsw[adapter]->read_hw_cursor)(adp, &col, &row); 3110 (*vidsw[adapter]->set_hw_cursor)(adp, -1, -1); 3111 3112 /* set up the first console */ 3113 current_default = &user_default; 3114 console[0] = &main_console; 3115 init_scp(console[0]); 3116 cur_console = console[0]; 3117 3118 /* copy screen to temporary buffer */ 3119 if (ISTEXTSC(console[0])) | 3202 /* extract the hardware cursor location and hide the cursor for now */ 3203 adp = vid_get_adapter(adapter); 3204 (*vidsw[adapter]->read_hw_cursor)(adp, &col, &row); 3205 (*vidsw[adapter]->set_hw_cursor)(adp, -1, -1); 3206 3207 /* set up the first console */ 3208 current_default = &user_default; 3209 console[0] = &main_console; 3210 init_scp(console[0]); 3211 cur_console = console[0]; 3212 3213 /* copy screen to temporary buffer */ 3214 if (ISTEXTSC(console[0])) |
3120 generic_bcopy((ushort *)(console[0]->adp->va_window), sc_buffer, 3121 console[0]->xsize * console[0]->ysize * sizeof(u_short)); | 3215 bcopy_fromio(console[0]->adp->va_window, sc_buffer, 3216 console[0]->xsize * console[0]->ysize * sizeof(u_short)); |
3122 3123 console[0]->scr_buf = console[0]->mouse_pos = console[0]->mouse_oldpos 3124 = sc_buffer; 3125 if (col >= console[0]->xsize) 3126 col = 0; 3127 if (row >= console[0]->ysize) 3128 row = console[0]->ysize - 1; 3129 console[0]->xpos = col; --- 48 unchanged lines hidden (view full) --- 3178 shutdown_in_progress = TRUE; 3179} 3180 3181int 3182sc_clean_up(scr_stat *scp) 3183{ 3184 int error; 3185 | 3217 3218 console[0]->scr_buf = console[0]->mouse_pos = console[0]->mouse_oldpos 3219 = sc_buffer; 3220 if (col >= console[0]->xsize) 3221 col = 0; 3222 if (row >= console[0]->ysize) 3223 row = console[0]->ysize - 1; 3224 console[0]->xpos = col; --- 48 unchanged lines hidden (view full) --- 3273 shutdown_in_progress = TRUE; 3274} 3275 3276int 3277sc_clean_up(scr_stat *scp) 3278{ 3279 int error; 3280 |
3281 sc_touch_scrn_saver(); |
|
3186 if ((error = wait_scrn_saver_stop())) 3187 return error; 3188 scp->status &= ~MOUSE_VISIBLE; 3189 remove_cutmarking(scp); 3190 return 0; 3191} 3192 3193void --- 112 unchanged lines hidden (view full) --- 3306 scp->end = 0; 3307 scp->term.esc = 0; 3308 scp->term.attr_mask = NORMAL_ATTR; 3309 scp->term.cur_attr = 3310 scp->term.cur_color = scp->term.std_color = 3311 current_default->std_color; 3312 scp->term.rev_color = current_default->rev_color; 3313 scp->border = BG_BLACK; | 3282 if ((error = wait_scrn_saver_stop())) 3283 return error; 3284 scp->status &= ~MOUSE_VISIBLE; 3285 remove_cutmarking(scp); 3286 return 0; 3287} 3288 3289void --- 112 unchanged lines hidden (view full) --- 3402 scp->end = 0; 3403 scp->term.esc = 0; 3404 scp->term.attr_mask = NORMAL_ATTR; 3405 scp->term.cur_attr = 3406 scp->term.cur_color = scp->term.std_color = 3407 current_default->std_color; 3408 scp->term.rev_color = current_default->rev_color; 3409 scp->border = BG_BLACK; |
3314 scp->cursor_start = *(u_int8_t *)pa_to_va(0x461); 3315 scp->cursor_end = *(u_int8_t *)pa_to_va(0x460); | 3410 scp->cursor_start = bios_value.cursor_start; 3411 scp->cursor_end = bios_value.cursor_end; |
3316 scp->mouse_xpos = scp->xsize*8/2; 3317 scp->mouse_ypos = scp->ysize*scp->font_size/2; 3318 scp->mouse_cut_start = scp->mouse_cut_end = NULL; 3319 scp->mouse_signal = 0; 3320 scp->mouse_pid = 0; 3321 scp->mouse_proc = NULL; 3322 scp->kbd_mode = K_XLATE; 3323 scp->bell_pitch = BELL_PITCH; 3324 scp->bell_duration = BELL_DURATION; | 3412 scp->mouse_xpos = scp->xsize*8/2; 3413 scp->mouse_ypos = scp->ysize*scp->font_size/2; 3414 scp->mouse_cut_start = scp->mouse_cut_end = NULL; 3415 scp->mouse_signal = 0; 3416 scp->mouse_pid = 0; 3417 scp->mouse_proc = NULL; 3418 scp->kbd_mode = K_XLATE; 3419 scp->bell_pitch = BELL_PITCH; 3420 scp->bell_duration = BELL_DURATION; |
3325 scp->status |= (*(u_int8_t *)pa_to_va(0x417) & 0x20) ? NLKED : 0; | 3421 scp->status |= (bios_value.shift_state & 0x20) ? NLKED : 0; |
3326 scp->status |= CURSOR_ENABLED; 3327 scp->pid = 0; 3328 scp->proc = NULL; 3329 scp->smode.mode = VT_AUTO; 3330 scp->history_head = scp->history_pos = scp->history = NULL; 3331 scp->history_size = imax(sc_history_size, scp->ysize) * scp->xsize; 3332} 3333 3334static void | 3422 scp->status |= CURSOR_ENABLED; 3423 scp->pid = 0; 3424 scp->proc = NULL; 3425 scp->smode.mode = VT_AUTO; 3426 scp->history_head = scp->history_pos = scp->history = NULL; 3427 scp->history_size = imax(sc_history_size, scp->ysize) * scp->xsize; 3428} 3429 3430static void |
3431get_bios_values(void) 3432{ 3433 bios_value.cursor_start = *(u_int8_t *)pa_to_va(0x461); 3434 bios_value.cursor_end = *(u_int8_t *)pa_to_va(0x460); 3435 bios_value.shift_state = *(u_int8_t *)pa_to_va(0x417); 3436} 3437 3438static void |
|
3335history_to_screen(scr_stat *scp) 3336{ 3337 int i; 3338 3339 for (i=0; i<scp->ysize; i++) 3340 bcopy(scp->history + (((scp->history_pos - scp->history) + 3341 scp->history_size-((i+1)*scp->xsize))%scp->history_size), 3342 scp->scr_buf + (scp->xsize * (scp->ysize-1 - i)), --- 58 unchanged lines hidden (view full) --- 3401 else 3402 break; 3403 } 3404 3405 /* make screensaver happy */ 3406 if (!(c & RELKEY)) 3407 sc_touch_scrn_saver(); 3408 | 3439history_to_screen(scr_stat *scp) 3440{ 3441 int i; 3442 3443 for (i=0; i<scp->ysize; i++) 3444 bcopy(scp->history + (((scp->history_pos - scp->history) + 3445 scp->history_size-((i+1)*scp->xsize))%scp->history_size), 3446 scp->scr_buf + (scp->xsize * (scp->ysize-1 - i)), --- 58 unchanged lines hidden (view full) --- 3505 else 3506 break; 3507 } 3508 3509 /* make screensaver happy */ 3510 if (!(c & RELKEY)) 3511 sc_touch_scrn_saver(); 3512 |
3513#ifdef __i386__ |
|
3409 if (!(flags & SCGETC_CN)) 3410 /* do the /dev/random device a favour */ 3411 add_keyboard_randomness(c); | 3514 if (!(flags & SCGETC_CN)) 3515 /* do the /dev/random device a favour */ 3516 add_keyboard_randomness(c); |
3517#endif |
|
3412 3413 if (cur_console->kbd_mode != K_XLATE) 3414 return KEYCHAR(c); 3415 3416 /* if scroll-lock pressed allow history browsing */ 3417 if (!ISGRAPHSC(cur_console) && cur_console->history 3418 && cur_console->status & SLKED) { 3419 --- 316 unchanged lines hidden (view full) --- 3736 return 1; 3737 3738 /* if this vty is not currently showing, do nothing */ 3739 if (scp != cur_console) 3740 return 0; 3741 3742 /* setup video hardware for the given mode */ 3743 (*vidsw[scp->ad]->set_mode)(scp->adp, scp->mode); | 3518 3519 if (cur_console->kbd_mode != K_XLATE) 3520 return KEYCHAR(c); 3521 3522 /* if scroll-lock pressed allow history browsing */ 3523 if (!ISGRAPHSC(cur_console) && cur_console->history 3524 && cur_console->status & SLKED) { 3525 --- 316 unchanged lines hidden (view full) --- 3842 return 1; 3843 3844 /* if this vty is not currently showing, do nothing */ 3845 if (scp != cur_console) 3846 return 0; 3847 3848 /* setup video hardware for the given mode */ 3849 (*vidsw[scp->ad]->set_mode)(scp->adp, scp->mode); |
3744 Crtat = (u_short *)scp->adp->va_window; | 3850 Crtat = scp->adp->va_window; |
3745 3746 if (!(scp->status & GRAPHICS_MODE)) { 3747 /* load appropriate font */ 3748 if (!(scp->status & PIXEL_MODE) && ISFONTAVAIL(scp->adp->va_flags)) { 3749 if (scp->font_size < 14) { 3750 if (fonts_loaded & FONT_8) 3751 copy_font(scp, LOAD, 8, font_8); 3752 } else if (scp->font_size >= 16) { --- 11 unchanged lines hidden (view full) --- 3764 * some video cards... XXX 3765 */ 3766 (*vidsw[scp->ad]->show_font)(scp->adp, 0); 3767 } 3768 mark_all(scp); 3769 } 3770 3771 if (scp->status & PIXEL_MODE) | 3851 3852 if (!(scp->status & GRAPHICS_MODE)) { 3853 /* load appropriate font */ 3854 if (!(scp->status & PIXEL_MODE) && ISFONTAVAIL(scp->adp->va_flags)) { 3855 if (scp->font_size < 14) { 3856 if (fonts_loaded & FONT_8) 3857 copy_font(scp, LOAD, 8, font_8); 3858 } else if (scp->font_size >= 16) { --- 11 unchanged lines hidden (view full) --- 3870 * some video cards... XXX 3871 */ 3872 (*vidsw[scp->ad]->show_font)(scp->adp, 0); 3873 } 3874 mark_all(scp); 3875 } 3876 3877 if (scp->status & PIXEL_MODE) |
3772 generic_bzero((u_char *)(scp->adp->va_window), 3773 scp->xpixel*scp->ypixel/8); | 3878 bzero_io(scp->adp->va_window, scp->xpixel*scp->ypixel/8); 3879 |
3774 set_border(scp, scp->border); 3775 3776 /* move hardware cursor out of the way */ 3777 (*vidsw[scp->ad]->set_hw_cursor)(scp->adp, -1, -1); 3778 3779 return 0; 3780} 3781 3782void 3783set_border(scr_stat *scp, int color) 3784{ | 3880 set_border(scp, scp->border); 3881 3882 /* move hardware cursor out of the way */ 3883 (*vidsw[scp->ad]->set_hw_cursor)(scp->adp, -1, -1); 3884 3885 return 0; 3886} 3887 3888void 3889set_border(scr_stat *scp, int color) 3890{ |
3785 u_char *p; | 3891 vm_offset_t p; |
3786 int xoff; 3787 int yoff; 3788 int xlen; 3789 int ylen; 3790 int i; 3791 3792 (*vidsw[scp->ad]->set_border)(scp->adp, color); 3793 3794 if (scp->status & PIXEL_MODE) { 3795 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 3796 outw(GDCIDX, 0x0003); /* data rotate/function select */ 3797 outw(GDCIDX, 0x0f01); /* set/reset enable */ 3798 outw(GDCIDX, 0xff08); /* bit mask */ 3799 outw(GDCIDX, (color << 8) | 0x00); /* set/reset */ | 3892 int xoff; 3893 int yoff; 3894 int xlen; 3895 int ylen; 3896 int i; 3897 3898 (*vidsw[scp->ad]->set_border)(scp->adp, color); 3899 3900 if (scp->status & PIXEL_MODE) { 3901 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 3902 outw(GDCIDX, 0x0003); /* data rotate/function select */ 3903 outw(GDCIDX, 0x0f01); /* set/reset enable */ 3904 outw(GDCIDX, 0xff08); /* bit mask */ 3905 outw(GDCIDX, (color << 8) | 0x00); /* set/reset */ |
3800 p = (u_char *)(scp->adp->va_window); | 3906 p = scp->adp->va_window; |
3801 xoff = scp->xoff; 3802 yoff = scp->yoff*scp->font_size; 3803 xlen = scp->xpixel/8; 3804 ylen = scp->ysize*scp->font_size; 3805 if (yoff > 0) { | 3907 xoff = scp->xoff; 3908 yoff = scp->yoff*scp->font_size; 3909 xlen = scp->xpixel/8; 3910 ylen = scp->ysize*scp->font_size; 3911 if (yoff > 0) { |
3806 generic_bzero(p, xlen*yoff); 3807 generic_bzero(p + xlen*(yoff + ylen), 3808 xlen*scp->ypixel - xlen*(yoff + ylen)); | 3912 bzero_io(p, xlen*yoff); 3913 bzero_io(p + xlen*(yoff + ylen), 3914 xlen*scp->ypixel - xlen*(yoff + ylen)); |
3809 } 3810 if (xoff > 0) { 3811 for (i = 0; i < ylen; ++i) { | 3915 } 3916 if (xoff > 0) { 3917 for (i = 0; i < ylen; ++i) { |
3812 generic_bzero(p + xlen*(yoff + i), xoff); 3813 generic_bzero(p + xlen*(yoff + i) + xoff + scp->xsize, 3814 xlen - xoff - scp->xsize); | 3918 bzero_io(p + xlen*(yoff + i), xoff); 3919 bzero_io(p + xlen*(yoff + i) + xoff + scp->xsize, 3920 xlen - xoff - scp->xsize); |
3815 } 3816 } 3817 outw(GDCIDX, 0x0000); /* set/reset */ 3818 outw(GDCIDX, 0x0001); /* set/reset enable */ 3819 } 3820} 3821 3822void --- 315 unchanged lines hidden (view full) --- 4138 } 4139} 4140 4141static void 4142draw_mouse_image(scr_stat *scp) 4143{ 4144 u_short buffer[32]; 4145 u_short xoffset, yoffset; | 3921 } 3922 } 3923 outw(GDCIDX, 0x0000); /* set/reset */ 3924 outw(GDCIDX, 0x0001); /* set/reset enable */ 3925 } 3926} 3927 3928void --- 315 unchanged lines hidden (view full) --- 4244 } 4245} 4246 4247static void 4248draw_mouse_image(scr_stat *scp) 4249{ 4250 u_short buffer[32]; 4251 u_short xoffset, yoffset; |
4146 u_short *crt_pos = (u_short *)(scp->adp->va_window) 4147 + (scp->mouse_pos - scp->scr_buf); | 4252 vm_offset_t crt_pos = scp->adp->va_window + 2*(scp->mouse_pos - scp->scr_buf); |
4148 u_char *font_buffer; 4149 int font_size; 4150 int crtc_addr; 4151 int i; 4152 4153 if (scp->font_size < 14) { 4154 font_buffer = font_8; 4155 font_size = 8; --- 42 unchanged lines hidden (view full) --- 4198 crtc_addr = scp->adp->va_crtc_addr; 4199 while (!(inb(crtc_addr+6) & 0x08)) /* idle */ ; 4200#endif 4201 font_loading_in_progress = TRUE; 4202 (*vidsw[scp->ad]->load_font)(scp->adp, 0, 32, scp->mouse_cursor, 4203 SC_MOUSE_CHAR, 4); 4204 font_loading_in_progress = FALSE; 4205 | 4253 u_char *font_buffer; 4254 int font_size; 4255 int crtc_addr; 4256 int i; 4257 4258 if (scp->font_size < 14) { 4259 font_buffer = font_8; 4260 font_size = 8; --- 42 unchanged lines hidden (view full) --- 4303 crtc_addr = scp->adp->va_crtc_addr; 4304 while (!(inb(crtc_addr+6) & 0x08)) /* idle */ ; 4305#endif 4306 font_loading_in_progress = TRUE; 4307 (*vidsw[scp->ad]->load_font)(scp->adp, 0, 32, scp->mouse_cursor, 4308 SC_MOUSE_CHAR, 4); 4309 font_loading_in_progress = FALSE; 4310 |
4206 *(crt_pos) = (*(scp->mouse_pos) & 0xff00) | SC_MOUSE_CHAR; 4207 *(crt_pos+scp->xsize) = 4208 (*(scp->mouse_pos + scp->xsize) & 0xff00) | (SC_MOUSE_CHAR + 2); | 4311 writew(crt_pos, (*(scp->mouse_pos) & 0xff00) | SC_MOUSE_CHAR); 4312 writew(crt_pos+2*scp->xsize, 4313 (*(scp->mouse_pos + scp->xsize) & 0xff00) | (SC_MOUSE_CHAR + 2)); |
4209 if (scp->mouse_xpos < (scp->xsize-1)*8) { | 4314 if (scp->mouse_xpos < (scp->xsize-1)*8) { |
4210 *(crt_pos + 1) = (*(scp->mouse_pos + 1) & 0xff00) | (SC_MOUSE_CHAR + 1); 4211 *(crt_pos+scp->xsize + 1) = 4212 (*(scp->mouse_pos + scp->xsize + 1) & 0xff00) | (SC_MOUSE_CHAR + 3); | 4315 writew(crt_pos + 2, (*(scp->mouse_pos + 1) & 0xff00) | (SC_MOUSE_CHAR + 1)); 4316 writew(crt_pos+2*scp->xsize + 2, 4317 (*(scp->mouse_pos + scp->xsize + 1) & 0xff00) | (SC_MOUSE_CHAR + 3)); |
4213 } 4214 mark_for_update(scp, scp->mouse_pos - scp->scr_buf); 4215 mark_for_update(scp, scp->mouse_pos + scp->xsize + 1 - scp->scr_buf); 4216} 4217 4218static void 4219remove_mouse_image(scr_stat *scp) 4220{ | 4318 } 4319 mark_for_update(scp, scp->mouse_pos - scp->scr_buf); 4320 mark_for_update(scp, scp->mouse_pos + scp->xsize + 1 - scp->scr_buf); 4321} 4322 4323static void 4324remove_mouse_image(scr_stat *scp) 4325{ |
4221 u_short *crt_pos; | 4326 vm_offset_t crt_pos; |
4222 4223 if (!ISTEXTSC(scp)) 4224 return; 4225 | 4327 4328 if (!ISTEXTSC(scp)) 4329 return; 4330 |
4226 crt_pos = (u_short *)(scp->adp->va_window) 4227 + (scp->mouse_oldpos - scp->scr_buf); 4228 *(crt_pos) = *(scp->mouse_oldpos); 4229 *(crt_pos+1) = *(scp->mouse_oldpos+1); 4230 *(crt_pos+scp->xsize) = *(scp->mouse_oldpos+scp->xsize); 4231 *(crt_pos+scp->xsize+1) = *(scp->mouse_oldpos+scp->xsize+1); | 4331 crt_pos = scp->adp->va_window + 2*(scp->mouse_oldpos - scp->scr_buf); 4332 writew(crt_pos, *(scp->mouse_oldpos)); 4333 writew(crt_pos+2, *(scp->mouse_oldpos+1)); 4334 writew(crt_pos+2*scp->xsize, *(scp->mouse_oldpos+scp->xsize)); 4335 writew(crt_pos+2*scp->xsize+2, *(scp->mouse_oldpos+scp->xsize+1)); |
4232 mark_for_update(scp, scp->mouse_oldpos - scp->scr_buf); 4233 mark_for_update(scp, scp->mouse_oldpos + scp->xsize + 1 - scp->scr_buf); 4234} 4235 4236static void 4237draw_cutmarking(scr_stat *scp) 4238{ | 4336 mark_for_update(scp, scp->mouse_oldpos - scp->scr_buf); 4337 mark_for_update(scp, scp->mouse_oldpos + scp->xsize + 1 - scp->scr_buf); 4338} 4339 4340static void 4341draw_cutmarking(scr_stat *scp) 4342{ |
4239 u_short *crt_pos; | 4343 vm_offset_t crt_pos; |
4240 u_short *ptr; 4241 u_short och, nch; 4242 | 4344 u_short *ptr; 4345 u_short och, nch; 4346 |
4243 crt_pos = (u_short *)(scp->adp->va_window); | 4347 crt_pos = scp->adp->va_window; |
4244 for (ptr=scp->scr_buf; ptr<=(scp->scr_buf+(scp->xsize*scp->ysize)); ptr++) { | 4348 for (ptr=scp->scr_buf; ptr<=(scp->scr_buf+(scp->xsize*scp->ysize)); ptr++) { |
4245 nch = och = *(crt_pos + (ptr - scp->scr_buf)); | 4349 nch = och = readw(crt_pos + 2*(ptr - scp->scr_buf)); |
4246 /* are we outside the selected area ? */ 4247 if ( ptr < (scp->mouse_cut_start > scp->mouse_cut_end ? 4248 scp->mouse_cut_end : scp->mouse_cut_start) || 4249 ptr >= (scp->mouse_cut_start > scp->mouse_cut_end ? 4250 scp->mouse_cut_start : scp->mouse_cut_end)) { 4251 if (ptr != scp->cursor_pos) 4252 nch = (och & 0xff) | (*ptr & 0xff00); 4253 } --- 5 unchanged lines hidden (view full) --- 4259 if (sc_flags & CHAR_CURSOR) 4260 nch = (och & 0x88ff)|(*ptr & 0x7000)>>4|(*ptr & 0x0700)<<4; 4261 else 4262 if (!(sc_flags & BLINK_CURSOR)) 4263 nch = (och & 0xff) | (*ptr & 0xff00); 4264 } 4265 } 4266 if (nch != och) | 4350 /* are we outside the selected area ? */ 4351 if ( ptr < (scp->mouse_cut_start > scp->mouse_cut_end ? 4352 scp->mouse_cut_end : scp->mouse_cut_start) || 4353 ptr >= (scp->mouse_cut_start > scp->mouse_cut_end ? 4354 scp->mouse_cut_start : scp->mouse_cut_end)) { 4355 if (ptr != scp->cursor_pos) 4356 nch = (och & 0xff) | (*ptr & 0xff00); 4357 } --- 5 unchanged lines hidden (view full) --- 4363 if (sc_flags & CHAR_CURSOR) 4364 nch = (och & 0x88ff)|(*ptr & 0x7000)>>4|(*ptr & 0x0700)<<4; 4365 else 4366 if (!(sc_flags & BLINK_CURSOR)) 4367 nch = (och & 0xff) | (*ptr & 0xff00); 4368 } 4369 } 4370 if (nch != och) |
4267 *(crt_pos + (ptr - scp->scr_buf)) = nch; | 4371 writew(crt_pos + 2*(ptr - scp->scr_buf), nch); |
4268 } 4269} 4270 4271static void 4272remove_cutmarking(scr_stat *scp) 4273{ 4274 scp->mouse_cut_start = scp->mouse_cut_end = NULL; 4275 scp->status &= ~MOUSE_CUTTING; --- 31 unchanged lines hidden (view full) --- 4307 if (!ISTEXTSC(scp) || (blink_in_progress <= 1)) { 4308 blink_in_progress = FALSE; 4309 mark_all(scp); 4310 if (delayed_next_scr) 4311 switch_scr(scp, delayed_next_scr - 1); 4312 } 4313 else { 4314 if (blink_in_progress & 1) | 4372 } 4373} 4374 4375static void 4376remove_cutmarking(scr_stat *scp) 4377{ 4378 scp->mouse_cut_start = scp->mouse_cut_end = NULL; 4379 scp->status &= ~MOUSE_CUTTING; --- 31 unchanged lines hidden (view full) --- 4411 if (!ISTEXTSC(scp) || (blink_in_progress <= 1)) { 4412 blink_in_progress = FALSE; 4413 mark_all(scp); 4414 if (delayed_next_scr) 4415 switch_scr(scp, delayed_next_scr - 1); 4416 } 4417 else { 4418 if (blink_in_progress & 1) |
4315 fillw(kernel_default.std_color | scr_map[0x20], 4316 (u_short *)(scp->adp->va_window), 4317 scp->xsize * scp->ysize); | 4419 fillw_io(kernel_default.std_color | scr_map[0x20], 4420 scp->adp->va_window, 4421 scp->xsize * scp->ysize); |
4318 else | 4422 else |
4319 fillw(kernel_default.rev_color | scr_map[0x20], 4320 (u_short *)(scp->adp->va_window), 4321 scp->xsize * scp->ysize); | 4423 fillw_io(kernel_default.rev_color | scr_map[0x20], 4424 scp->adp->va_window, 4425 scp->xsize * scp->ysize); |
4322 blink_in_progress--; 4323 timeout(blink_screen, scp, hz / 10); 4324 } 4325} 4326 4327void 4328sc_bcopy(scr_stat *scp, u_short *p, int from, int to, int mark) 4329{ 4330 u_char *font; | 4426 blink_in_progress--; 4427 timeout(blink_screen, scp, hz / 10); 4428 } 4429} 4430 4431void 4432sc_bcopy(scr_stat *scp, u_short *p, int from, int to, int mark) 4433{ 4434 u_char *font; |
4331 u_char volatile *d; 4332 u_char *e; | 4435 vm_offset_t d; 4436 vm_offset_t e; |
4333 u_char *f; 4334 int font_size; 4335 int line_length; 4336 int xsize; 4337 u_short bg; 4338 int i, j; 4339 u_char c; 4340 4341 if (ISTEXTSC(scp)) { | 4437 u_char *f; 4438 int font_size; 4439 int line_length; 4440 int xsize; 4441 u_short bg; 4442 int i, j; 4443 u_char c; 4444 4445 if (ISTEXTSC(scp)) { |
4342 generic_bcopy(p + from, (u_short *)(scp->adp->va_window) + from, 4343 (to - from + 1)*sizeof(u_short)); | 4446 bcopy_toio(p + from, scp->adp->va_window + 2*from, 4447 (to - from + 1)*sizeof(u_short)); |
4344 } else /* if ISPIXELSC(scp) */ { 4345 if (mark) 4346 mark = 255; 4347 font_size = scp->font_size; 4348 if (font_size < 14) 4349 font = font_8; 4350 else if (font_size >= 16) 4351 font = font_16; 4352 else 4353 font = font_14; 4354 line_length = scp->xpixel/8; 4355 xsize = scp->xsize; | 4448 } else /* if ISPIXELSC(scp) */ { 4449 if (mark) 4450 mark = 255; 4451 font_size = scp->font_size; 4452 if (font_size < 14) 4453 font = font_8; 4454 else if (font_size >= 16) 4455 font = font_16; 4456 else 4457 font = font_14; 4458 line_length = scp->xpixel/8; 4459 xsize = scp->xsize; |
4356 d = (u_char *)(scp->adp->va_window) | 4460 d = scp->adp->va_window |
4357 + scp->xoff + scp->yoff*font_size*line_length 4358 + (from%xsize) + font_size*line_length*(from/xsize); 4359 4360 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 4361 outw(GDCIDX, 0x0003); /* data rotate/function select */ 4362 outw(GDCIDX, 0x0f01); /* set/reset enable */ 4363 bg = -1; 4364 for (i = from ; i <= to ; i++) { 4365 /* set background color in EGA/VGA latch */ 4366 if (bg != (p[i] & 0xf000)) { 4367 bg = (p[i] & 0xf000); 4368 outw(GDCIDX, (bg >> 4) | 0x00); /* set/reset */ 4369 outw(GDCIDX, 0xff08); /* bit mask */ | 4461 + scp->xoff + scp->yoff*font_size*line_length 4462 + (from%xsize) + font_size*line_length*(from/xsize); 4463 4464 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 4465 outw(GDCIDX, 0x0003); /* data rotate/function select */ 4466 outw(GDCIDX, 0x0f01); /* set/reset enable */ 4467 bg = -1; 4468 for (i = from ; i <= to ; i++) { 4469 /* set background color in EGA/VGA latch */ 4470 if (bg != (p[i] & 0xf000)) { 4471 bg = (p[i] & 0xf000); 4472 outw(GDCIDX, (bg >> 4) | 0x00); /* set/reset */ 4473 outw(GDCIDX, 0xff08); /* bit mask */ |
4370 *d = 0; 4371 c = *d; /* set the background color in the latch */ | 4474 writeb(d, 0); 4475 c = readb(d); /* set the background color in the latch */ |
4372 } 4373 /* foreground color */ 4374 outw(GDCIDX, (p[i] & 0x0f00) | 0x00); /* set/reset */ | 4476 } 4477 /* foreground color */ 4478 outw(GDCIDX, (p[i] & 0x0f00) | 0x00); /* set/reset */ |
4375 e = (u_char *)d; | 4479 e = d; |
4376 f = &font[(p[i] & 0x00ff)*font_size]; 4377 for (j = 0 ; j < font_size; j++, f++) { 4378 outw(GDCIDX, ((*f^mark) << 8) | 0x08); /* bit mask */ | 4480 f = &font[(p[i] & 0x00ff)*font_size]; 4481 for (j = 0 ; j < font_size; j++, f++) { 4482 outw(GDCIDX, ((*f^mark) << 8) | 0x08); /* bit mask */ |
4379 *e = 0; | 4483 writeb(e, 0); |
4380 e += line_length; 4381 } 4382 d++; 4383 if ((i % xsize) == xsize - 1) 4384 d += scp->xoff*2 + (font_size - 1)*line_length; 4385 } 4386 outw(GDCIDX, 0x0000); /* set/reset */ 4387 outw(GDCIDX, 0x0001); /* set/reset enable */ --- 38 unchanged lines hidden --- | 4484 e += line_length; 4485 } 4486 d++; 4487 if ((i % xsize) == xsize - 1) 4488 d += scp->xoff*2 + (font_size - 1)*line_length; 4489 } 4490 outw(GDCIDX, 0x0000); /* set/reset */ 4491 outw(GDCIDX, 0x0001); /* set/reset enable */ --- 38 unchanged lines hidden --- |