Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1895 → Rev 1896

/trunk/kernel/arch/sparc64/include/boot/boot.h
79,11 → 79,6
} screen_t;
 
typedef struct {
uintptr_t addr;
uint32_t size;
} keyboard_t;
 
typedef struct {
uint32_t clock_frequency;
} processor_t;
 
95,7 → 90,6
taskmap_t taskmap;
memmap_t memmap;
screen_t screen;
keyboard_t keyboard;
processor_t processor;
ballocs_t ballocs;
ofw_tree_node_t *ofw_root;
/trunk/kernel/arch/sparc64/include/drivers/kbd.h
36,10 → 36,19
#define KERN_sparc64_KBD_H_
 
#include <arch/types.h>
#include <genarch/ofw/ofw_tree.h>
 
typedef enum {
KBD_UNKNOWN,
KBD_Z8530,
KBD_NS16550
} kbd_type_t;
 
extern kbd_type_t kbd_type;
 
extern volatile uint8_t *kbd_virt_address;
 
extern void kbd_init(void);
extern void kbd_init(ofw_tree_node_t *node);
 
#endif
 
/trunk/kernel/arch/sparc64/Makefile.inc
60,30 → 60,16
 
CONFIG_FB = y
 
## Compile with support for Sun keyboard.
#
 
CONFIG_SUN_KBD = y
 
## Compile with support for OpenFirmware device tree.
#
 
CONFIG_OFW_TREE = y
 
ifeq ($(MACHINE),enterprise)
## Compile with support for z8530 controller.
#
 
CONFIG_Z8530 = y
DEFS += -DCONFIG_Z8530
endif
ifeq ($(MACHINE),ultra)
## Compile with support for ns16550 controller.
#
CONFIG_NS16550 = y
DEFS += -DCONFIG_NS16550
DEFS += -DKBD_ADDR_OVRD=0x1fff13083f8ULL
endif
 
 
ARCH_SOURCES = \
arch/$(ARCH)/src/cpu/cpu.c \
arch/$(ARCH)/src/asm.S \
/trunk/kernel/arch/sparc64/src/console.c
53,7 → 53,10
#include <proc/thread.h>
#include <arch/mm/tlb.h>
#include <arch/boot/boot.h>
#include <genarch/ofw/ofw_tree.h>
#include <arch.h>
#include <panic.h>
#include <print.h>
 
#define KEYBOARD_POLL_PAUSE 50000 /* 50ms */
 
61,17 → 64,38
void standalone_sparc64_console_init(void)
{
stdin = NULL;
 
ofw_tree_node_t *aliases;
ofw_tree_property_t *prop;
ofw_tree_node_t *screen;
ofw_tree_node_t *keyboard;
aliases = ofw_tree_lookup("/aliases");
if (!aliases)
panic("Can't find /aliases.\n");
prop = ofw_tree_getprop(aliases, "screen");
if (!prop)
panic("Can't find property \"screen\".\n");
if (!prop->value)
panic("Can't find screen alias.\n");
screen = ofw_tree_lookup(prop->value);
if (!screen)
panic("Can't find %s\n", prop->value);
 
fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height,
bootinfo.screen.bpp, bootinfo.screen.scanline, true);
prop = ofw_tree_getprop(aliases, "keyboard");
if (!prop)
panic("Can't find property \"keyboard\".\n");
if (!prop->value)
panic("Can't find keyboard alias.\n");
keyboard = ofw_tree_lookup(prop->value);
if (!keyboard)
panic("Can't find %s\n", prop->value);
 
#ifdef KBD_ADDR_OVRD
if (!bootinfo.keyboard.addr)
bootinfo.keyboard.addr = KBD_ADDR_OVRD;
#endif
 
if (bootinfo.keyboard.addr)
kbd_init();
kbd_init(keyboard);
}
 
/** Kernel thread for polling keyboard.
82,15 → 106,15
{
thread_detach(THREAD);
 
if (!bootinfo.keyboard.addr)
return;
while (1) {
#ifdef CONFIG_Z8530
if (kbd_type == KBD_Z8530)
return;
#endif
 
while (1) {
#ifdef CONFIG_NS16550
ns16550_poll();
if (kbd_type == KBD_NS16550)
ns16550_poll();
#endif
thread_usleep(KEYBOARD_POLL_PAUSE);
}
102,7 → 126,8
void arch_grab_console(void)
{
#ifdef CONFIG_Z8530
z8530_grab();
if (kbd_type == KBD_Z8530)
z8530_grab();
#endif
}
 
112,7 → 137,8
void arch_release_console(void)
{
#ifdef CONFIG_Z8530
z8530_release();
if (kbd_type == KBD_Z8530)
z8530_release();
#endif
}
 
/trunk/kernel/arch/sparc64/src/trap/interrupt.c
36,6 → 36,7
#include <arch/trap/interrupt.h>
#include <interrupt.h>
#include <arch/drivers/fhc.h>
#include <arch/drivers/kbd.h>
#include <typedefs.h>
#include <arch/types.h>
#include <debug.h>
62,7 → 63,8
void irq_ipc_bind_arch(unative_t irq)
{
#ifdef CONFIG_Z8530
z8530_belongs_to_kernel = false;
if (kbd_type == KBD_Z8530)
z8530_belongs_to_kernel = false;
#endif
}
 
77,6 → 79,8
switch (data0) {
#ifdef CONFIG_Z8530
case Z8530_INTRCV_DATA0:
if (kbd_type != KBD_Z8530)
break;
/*
* So far, we know we got this interrupt through the FHC.
* Since we don't have enough information about the FHC and
/trunk/kernel/arch/sparc64/src/drivers/kbd.c
33,6 → 33,7
*/
 
#include <arch/drivers/kbd.h>
#include <genarch/ofw/ofw_tree.h>
#ifdef CONFIG_Z8530
#include <genarch/kbd/z8530.h>
#endif
40,38 → 41,93
#include <genarch/kbd/ns16550.h>
#endif
 
#include <arch/boot/boot.h>
#include <arch/mm/page.h>
#include <arch/types.h>
#include <typedefs.h>
#include <align.h>
#include <func.h>
#include <print.h>
 
volatile uint8_t *kbd_virt_address = NULL;
 
void kbd_init()
kbd_type_t kbd_type = KBD_UNKNOWN;
 
/** Initialize keyboard.
*
* Traverse OpenFirmware device tree in order to find necessary
* info about the keyboard device.
*
* @param node Keyboard device node.
*/
void kbd_init(ofw_tree_node_t *node)
{
size_t offset;
uintptr_t aligned_addr;
 
/* FIXME: supply value read from OpenFirmware */
bootinfo.keyboard.size = 8;
 
ofw_tree_property_t *prop;
const char *name;
name = ofw_tree_node_name(node);
if (strcmp(name, "zs") == 0)
kbd_type = KBD_Z8530;
else if (strcmp(name, "su") == 0)
kbd_type = KBD_NS16550;
if (kbd_type == KBD_UNKNOWN) {
printf("Unknown keyboard device.\n");
return;
}
prop = ofw_tree_getprop(node, "reg");
if (!prop)
panic("Can't find \"reg\" property.\n");
uintptr_t pa;
size_t size;
switch (kbd_type) {
case KBD_Z8530:
size = ((ofw_fhc_reg_t *) prop->value)->size;
if (!ofw_fhc_apply_ranges(node->parent, ((ofw_fhc_reg_t *) prop->value) , &pa)) {
printf("Failed to determine keyboard address.\n");
return;
}
break;
case KBD_NS16550:
size = ((ofw_ebus_reg_t *) prop->value)->size;
if (!ofw_ebus_apply_ranges(node->parent, ((ofw_ebus_reg_t *) prop->value) , &pa)) {
printf("Failed to determine keyboard address.\n");
return;
}
break;
default:
panic("Unexpected type.\n");
}
/*
* We need to pass aligned address to hw_map().
* However, the physical keyboard address can
* be pretty much unaligned on some systems
* (e.g. Ultra 5, Ultra 60).
* be pretty much unaligned, depending on the
* underlying controller.
*/
aligned_addr = ALIGN_DOWN(bootinfo.keyboard.addr, PAGE_SIZE);
offset = bootinfo.keyboard.addr - aligned_addr;
kbd_virt_address = (uint8_t *) hw_map(aligned_addr, offset + bootinfo.keyboard.size) + offset;
aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE);
offset = pa - aligned_addr;
kbd_virt_address = (uint8_t *) hw_map(aligned_addr, offset + size) + offset;
 
switch (kbd_type) {
#ifdef CONFIG_Z8530
z8530_init();
case KBD_Z8530:
z8530_init();
break;
#endif
#ifdef CONFIG_NS16550
ns16550_init();
case KBD_NS16550:
ns16550_init();
break;
#endif
default:
printf("Kernel is not compiled with the necessary keyboard driver this machine requires.\n");
}
}
 
/** @}