Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bvm/bvm_console.c
Show All 34 Lines | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/cons.h> | #include <sys/cons.h> | ||||
#include <sys/tty.h> | #include <sys/tty.h> | ||||
#include <sys/reboot.h> | #include <sys/reboot.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#if defined(__aarch64__) | |||||
#include <vm/vm.h> | |||||
#include <vm/pmap.h> | |||||
#endif | |||||
#include <sys/kdb.h> | #include <sys/kdb.h> | ||||
#include <ddb/ddb.h> | #include <ddb/ddb.h> | ||||
#ifndef BVMCONS_POLL_HZ | #ifndef BVMCONS_POLL_HZ | ||||
#define BVMCONS_POLL_HZ 4 | #define BVMCONS_POLL_HZ 4 | ||||
#endif | #endif | ||||
#define BVMBURSTLEN 16 /* max number of bytes to write in one chunk */ | #define BVMBURSTLEN 16 /* max number of bytes to write in one chunk */ | ||||
Show All 10 Lines | |||||
static int polltime; | static int polltime; | ||||
static struct callout bvm_timer; | static struct callout bvm_timer; | ||||
#if defined(KDB) | #if defined(KDB) | ||||
static int alt_break_state; | static int alt_break_state; | ||||
#endif | #endif | ||||
#if defined(__i386__) || defined(__amd64__) | |||||
#define BVM_CONS_PORT 0x220 | #define BVM_CONS_PORT 0x220 | ||||
static int bvm_cons_port = BVM_CONS_PORT; | #elif defined(__aarch64__) | ||||
#define BVM_CONS_PORT 0x090000 | |||||
#endif | |||||
static vm_offset_t bvm_cons_port = BVM_CONS_PORT; | |||||
#define BVM_CONS_SIG ('b' << 8 | 'v') | #define BVM_CONS_SIG ('b' << 8 | 'v') | ||||
static void bvm_timeout(void *); | static void bvm_timeout(void *); | ||||
static cn_probe_t bvm_cnprobe; | static cn_probe_t bvm_cnprobe; | ||||
static cn_init_t bvm_cninit; | static cn_init_t bvm_cninit; | ||||
static cn_term_t bvm_cnterm; | static cn_term_t bvm_cnterm; | ||||
static cn_getc_t bvm_cngetc; | static cn_getc_t bvm_cngetc; | ||||
static cn_putc_t bvm_cnputc; | static cn_putc_t bvm_cnputc; | ||||
static cn_grab_t bvm_cngrab; | static cn_grab_t bvm_cngrab; | ||||
static cn_ungrab_t bvm_cnungrab; | static cn_ungrab_t bvm_cnungrab; | ||||
CONSOLE_DRIVER(bvm); | CONSOLE_DRIVER(bvm); | ||||
static int | static int | ||||
bvm_rcons(u_char *ch) | bvm_rcons(u_char *ch) | ||||
{ | { | ||||
int c; | int c; | ||||
#if defined(__i386__) || defined(__amd64__) | |||||
c = inl(bvm_cons_port); | c = inl(bvm_cons_port); | ||||
#elif defined(__arm__) || defined(__aarch64__) | |||||
c = *(int *)bvm_cons_port; | |||||
#endif | |||||
if (c != -1) { | if (c != -1) { | ||||
*ch = (u_char)c; | *ch = (u_char)c; | ||||
return (0); | return (0); | ||||
} else | } else | ||||
return (-1); | return (-1); | ||||
} | } | ||||
static void | static void | ||||
bvm_wcons(u_char ch) | bvm_wcons(u_char ch) | ||||
{ | { | ||||
#if defined(__i386__) || defined(__amd64__) | |||||
outl(bvm_cons_port, ch); | outl(bvm_cons_port, ch); | ||||
#elif defined(__arm__) || defined(__aarch64__) | |||||
*(int *)bvm_cons_port = ch; | |||||
#endif | |||||
} | } | ||||
static void | static void | ||||
cn_drvinit(void *unused) | cn_drvinit(void *unused) | ||||
{ | { | ||||
struct tty *tp; | struct tty *tp; | ||||
if (bvm_consdev.cn_pri != CN_DEAD) { | if (bvm_consdev.cn_pri != CN_DEAD) { | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | bvm_timeout(void *v) | ||||
ttydisc_rint_done(tp); | ttydisc_rint_done(tp); | ||||
callout_reset(&bvm_timer, polltime, bvm_timeout, tp); | callout_reset(&bvm_timer, polltime, bvm_timeout, tp); | ||||
} | } | ||||
static void | static void | ||||
bvm_cnprobe(struct consdev *cp) | bvm_cnprobe(struct consdev *cp) | ||||
{ | { | ||||
int disabled, port; | int disabled; | ||||
#if defined(__i386__) || defined(__amd64__) | |||||
int port; | |||||
#endif | |||||
disabled = 0; | disabled = 0; | ||||
cp->cn_pri = CN_DEAD; | cp->cn_pri = CN_DEAD; | ||||
strcpy(cp->cn_name, "bvmcons"); | strcpy(cp->cn_name, "bvmcons"); | ||||
resource_int_value("bvmconsole", 0, "disabled", &disabled); | resource_int_value("bvmconsole", 0, "disabled", &disabled); | ||||
if (!disabled) { | if (!disabled) { | ||||
#if defined(__i386__) || defined(__amd64__) | |||||
if (resource_int_value("bvmconsole", 0, "port", &port) == 0) | if (resource_int_value("bvmconsole", 0, "port", &port) == 0) | ||||
bvm_cons_port = port; | bvm_cons_port = port; | ||||
if (inw(bvm_cons_port) == BVM_CONS_SIG) | if (inw(bvm_cons_port) == BVM_CONS_SIG) | ||||
#elif defined(__arm__) || defined(__aarch64__) | |||||
bvm_cons_port = (vm_offset_t)pmap_mapdev(bvm_cons_port, 0x1000); | |||||
if ((*(short *)bvm_cons_port) == BVM_CONS_SIG) { | |||||
#endif | |||||
cp->cn_pri = CN_REMOTE; | cp->cn_pri = CN_REMOTE; | ||||
} | |||||
} | } | ||||
} | } | ||||
static void | static void | ||||
bvm_cninit(struct consdev *cp) | bvm_cninit(struct consdev *cp) | ||||
{ | { | ||||
int i; | int i; | ||||
const char *bootmsg = "Using bvm console.\n"; | const char *bootmsg = "Using bvm console.\n"; | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |