Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 893 → Rev 892

/kernel/trunk/arch/ia64/src/ski/ski.c
86,20 → 86,18
}
 
/**
* This is a blocking wrapper for ski_getchar().
* To be used when the kernel crashes.
*/
This is blocking wrap function of ski_getchar
It active waits ... for using with non-stable kernel
*/
static char ski_getchar_blocking(chardev_t *d)
{
int ch;
 
while(!(ch=ski_getchar()))
;
if(ch == '\r')
ch = '\n';
volatile int ch;
while(!(ch=ski_getchar()));
if(ch == '\r') ch = '\n';
return (char) ch;
}
 
 
/** Ask keyboard if a key was pressed. */
void poll_keyboard(void)
{
/kernel/trunk/arch/ia64/src/start.S
26,18 → 26,22
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
 
#include <arch/register.h>
#include <arch/mm/page.h>
#include <arch/mm/asid.h>
#include <mm/asid.h>
 
 
#define RR_MASK (0xFFFFFFFF00000002)
#define RID_SHIFT 8
#define PS_SHIFT 2
 
 
#define KERNEL_TRANSLATION_I 0x0010000000000661
#define KERNEL_TRANSLATION_D 0x0010000000000661
 
 
.section K_TEXT_START
 
.global kernel_image_start
46,7 → 50,7
kernel_image_start:
.auto
 
# Fill TR.i and TR.d using Region Register #VRN_KERNEL
#Fill TR.i and TR.d using Region Register #VRN_KERNEL
 
movl r8=(VRN_KERNEL<<VRN_SHIFT)
mov r9=rr[r8]
56,6 → 60,7
or r9=r10,r9
mov rr[r8]=r9
 
 
movl r8=(VRN_KERNEL<<VRN_SHIFT)
mov cr.ifa=r8
movl r10=(KERNEL_PAGE_WIDTH<<PS_SHIFT)
62,14 → 67,16
mov cr.itir=r10
movl r10=(KERNEL_TRANSLATION_I)
itr.i itr[r0]=r10
 
movl r10=(KERNEL_TRANSLATION_D)
itr.d dtr[r0]=r10
 
 
# initialize PSR
mov psr.l = r0
srlz.i
srlz.d
movl r10=(PSR_DT_MASK|PSR_RT_MASK|PSR_IT_MASK|PSR_IC_MASK) /* Enable paging */
movl r10=(PSR_DT_MASK|PSR_RT_MASK|PSR_IT_MASK|PSR_IC_MASK) /*Enable paging*/
mov r9=psr
or r10=r10,r9
mov cr.ipsr=r10
78,12 → 85,10
mov cr.iip=r8
srlz.d
srlz.i
.explicit
 
.explicit
/*
* Return From Interupt is the only the way to fill upper half word of PSR.
*/
rfi;;
/*Return from interupt is only the way how to fill upper half word of PSR*/
{rfi;;}
{nop 0;;}
{nop 0;;}
{nop 0;;}
94,12 → 99,8
{nop 0;;}
 
.global paging_start
/*Now we are paging*/
paging_start:
 
/*
* Now we are paging.
*/
 
{nop 0;;}
{nop 0;;}
{nop 0;;}
109,15 → 110,18
{nop 0;;}
{nop 0;;}
 
.auto
# switch to register bank 1
bsw.1
# initialize register stack
mov ar.rsc = r0
movl r8=(VRN_KERNEL<<VRN_SHIFT) ;;
movl r8=(VRN_KERNEL<<VRN_SHIFT)
mov ar.bspstore = r8
loadrs
 
.explicit
# initialize memory stack to some sane value
movl r12 = stack0;;
126,9 → 130,11
# initialize gp (Global Pointer) register
movl r1 = _hardcoded_load_address ;;
 
/*
* Initialize hardcoded_* variables.
*/
 
#
# Initialize hardcoded_* variables.
#
movl r14 = _hardcoded_ktext_size
movl r15 = _hardcoded_kdata_size
movl r16 = _hardcoded_load_address
140,9 → 146,13
st8 [r18] = r15
st8 [r19] = r16
 
movl r18=main_bsp ;;
mov b1=r18 ;;
 
.auto
movl r18=main_bsp
mov b1=r18
br.call.sptk.many b0=b1
 
 
0:
br 0b
/kernel/trunk/arch/sparc64/include/console.h
29,8 → 29,6
#ifndef __sparc64_CONSOLE_H__
#define __sparc64_CONSOLE_H__
 
extern void kofwinput(void *arg);
extern void ofw_sparc64_console_init(void);
extern void standalone_sparc64_console_init(void);
extern void fb_sparc64_console_init(void);
 
#endif
/kernel/trunk/arch/sparc64/src/console.c
31,129 → 31,8
#include <typedefs.h>
#include <genarch/fb/fb.h>
#include <arch/drivers/fb.h>
#include <genarch/ofw/ofw.h>
#include <console/chardev.h>
#include <console/console.h>
#include <arch/asm.h>
#include <arch/register.h>
#include <proc/thread.h>
#include <synch/mutex.h>
 
static void ofw_sparc64_putchar(chardev_t *d, const char ch);
static char ofw_sparc64_getchar(chardev_t *d);
static void ofw_sparc64_suspend(chardev_t *d);
static void ofw_sparc64_resume(chardev_t *d);
 
mutex_t canwork;
 
static volatile int ofw_console_active;
 
static chardev_t ofw_sparc64_console;
static chardev_operations_t ofw_sparc64_console_ops = {
.write = ofw_sparc64_putchar,
.read = ofw_sparc64_getchar,
.resume = ofw_sparc64_resume,
.suspend = ofw_sparc64_suspend
};
 
/** Initialize kernel console to use OpenFirmware services. */
void ofw_sparc64_console_init(void)
void fb_sparc64_console_init(void)
{
chardev_initialize("ofw_sparc64_console", &ofw_sparc64_console, &ofw_sparc64_console_ops);
stdin = &ofw_sparc64_console;
stdout = &ofw_sparc64_console;
mutex_initialize(&canwork);
ofw_console_active = 1;
}
 
/** Initialize kernel console to use framebuffer and keyboard directly. */
void standalone_sparc64_console_init(void)
{
ofw_console_active = 0;
stdin = NULL;
fb_init(FB_VIRT_ADDRESS, FB_X_RES, FB_Y_RES, FB_COLOR_DEPTH/8);
}
 
/** Write one character using OpenFirmware.
*
* @param d Character device (ignored).
* @param ch Character to be written.
*/
void ofw_sparc64_putchar(chardev_t *d, const char ch)
{
pstate_reg_t pstate;
 
/*
* 32-bit OpenFirmware depends on PSTATE.AM bit set.
*/
pstate.value = pstate_read();
pstate.am = true;
pstate_write(pstate.value);
 
if (ch == '\n')
ofw_putchar('\r');
ofw_putchar(ch);
pstate.am = false;
pstate_write(pstate.value);
}
 
/** Read one character using OpenFirmware.
*
* The call is non-blocking.
*
* @param d Character device (ignored).
* @return Character read or zero if no character was read.
*/
char ofw_sparc64_getchar(chardev_t *d)
{
char ch;
pstate_reg_t pstate;
 
/*
* 32-bit OpenFirmware depends on PSTATE.AM bit set.
*/
pstate.value = pstate_read();
pstate.am = true;
pstate_write(pstate.value);
 
ch = ofw_getchar();
pstate.am = false;
pstate_write(pstate.value);
return ch;
}
 
void ofw_sparc64_suspend(chardev_t *d)
{
mutex_lock(&canwork);
}
 
void ofw_sparc64_resume(chardev_t *d)
{
mutex_unlock(&canwork);
}
 
/** Kernel thread for pushing characters read from OFW to input buffer.
*
* @param arg Ignored.
*/
void kofwinput(void *arg)
{
 
while (ofw_console_active) {
char ch = 0;
mutex_lock(&canwork);
mutex_unlock(&canwork);
ch = ofw_sparc64_getchar(NULL);
if (ch) {
if (ch == '\r')
ch = '\n';
chardev_push_character(&ofw_sparc64_console, ch);
}
thread_usleep(25000);
}
}
/kernel/trunk/arch/sparc64/src/sparc64.c
36,7 → 36,6
void arch_pre_mm_init(void)
{
interrupts_disable();
ofw_sparc64_console_init();
trap_init();
tick_init();
}
43,7 → 42,7
 
void arch_post_mm_init(void)
{
standalone_sparc64_console_init();
fb_sparc64_console_init();
}
 
void arch_pre_smp_init(void)
52,15 → 51,6
 
void arch_post_smp_init(void)
{
thread_t *t;
 
/*
* Create thread that reads characters from OFW's input.
*/
t = thread_create(kofwinput, NULL, TASK, 0);
if (!t)
panic("cannot create kofwinput\n");
thread_ready(t);
}
 
void calibrate_delay_loop(void)
/kernel/trunk/arch/ia32/src/drivers/i8042.c
45,10 → 45,11
* It takes care of low-level keyboard functions.
*/
 
#define i8042_DATA 0x60
#define i8042_STATUS 0x64
#define i8042_DATA 0x60
#define i8042_STATUS 0x64
#define i8042_BUFFER_FULL_MASK 0x01
 
 
/** Keyboard commands. */
#define KBD_ENABLE 0xf4
#define KBD_DISABLE 0xf5
55,24 → 56,25
#define KBD_ACK 0xfa
 
/*
* 60 Write 8042 Command Byte: next data byte written to port 60h is
* placed in 8042 command register.Format:
*
* |7|6|5|4|3|2|1|0|8042 Command Byte
* | | | | | | | `---- 1=enable output register full interrupt
* | | | | | | `----- should be 0
* | | | | | `------ 1=set status register system, 0=clear
* | | | | `------- 1=override keyboard inhibit, 0=allow inhibit
* | | | `-------- disable keyboard I/O by driving clock line low
* | | `--------- disable auxiliary device, drives clock line low
* | `---------- IBM scancode translation 0=AT, 1=PC/XT
* `----------- reserved, should be 0
*/
60 Write 8042 Command Byte: next data byte written to port 60h is
placed in 8042 command register.Format:
 
#define i8042_SET_COMMAND 0x60
#define i8042_COMMAND 0x49
#define i8042_WAIT_MASK 0x02
|7|6|5|4|3|2|1|0|8042 Command Byte
| | | | | | | `---- 1=enable output register full interrupt
| | | | | | `----- should be 0
| | | | | `------ 1=set status register system, 0=clear
| | | | `------- 1=override keyboard inhibit, 0=allow inhibit
| | | `-------- disable keyboard I/O by driving clock line low
| | `--------- disable auxiliary device, drives clock line low
| `---------- IBM scancode translation 0=AT, 1=PC/XT
`----------- reserved, should be 0
*/
 
#define i8042_SET_COMMAND 0x60
#define i8042_COMMAND 0x49
#define i8042_WAIT_MASK 0x02
 
 
#define SPECIAL '?'
#define KEY_RELEASE 0x80
 
86,6 → 88,7
 
#define ACTIVE_READ_BUFF_SIZE 16 /*Must be power of 2*/
 
 
__u8 active_read_buff[ACTIVE_READ_BUFF_SIZE]={0};
 
SPINLOCK_INITIALIZE(keylock); /**< keylock protects keyflags and lockflags. */
268,13 → 271,9
void i8042_init(void)
{
exc_register(VECTOR_KBD, "i8042_interrupt", i8042_interrupt);
while (inb(i8042_STATUS)&i8042_WAIT_MASK) {
/* wait */
}
while (inb(i8042_STATUS)&i8042_WAIT_MASK); /*Wait*/
outb(i8042_STATUS,i8042_SET_COMMAND);
while (inb(i8042_STATUS)&i8042_WAIT_MASK) {
/* wait */
}
while (inb(i8042_STATUS)&i8042_WAIT_MASK); /*Wait*/
outb(i8042_DATA,i8042_COMMAND);
 
trap_virtual_enable_irqs(1<<IRQ_KBD);
406,6 → 405,7
{
}
 
 
static __u8 active_read_buff_read(void)
{
static int i=0;
427,7 → 427,7
}
 
 
static void active_read_key_pressed(__u8 sc)
static void active_readed_key_pressed(__u8 sc)
{
char *map = sc_primary_map;
char ascii = sc_primary_map[sc];
496,9 → 496,11
 
}
 
 
static char key_read(chardev_t *d)
{
char ch;
 
while(!(ch=active_read_buff_read()))
{
508,7 → 510,9
if (x & KEY_RELEASE)
key_released(x ^ KEY_RELEASE);
else
active_read_key_pressed(x);
active_readed_key_pressed(x);
}
return ch;
}