Feat: kernel thread done

This commit is contained in:
2025-04-27 11:04:28 +08:00
parent 02b2a87fed
commit 981cae803b
14 changed files with 303 additions and 122 deletions

View File

@@ -19,6 +19,8 @@ static inline char *_logger_string(char *dest, const char *src)
}
static inline char *_logger_hex(char *dest, uint64_t x)
{
*dest++ = '0';
*dest++ = 'x';
for (int n, c = 60; c >= 0; c -= 4) {
n = (x >> c) & 0xf;
n += (n > 9) ? 0x37 : 0x30;
@@ -27,10 +29,27 @@ static inline char *_logger_hex(char *dest, uint64_t x)
*dest = '\0';
return dest;
}
static inline char *_logger_int(char *dest, int x)
{
char arr[12], *c = &arr[11];
arr[11] = '\0';
if (x < 0)
*dest++ = '-', x = -x;
if (x == 0)
*dest++ = '0';
while (x > 0)
*--c = x % 10 + '0', x /= 10;
for (int i = 0; c[i] != '\0'; ++i)
*dest++ = c[i];
*dest = '\0';
return dest;
}
static inline char *_logger_pointer(char *dest, void *x)
{
*dest++ = '0';
*dest++ = 'x';
*dest++ = '*';
return _logger_hex(dest, (uint64_t)x);
}
@@ -51,6 +70,7 @@ logger_cur = _Generic((msg), \
char * : _logger_string, \
const char *: _logger_string, \
uint64_t : _logger_hex, \
int32_t : _logger_int, \
default : _logger_pointer \
)(logger_cur, msg)
@@ -101,8 +121,8 @@ logger_cur = _Generic((msg), \
// #define DEBUG_DTB(val) DEBUG(val)
#define DEBUG_DTB(val) CLEAN
#define DEBUG_EXCEP(val) DEBUG(val)
// #define DEBUG_EXCEP(val) CLEAN
// #define DEBUG_EXCEP(val) DEBUG(val)
#define DEBUG_EXCEP(val) CLEAN
// #define DEBUG_MEM(val) DEBUG(val)
#define DEBUG_MEM(val) CLEAN
@@ -110,5 +130,7 @@ logger_cur = _Generic((msg), \
// #define DEBUG_INITRD(val) DEBUG(val)
#define DEBUG_INITRD(val) CLEAN
#define DEBUG_THREAD(val) DEBUG(val)
extern char logger_buf[LOGGER_BUFLEN];
extern char *logger_cur;

View File

@@ -1,7 +1,9 @@
#pragma once
#define bool _Bool
#define true 0x1
#define false 0x0
#define __bool_true_false_are_defined 0x1
#define ENDL "\r\n"

View File

@@ -8,4 +8,5 @@ size_t strlen(const char *str);
char *strtok_r(char *str, const char *delimiters, char **saveptr);
void *memcpy(void *dest, const void *src, size_t count);
void *memset(void *dest, int ch, size_t count);
void *memzero(void *start, void *end);