Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3816 → Rev 3817

/branches/sparc/kernel/arch/sparc64/src/drivers/niagara.c
37,19 → 37,28
#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
.write = niagara_putchar,
.suspend = niagara_noop,
.resume = niagara_noop,
.read = niagara_read
};
 
/** 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)
{
58,7 → 67,6
__hypercall_fast1(CONS_PUTCHAR, '\r');
}
 
 
/**
* Grabs the input for kernel.
*/
74,11 → 82,45
}
 
/**
* 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;