Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 606 → Rev 607

/kernel/trunk/generic/include/console/chardev.h
41,6 → 41,8
void (* suspend)(chardev_t *); /**< Suspend pushing characters. */
void (* resume)(chardev_t *); /**< Resume pushing characters. */
void (* write)(chardev_t *, char c); /**< Write character to stream. */
/** Read character directly from device, assume interrupts disabled */
char (* read)(chardev_t *);
};
 
typedef struct chardev_operations chardev_operations_t;
/kernel/trunk/generic/src/console/console.c
34,6 → 34,8
#include <arch/types.h>
#include <typedefs.h>
#include <arch.h>
#include <func.h>
#include <print.h>
 
/** Standard input character device. */
chardev_t *stdin = NULL;
50,6 → 52,18
__u8 ch;
ipl_t ipl;
 
if (haltstate) {
/* If we are here, we are hopefully on the processor, that
* issued the 'halt' command, so proceed to read the character
* directly from input
*/
if (chardev->op->read)
return chardev->op->read(chardev);
/* no other way of interacting with user, halt */
printf("cpu: halted - no kconsole\n");
cpu_halt();
}
 
waitq_sleep(&chardev->wq);
ipl = interrupts_disable();
spinlock_lock(&chardev->lock);
114,5 → 128,6
 
void putchar(char c)
{
stdout->op->write(stdout, c);
if (stdout->op->write)
stdout->op->write(stdout, c);
}
/kernel/trunk/generic/src/console/kconsole.c
247,7 → 247,7
if (c == '\n') {
putchar(c);
break;
} if (c == '\b') {
} if (c == '\b') { /* Backspace */
if (position == 0)
continue;
for (i=position; i<curlen;i++)
261,7 → 261,7
rdln_print_c('\b',curlen-position+1);
continue;
}
if (c == '\t') {
if (c == '\t') { /* Tabulator */
int found;
 
/* Move to the end of the word */
309,7 → 309,7
rdln_print_c('\b', curlen-position);
continue;
}
if (c == 0x1b) {
if (c == 0x1b) { /* Special command */
mod = _getc(input);
c = _getc(input);
 
317,6 → 317,7
continue;
 
if (c == 0x33 && _getc(input) == 0x7e) {
/* Delete */
if (position == curlen)
continue;
for (i=position+1; i<curlen;i++) {
331,7 → 332,7
rdln_print_c('\b',position);
position = 0;
}
else if (c == 0x46) {
else if (c == 0x46) { /* End */
for (i=position;i<curlen;i++)
putchar(current[i]);
position = curlen;
355,7 → 356,7
rdln_print_c('\b',position);
rdln_print_c(' ',curlen);
rdln_print_c('\b',curlen);
if (c == 0x41)
if (c == 0x41) /* Up */
histposition--;
else
histposition++;
/kernel/trunk/generic/src/lib/func.c
32,6 → 32,7
#include <arch/asm.h>
#include <arch.h>
#include <typedefs.h>
#include <console/kconsole.h>
 
__u32 haltstate = 0; /**< Halt flag */
 
45,6 → 46,11
{
haltstate = 1;
interrupts_disable();
#ifdef CONFIG_DEBUG
printf("\n");
kconsole(NULL); /* Run kconsole as a last resort to user */
#endif
 
if (CPU)
printf("cpu%d: halted\n", CPU->id);
else
/kernel/trunk/arch/mips32/src/panic.S
38,6 → 38,11
 
/* From printf return directly to halt() */
panic_printf:
lui $ra, %hi(halt)
jal printf
nop
j halt
nop
/* This code does not work, god knows why */
/* lui $ra, %hi(halt)
j printf
ori $ra, %lo(halt)
ori $ra, %lo(halt) */
/kernel/trunk/arch/mips32/src/drivers/serial.c
71,12 → 71,22
return i;
}
 
static chardev_operations_t serial_ops = {
.resume = serial_enable,
.suspend = serial_disable,
.write = serial_write
};
/** Read character from serial port, wait until available */
static char serial_do_read(chardev_t *dev)
{
serial_t *sd = (serial_t *)dev->data;
char ch;
 
while (!(SERIAL_READ_LSR(sd->port) & 1))
;
ch = SERIAL_READ(sd->port);
 
if (ch =='\r')
ch = '\n';
return ch;
}
 
 
/** Process keyboard interrupt. Does not work in simics? */
static void serial_interrupt(int n, void *stack)
{
93,6 → 103,14
}
 
 
 
static chardev_operations_t serial_ops = {
.resume = serial_enable,
.suspend = serial_disable,
.write = serial_write,
.read = serial_do_read
};
 
iroutine old_timer;
/** Do polling on timer interrupt */
static void timer_replace(int n, void *stack)
/kernel/trunk/arch/mips32/src/drivers/msim.c
37,11 → 37,13
static void msim_write(chardev_t *dev, const char ch);
static void msim_enable(chardev_t *dev);
static void msim_disable(chardev_t *dev);
static char msim_do_read(chardev_t *dev);
 
static chardev_operations_t msim_ops = {
.resume = msim_enable,
.suspend = msim_disable,
.write = msim_write
.write = msim_write,
.read = msim_do_read,
};
 
/** Putchar that works with MSIM & gxemul */
63,10 → 65,27
}
 
#include <print.h>
/** Read character using polling, assume interrupts disabled */
static char msim_do_read(chardev_t *dev)
{
char ch;
 
while (1) {
ch = *((volatile char *) MSIM_KBD_ADDRESS);
if (ch) {
if (ch == '\r')
return '\n';
if (ch == 0x7f)
return '\b';
return ch;
}
}
}
 
/** Process keyboard interrupt. */
static void msim_interrupt(int n, void *stack)
{
char ch;
char ch = 0;
 
ch = *((char *) MSIM_KBD_ADDRESS);
if (ch =='\r')