Added /SHUTDOWN and /REBOOT for shutting down/rebooting the console

This commit is contained in:
Swizzy 2013-07-07 23:41:38 +02:00 committed by tuxuser
parent 5c251ff66d
commit 9a07abe24c
2 changed files with 53 additions and 0 deletions

View File

@ -22,6 +22,9 @@
#include "httpd_index.h"
#include <xenon_smc/xenon_smc.h> //For reboot and shutdown commands
#include <time/time.h> //For delay...
extern void console_clrline();
#define hdprintf(x...)
// fprintf(stderr, x)
@ -817,6 +820,36 @@ static int response_log_process_request(struct http_state *http, const char *met
return 1;
}
static int response_reboot_process_request(struct http_state *http, const char *method, const char *url)
{
if (strcmp(method, "GET"))
return 0;
if (strcmp(url, "/REBOOT"))
return 0;
http->code = 200;
response_static_process_request(http, "Console is rebooting...");
console_clrline();
printf("Rebooting console in 5 seconds...");
delay(5);
xenon_smc_power_reboot();
return 1;
}
static int response_shutdown_process_request(struct http_state *http, const char *method, const char *url)
{
if (strcmp(method, "GET"))
return 0;
if (strcmp(url, "/SHUTDOWN"))
return 0;
http->code = 200;
response_static_process_request(http, "Console is shutting down...");
console_clrline();
printf("Shutting down console in 5 seconds...");
delay(5);
xenon_smc_power_shutdown();
return 1;
}
struct httpd_handler http_handler[]=
{
#ifdef UNIX
@ -836,6 +869,8 @@ struct httpd_handler http_handler[]=
{response_keyvault2_process_request, 0, 0, response_keyvault2_do_header, response_keyvault2_do_data, 0, response_keyvault2_finish},
// {response_setdvdkey_process_request, 0, 0, response_setdvdkey_do_header, response_setdvdkey_do_data, response_setdvdkey_finish},
{response_log_process_request, 0, 0, 0, response_static_do_data, 0, response_static_finish},
{response_reboot_process_request, 0, 0, 0, response_static_do_data, 0, response_static_finish},
{response_shutdown_process_request, 0, 0, 0, response_static_do_data, 0, response_static_finish},
{response_err400_process_request, 0, 0, 0, response_static_do_data, 0, response_static_finish},
//Should always be at the end!

View File

@ -181,6 +181,24 @@ char *INDEX_HTML[] = {
" This will give you a log of everything that was printed to screen (except for the Ascii art) after Stage2 started, including 2 ANA dumps...",
"</td>",
"</tr>",
"<tr>",
"<td width=\"140\" align=\"right\">",
" <div class=\"buttons\">",
" <button VALUE=\"Shutdown\" TYPE=\"BUTTON\" class=\"button\" ONCLICK=\"window.location.href='/SHUTDOWN'\"><b>Shutdown</b></button>",
" </div>",
"</td>",
"<td>",
" This will shutdown your console...",
"</td>",
"</tr>",
"<tr>",
"<td width=\"140\" align=\"right\">",
" <div class=\"buttons\">",
" <button VALUE=\"Reboot\" TYPE=\"BUTTON\" class=\"button\" ONCLICK=\"window.location.href='/REBOOT'\"><b>Reboot</b></button>",
" </div>",
"</td>",
"<td>",
" This will reboot your console...",
"</td>",
"</tr>",
"</tbody></table>",