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