Feat: add memalloc command
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
void help(void);
|
||||
void hello(void);
|
||||
void hwinfo(void);
|
||||
void memalloc(size_t size);
|
||||
void ls(file_node_t *root);
|
||||
void cat(file_node_t *root, const char *filename);
|
||||
void reboot(void);
|
||||
|
||||
@@ -16,8 +16,7 @@ void *simple_alloc(size_t size)
|
||||
_heap_top = (void *)&__heap_start;
|
||||
}
|
||||
|
||||
if (size & 0xff)
|
||||
size = (size & ~0xff) + 0x100;
|
||||
size = (size_t)ALIGN8(size);
|
||||
|
||||
if ((uint64_t)_heap_top + size >= (uint64_t)&__heap_end)
|
||||
exit(ERR_NO_MEM);
|
||||
|
||||
15
lib/shell.c
15
lib/shell.c
@@ -1,4 +1,5 @@
|
||||
#include <stddef.h>
|
||||
#include <kmalloc.h>
|
||||
#include <utils.h>
|
||||
#include <string.h>
|
||||
#include <uart.h>
|
||||
@@ -17,10 +18,11 @@ void help (void)
|
||||
uart_puts(
|
||||
"help : print this help menu" ENDL
|
||||
"hello : print Hello World!" ENDL
|
||||
"hwinfo: print hardware info" ENDL
|
||||
"hwinfo : print hardware info" ENDL
|
||||
"memalloc : alloate memory and print" ENDL
|
||||
"ls : list directory contents" ENDL
|
||||
"cat : concatenate files and print" ENDL
|
||||
"reboot: reboot the device" ENDL
|
||||
"reboot : reboot the device" ENDL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,6 +51,13 @@ void hwinfo (void)
|
||||
uart_puts(ENDL);
|
||||
}
|
||||
|
||||
void memalloc(size_t size)
|
||||
{
|
||||
DEBUG(size);
|
||||
void *addr = kmalloc(size);
|
||||
DEBUG(addr);
|
||||
}
|
||||
|
||||
void ls_initrd_callback(file_node_t *tr)
|
||||
{
|
||||
uart_puts(tr->filename);
|
||||
@@ -118,6 +127,8 @@ int shell(file_node_t *initrd_root)
|
||||
hello();
|
||||
} else if (!strcmp(bin, "hwinfo")) {
|
||||
hwinfo();
|
||||
} else if (!strcmp(bin, "memalloc")){
|
||||
memalloc((size_t)atoi32(param));
|
||||
} else if (!strcmp(bin, "ls")) {
|
||||
ls(initrd_root);
|
||||
} else if (!strcmp(bin, "cat")) {
|
||||
|
||||
Reference in New Issue
Block a user