37,28 → 37,19 |
#include <arch/drivers/niagara.h> |
#include <console/chardev.h> |
#include <console/console.h> |
#include <arch/drivers/kbd.h> |
#include <arch/sun4v/hypercall.h> |
|
/* functions referenced from definitions of I/O operations structures */ |
static void niagara_putchar(chardev_t *, const char); |
static void niagara_noop(chardev_t *); |
static char niagara_read(chardev_t *); |
|
/** character device operations */ |
static chardev_operations_t niagara_ops = { |
.write = niagara_putchar, |
.suspend = niagara_noop, |
.resume = niagara_noop, |
.read = niagara_read |
.write = niagara_putchar |
}; |
|
/** Niagara character device */ |
chardev_t niagara_io; |
|
/** defined in drivers/kbd.c */ |
extern kbd_type_t kbd_type; |
|
/** Writes a single character to the standard output. */ |
static void niagara_putchar(struct chardev * cd, const char c) |
{ |
67,6 → 58,7 |
__hypercall_fast1(CONS_PUTCHAR, '\r'); |
} |
|
|
/** |
* Grabs the input for kernel. |
*/ |
82,45 → 74,11 |
} |
|
/** |
* Default suspend/resume operation for the input device. |
*/ |
static void niagara_noop(chardev_t *d) |
{ |
} |
|
/** |
* Called when actively reading the character. Not implemented yet. |
*/ |
static char niagara_read(chardev_t *d) |
{ |
return (char) 0; |
} |
|
/** |
* Function regularly called by the keyboard polling thread. Asks the |
* hypervisor whether there is any unread character. If so, it picks it up |
* and sends it to the upper layers of HelenOS. |
*/ |
void niagara_poll(void) |
{ |
uint64_t c = 50; |
|
if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) { |
chardev_push_character(&niagara_io, c); |
if (c == '\r') |
chardev_push_character(&niagara_io, '\n'); |
} |
|
} |
|
/** |
* Initializes the input/output subsystem so that the Niagara standard |
* input/output is used. |
*/ |
void niagara_init(void) |
{ |
kbd_type = KBD_SUN4V; |
|
chardev_initialize("niagara_io", &niagara_io, &niagara_ops); |
stdin = &niagara_io; |
stdout = &niagara_io; |