1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
/*
* Copyright (c) 1996, 1998, 1999 University of Utah and the Flux Group.
* All rights reserved.
*
* This file is part of the Flux OSKit. The OSKit is free software, also known
* as "open source;" you can redistribute it and/or modify it under the terms
* of the GNU General Public License (GPL), version 2, as published by the Free
* Software Foundation (FSF). To explore alternate licensing terms, contact
* the University of Utah at csl-dist@cs.utah.edu or +1-801-585-3271.
*
* The OSKit is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GPL for more details. You should have
* received a copy of the GPL along with the OSKit; see the file COPYING. If
* not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
*/
/*
* Define console routines so we can use printf.
*
* We could probably get away with using the console code from libkern's
* base_console.c if we consed up an argv/argc from our boothowto and
* called base_console_init with them.
*/
#include <oskit/x86/pc/com_cons.h>
#include <oskit/x86/pc/direct_cons.h>
#include <oskit/x86/pc/base_console.h>
#include <oskit/x86/pc/reset.h>
#include <oskit/tty.h>
#include <oskit/console.h>
#include <oskit/c/termios.h>
#include <oskit/c/stdlib.h>
#include "reboot.h"
#include "boottype.h"
/*
* Define this if you want the boot adaptor to always use the serial
* line for the console,
* regardless of what the RB_SERIAL flag (if any) is set to.
*/
#undef BA_FORCE_SERIAL
static int serial = 0; /* Use serial console or not. */
static int cons_com_port = 1;
static void our_exit(int rc);
/* A common symbol that is overridden */
void (*oskit_libc_exit)(int) = our_exit;
/*
* This overrides the _exit() function in libc.
* When it is done, it calls pc_reset() to reboot the computer.
*/
static void
our_exit(int rc)
{
if (serial)
com_cons_flush(cons_com_port);
pc_reset();
}
static void
putchar_init()
{
/*
* Check the BSD-style RB_SERIAL flag if we're booting from
* BSD bootblocks.
*/
#ifdef BA_FORCE_SERIAL
serial = 1;
#else
serial = (boottype == BOOTTYPE_OLDBSD || boottype == BOOTTYPE_NEWBSD)
&& (boothowto & BSD_RB_SERIAL);
#endif
if (serial) {
if (boothowto & BSD_RB_FASTCONSOLE) {
base_cooked_termios.c_ispeed = B115200;
base_cooked_termios.c_ospeed = B115200;
}
com_cons_init(cons_com_port, &base_cooked_termios);
}
}
int
console_putchar(int c)
{
static int inited = 0;
if (! inited) {
putchar_init();
inited = 1;
}
serial ? com_cons_putchar(cons_com_port, c) : direct_cons_putchar(c);
return c;
}
/*
* This is more efficient for console output, and allows similar treatment
* in usermode where character based output is really bad.
*/
int
console_putbytes(const char *s, int len)
{
while (len) {
console_putchar(*s++);
len--;
}
return 0;
}
/*
* Provided for completeness, and to avoid linker problems.
*/
int
console_getchar(void)
{
panic("console_getchar: BSD boot adaptor stub version");
}
|