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; |
|