2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/arch/sh/kernel/sh_bios.c
|
|
|
|
* C interface for trapping into the standard LinuxSH BIOS.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000 Greg Banks, Mitch Davis
|
|
|
|
*
|
|
|
|
*/
|
2007-07-20 15:59:49 +08:00
|
|
|
#include <linux/module.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/sh_bios.h>
|
|
|
|
|
2008-12-17 10:37:51 +08:00
|
|
|
#define BIOS_CALL_CONSOLE_WRITE 0
|
2005-04-17 06:20:36 +08:00
|
|
|
#define BIOS_CALL_ETH_NODE_ADDR 10
|
|
|
|
#define BIOS_CALL_SHUTDOWN 11
|
2008-12-17 10:37:51 +08:00
|
|
|
#define BIOS_CALL_CHAR_OUT 0x1f /* TODO: hack */
|
|
|
|
#define BIOS_CALL_GDB_DETACH 0xff
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-12-17 10:37:51 +08:00
|
|
|
static inline long sh_bios_call(long func, long arg0, long arg1, long arg2,
|
|
|
|
long arg3)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-12-17 10:37:51 +08:00
|
|
|
register long r0 __asm__("r0") = func;
|
|
|
|
register long r4 __asm__("r4") = arg0;
|
|
|
|
register long r5 __asm__("r5") = arg1;
|
|
|
|
register long r6 __asm__("r6") = arg2;
|
|
|
|
register long r7 __asm__("r7") = arg3;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-12-17 10:37:51 +08:00
|
|
|
__asm__ __volatile__("trapa #0x3f":"=z"(r0)
|
|
|
|
:"0"(r0), "r"(r4), "r"(r5), "r"(r6), "r"(r7)
|
|
|
|
:"memory");
|
|
|
|
return r0;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
void sh_bios_console_write(const char *buf, unsigned int len)
|
|
|
|
{
|
2008-12-17 10:37:51 +08:00
|
|
|
sh_bios_call(BIOS_CALL_CONSOLE_WRITE, (long)buf, (long)len, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void sh_bios_char_out(char ch)
|
|
|
|
{
|
2008-12-17 10:37:51 +08:00
|
|
|
sh_bios_call(BIOS_CALL_CHAR_OUT, ch, 0, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void sh_bios_gdb_detach(void)
|
|
|
|
{
|
2008-12-17 10:37:51 +08:00
|
|
|
sh_bios_call(BIOS_CALL_GDB_DETACH, 0, 0, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-12-17 10:39:33 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sh_bios_gdb_detach);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-12-17 10:37:51 +08:00
|
|
|
void sh_bios_get_node_addr(unsigned char *node_addr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-12-17 10:37:51 +08:00
|
|
|
sh_bios_call(BIOS_CALL_ETH_NODE_ADDR, 0, (long)node_addr, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-12-17 10:39:33 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sh_bios_get_node_addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
void sh_bios_shutdown(unsigned int how)
|
|
|
|
{
|
2008-12-17 10:37:51 +08:00
|
|
|
sh_bios_call(BIOS_CALL_SHUTDOWN, how, 0, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|