1
0
Fork 0

feat/kernel: Added IDT

This commit is contained in:
Kevin Alavik 2025-05-14 14:23:13 +02:00
parent 248879c099
commit af7599a266
Signed by: cmpsb
GPG key ID: 10D1CC0526FDC6D7
15 changed files with 412 additions and 19 deletions

View file

@ -1,3 +1,4 @@
/* EMK 1.0 Copyright (c) 2025 Piraterna */
#include <dev/serial.h>
#include <util/kprintf.h>
@ -24,5 +25,26 @@ int kprintf(const char *fmt, ...)
}
va_end(args);
return length;
}
int snprintf(char *buf, size_t size, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
int length = vsnprintf(buf, size, fmt, args);
va_end(args);
return length;
}
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
int length = npf_vsnprintf(buf, size, fmt, args);
if (length >= (int)size)
{
buf[size - 1] = '\0';
}
return length;
}

View file

@ -1,7 +1,15 @@
/* EMK 1.0 Copyright (c) 2025 Piraterna */
#ifndef KPRINTF_H
#define KPRINTF_H
#include <stddef.h>
#include <stdarg.h>
/* Minimal kprintf using nanoprintf, see external/nanoprintf.h */
int kprintf(const char *fmt, ...);
/* Careful with these */
int snprintf(char *buf, size_t size, const char *fmt, ...);
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
#endif // KPRINTF_H

View file

@ -1,8 +1,10 @@
/* EMK 1.0 Copyright (c) 2025 Piraterna */
#ifndef LOG_H
#define LOG_H
#include <util/kprintf.h>
#define early(fmt, ...) kprintf("early: " fmt "\n", ##__VA_ARGS__)
#define log_early(fmt, ...) kprintf("early: " fmt "\n", ##__VA_ARGS__)
#define log_panic(fmt, ...) kprintf("panic: " fmt "\n", ##__VA_ARGS__)
#endif // LOG_H