skiconsole.c revision 225736
11553Srgrimes/*- 21553Srgrimes * Copyright (c) 2000 Doug Rabson 31553Srgrimes * All rights reserved. 41553Srgrimes * 51553Srgrimes * Redistribution and use in source and binary forms, with or without 61553Srgrimes * modification, are permitted provided that the following conditions 71553Srgrimes * are met: 81553Srgrimes * 1. Redistributions of source code must retain the above copyright 91553Srgrimes * notice, this list of conditions and the following disclaimer. 101553Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111553Srgrimes * notice, this list of conditions and the following disclaimer in the 121553Srgrimes * documentation and/or other materials provided with the distribution. 131553Srgrimes * 141553Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 151553Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 161553Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 171553Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181553Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 191553Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 201553Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 211553Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 221553Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 231553Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 241553Srgrimes * SUCH DAMAGE. 251553Srgrimes */ 261553Srgrimes 271553Srgrimes#include <sys/cdefs.h> 281553Srgrimes__FBSDID("$FreeBSD: stable/9/sys/boot/ia64/ski/skiconsole.c 113038 2003-04-03 21:36:33Z obrien $"); 291553Srgrimes 301553Srgrimes#include <stand.h> 311553Srgrimes 321553Srgrimes#include "bootstrap.h" 331553Srgrimes#include "libski.h" 341553Srgrimes 351553Srgrimesstatic void 361553Srgrimesski_cons_probe(struct console *cp) 371553Srgrimes{ 381553Srgrimes cp->c_flags |= C_PRESENTIN | C_PRESENTOUT; 391553Srgrimes} 401553Srgrimes 411553Srgrimesstatic int 421553Srgrimesski_cons_init(int arg) 431553Srgrimes{ 441553Srgrimes ssc(0, 0, 0, 0, SSC_CONSOLE_INIT); 451553Srgrimes return 0; 461553Srgrimes} 471553Srgrimes 481553Srgrimesvoid 491553Srgrimesski_cons_putchar(int c) 501553Srgrimes{ 511553Srgrimes ssc(c, 0, 0, 0, SSC_PUTCHAR); 521553Srgrimes} 531553Srgrimes 54static int pollchar = -1; 55 56int 57ski_cons_getchar() 58{ 59 int c; 60 61 if (pollchar > 0) { 62 c = pollchar; 63 pollchar = -1; 64 return c; 65 } 66 67 do { 68 c = ssc(0, 0, 0, 0, SSC_GETCHAR); 69 } while (c == 0); 70 71 return c; 72} 73 74int 75ski_cons_poll() 76{ 77 int c; 78 if (pollchar > 0) 79 return 1; 80 c = ssc(0, 0, 0, 0, SSC_GETCHAR); 81 if (!c) 82 return 0; 83 pollchar = c; 84 return 1; 85} 86 87struct console ski_console = { 88 "ski", 89 "ia64 SKI console", 90 0, 91 ski_cons_probe, 92 ski_cons_init, 93 ski_cons_putchar, 94 ski_cons_getchar, 95 ski_cons_poll 96}; 97