mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
Clean up host command module
Code cleanup only; no functional changes BUG=chrome-os-partner:15579 BRANCH=none TEST=ectool hello -> success Change-Id: I40391b66efaeab873e99500d4f58a5a779eb2c71 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36557 Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "console.h"
|
||||
#include "ec_commands.h"
|
||||
#include "host_command.h"
|
||||
#include "link_defs.h"
|
||||
#include "lpc.h"
|
||||
@@ -133,9 +132,11 @@ void host_command_received(struct host_cmd_handler_args *args)
|
||||
host_send_response(args);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a command by command number. Returns the command structure, or NULL if
|
||||
* no match found.
|
||||
/**
|
||||
* Find a command by command number.
|
||||
*
|
||||
* @param command Command number to find
|
||||
* @return The command structure, or NULL if no match found.
|
||||
*/
|
||||
static const struct host_command *find_host_command(int command)
|
||||
{
|
||||
@@ -149,6 +150,38 @@ static const struct host_command *find_host_command(int command)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void host_command_init(void)
|
||||
{
|
||||
/* Initialize memory map ID area */
|
||||
host_get_memmap(EC_MEMMAP_ID)[0] = 'E';
|
||||
host_get_memmap(EC_MEMMAP_ID)[1] = 'C';
|
||||
*host_get_memmap(EC_MEMMAP_ID_VERSION) = 1;
|
||||
*host_get_memmap(EC_MEMMAP_EVENTS_VERSION) = 1;
|
||||
|
||||
host_set_single_event(EC_HOST_EVENT_INTERFACE_READY);
|
||||
CPRINTF("[%T hostcmd init 0x%x]\n", host_get_events());
|
||||
}
|
||||
|
||||
void host_command_task(void)
|
||||
{
|
||||
host_command_init();
|
||||
|
||||
while (1) {
|
||||
/* Wait for the next command event */
|
||||
int evt = task_wait_event(-1);
|
||||
|
||||
/* Process it */
|
||||
if ((evt & TASK_EVENT_CMD_PENDING) && pending_args) {
|
||||
pending_args->result =
|
||||
host_command_process(pending_args);
|
||||
host_send_response(pending_args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Host commands */
|
||||
|
||||
static int host_command_proto_version(struct host_cmd_handler_args *args)
|
||||
{
|
||||
struct ec_response_proto_version *r = args->response;
|
||||
@@ -309,41 +342,7 @@ DECLARE_HOST_COMMAND(EC_CMD_RESEND_RESPONSE,
|
||||
#endif /* CONFIG_HOST_COMMAND_STATUS */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Initialization / task */
|
||||
|
||||
static int host_command_init(void)
|
||||
{
|
||||
/* Initialize memory map ID area */
|
||||
host_get_memmap(EC_MEMMAP_ID)[0] = 'E';
|
||||
host_get_memmap(EC_MEMMAP_ID)[1] = 'C';
|
||||
*host_get_memmap(EC_MEMMAP_ID_VERSION) = 1;
|
||||
*host_get_memmap(EC_MEMMAP_EVENTS_VERSION) = 1;
|
||||
|
||||
|
||||
host_set_single_event(EC_HOST_EVENT_INTERFACE_READY);
|
||||
CPRINTF("[%T hostcmd init 0x%x]\n", host_get_events());
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
void host_command_task(void)
|
||||
{
|
||||
host_command_init();
|
||||
|
||||
while (1) {
|
||||
/* wait for the next command event */
|
||||
int evt = task_wait_event(-1);
|
||||
/* process it */
|
||||
if ((evt & TASK_EVENT_CMD_PENDING) && pending_args) {
|
||||
pending_args->result =
|
||||
host_command_process(pending_args);
|
||||
host_send_response(pending_args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Console commands*/
|
||||
/* Console commands */
|
||||
|
||||
static int parse_byte(char *b, uint8_t *out)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user