Mass reformat

This commit is contained in:
Imbus 2025-09-01 22:43:50 +02:00
parent 3450ab2cb8
commit f1fd7de79f
10 changed files with 317 additions and 297 deletions

View file

@ -1,10 +1,10 @@
#include <spinlock.h>
#include <kalloc.h>
#include <memory.h>
#include <panic.h>
#include <riscv.h>
#include <string.h>
#include <spinlock.h>
#include <stdint.h>
#include <string.h>
// Physical memory allocator, for user processes,
// kernel stacks, page-table pages,

View file

@ -52,24 +52,12 @@ int kvsnprintf(char *buf, size_t size, const char *fmt, va_list args) {
fmt++; // skip '%'
switch (*fmt) {
case 's':
append_str(&p, &remaining, va_arg(args, const char *));
break;
case 'd':
append_int(&p, &remaining, va_arg(args, int), 10);
break;
case 'x':
append_int(&p, &remaining, va_arg(args, unsigned int), 16);
break;
case 'c':
append_char(&p, &remaining, (char)va_arg(args, int));
break;
case '%':
append_char(&p, &remaining, '%');
break;
default:
append_char(&p, &remaining, '?');
break;
case 's': append_str(&p, &remaining, va_arg(args, const char *)); break;
case 'd': append_int(&p, &remaining, va_arg(args, int), 10); break;
case 'x': append_int(&p, &remaining, va_arg(args, unsigned int), 16); break;
case 'c': append_char(&p, &remaining, (char)va_arg(args, int)); break;
case '%': append_char(&p, &remaining, '%'); break;
default: append_char(&p, &remaining, '?'); break;
}
fmt++;
}

View file

@ -4,88 +4,133 @@
#include <types.h>
/** Swap byte order of 16-bit value */
static inline u16 swap16(u16 x) { return (x >> 8) | (x << 8); }
static inline u16 swap16(u16 x) {
return (x >> 8) | (x << 8);
}
/** Swap byte order of 32-bit value */
static inline u32 swap32(u32 x) {
return ((x >> 24) & 0x000000ff) | ((x >> 8) & 0x0000ff00) |
((x << 8) & 0x00ff0000) | ((x << 24) & 0xff000000);
return ((x >> 24) & 0x000000ff) | ((x >> 8) & 0x0000ff00) | ((x << 8) & 0x00ff0000) | ((x << 24) & 0xff000000);
}
/** Swap byte order of 64-bit value */
static inline u64 swap64(u64 x) {
return ((x >> 56) & 0x00000000000000ffULL) |
((x >> 40) & 0x000000000000ff00ULL) |
((x >> 24) & 0x0000000000ff0000ULL) |
((x >> 8) & 0x00000000ff000000ULL) |
((x << 8) & 0x000000ff00000000ULL) |
((x << 24) & 0x0000ff0000000000ULL) |
((x << 40) & 0x00ff000000000000ULL) |
((x << 56) & 0xff00000000000000ULL);
return ((x >> 56) & 0x00000000000000ffULL) | ((x >> 40) & 0x000000000000ff00ULL) |
((x >> 24) & 0x0000000000ff0000ULL) | ((x >> 8) & 0x00000000ff000000ULL) |
((x << 8) & 0x000000ff00000000ULL) | ((x << 24) & 0x0000ff0000000000ULL) |
((x << 40) & 0x00ff000000000000ULL) | ((x << 56) & 0xff00000000000000ULL);
}
#ifdef __LITTLE_ENDIAN__
/** Convert 16-bit value to little-endian */
static inline u16 to_le16(u16 x) { return x; }
static inline u16 to_le16(u16 x) {
return x;
}
/** Convert 16-bit little-endian value to host */
static inline u16 from_le16(u16 x) { return x; }
static inline u16 from_le16(u16 x) {
return x;
}
/** Convert 32-bit value to little-endian */
static inline u32 to_le32(u32 x) { return x; }
static inline u32 to_le32(u32 x) {
return x;
}
/** Convert 32-bit little-endian value to host */
static inline u32 from_le32(u32 x) { return x; }
static inline u32 from_le32(u32 x) {
return x;
}
/** Convert 64-bit value to little-endian */
static inline u64 to_le64(u64 x) { return x; }
static inline u64 to_le64(u64 x) {
return x;
}
/** Convert 64-bit little-endian value to host */
static inline u64 from_le64(u64 x) { return x; }
static inline u64 from_le64(u64 x) {
return x;
}
/** Convert 16-bit value to big-endian */
static inline u16 to_be16(u16 x) { return swap16(x); }
static inline u16 to_be16(u16 x) {
return swap16(x);
}
/** Convert 16-bit big-endian value to host */
static inline u16 from_be16(u16 x) { return swap16(x); }
static inline u16 from_be16(u16 x) {
return swap16(x);
}
/** Convert 32-bit value to big-endian */
static inline u32 to_be32(u32 x) { return swap32(x); }
static inline u32 to_be32(u32 x) {
return swap32(x);
}
/** Convert 32-bit big-endian value to host */
static inline u32 from_be32(u32 x) { return swap32(x); }
static inline u32 from_be32(u32 x) {
return swap32(x);
}
/** Convert 64-bit value to big-endian */
static inline u64 to_be64(u64 x) { return swap64(x); }
static inline u64 to_be64(u64 x) {
return swap64(x);
}
/** Convert 64-bit big-endian value to host */
static inline u64 from_be64(u64 x) { return swap64(x); }
static inline u64 from_be64(u64 x) {
return swap64(x);
}
#else // Big-endian
/** Convert 16-bit value to little-endian */
static inline u16 to_le16(u16 x) { return swap16(x); }
static inline u16 to_le16(u16 x) {
return swap16(x);
}
/** Convert 16-bit little-endian value to host */
static inline u16 from_le16(u16 x) { return swap16(x); }
static inline u16 from_le16(u16 x) {
return swap16(x);
}
/** Convert 32-bit value to little-endian */
static inline u32 to_le32(u32 x) { return swap32(x); }
static inline u32 to_le32(u32 x) {
return swap32(x);
}
/** Convert 32-bit little-endian value to host */
static inline u32 from_le32(u32 x) { return swap32(x); }
static inline u32 from_le32(u32 x) {
return swap32(x);
}
/** Convert 64-bit value to little-endian */
static inline u64 to_le64(u64 x) { return swap64(x); }
static inline u64 to_le64(u64 x) {
return swap64(x);
}
/** Convert 64-bit little-endian value to host */
static inline u64 from_le64(u64 x) { return swap64(x); }
static inline u64 from_le64(u64 x) {
return swap64(x);
}
/** Convert 16-bit value to big-endian */
static inline u16 to_be16(u16 x) { return x; }
static inline u16 to_be16(u16 x) {
return x;
}
/** Convert 16-bit big-endian value to host */
static inline u16 from_be16(u16 x) { return x; }
static inline u16 from_be16(u16 x) {
return x;
}
/** Convert 32-bit value to big-endian */
static inline u32 to_be32(u32 x) { return x; }
static inline u32 to_be32(u32 x) {
return x;
}
/** Convert 32-bit big-endian value to host */
static inline u32 from_be32(u32 x) { return x; }
static inline u32 from_be32(u32 x) {
return x;
}
/** Convert 64-bit value to big-endian */
static inline u64 to_be64(u64 x) { return x; }
static inline u64 to_be64(u64 x) {
return x;
}
/** Convert 64-bit big-endian value to host */
static inline u64 from_be64(u64 x) { return x; }
static inline u64 from_be64(u64 x) {
return x;
}
#endif // __LITTLE_ENDIAN__

View file

@ -10,8 +10,7 @@ size_t probe_memory(void) {
u32 test_pattern = 0xA5A5A5A5;
size_t detected = 0;
for (size_t offset = 4096 * 16; offset < MAX_PROBE_SIZE;
offset += PROBE_STEP) {
for (size_t offset = 4096 * 16; offset < MAX_PROBE_SIZE; offset += PROBE_STEP) {
addr = (volatile u32 *)(KERNBASE + offset);
u32 old = *addr;

View file

@ -43,269 +43,251 @@
#include "mini-printf.h"
static int
mini_strlen(const char *s)
{
int len = 0;
while (s[len] != '\0') len++;
return len;
static int mini_strlen(const char *s) {
int len = 0;
while (s[len] != '\0') len++;
return len;
}
static int
mini_itoa(long value, unsigned int radix, int uppercase, int unsig,
char *buffer)
{
char *pbuffer = buffer;
int negative = 0;
int i, len;
static int mini_itoa(long value, unsigned int radix, int uppercase, int unsig, char *buffer) {
char *pbuffer = buffer;
int negative = 0;
int i, len;
/* No support for unusual radixes. */
if (radix > 16)
return 0;
/* No support for unusual radixes. */
if (radix > 16)
return 0;
if (value < 0 && !unsig) {
negative = 1;
value = -value;
}
if (value < 0 && !unsig) {
negative = 1;
value = -value;
}
/* This builds the string back to front ... */
do {
int digit = value % radix;
*(pbuffer++) = (digit < 10 ? '0' + digit : (uppercase ? 'A' : 'a') + digit - 10);
value /= radix;
} while (value > 0);
/* This builds the string back to front ... */
do {
int digit = value % radix;
*(pbuffer++) = (digit < 10 ? '0' + digit : (uppercase ? 'A' : 'a') + digit - 10);
value /= radix;
} while (value > 0);
if (negative)
*(pbuffer++) = '-';
if (negative)
*(pbuffer++) = '-';
*(pbuffer) = '\0';
*(pbuffer) = '\0';
/* ... now we reverse it (could do it recursively but will
* conserve the stack space) */
len = (pbuffer - buffer);
for (i = 0; i < len / 2; i++) {
char j = buffer[i];
buffer[i] = buffer[len-i-1];
buffer[len-i-1] = j;
}
/* ... now we reverse it (could do it recursively but will
* conserve the stack space) */
len = (pbuffer - buffer);
for (i = 0; i < len / 2; i++) {
char j = buffer[i];
buffer[i] = buffer[len - i - 1];
buffer[len - i - 1] = j;
}
return len;
return len;
}
static int
mini_pad(char* ptr, int len, char pad_char, int pad_to, char *buffer)
{
int i;
int overflow = 0;
char * pbuffer = buffer;
if(pad_to == 0) pad_to = len;
if(len > pad_to) {
len = pad_to;
overflow = 1;
}
for(i = pad_to - len; i > 0; i --) {
*(pbuffer++) = pad_char;
}
for(i = len; i > 0; i --) {
*(pbuffer++) = *(ptr++);
}
len = pbuffer - buffer;
if(overflow) {
for (i = 0; i < 3 && pbuffer > buffer; i ++) {
*(pbuffer-- - 1) = '*';
}
}
return len;
static int mini_pad(char *ptr, int len, char pad_char, int pad_to, char *buffer) {
int i;
int overflow = 0;
char *pbuffer = buffer;
if (pad_to == 0)
pad_to = len;
if (len > pad_to) {
len = pad_to;
overflow = 1;
}
for (i = pad_to - len; i > 0; i--) {
*(pbuffer++) = pad_char;
}
for (i = len; i > 0; i--) {
*(pbuffer++) = *(ptr++);
}
len = pbuffer - buffer;
if (overflow) {
for (i = 0; i < 3 && pbuffer > buffer; i++) {
*(pbuffer-- - 1) = '*';
}
}
return len;
}
struct mini_buff {
char *buffer, *pbuffer;
unsigned int buffer_len;
char *buffer, *pbuffer;
unsigned int buffer_len;
};
static int
_puts(char *s, int len, void *buf)
{
if(!buf) return len;
struct mini_buff *b = buf;
char * p0 = b->buffer;
int i;
/* Copy to buffer */
for (i = 0; i < len; i++) {
if(b->pbuffer == b->buffer + b->buffer_len - 1) {
break;
}
*(b->pbuffer ++) = s[i];
}
*(b->pbuffer) = 0;
return b->pbuffer - p0;
static int _puts(char *s, int len, void *buf) {
if (!buf)
return len;
struct mini_buff *b = buf;
char *p0 = b->buffer;
int i;
/* Copy to buffer */
for (i = 0; i < len; i++) {
if (b->pbuffer == b->buffer + b->buffer_len - 1) {
break;
}
*(b->pbuffer++) = s[i];
}
*(b->pbuffer) = 0;
return b->pbuffer - p0;
}
#ifdef MINI_PRINTF_ENABLE_OBJECTS
static int (*mini_handler) (void* data, void* obj, int ch, int lhint, char** bf) = 0;
static void (*mini_handler_freeor)(void* data, void*) = 0;
static void * mini_handler_data = 0;
static int (*mini_handler)(void *data, void *obj, int ch, int lhint, char **bf) = 0;
static void (*mini_handler_freeor)(void *data, void *) = 0;
static void *mini_handler_data = 0;
void mini_printf_set_handler(
void* data,
int (*handler)(void* data, void* obj, int ch, int len_hint, char** buf),
void (*freeor)(void* data, void* buf))
{
mini_handler = handler;
mini_handler_freeor = freeor;
mini_handler_data = data;
void mini_printf_set_handler(void *data, int (*handler)(void *data, void *obj, int ch, int len_hint, char **buf),
void (*freeor)(void *data, void *buf)) {
mini_handler = handler;
mini_handler_freeor = freeor;
mini_handler_data = data;
}
#endif
int
mini_vsnprintf(char *buffer, unsigned int buffer_len, const char *fmt, va_list va)
{
struct mini_buff b;
b.buffer = buffer;
b.pbuffer = buffer;
b.buffer_len = buffer_len;
if(buffer_len == 0) buffer = (void*) 0;
int n = mini_vpprintf(_puts, (buffer != (void*)0)?&b:(void*)0, fmt, va);
if(buffer == (void*) 0) {
return n;
}
return b.pbuffer - b.buffer;
int mini_vsnprintf(char *buffer, unsigned int buffer_len, const char *fmt, va_list va) {
struct mini_buff b;
b.buffer = buffer;
b.pbuffer = buffer;
b.buffer_len = buffer_len;
if (buffer_len == 0)
buffer = (void *)0;
int n = mini_vpprintf(_puts, (buffer != (void *)0) ? &b : (void *)0, fmt, va);
if (buffer == (void *)0) {
return n;
}
return b.pbuffer - b.buffer;
}
int
mini_vpprintf(int (*puts)(char* s, int len, void* buf), void* buf, const char *fmt, va_list va)
{
char bf[24];
char bf2[24];
char ch;
int mini_vpprintf(int (*puts)(char *s, int len, void *buf), void *buf, const char *fmt, va_list va) {
char bf[24];
char bf2[24];
char ch;
#ifdef MINI_PRINTF_ENABLE_OBJECTS
void* obj;
void *obj;
#endif
if(puts == (void*)0) {
/* run puts in counting mode. */
puts = _puts; buf = (void*)0;
}
int n = 0;
while ((ch=*(fmt++))) {
int len;
if (ch!='%') {
len = 1;
len = puts(&ch, len, buf);
} else {
char pad_char = ' ';
int pad_to = 0;
char l = 0;
char *ptr;
if (puts == (void *)0) {
/* run puts in counting mode. */
puts = _puts;
buf = (void *)0;
}
int n = 0;
while ((ch = *(fmt++))) {
int len;
if (ch != '%') {
len = 1;
len = puts(&ch, len, buf);
} else {
char pad_char = ' ';
int pad_to = 0;
char l = 0;
char *ptr;
ch=*(fmt++);
ch = *(fmt++);
/* Zero padding requested */
if (ch == '0') pad_char = '0';
while (ch >= '0' && ch <= '9') {
pad_to = pad_to * 10 + (ch - '0');
ch=*(fmt++);
}
if(pad_to > (signed int) sizeof(bf)) {
pad_to = sizeof(bf);
}
if (ch == 'l') {
l = 1;
ch=*(fmt++);
}
/* Zero padding requested */
if (ch == '0')
pad_char = '0';
while (ch >= '0' && ch <= '9') {
pad_to = pad_to * 10 + (ch - '0');
ch = *(fmt++);
}
if (pad_to > (signed int)sizeof(bf)) {
pad_to = sizeof(bf);
}
if (ch == 'l') {
l = 1;
ch = *(fmt++);
}
switch (ch) {
case 0:
goto end;
case 'u':
case 'd':
if(l) {
len = mini_itoa(va_arg(va, unsigned long), 10, 0, (ch=='u'), bf2);
} else {
if(ch == 'u') {
len = mini_itoa((unsigned long) va_arg(va, unsigned int), 10, 0, 1, bf2);
} else {
len = mini_itoa((long) va_arg(va, int), 10, 0, 0, bf2);
}
}
len = mini_pad(bf2, len, pad_char, pad_to, bf);
len = puts(bf, len, buf);
break;
switch (ch) {
case 0: goto end;
case 'u':
case 'd':
if (l) {
len = mini_itoa(va_arg(va, unsigned long), 10, 0, (ch == 'u'), bf2);
} else {
if (ch == 'u') {
len = mini_itoa((unsigned long)va_arg(va, unsigned int), 10, 0, 1, bf2);
} else {
len = mini_itoa((long)va_arg(va, int), 10, 0, 0, bf2);
}
}
len = mini_pad(bf2, len, pad_char, pad_to, bf);
len = puts(bf, len, buf);
break;
case 'x':
case 'X':
if(l) {
len = mini_itoa(va_arg(va, unsigned long), 16, (ch=='X'), 1, bf2);
} else {
len = mini_itoa((unsigned long) va_arg(va, unsigned int), 16, (ch=='X'), 1, bf2);
}
len = mini_pad(bf2, len, pad_char, pad_to, bf);
len = puts(bf, len, buf);
break;
case 'x':
case 'X':
if (l) {
len = mini_itoa(va_arg(va, unsigned long), 16, (ch == 'X'), 1, bf2);
} else {
len = mini_itoa((unsigned long)va_arg(va, unsigned int), 16, (ch == 'X'), 1, bf2);
}
len = mini_pad(bf2, len, pad_char, pad_to, bf);
len = puts(bf, len, buf);
break;
case 'c' :
ch = (char)(va_arg(va, int));
len = mini_pad(&ch, 1, pad_char, pad_to, bf);
len = puts(bf, len, buf);
break;
case 'c':
ch = (char)(va_arg(va, int));
len = mini_pad(&ch, 1, pad_char, pad_to, bf);
len = puts(bf, len, buf);
break;
case 's' :
ptr = va_arg(va, char*);
len = mini_strlen(ptr);
if (pad_to > 0) {
len = mini_pad(ptr, len, pad_char, pad_to, bf);
len = puts(bf, len, buf);
} else {
len = puts(ptr, len, buf);
}
break;
case 's':
ptr = va_arg(va, char *);
len = mini_strlen(ptr);
if (pad_to > 0) {
len = mini_pad(ptr, len, pad_char, pad_to, bf);
len = puts(bf, len, buf);
} else {
len = puts(ptr, len, buf);
}
break;
#ifdef MINI_PRINTF_ENABLE_OBJECTS
case 'O' : /* Object by content (e.g. str) */
case 'R' : /* Object by representation (e.g. repr)*/
obj = va_arg(va, void*);
len = mini_handler(mini_handler_data, obj, ch, pad_to, &ptr);
if (pad_to > 0) {
len = mini_pad(ptr, len, pad_char, pad_to, bf);
len = puts(bf, len, buf);
} else {
len = puts(ptr, len, buf);
}
mini_handler_freeor(mini_handler_data, ptr);
break;
case 'O': /* Object by content (e.g. str) */
case 'R': /* Object by representation (e.g. repr)*/
obj = va_arg(va, void *);
len = mini_handler(mini_handler_data, obj, ch, pad_to, &ptr);
if (pad_to > 0) {
len = mini_pad(ptr, len, pad_char, pad_to, bf);
len = puts(bf, len, buf);
} else {
len = puts(ptr, len, buf);
}
mini_handler_freeor(mini_handler_data, ptr);
break;
#endif
default:
len = 1;
len = puts(&ch, len, buf);
break;
}
}
n = n + len;
}
default:
len = 1;
len = puts(&ch, len, buf);
break;
}
}
n = n + len;
}
end:
return n;
return n;
}
int mini_snprintf(char *buffer, unsigned int buffer_len, const char *fmt, ...) {
int ret;
va_list va;
va_start(va, fmt);
ret = mini_vsnprintf(buffer, buffer_len, fmt, va);
va_end(va);
int
mini_snprintf(char* buffer, unsigned int buffer_len, const char *fmt, ...)
{
int ret;
va_list va;
va_start(va, fmt);
ret = mini_vsnprintf(buffer, buffer_len, fmt, va);
va_end(va);
return ret;
return ret;
}
int
mini_pprintf(int (*puts)(char*s, int len, void* buf), void* buf, const char *fmt, ...)
{
int ret;
va_list va;
va_start(va, fmt);
ret = mini_vpprintf(puts, buf, fmt, va);
va_end(va);
int mini_pprintf(int (*puts)(char *s, int len, void *buf), void *buf, const char *fmt, ...) {
int ret;
va_list va;
va_start(va, fmt);
ret = mini_vpprintf(puts, buf, fmt, va);
va_end(va);
return ret;
return ret;
}

View file

@ -27,7 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __MINI_PRINTF__
#define __MINI_PRINTF__
@ -42,32 +41,31 @@ extern "C" {
* void* arguments matching %O and %R are sent to handler as obj.
* the result string created by handler at *buf is freed by freeor.
* */
void mini_printf_set_handler(
void * data,
/* handler returns number of chars in *buf; *buf is not NUL-terminated. */
int (*handler)(void* data, void* obj, int ch, int len_hint, char** buf),
void (*freeor)(void* data, void* buf));
void mini_printf_set_handler(void *data,
/* handler returns number of chars in *buf; *buf is not NUL-terminated. */
int (*handler)(void *data, void *obj, int ch, int len_hint, char **buf),
void (*freeor)(void *data, void *buf));
#endif
/* String IO interface; returns number of bytes written, not including the ending NUL.
* Always appends a NUL at the end, therefore buffer_len shall be at least 1 in normal operation.
* If buffer is NULL or buffer_len is 0, returns number of bytes to be written, not including the ending NUL.
*/
int mini_vsnprintf(char* buffer, unsigned int buffer_len, const char *fmt, va_list va);
int mini_snprintf(char* buffer, unsigned int buffer_len, const char *fmt, ...);
int mini_vsnprintf(char *buffer, unsigned int buffer_len, const char *fmt, va_list va);
int mini_snprintf(char *buffer, unsigned int buffer_len, const char *fmt, ...);
/* Stream IO interface; returns number of bytes written.
* If puts is NULL, number of bytes to be written.
* puts shall return number of bytes written.
*/
int mini_vpprintf(int (*puts)(char* s, int len, void* buf), void* buf, const char *fmt, va_list va);
int mini_pprintf(int (*puts)(char*s, int len, void* buf), void* buf, const char *fmt, ...);
int mini_vpprintf(int (*puts)(char *s, int len, void *buf), void *buf, const char *fmt, va_list va);
int mini_pprintf(int (*puts)(char *s, int len, void *buf), void *buf, const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#define vsnprintf mini_vsnprintf
#define snprintf mini_snprintf
#define snprintf mini_snprintf
#endif

View file

@ -39,7 +39,9 @@ static inline u64 read_tp() {
}
/** Write thread pointer */
static inline void write_tp(u64 x) { asm volatile("mv tp, %0" : : "r"(x)); }
static inline void write_tp(u64 x) {
asm volatile("mv tp, %0" : : "r"(x));
}
/**
* Read the value of the sstatus register.
@ -60,10 +62,14 @@ static inline void w_sstatus(u64 x) {
}
/** Enable device interrupts */
static inline void intr_on() { w_sstatus(r_sstatus() | SSTATUS_SIE); }
static inline void intr_on() {
w_sstatus(r_sstatus() | SSTATUS_SIE);
}
/** Disable device interrupts */
static inline void intr_off() { w_sstatus(r_sstatus() & ~SSTATUS_SIE); }
static inline void intr_off() {
w_sstatus(r_sstatus() & ~SSTATUS_SIE);
}
/** Are device interrupts enabled? */
static inline int intr_get() {

View file

@ -1,7 +1,9 @@
/* QEMU memory maps a UART device here. */
#define UART_BASE ((volatile char *)0x10000000)
void uart_putc(char c) { *UART_BASE = c; }
void uart_putc(char c) {
*UART_BASE = c;
}
void uart_puts(const char *s) {
while (*s) uart_putc(*s++);

View file

@ -1,6 +1,6 @@
#include <config.h>
#include <spinlock.h>
#include <riscv.h>
#include <spinlock.h>
#include <stdint.h>
typedef enum {

View file

@ -1,9 +1,9 @@
#include <config.h>
#include <spinlock.h>
#include <kalloc.h>
#include <memory.h>
#include <proc.h>
#include <riscv.h>
#include <spinlock.h>
#include <stdint.h>
#include <uart.h>