Basic log level support
This commit is contained in:
parent
44195fd034
commit
4b6006bd9a
@ -158,15 +158,17 @@ trap_entry(TrapFrame *tf)
|
||||
return;
|
||||
case T_DB:
|
||||
case T_BP:
|
||||
case T_UD:
|
||||
case T_UD: {
|
||||
kprintf("Userlevel breakpoint\n");
|
||||
Debug_Breakpoint(tf);
|
||||
return;
|
||||
case T_SYSCALL:
|
||||
kprintf("Syscall %016llx\n", tf->rdi);
|
||||
}
|
||||
case T_SYSCALL: {
|
||||
VLOG(syscall, "Syscall %016llx\n", tf->rdi);
|
||||
tf->rax = Syscall_Entry(tf->rdi, tf->rsi, tf->rdx, tf->rcx, tf->r8, tf->r9);
|
||||
kprintf("Return %016llx\n", tf->rax);
|
||||
VLOG(syscall, "Return %016llx\n", tf->rax);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// IRQs
|
||||
|
@ -44,26 +44,26 @@ O2FS_Mount(Disk *disk)
|
||||
|
||||
status = DiskCache_Read(disk, 0, &entry);
|
||||
if (status < 0) {
|
||||
kprintf("O2FS: Disk cache read failed\n");
|
||||
Alert(o2fs, "O2FS: Disk cache read failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Read superblock
|
||||
sb = entry->buffer;
|
||||
if (memcmp(sb->magic, SUPERBLOCK_MAGIC, 8) != 0) {
|
||||
kprintf("O2FS: Invalid file system\n");
|
||||
Alert(o2fs, "O2FS: Invalid file system\n");
|
||||
DiskCache_Release(entry);
|
||||
return NULL;
|
||||
}
|
||||
if (sb->versionMajor != O2FS_VERSION_MAJOR ||
|
||||
sb->versionMinor != O2FS_VERSION_MINOR) {
|
||||
kprintf("O2FS: Unsupported file system version\n");
|
||||
Alert(o2fs, "O2FS: Unsupported file system version\n");
|
||||
DiskCache_Release(entry);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
kprintf("O2FS: File system mounted\n");
|
||||
kprintf("O2FS: Root @ 0x%llx\n", sb->root.offset);
|
||||
Log(o2fs, "O2FS: File system mounted\n");
|
||||
Log(o2fs, "O2FS: Root @ 0x%llx\n", sb->root.offset);
|
||||
|
||||
fs->fsptr = entry;
|
||||
fs->fsval = sb->root.offset;
|
||||
@ -77,7 +77,7 @@ O2FS_Mount(Disk *disk)
|
||||
|
||||
status = O2FS_GetRoot(fs, &fs->root);
|
||||
if (status < 0) {
|
||||
kprintf("O2FS: Mount failed");
|
||||
Alert(o2fs, "O2FS: Mount failed");
|
||||
DiskCache_Release(entry);
|
||||
return NULL;
|
||||
}
|
||||
@ -102,19 +102,19 @@ O2FSLoadVNode(VFS *fs, ObjID *objid)
|
||||
|
||||
status = DiskCache_Read(fs->disk, objid->offset, &entry);
|
||||
if (status < 0) {
|
||||
kprintf("O2FS: disk read error\n");
|
||||
Alert(o2fs, "O2FS: disk read error\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bn = entry->buffer;
|
||||
if (memcmp(&bn->magic, BNODE_MAGIC, 8) != 0) {
|
||||
kprintf("O2FS: bad BNode magic\n");
|
||||
Alert(o2fs, "O2FS: bad BNode magic\n");
|
||||
DiskCache_Release(entry);
|
||||
return NULL;
|
||||
}
|
||||
if (bn->versionMajor != O2FS_VERSION_MAJOR ||
|
||||
bn->versionMinor != O2FS_VERSION_MINOR) {
|
||||
kprintf("O2FS: unsupported BNode version\n");
|
||||
Alert(o2fs, "O2FS: unsupported BNode version\n");
|
||||
DiskCache_Release(entry);
|
||||
return NULL;
|
||||
}
|
||||
@ -167,19 +167,19 @@ O2FS_GetRoot(VFS *fs, VNode **dn)
|
||||
|
||||
status = DiskCache_Read(fs->disk, fs->fsval, &entry);
|
||||
if (status < 0) {
|
||||
kprintf("O2FS: disk read error\n");
|
||||
Alert(o2fs, "O2FS: disk read error\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
bn = entry->buffer;
|
||||
if (memcmp(&bn->magic, BNODE_MAGIC, 8) != 0) {
|
||||
kprintf("O2FS: bad BNode magic\n");
|
||||
Alert(o2fs, "O2FS: bad BNode magic\n");
|
||||
DiskCache_Release(entry);
|
||||
return -1;
|
||||
}
|
||||
if (bn->versionMajor != O2FS_VERSION_MAJOR ||
|
||||
bn->versionMinor != O2FS_VERSION_MINOR) {
|
||||
kprintf("O2FS: unsupported BNode version\n");
|
||||
Alert(o2fs, "O2FS: unsupported BNode version\n");
|
||||
DiskCache_Release(entry);
|
||||
return -1;
|
||||
}
|
||||
@ -200,7 +200,7 @@ O2FS_GetRoot(VFS *fs, VNode **dn)
|
||||
void
|
||||
O2FSDumpDirEntry(BDirEntry *entry)
|
||||
{
|
||||
kprintf("%16s %08llx %08llx\n", entry->name, entry->objId.offset, entry->size);
|
||||
VLOG(o2fs, "%16s %08llx %08llx\n", entry->name, entry->objId.offset, entry->size);
|
||||
}
|
||||
|
||||
int
|
||||
@ -215,7 +215,7 @@ O2FS_Lookup(VNode *dn, VNode **fn, const char *name)
|
||||
uint64_t blocks = (dirBN->size + sb->blockSize - 1) / sb->blockSize;
|
||||
uint64_t b;
|
||||
|
||||
kprintf("O2FS: LOOKUP %lld %d\n", dirBN->size, blocks);
|
||||
VLOG(o2fs, "O2FS: LOOKUP %lld %d\n", dirBN->size, blocks);
|
||||
|
||||
for (b = 0; b < blocks; b++) {
|
||||
// Read block
|
||||
@ -269,7 +269,7 @@ O2FS_Read(VNode *fn, void *buf, uint64_t off, uint64_t len)
|
||||
uint64_t blocks = (fileBN->size + sb->blockSize - 1) / sb->blockSize;
|
||||
uint64_t readBytes = 0;
|
||||
|
||||
kprintf("O2FS: READ %lld %d\n", fileBN->size, blocks);
|
||||
VLOG(o2fs, "O2FS: READ %lld %d\n", fileBN->size, blocks);
|
||||
|
||||
if (off > fileBN->size) {
|
||||
return 0;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define __KASSERT_H__
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#define ASSERT(_x) \
|
||||
if (!(_x)) { \
|
||||
@ -23,5 +24,22 @@ void Debug_Assert(const char *fmt, ...);
|
||||
|
||||
#define static_assert _Static_assert
|
||||
|
||||
// Alert
|
||||
#define Alert(_module, _format, ...) kprintf(_format, ##__VA_ARGS__)
|
||||
// Warning
|
||||
#define Warning(_module, _format, ...) kprintf(_format, ##__VA_ARGS__)
|
||||
// Normal Logging
|
||||
#define Log(_module, _format, ...) kprintf(_format, ##__VA_ARGS__)
|
||||
// Debug Logging
|
||||
#define DLOG(_module, _format, ...) \
|
||||
if (SYSCTL_GETINT(log_##_module) >= 5) { \
|
||||
kprintf(_format, ##__VA_ARGS__); \
|
||||
}
|
||||
// Verbose Logging
|
||||
#define VLOG(_module, _format, ...) \
|
||||
if (SYSCTL_GETINT(log_##_module) >= 10) { \
|
||||
kprintf(_format, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#endif /* __KASSERT_H__ */
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
#ifndef __SYS_SYSCTL_H__
|
||||
#define __SYS_SYSCTL_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/*
|
||||
* System Control Macros
|
||||
* SYSCTL_STR(PATH, FLAGS, DESCRIPTION, DEFAULT)
|
||||
@ -16,7 +18,10 @@
|
||||
#define SYSCTL_LIST \
|
||||
SYSCTL_STR(kern_ostype, SYSCTL_FLAG_RO, "OS Type", "Castor") \
|
||||
SYSCTL_INT(kern_hz, SYSCTL_FLAG_RW, "Tick frequency", 100) \
|
||||
SYSCTL_INT(time_tzadj, SYSCTL_FLAG_RW, "time zone offset in seconds", 0) \
|
||||
SYSCTL_INT(time_tzadj, SYSCTL_FLAG_RW, "Time zone offset in seconds", 0) \
|
||||
SYSCTL_INT(log_syscall, SYSCTL_FLAG_RW, "Syscall log level", 0) \
|
||||
SYSCTL_INT(log_loader, SYSCTL_FLAG_RW, "Loader log level", 0) \
|
||||
SYSCTL_INT(log_o2fs, SYSCTL_FLAG_RW, "O2FS log level", 0)
|
||||
|
||||
#define SYSCTL_STR_MAXLENGTH 128
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/kassert.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/disk.h>
|
||||
|
@ -49,7 +49,7 @@ Syscall_Spawn(uint64_t user_path)
|
||||
if (status != 0)
|
||||
return status;
|
||||
|
||||
kprintf("Spawn(%s)\n", path);
|
||||
Log(syscall, "Spawn(%s)\n", path);
|
||||
|
||||
pg = PAlloc_AllocPage();
|
||||
if (!pg) {
|
||||
@ -64,20 +64,20 @@ Syscall_Spawn(uint64_t user_path)
|
||||
|
||||
status = VFS_Open(file);
|
||||
if (status < 0) {
|
||||
kprintf("Error VFS_Open\n");
|
||||
Log(syscall, "Error VFS_Open\n");
|
||||
// Release & free
|
||||
return status;
|
||||
}
|
||||
|
||||
status = VFS_Read(file, pg, 0, 1024);
|
||||
if (status < 0) {
|
||||
kprintf("Error VFS_Read\n");
|
||||
Log(syscall, "Error VFS_Read\n");
|
||||
// Release & free
|
||||
return status;
|
||||
}
|
||||
|
||||
thr = Thread_Create();
|
||||
kprintf("SPAWN %lx\n", thr);
|
||||
Log(syscall, "SPAWN %lx\n", thr);
|
||||
|
||||
Handle *handle = Console_OpenHandle();
|
||||
Handle_Add(thr, handle);
|
||||
|
Loading…
Reference in New Issue
Block a user