mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
Kernel: due to performance and real hardware testing reasons, put syscall logging and e9 behind compile time options
This commit is contained in:
+2
-1
@@ -10,7 +10,8 @@ LDFLAGS=-ffreestanding -nostdlib -lgcc -Wl,-T,"$(ARCHDIR)/kernel.ld" -g
|
||||
PRINTFOPTS=-DPRINTF_DISABLE_SUPPORT_FLOAT
|
||||
# flanterm includes break if the headers are moved into the include dir in the tree
|
||||
FLANTERMINCDIR=$(shell pwd)/flanterm
|
||||
CFLAGS=-g -ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mgeneral-regs-only -mno-mmx -mno-sse -mno-sse2 -nostdlib -Wall -I "${INCDIR}" -I "$(ARCHINCDIR)" -I "$(FLANTERMINCDIR)" $(PRINTFOPTS)
|
||||
KERNELCONFIG=#-DX86_64_ENABLE_E9 -DSYSCALL_LOGGING
|
||||
CFLAGS=-g -ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mgeneral-regs-only -mno-mmx -mno-sse -mno-sse2 -nostdlib -Wall -I "${INCDIR}" -I "$(ARCHINCDIR)" -I "$(FLANTERMINCDIR)" $(PRINTFOPTS) $(KERNELCONFIG)
|
||||
ASFLAGS=-felf64
|
||||
|
||||
astral: $(OBJS)
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
// TODO compile time options for disabling output to port e9h
|
||||
|
||||
void arch_e9_putc(char c) {
|
||||
#ifdef X86_64_ENABLE_E9
|
||||
outb(0xe9, c);
|
||||
#endif
|
||||
}
|
||||
|
||||
void arch_e9_puts(char *c) {
|
||||
#ifdef X86_64_ENABLE_E9
|
||||
while (*c) {
|
||||
outb(0xe9, *c++);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <arch/e9.h>
|
||||
#include <arch/cpu.h>
|
||||
|
||||
#ifdef SYSCALL_LOGGING
|
||||
|
||||
#define SYSCALL_COUNT 25
|
||||
#define LOGSTR(x) arch_e9_puts(x)
|
||||
|
||||
@@ -63,7 +65,10 @@ static char *args[] = {
|
||||
"dirfd %d pathname %d flags %d" // unlinkat
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
__attribute__((no_caller_saved_registers)) void arch_syscall_log(int syscall, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6) {
|
||||
#ifdef SYSCALL_LOGGING
|
||||
char argbuff[768];
|
||||
char printbuff[1024];
|
||||
|
||||
@@ -74,9 +79,11 @@ __attribute__((no_caller_saved_registers)) void arch_syscall_log(int syscall, ui
|
||||
snprintf(printbuff, 1024, "\e[92msyscall: pid %d tid %d: %s: %s\n\e[0m", proc->pid, thread->tid, syscall < SYSCALL_COUNT ? name[syscall] : "invalid syscall", argbuff);
|
||||
|
||||
LOGSTR(printbuff);
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((no_caller_saved_registers)) void arch_syscall_log_return(uint64_t ret, uint64_t errno) {
|
||||
#ifdef SYSCALL_LOGGING
|
||||
char printbuff[1024];
|
||||
|
||||
thread_t *thread = _cpu()->thread;
|
||||
@@ -84,4 +91,5 @@ __attribute__((no_caller_saved_registers)) void arch_syscall_log_return(uint64_t
|
||||
|
||||
snprintf(printbuff, 1024, "\e[94msyscall return: pid %d tid %d: %lu %lu\n\e[0m", proc->pid, thread->tid, ret, errno);
|
||||
LOGSTR(printbuff);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user