Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4073 → Rev 4072

/branches/sparc/kernel/arch/sparc64/src/drivers/niagara.c
37,23 → 37,9
#include <arch/drivers/niagara.h>
#include <console/chardev.h>
#include <console/console.h>
#include <ddi/ddi.h>
#include <ddi/device.h>
#include <arch/asm.h>
#include <arch/drivers/kbd.h>
#include <arch/sun4v/hypercall.h>
#include <sysinfo/sysinfo.h>
#include <ipc/irq.h>
 
/**
* The driver is polling based, but in order to notify the userspace
* of a key being pressed, we need to supply the interface with some
* interrupt number. The interrupt number can be arbitrary as it it
* will never be used for identifying HW interrupts, but only in
* notifying the userspace.
*/
#define FICTIONAL_INR 1
 
/* functions referenced from definitions of I/O operations structures */
static void niagara_putchar(chardev_t *, const char);
static void niagara_noop(chardev_t *);
67,61 → 53,12
.read = niagara_read
};
 
/*
* The driver uses hypercalls to print characters to the console. Since the
* hypercall cannot be performed from the userspace, we do this:
* The kernel "little brother" driver (which will be present no matter what the
* DDI architecture is - as we need the kernel part for the kconsole)
* defines a shared buffer. Kernel walks through the buffer (in the same thread
* which is used for polling the keyboard) and prints any pending characters
* to the console (using hypercalls). The userspace fb server maps this shared
* buffer to its address space and output operation it does is performed using
* the mapped buffer. The shared buffer definition follows.
*/
#define OUTPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8)
static volatile struct {
uint64_t read_ptr;
uint64_t write_ptr;
char data[OUTPUT_BUFFER_SIZE];
}
__attribute__ ((packed))
__attribute__ ((aligned(PAGE_SIZE)))
output_buffer;
 
/** Niagara character device */
chardev_t niagara_io;
 
/**
* Niagara IRQ structure. So far used only for notifying the userspace of the
* key being pressed, not for kernel being informed about keyboard interrupts.
*/
static irq_t niagara_irq;
 
/** defined in drivers/kbd.c */
extern kbd_type_t kbd_type;
 
/**
* The character read will be stored here until the (notified) uspace
* driver picks it up.
*/
static char read_char;
 
/**
* The driver works in polled mode, so no interrupt should be handled by it.
*/
static irq_ownership_t niagara_claim(void)
{
return IRQ_DECLINE;
}
 
/**
* The driver works in polled mode, so no interrupt should be handled by it.
*/
static void niagara_irq_handler(irq_t *irq, void *arg, ...)
{
panic("Not yet implemented, SGCN works in polled mode.\n");
}
 
/** Writes a single character to the standard output. */
static inline void do_putchar(const char c) {
/* repeat until the buffer is non-full */
142,11 → 79,6
*/
void niagara_grab(void)
{
ipl_t ipl = interrupts_disable();
spinlock_lock(&niagara_irq.lock);
niagara_irq.notif_cfg.notify = false;
spinlock_unlock(&niagara_irq.lock);
interrupts_restore(ipl);
}
 
/**
154,12 → 86,6
*/
void niagara_release(void)
{
ipl_t ipl = interrupts_disable();
spinlock_lock(&niagara_irq.lock);
if (niagara_irq.notif_cfg.answerbox)
niagara_irq.notif_cfg.notify = true;
spinlock_unlock(&niagara_irq.lock);
interrupts_restore(ipl);
}
 
/**
170,29 → 96,14
}
 
/**
* Called when actively reading the character.
* Called when actively reading the character. Not implemented yet.
*/
static char niagara_read(chardev_t *d)
{
uint64_t c;
 
if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) {
return (char) c;
}
 
return '\0';
return (char) 0;
}
 
/**
* Returns the character last read. This function is called from the
* pseudocode - the character returned by this function is passed to
* the userspace keyboard driver.
*/
char niagara_getc(void) {
return read_char;
}
 
/**
* 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.
199,37 → 110,12
*/
void niagara_poll(void)
{
while (output_buffer.read_ptr != output_buffer.write_ptr) {
do_putchar(output_buffer.data[output_buffer.read_ptr]);
output_buffer.read_ptr =
((output_buffer.read_ptr) + 1) % OUTPUT_BUFFER_SIZE;
}
uint64_t c = 50;
 
uint64_t c;
 
if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) {
ipl_t ipl = interrupts_disable();
spinlock_lock(&niagara_irq.lock);
 
if (niagara_irq.notif_cfg.notify &&
niagara_irq.notif_cfg.answerbox) {
/*
* remember the character, uspace will pick it
* up using pseudocode
*/
read_char = (char) c;
ipc_irq_send_notif(&niagara_irq);
spinlock_unlock(&niagara_irq.lock);
interrupts_restore(ipl);
return;
} else {
spinlock_unlock(&niagara_irq.lock);
interrupts_restore(ipl);
 
chardev_push_character(&niagara_io, c);
if (c == '\r')
chardev_push_character(&niagara_io, '\n');
}
chardev_push_character(&niagara_io, c);
if (c == '\r')
chardev_push_character(&niagara_io, '\n');
}
 
}
242,39 → 128,6
{
kbd_type = KBD_SUN4V;
 
devno_t devno = device_assign_devno();
irq_initialize(&niagara_irq);
niagara_irq.devno = devno;
niagara_irq.inr = FICTIONAL_INR;
niagara_irq.claim = niagara_claim;
niagara_irq.handler = niagara_irq_handler;
irq_register(&niagara_irq);
sysinfo_set_item_val("kbd", NULL, true);
sysinfo_set_item_val("kbd.type", NULL, KBD_SUN4V);
sysinfo_set_item_val("kbd.devno", NULL, devno);
sysinfo_set_item_val("kbd.inr", NULL, FICTIONAL_INR);
sysinfo_set_item_val("fb.kind", NULL, 5);
 
/*
* Set sysinfos and pareas so that the userspace counterpart of the
* niagara fb driver can communicate with kernel using a shared buffer.
*/
output_buffer.read_ptr = 0;
output_buffer.write_ptr = 0;
sysinfo_set_item_val("niagara.outbuf.address", NULL,
KA2PA(&output_buffer));
sysinfo_set_item_val("niagara.outbuf.size", NULL,
PAGE_SIZE);
sysinfo_set_item_val("niagara.outbuf.datasize", NULL,
OUTPUT_BUFFER_SIZE);
static parea_t outbuf_parea;
outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer));
outbuf_parea.vbase = (uintptr_t) (&output_buffer);
outbuf_parea.frames = 1;
outbuf_parea.cacheable = false;
ddi_parea_register(&outbuf_parea);
 
chardev_initialize("niagara_io", &niagara_io, &niagara_ops);
stdin = &niagara_io;
stdout = &niagara_io;
/branches/sparc/kernel/arch/sparc64/src/console.c
208,11 → 208,6
sgcn_grab();
break;
#endif
#ifdef SUN4V
case KBD_SUN4V:
niagara_grab();
break;
#endif
default:
break;
}
239,11 → 234,6
sgcn_release();
break;
#endif
#ifdef SUN4V
case KBD_SUN4V:
niagara_release();
break;
#endif
default:
break;
}
/branches/sparc/kernel/arch/sparc64/include/drivers/niagara.h
35,7 → 35,6
#ifndef KERN_sparc64_NIAGARA_H
#define KERN_sparc64_NIAGARA_H
 
char niagara_getc(void);
void niagara_grab(void);
void niagara_release(void);
void niagara_init(void);
/branches/sparc/kernel/generic/src/ipc/irq.c
59,10 → 59,6
#include <console/console.h>
#include <print.h>
 
#if defined(sparc64) && defined(SUN4V)
#include <arch/drivers/niagara.h>
#endif
 
/** Execute code associated with IRQ notification.
*
* @param call Notification call.
118,11 → 114,6
dstval = _getc(&ski_uconsole);
break;
#endif
#if defined(sparc64) && defined(SUN4V)
case CMD_NIAGARA_GETCHAR:
dstval = niagara_getc();
break;
#endif
#if defined(ppc32)
case CMD_PPC32_GETCHAR:
dstval = cuda_get_scancode();
/branches/sparc/kernel/generic/src/ipc/kbox.c
38,10 → 38,8
#include <ipc/ipc.h>
#include <ipc/ipcrsc.h>
#include <arch.h>
#include <arch/asm.h>
#include <errno.h>
#include <debug.h>
#include <print.h>
#include <udebug/udebug_ipc.h>
#include <ipc/kbox.h>
 
/branches/sparc/kernel/generic/src/udebug/udebug.c
42,8 → 42,6
#include <udebug/udebug.h>
#include <errno.h>
#include <arch.h>
#include <arch/asm.h>
#include <print.h>
 
 
/** Initialize udebug part of task structure.
/branches/sparc/kernel/generic/src/udebug/udebug_ops.c
43,13 → 43,11
#include <proc/task.h>
#include <proc/thread.h>
#include <arch.h>
#include <arch/asm.h>
#include <errno.h>
#include <syscall/copy.h>
#include <ipc/ipc.h>
#include <udebug/udebug.h>
#include <udebug/udebug_ops.h>
#include <print.h>
 
/**
* Prepare a thread for a debugging operation.
/branches/sparc/kernel/generic/src/udebug/udebug_ipc.c
41,7 → 41,6
#include <proc/task.h>
#include <proc/thread.h>
#include <arch.h>
#include <arch/asm.h>
#include <errno.h>
#include <ipc/ipc.h>
#include <syscall/copy.h>
/branches/sparc/kernel/generic/include/ddi/irq.h
48,7 → 48,6
CMD_PORT_WRITE_1,
CMD_IA64_GETCHAR,
CMD_PPC32_GETCHAR,
CMD_NIAGARA_GETCHAR,
CMD_LAST
} irq_cmd_type;
 
/branches/sparc/uspace/srv/fb/niagara.c
File deleted
/branches/sparc/uspace/srv/fb/niagara.h
File deleted
/branches/sparc/uspace/srv/fb/main.c
40,7 → 40,6
#include "msim.h"
#include "ski.h"
#include "sgcn.h"
#include "niagara.h"
#include "main.h"
 
#define NAME "fb"
88,10 → 87,6
initialized = true;
}
#endif
if ((!initialized) && (sysinfo_value("fb.kind") == 5)) {
if (niagara_init() == 0)
initialized = true;
}
#ifdef SKI_ENABLED
if ((!initialized) && (sysinfo_value("fb") != true)) {
if (ski_init() == 0)
/branches/sparc/uspace/srv/fb/Makefile
74,7 → 74,6
endif
ifeq ($(ARCH), sparc64)
SOURCES += sgcn.c \
niagara.c \
serial_console.c
CFLAGS += -DSGCN_ENABLED
endif
/branches/sparc/uspace/srv/kbd/Makefile
79,8 → 79,7
ifeq ($(ARCH), sparc64)
ARCH_SOURCES += \
arch/$(ARCH)/src/scanc.c \
arch/$(ARCH)/src/sgcn.c \
arch/$(ARCH)/src/niagara.c
arch/$(ARCH)/src/sgcn.c
GENARCH_SOURCES = \
genarch/src/kbd.c \
genarch/src/nofb.c
/branches/sparc/uspace/srv/kbd/arch/sparc64/src/niagara.c
File deleted
/branches/sparc/uspace/srv/kbd/arch/sparc64/src/kbd.c
36,7 → 36,6
 
#include <arch/kbd.h>
#include <arch/sgcn.h>
#include <arch/niagara.h>
#include <ipc/ipc.h>
#include <sysinfo.h>
#include <kbd.h>
78,25 → 77,9
ns16550_cmds
};
 
/** Top-half pseudocode for Niagara keyboard driver. */
irq_cmd_t niagara_cmds[] = {
{
CMD_NIAGARA_GETCHAR,
0, /**< Address. Not used. */
0, /**< Value. Not used. */
1 /**< Arg 1 will contain the result. */
}
};
irq_code_t niagara_kbd = {
1,
niagara_cmds
};
 
#define KBD_Z8530 1
#define KBD_NS16550 2
#define KBD_SGCN 3
#define KBD_SUN4V 4
 
int kbd_arch_init(void)
{
113,13 → 96,9
case KBD_SGCN:
sgcn_init();
break;
case KBD_SUN4V:
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &niagara_kbd);
break;
default:
break;
}
 
return 0;
}
 
129,10 → 108,6
if (sysinfo_value("kbd.type") == KBD_SGCN) {
sgcn_key_pressed();
return 1;
} else if (sysinfo_value("kbd.type") == KBD_SUN4V) {
char c = IPC_GET_ARG1(*call);
niagara_key_pressed(c);
return 1;
}
int scan_code = IPC_GET_ARG1(*call);
/branches/sparc/uspace/srv/kbd/arch/sparc64/include/niagara.h
File deleted
/branches/sparc/uspace/srv/kbd/genarch/src/nofb.c
53,7 → 53,7
 
/**
* Processes the key pressed - pushes the key code into the key buffer.
* Used in MSIM, Serengeti and Niagara, i.e. non-framebuffer consoles.
* Used in MSIM and Serengeti, i.e. non-framebuffer consoles.
*/
int kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code)
{
184,4 → 184,4
}
 
/** @}
*/
*/