mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
Rather than go through the task queue, host_command_process() processes the command immediately, has all of its required state passed in, allowing the caller complete control of the buffers. BUG=chrome-os-partner:10533 TEST=manual: build and boot on link, see that messages are stil processed build and boot on snow, which uses this new command See that the SPI keyboard works now Change-Id: Ib7587de10c42caf01bc95bb4d515fd0afc3da7d8 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/25983 Reviewed-by: David Hendricks <dhendrix@chromium.org>
65 lines
2.3 KiB
C
65 lines
2.3 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Host command module for Chrome EC */
|
|
|
|
#ifndef __CROS_EC_HOST_COMMAND_H
|
|
#define __CROS_EC_HOST_COMMAND_H
|
|
|
|
#include "common.h"
|
|
#include "ec_commands.h"
|
|
|
|
/* Host command */
|
|
struct host_command {
|
|
/* Command code. */
|
|
int command;
|
|
/* Handler for the command; data points to parameters/response.
|
|
* returns negative error code if case of failure (using EC_LPC_STATUS
|
|
* codes). sets <response_size> if it returns a payload to the host. */
|
|
int (*handler)(uint8_t *data, int *response_size);
|
|
};
|
|
|
|
/**
|
|
* Process a host command and return its response
|
|
*
|
|
* @param slot is 0 for kernel-originated commands,
|
|
* 1 for usermode-originated commands.
|
|
* @param command The command code
|
|
* @param data Buffer holding the command, and used for the
|
|
* response payload.
|
|
* @param response_size Returns the size of the response
|
|
* @return resulting status
|
|
*/
|
|
enum ec_status host_command_process(int slot, int command, uint8_t *data,
|
|
int *response_size);
|
|
|
|
/* Called by LPC module when a command is written to one of the
|
|
command slots (0=kernel, 1=user). */
|
|
void host_command_received(int slot, int command);
|
|
|
|
// success results with response data
|
|
/* Send a successful result code along with response data to a host command.
|
|
* <slot> is 0 for kernel-originated commands,
|
|
* 1 for usermode-originated commands.
|
|
* <result> is the result code for the command (EC_RES_...)
|
|
* <data> is the buffer with the response payload.
|
|
* <size> is the size of the response buffer. */
|
|
void host_send_response(int slot, enum ec_status result, const uint8_t *data,
|
|
int size);
|
|
|
|
/* Return a pointer to the host command data buffer. This buffer must
|
|
* only be accessed between a notification to host_command_received()
|
|
* and a subsequent call to lpc_SendHostResponse(). <slot> is 0 for
|
|
* kernel-originated commands, 1 for usermode-originated commands. */
|
|
uint8_t *host_get_buffer(int slot);
|
|
|
|
/* Register a host command handler */
|
|
#define DECLARE_HOST_COMMAND(command, routine) \
|
|
const struct host_command __host_cmd_##command \
|
|
__attribute__((section(".rodata.hcmds"))) \
|
|
= {command, routine}
|
|
|
|
#endif /* __CROS_EC_HOST_COMMAND_H */
|