[lkboot] reboot support

This commit is contained in:
Brian Swetland
2014-08-06 16:09:55 -07:00
parent bf222fad5a
commit 312e5e146a
2 changed files with 20 additions and 0 deletions

View File

@@ -28,6 +28,8 @@
#include <string.h> #include <string.h>
#include <endian.h> #include <endian.h>
#include <kernel/thread.h>
#include <lib/ptable.h> #include <lib/ptable.h>
#include <lib/bio.h> #include <lib/bio.h>
#include <lib/sysparam.h> #include <lib/sysparam.h>
@@ -48,6 +50,12 @@ extern void *lkb_iobuffer;
extern paddr_t lkb_iobuffer_phys; extern paddr_t lkb_iobuffer_phys;
extern size_t lkb_iobuffer_size; extern size_t lkb_iobuffer_size;
static int do_reboot(void *arg) {
thread_sleep(250);
platform_halt(HALT_ACTION_REBOOT, HALT_REASON_SW_RESET);
return 0;
}
// return NULL for success, error string for failure // return NULL for success, error string for failure
const char *lkb_handle_command(lkb_t *lkb, const char *cmd, const char *arg, unsigned len) { const char *lkb_handle_command(lkb_t *lkb, const char *cmd, const char *arg, unsigned len) {
if (len > lkb_iobuffer_size) { if (len > lkb_iobuffer_size) {
@@ -103,6 +111,10 @@ const char *lkb_handle_command(lkb_t *lkb, const char *cmd, const char *arg, uns
lkb_write(lkb, ptr, len); lkb_write(lkb, ptr, len);
} }
return NULL; return NULL;
} else if (!strcmp(cmd, "reboot")) {
thread_resume(thread_create("reboot", &do_reboot, NULL,
DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
return NULL;
} else { } else {
return "unknown command"; return "unknown command";
} }

View File

@@ -207,6 +207,14 @@ int main(int argc, char **argv) {
const char *fn = NULL; const char *fn = NULL;
int fd = -1; int fd = -1;
if (argc == 3) {
if (!strcmp(cmd, "reboot")) {
return lkboot_txn(host, cmd, fd, "");
} else {
usage();
}
}
if (argc < 4) usage(); if (argc < 4) usage();
if (!strcmp(cmd, "flash")) { if (!strcmp(cmd, "flash")) {