Fix: mman behavior
This commit is contained in:
@@ -30,6 +30,7 @@ void _help (void)
|
||||
"cat <file> : concatenate files and print" ENDL
|
||||
"exec <file> : execute file in usermode" ENDL
|
||||
"settimeout <sec> <message...>: pring message after a few seconds" ENDL
|
||||
"time : print current time tick" ENDL
|
||||
"reboot : reboot the device" ENDL
|
||||
);
|
||||
}
|
||||
@@ -74,6 +75,14 @@ void _memalloc(size_t size)
|
||||
uart_puts(ENDL);
|
||||
}
|
||||
|
||||
static inline
|
||||
void _free(uint64_t ptr)
|
||||
{
|
||||
kfree((void *)ptr);
|
||||
LOG(ptr);
|
||||
INFOR("has been freed");
|
||||
}
|
||||
|
||||
static inline
|
||||
void _ls_initrd_callback(file_node_t *tr)
|
||||
{
|
||||
@@ -138,7 +147,22 @@ void _settimeout(int32_t sec, vector_t *args)
|
||||
.func = _settimeout_cb_func,
|
||||
.param = (uint64_t)args,
|
||||
};
|
||||
add_task(task);
|
||||
add_timer_task(task);
|
||||
}
|
||||
|
||||
static inline
|
||||
void _time()
|
||||
{
|
||||
uint64_t cntpct_el0, cntfrq_el0, cntp_cval_el0, cntp_tval_el0;
|
||||
R_SYSREG(cntpct_el0, cntpct_el0);
|
||||
R_SYSREG(cntfrq_el0, cntfrq_el0);
|
||||
R_SYSREG(cntp_cval_el0, cntp_cval_el0);
|
||||
R_SYSREG(cntp_tval_el0, cntp_tval_el0);
|
||||
|
||||
LOG(cntpct_el0);
|
||||
LOG(cntfrq_el0);
|
||||
LOG(cntp_cval_el0);
|
||||
INFOR(cntp_tval_el0);
|
||||
}
|
||||
|
||||
static inline
|
||||
@@ -209,9 +233,12 @@ int shell(file_node_t *initrd_root)
|
||||
_hello();
|
||||
} else if (!strcmp(cmd, "hwinfo")) {
|
||||
_hwinfo();
|
||||
} else if (!strcmp(cmd, "memalloc") && args->size >= 2){
|
||||
} else if (!strcmp(cmd, "memalloc") && args->size >= 2) {
|
||||
char *p1 = VEC_AT(char, args, 1);
|
||||
_memalloc((size_t)atoi32(p1));
|
||||
} else if (!strcmp(cmd, "free") && args->size >= 2) {
|
||||
char *p1 = VEC_AT(char, args, 1);
|
||||
_free((uint64_t)atoh32(p1));
|
||||
} else if (!strcmp(cmd, "ls")) {
|
||||
_ls(initrd_root);
|
||||
} else if (!strcmp(cmd, "cat") && args->size >= 2) {
|
||||
@@ -223,6 +250,8 @@ int shell(file_node_t *initrd_root)
|
||||
} else if (!strcmp(cmd, "settimeout") && args->size >= 2) {
|
||||
char *p1 = VEC_AT(char, args, 1);
|
||||
_settimeout(atoi32(p1), args);
|
||||
} else if (!strcmp(cmd, "time")) {
|
||||
_time();
|
||||
} else if (!strcmp(cmd, "reboot")) {
|
||||
_reboot();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user