CTAOS v4
This commit is contained in:
@ -8,12 +8,9 @@ const char *apps_lst[] = {
|
||||
"memory",
|
||||
"help",
|
||||
"cpu_info",
|
||||
"mem_alloc", //0
|
||||
"mem_free", //1
|
||||
"mem_stat",
|
||||
"mem_test", //2
|
||||
"memstat"
|
||||
};
|
||||
int apps_count = 13;
|
||||
int apps_count = 10;
|
||||
|
||||
|
||||
|
||||
@ -139,54 +136,6 @@ void apps_help(const int pn, const char* param[])
|
||||
|
||||
extern void detect_cpu();
|
||||
|
||||
|
||||
|
||||
|
||||
void apps_memory_manager (const int function, const int pn, const char* param[])
|
||||
{
|
||||
switch (function) {
|
||||
// Alloc
|
||||
case 0:
|
||||
{ unsigned int times = 1;
|
||||
if (pn > 1 && strcmp(param[1], "times") == 0)
|
||||
times = atoui(param[2]);
|
||||
|
||||
uint32_t temp;
|
||||
for (; times > 0; times--) {
|
||||
temp = (uint32_t) pmmngr_alloc_block();
|
||||
if (temp == 0) {
|
||||
printf ("Out of memory.\n");
|
||||
break;
|
||||
}
|
||||
else printf ("New block allocated at address 0x%x\n", temp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Free
|
||||
case 1:
|
||||
{ if (pn <= 1) {
|
||||
printf ("Parameter missing: [address (hex)]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t temp = atox(param[1]);
|
||||
pmmngr_free_block ((void*)temp);
|
||||
printf ("Block containing address 0x%x now free.", temp);
|
||||
return;
|
||||
}
|
||||
// Test
|
||||
case 2:
|
||||
{ if (pn <= 1) {
|
||||
printf ("Parameter missing: [block number]");
|
||||
return ; }
|
||||
unsigned int temp = atoui(param[1]);
|
||||
printf (pmmngr_test_block(temp) ? "Block %u is free.\n" : "Block %u is used.\n", temp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void apps_memory_status()
|
||||
{
|
||||
printf ("Memory available: %u KB \n", pmmngr_get_memory_size ());
|
||||
|
@ -74,11 +74,7 @@ void shell()
|
||||
case 6: apps_memory(params, (const char**)param); break;
|
||||
case 7: apps_help(params, (const char**)param); break;
|
||||
case 8: puts((char*)get_cpu_vender()); break;
|
||||
case 9: apps_memory_manager (0, params, (const char**)param); break;
|
||||
case 10: apps_memory_manager (1, params, (const char**)param); break;
|
||||
case 11: apps_memory_status(); break;
|
||||
case 12: apps_memory_manager (2, params, (const char**)param); break;
|
||||
|
||||
case 9: apps_memory_status(); break;
|
||||
default: puts("Invalid function: "); puts(param[0]);
|
||||
putc('\n');
|
||||
break;
|
||||
|
Reference in New Issue
Block a user