feature: heap command prints the status of the allocator

kprintf: change KERN_DEFAULT to 0
This commit is contained in:
2024-09-22 01:57:27 +02:00
parent deca2b9bfc
commit 283f073124
5 changed files with 26 additions and 25 deletions

View File

@ -1,9 +1,10 @@
#include "alloc.h"
#include "kprintf.h"
#include "shell.h"
#include "string.h"
#include "terminal.h"
#define NB_CMDS 8
#define NB_CMDS (sizeof(commands) / sizeof(commands[0]))
#define BORDER "==========================================================="
#define HEADER "Welcome to bozOShell - Available Commands"
@ -17,12 +18,13 @@ struct shell_command {
static void help(void);
static const struct shell_command commands[NB_CMDS] = {
static const struct shell_command commands[] = {
{"help", "Print this help menu", help},
{"reboot", "Reboot the system", reboot},
{"poweroff", "Shut down the system", halt},
{"halt", "Stop all CPU functions", halt},
{"stack", "Print the stack trace", print_stack},
{"heap", "Print the heaps", show_alloc_mem},
{"clear", "Clear the current terminal", terminal_clear},
{"date", "Display the current time and date (UTC+0)", date},
{"merdella", "Surprise", merdella},
@ -36,7 +38,7 @@ static void help(void)
kprintf(" %s\n", HEADER);
kprintf("%s\n", BORDER);
for (size_t i = 0; i < sizeof(commands) / sizeof(commands[0]); i++) {
for (size_t i = 0; i < NB_CMDS; i++) {
kprintf(" %s", commands[i].name);
for (size_t j = 0; j < (padding - strlen(commands[i].name));
j++)
@ -107,7 +109,7 @@ void shell_init(void)
kprintf(PROMPT);
read_line();
bool invalid = true;
for (int i = 0; i < NB_CMDS; i++) {
for (unsigned i = 0; i < NB_CMDS; i++) {
if (!strcmp(commands[i].name, screen->line)) {
commands[i].fn();
invalid = false;