2
* linux/arch/sh/kernel/sh_bios.c
3
2
* C interface for trapping into the standard LinuxSH BIOS.
5
4
* Copyright (C) 2000 Greg Banks, Mitch Davis
5
* Copyright (C) 1999, 2000 Niibe Yutaka
6
* Copyright (C) 2002 M. R. Brown
7
* Copyright (C) 2004 - 2010 Paul Mundt
9
* This file is subject to the terms and conditions of the GNU General Public
10
* License. See the file "COPYING" in the main directory of this archive
8
13
#include <linux/module.h>
14
#include <linux/console.h>
15
#include <linux/tty.h>
16
#include <linux/init.h>
18
#include <linux/delay.h>
9
19
#include <asm/sh_bios.h>
11
21
#define BIOS_CALL_CONSOLE_WRITE 0
12
22
#define BIOS_CALL_ETH_NODE_ADDR 10
13
23
#define BIOS_CALL_SHUTDOWN 11
14
#define BIOS_CALL_CHAR_OUT 0x1f /* TODO: hack */
15
24
#define BIOS_CALL_GDB_DETACH 0xff
26
void *gdb_vbr_vector = NULL;
17
28
static inline long sh_bios_call(long func, long arg0, long arg1, long arg2,
34
48
sh_bios_call(BIOS_CALL_CONSOLE_WRITE, (long)buf, (long)len, 0, 0);
37
void sh_bios_char_out(char ch)
39
sh_bios_call(BIOS_CALL_CHAR_OUT, ch, 0, 0, 0);
42
51
void sh_bios_gdb_detach(void)
44
53
sh_bios_call(BIOS_CALL_GDB_DETACH, 0, 0, 0, 0);
56
65
sh_bios_call(BIOS_CALL_SHUTDOWN, how, 0, 0, 0);
69
* Read the old value of the VBR register to initialise the vector
70
* through which debug and BIOS traps are delegated by the Linux trap
73
void sh_bios_vbr_init(void)
77
if (unlikely(gdb_vbr_vector))
80
__asm__ __volatile__ ("stc vbr, %0" : "=r" (vbr));
83
gdb_vbr_vector = (void *)(vbr + 0x100);
84
printk(KERN_NOTICE "Setting GDB trap vector to %p\n",
87
printk(KERN_NOTICE "SH-BIOS not detected\n");
91
* sh_bios_vbr_reload - Re-load the system VBR from the BIOS vector.
93
* This can be used by save/restore code to reinitialize the system VBR
94
* from the fixed BIOS VBR. A no-op if no BIOS VBR is known.
96
void sh_bios_vbr_reload(void)
99
__asm__ __volatile__ (
102
: "r" (((unsigned long) gdb_vbr_vector) - 0x100)
108
* Print a string through the BIOS
110
static void sh_console_write(struct console *co, const char *s,
113
sh_bios_console_write(s, count);
117
* Setup initial baud/bits/parity. We do two things here:
118
* - construct a cflag setting for the first rs_open()
119
* - initialize the serial port
120
* Return non-zero if we didn't find a serial port.
122
static int __init sh_console_setup(struct console *co, char *options)
124
int cflag = CREAD | HUPCL | CLOCAL;
127
* Now construct a cflag setting.
128
* TODO: this is a totally bogus cflag, as we have
129
* no idea what serial settings the BIOS is using, or
130
* even if its using the serial port at all.
132
cflag |= B115200 | CS8 | /*no parity*/0;
139
static struct console bios_console = {
141
.write = sh_console_write,
142
.setup = sh_console_setup,
143
.flags = CON_PRINTBUFFER,
147
static struct console *early_console;
149
static int __init setup_early_printk(char *buf)
156
if (strstr(buf, "keep"))
159
if (!strncmp(buf, "bios", 4))
160
early_console = &bios_console;
162
if (likely(early_console)) {
164
early_console->flags &= ~CON_BOOT;
166
early_console->flags |= CON_BOOT;
167
register_console(early_console);
172
early_param("earlyprintk", setup_early_printk);