#include <lunaix/fs/twimap.h>
#include <lunaix/syscall.h>
#include <lunaix/syslog.h>
+#include <lunaix/device.h>
+#include <lunaix/owloysius.h>
-#include <lunaix/lxconsole.h>
+#include <hal/term.h>
#include <klibc/strfmt.h>
.max_recs = MAX_KPENT_NUM,
.kp_ent_wp = &kprecs.kp_ents.ents
};
+export_symbol(debug, kprecs);
static char*
shift_level(const char* str, int* level)
kprintf_ml(const char* component, int level, const char* fmt, va_list args)
{
char* buf = &tmp_buf[MAX_BUFSZ_HLF];
- ksnprintf(buf, MAX_BUFSZ_HLF, "%s: %s", component, fmt);
+ ksnprintf(buf, MAX_BUFSZ_HLF, "%s: %s\n", component, fmt);
size_t sz = ksnprintfv(tmp_buf, buf, MAX_BUFSZ_HLF, args);
kprec_put(&kprecs, level, tmp_buf, sz);
- // FIXME temp measure, get some output
- console_write_str(tmp_buf);
- console_write_char('\n');
+ if (likely(sysconsole)) {
+ sysconsole->ops.write(sysconsole, tmp_buf, 0, sz);
+ }
}
void
static void
__twimap_kprintf_read(struct twimap* map)
{
- struct kp_records* kprecs = twimap_data(map, struct kp_records*);
+ struct kp_records* __kprecs = twimap_data(map, struct kp_records*);
/*
XXX we can foreach all records in a single twimap read call,
as records is monotonic increasing by design.
*/
struct kp_entry *pos, *n;
- llist_for_each(pos, n, kprecs->kp_ent_wp, ents)
+ llist_for_each(pos, n, __kprecs->kp_ent_wp, ents)
{
time_t s = pos->time / 1000;
time_t ms = pos->time % 1000;
}
EXPORT_TWIFS_PLUGIN(kprintf, kprintf_mapping_init);
+
+static void kprintf_init() {
+ if (unlikely(!sysconsole)) {
+ return;
+ }
+
+ struct kp_entry *pos, *n;
+ llist_for_each(pos, n, kprecs.kp_ent_wp, ents)
+ {
+ sysconsole->ops.write(sysconsole, pos->content, 0, pos->len);
+ }
+}
+lunaix_initfn(kprintf_init, call_on_postboot);
+
__DEFINE_LXSYSCALL3(void, syslog, int, level, const char*, fmt, va_list, args)
{
kprintf_ml("syslog", level, fmt, args);