Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4072 → Rev 4073

/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 and Serengeti, i.e. non-framebuffer consoles.
* Used in MSIM, Serengeti and Niagara, i.e. non-framebuffer consoles.
*/
int kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code)
{
184,4 → 184,4
}
 
/** @}
*/
*/
/branches/sparc/uspace/srv/kbd/Makefile
79,7 → 79,8
ifeq ($(ARCH), sparc64)
ARCH_SOURCES += \
arch/$(ARCH)/src/scanc.c \
arch/$(ARCH)/src/sgcn.c
arch/$(ARCH)/src/sgcn.c \
arch/$(ARCH)/src/niagara.c
GENARCH_SOURCES = \
genarch/src/kbd.c \
genarch/src/nofb.c
/branches/sparc/uspace/srv/kbd/arch/sparc64/include/niagara.h
0,0 → 1,45
/*
* Copyright (c) 2008 Pavel Rimsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup kbdsparc64 sparc64
* @brief Serengeti-specific parts of uspace keyboard handler.
* @ingroup kbd
* @{
*/
/** @file
*/
 
#ifndef KBD_sparc64_NIAGARA_H_
#define KBD_sparc64_NIAGARA_H_
 
void niagara_key_pressed(char c);
 
#endif
 
/** @}
*/
/branches/sparc/uspace/srv/kbd/arch/sparc64/src/kbd.c
36,6 → 36,7
 
#include <arch/kbd.h>
#include <arch/sgcn.h>
#include <arch/niagara.h>
#include <ipc/ipc.h>
#include <sysinfo.h>
#include <kbd.h>
77,9 → 78,25
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)
{
96,9 → 113,13
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;
}
 
108,6 → 129,10
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/src/niagara.c
0,0 → 1,63
/*
* Copyright (c) 2008 Pavel Rimsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup kbdsparc64 sparc64
* @brief Serengeti-specific parts of uspace keyboard handler.
* @ingroup kbd
* @{
*/
/** @file
*/
 
#include <arch/niagara.h>
#include <as.h>
#include <ddi.h>
#include <ipc/ipc.h>
#include <kbd.h>
#include <genarch/nofb.h>
#include <genarch/kbd.h>
#include <sysinfo.h>
#include <stdio.h>
#include <futex.h>
 
extern keybuffer_t keybuffer;
 
/**
* Handler of the "key pressed" event.
*/
void niagara_key_pressed(char c)
{
if (c == '\r') {
c = '\n';
}
 
kbd_process_no_fb(&keybuffer, c);
}
 
/** @}
*/
/branches/sparc/uspace/srv/fb/niagara.c
0,0 → 1,114
/*
* Copyright (c) 2006 Ondrej Palkovsky
* Copyright (c) 2008 Martin Decky
* Copyright (c) 2008 Pavel Rimsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @defgroup niagarafb SGCN
* @brief userland driver of the Niagara console output
* @{
*/
/** @file
*/
 
#include <async.h>
#include <sysinfo.h>
#include <as.h>
#include <errno.h>
#include <stdio.h>
#include <ddi.h>
 
#include "serial_console.h"
#include "niagara.h"
 
#define WIDTH 80
#define HEIGHT 24
 
/**
* Virtual address mapped to the buffer shared with the kernel counterpart.
*/
static uintptr_t output_buffer_addr;
 
/*
* Kernel counterpart of the driver reads characters to be printed from here.
* Keep in sync with the definition from
* kernel/arch/sparc64/src/drivers/niagara.c.
*/
#define OUTPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8)
typedef volatile struct {
uint64_t read_ptr;
uint64_t write_ptr;
char data[OUTPUT_BUFFER_SIZE];
}
__attribute__ ((packed))
__attribute__ ((aligned(PAGE_SIZE)))
*output_buffer_t;
 
output_buffer_t output_buffer;
 
/**
* Pushes the character to the Niagara serial.
* @param c character to be pushed
*/
static void niagara_putc(char c)
{
while (output_buffer->write_ptr ==
(output_buffer->read_ptr + OUTPUT_BUFFER_SIZE - 1)
% OUTPUT_BUFFER_SIZE)
;
output_buffer->data[output_buffer->write_ptr] = (uint64_t) c;
output_buffer->write_ptr =
((output_buffer->write_ptr) + 1) % OUTPUT_BUFFER_SIZE;
}
 
/**
* Initializes the Niagara serial driver.
*/
int niagara_init(void)
{
output_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE);
int result = physmem_map(
(void *) sysinfo_value("niagara.outbuf.address"),
(void *) output_buffer_addr,
1, AS_AREA_READ | AS_AREA_WRITE);
 
if (result != 0) {
printf("Niagara: uspace driver couldn't map physical memory: %d\n",
result);
}
 
output_buffer = (output_buffer_t) output_buffer_addr;
 
serial_console_init(niagara_putc, WIDTH, HEIGHT);
async_set_client_connection(serial_client_connection);
return 0;
}
 
/**
* @}
*/
/branches/sparc/uspace/srv/fb/niagara.h
0,0 → 1,46
/*
* Copyright (c) 2008 Pavel Rimsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @defgroup sgcnfb SGCN
* @brief userland driver of the Serengeti console output
* @{
*/
/** @file
*/
 
#ifndef FB_NIAGARA_H_
#define FB_NIAGARA_H_
 
int niagara_init(void);
 
#endif
 
/**
* @}
*/
/branches/sparc/uspace/srv/fb/main.c
40,6 → 40,7
#include "msim.h"
#include "ski.h"
#include "sgcn.h"
#include "niagara.h"
#include "main.h"
 
#define NAME "fb"
87,6 → 88,10
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,6 → 74,7
endif
ifeq ($(ARCH), sparc64)
SOURCES += sgcn.c \
niagara.c \
serial_console.c
CFLAGS += -DSGCN_ENABLED
endif