feat: added some comments to command.c
This commit is contained in:
@@ -49,15 +49,15 @@ void help(const char *args);
|
|||||||
|
|
||||||
void shutdown(const char *args);
|
void shutdown(const char *args);
|
||||||
|
|
||||||
void explode(const char *args);
|
|
||||||
|
|
||||||
#ifdef ENABLE_SELF_TEST
|
#ifdef ENABLE_SELF_TEST
|
||||||
|
|
||||||
|
void explode(const char *args);
|
||||||
|
|
||||||
void exec_self_test(const char *args);
|
void exec_self_test(const char *args);
|
||||||
|
|
||||||
void smash(const char *args);
|
void smash(const char *args);
|
||||||
|
|
||||||
void slingurl(const char* args);
|
void slingurl(const char *args);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -67,36 +67,43 @@ cmd_handler cmd_handlers[] = {
|
|||||||
{"print", print},
|
{"print", print},
|
||||||
{"ide", ide},
|
{"ide", ide},
|
||||||
{"shutdown", shutdown},
|
{"shutdown", shutdown},
|
||||||
{"explode", explode},
|
|
||||||
{"slingurl", slingurl},
|
{"slingurl", slingurl},
|
||||||
#ifdef ENABLE_SELF_TEST
|
#ifdef ENABLE_SELF_TEST
|
||||||
{"self-test", exec_self_test},
|
{"self-test", exec_self_test},
|
||||||
{"smash", smash},
|
{"smash", smash},
|
||||||
|
{"explode", explode},
|
||||||
#endif
|
#endif
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
void slingurl(const char* args) {
|
void slingurl(const char *args) {
|
||||||
slingurl_decompose(args);
|
slingurl_decompose(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_SELF_TEST
|
||||||
|
|
||||||
void smash(const char *args) {
|
void smash(const char *args) {
|
||||||
|
// smash the stack, should trigger the stack protector
|
||||||
char data[16];
|
char data[16];
|
||||||
memset(data, 'A', 32);
|
memset(data, 'A', 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_self_test(const char *args) {
|
void exec_self_test(const char *args) {
|
||||||
|
// unit tests
|
||||||
self_test();
|
self_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void explode(const char *args) {
|
void explode(const char *args) {
|
||||||
|
// trigger a divide by zero exception
|
||||||
uint32_t x = 0;
|
uint32_t x = 0;
|
||||||
uint32_t y = 0;
|
uint32_t y = 0;
|
||||||
__asm__("div %%ebx" :
|
__asm__("div %%ebx" :
|
||||||
"=a" (x), "=b" (y));
|
"=a" (x), "=b" (y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void shutdown(const char *args) {
|
void shutdown(const char *args) {
|
||||||
power_shutdown();
|
power_shutdown();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user