Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4200 → Rev 4201

/branches/dd/kernel/generic/src/console/console.c
41,19 → 41,21
#include <arch/types.h>
#include <ddi/irq.h>
#include <ddi/ddi.h>
#include <event/event.h>
#include <ipc/irq.h>
#include <arch.h>
#include <func.h>
#include <print.h>
#include <putchar.h>
#include <atomic.h>
#include <syscall/copy.h>
#include <errno.h>
 
#define KLOG_SIZE PAGE_SIZE
#define KLOG_LATENCY 8
#define KLOG_SIZE PAGE_SIZE
#define KLOG_LATENCY 8
 
/** Kernel log cyclic buffer */
static char klog[KLOG_SIZE] __attribute__ ((aligned (PAGE_SIZE)));
static wchar_t klog[KLOG_SIZE] __attribute__ ((aligned (PAGE_SIZE)));
 
/** Kernel log initialized */
static bool klog_inited = false;
94,18 → 96,12
ASSERT(KLOG_SIZE % FRAME_SIZE == 0);
klog_parea.pbase = (uintptr_t) faddr;
klog_parea.frames = SIZE2FRAMES(KLOG_SIZE);
klog_parea.frames = SIZE2FRAMES(sizeof(klog));
ddi_parea_register(&klog_parea);
sysinfo_set_item_val("klog.faddr", NULL, (unative_t) faddr);
sysinfo_set_item_val("klog.pages", NULL, SIZE2FRAMES(KLOG_SIZE));
sysinfo_set_item_val("klog.pages", NULL, SIZE2FRAMES(sizeof(klog)));
//irq_initialize(&klog_irq);
//klog_irq.devno = devno;
//klog_irq.inr = KLOG_VIRT_INR;
//klog_irq.claim = klog_claim;
//irq_register(&klog_irq);
spinlock_lock(&klog_lock);
klog_inited = true;
spinlock_unlock(&klog_lock);
242,15 → 238,15
{
spinlock_lock(&klog_lock);
// if ((klog_inited) && (klog_irq.notif_cfg.notify) && (klog_uspace > 0)) {
// ipc_irq_send_msg_3(&klog_irq, klog_start, klog_len, klog_uspace);
// klog_uspace = 0;
// }
if ((klog_inited) && (event_is_subscribed(EVENT_KLOG)) && (klog_uspace > 0)) {
event_notify_3(EVENT_KLOG, klog_start, klog_len, klog_uspace);
klog_uspace = 0;
}
spinlock_unlock(&klog_lock);
}
 
void putchar(char c)
void putchar(const wchar_t ch)
{
spinlock_lock(&klog_lock);
263,7 → 259,7
}
/* Store character in the cyclic kernel log */
klog[(klog_start + klog_len) % KLOG_SIZE] = c;
klog[(klog_start + klog_len) % KLOG_SIZE] = ch;
if (klog_len < KLOG_SIZE)
klog_len++;
else
270,7 → 266,7
klog_start = (klog_start + 1) % KLOG_SIZE;
if ((stdout) && (stdout->op->write))
stdout->op->write(stdout, c, silent);
stdout->op->write(stdout, ch, silent);
else {
/* The character is just in the kernel log */
if (klog_stored < klog_len)
283,7 → 279,7
/* Check notify uspace to update */
bool update;
if ((klog_uspace > KLOG_LATENCY) || (c == '\n'))
if ((klog_uspace > KLOG_LATENCY) || (ch == '\n'))
update = true;
else
update = false;
299,11 → 295,11
* Print to kernel log.
*
*/
unative_t sys_klog(int fd, const void * buf, size_t count)
unative_t sys_klog(int fd, const void * buf, size_t count)
{
char *data;
int rc;
 
if (count > PAGE_SIZE)
return ELIMIT;
/branches/dd/kernel/generic/src/console/cmd.c
64,6 → 64,7
#include <proc/task.h>
#include <ipc/ipc.h>
#include <ipc/irq.h>
#include <event/event.h>
#include <symtab.h>
#include <errno.h>
 
954,8 → 955,7
printf("The kernel will now relinquish the console.\n");
release_console();
if ((kconsole_notify) && (kconsole_irq.notif_cfg.notify))
ipc_irq_send_msg_0(&kconsole_irq);
event_notify_0(EVENT_KCONSOLE);
return 1;
}
/branches/dd/kernel/generic/src/console/chardev.c
33,7 → 33,6
*/
 
#include <console/chardev.h>
#include <putchar.h>
#include <synch/waitq.h>
#include <synch/spinlock.h>
 
/branches/dd/kernel/generic/src/console/kconsole.c
55,6 → 55,7
#include <ddi/device.h>
#include <symtab.h>
#include <errno.h>
#include <putchar.h>
 
/** Simple kernel console.
*
87,30 → 88,6
index_t *end);
static char history[KCONSOLE_HISTORY][MAX_CMDLINE] = {};
 
/*
* For now, we use 0 as INR.
* However, it is therefore desirable to have architecture specific
* definition of KCONSOLE_VIRT_INR in the future.
*/
#define KCONSOLE_VIRT_INR 0
 
bool kconsole_notify = false;
irq_t kconsole_irq;
 
 
/** Allways refuse IRQ ownership.
*
* This is not a real IRQ, so we always decline.
*
* @return Always returns IRQ_DECLINE.
*
*/
static irq_ownership_t kconsole_claim(irq_t *irq)
{
return IRQ_DECLINE;
}
 
 
/** Initialize kconsole data structures
*
* This is the most basic initialization, almost no
126,27 → 103,6
history[i][0] = '\0';
}
 
 
/** Initialize kconsole notification mechanism
*
* Initialize the virtual IRQ notification mechanism.
*
*/
void kconsole_notify_init(void)
{
sysinfo_set_item_val("kconsole.present", NULL, true);
sysinfo_set_item_val("kconsole.inr", NULL, KCONSOLE_VIRT_INR);
irq_initialize(&kconsole_irq);
kconsole_irq.devno = device_assign_devno();
kconsole_irq.inr = KCONSOLE_VIRT_INR;
kconsole_irq.claim = kconsole_claim;
irq_register(&kconsole_irq);
kconsole_notify = true;
}
 
 
/** Register kconsole command.
*
* @param cmd Structure describing the command.
204,9 → 160,9
}
 
/** Print count times a character */
static void rdln_print_c(char ch, int count)
static void rdln_print_c(wchar_t ch, count_t count)
{
int i;
count_t i;
for (i = 0; i < count; i++)
putchar(ch);
}