coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
crosec_proto.c File Reference
#include <console/console.h>
#include <stdint.h>
#include <string.h>
#include "ec.h"
#include "ec_commands.h"
#include "ec_message.h"
Include dependency graph for crosec_proto.c:

Go to the source code of this file.

Data Structures

struct  ec_command_v3
 
struct  ec_response_v3
 

Functions

void *__weak crosec_get_buffer (size_t size, int req)
 
static void cros_ec_dump_data (const char *name, int cmd, const uint8_t *data, int len)
 
static int cros_ec_calc_checksum (const uint8_t *data, int size)
 
static int create_proto3_request (const struct chromeec_command *cec_command, struct ec_command_v3 *cmd)
 Create a request packet for protocol version 3. More...
 
static int prepare_proto3_response_buffer (const struct chromeec_command *cec_command, struct ec_response_v3 *resp)
 Prepare the device to receive a protocol version 3 response. More...
 
static int handle_proto3_response (struct ec_response_v3 *resp, struct chromeec_command *cec_command)
 Handle a protocol version 3 response packet. More...
 
static int send_command_proto3 (struct chromeec_command *cec_command, crosec_io_t crosec_io, void *context)
 
static int crosec_command_proto_v3 (struct chromeec_command *cec_command, crosec_io_t crosec_io, void *context)
 
int crosec_command_proto (struct chromeec_command *cec_command, crosec_io_t crosec_io, void *context)
 

Function Documentation

◆ create_proto3_request()

static int create_proto3_request ( const struct chromeec_command cec_command,
struct ec_command_v3 cmd 
)
static

Create a request packet for protocol version 3.

Parameters
cec_commandCommand description.
cmdPacked command bit stream.
Returns
packet size in bytes, or <0 if error.

Definition at line 72 of file crosec_proto.c.

References BIOS_ERR, ec_host_request::checksum, ec_host_request::command, ec_host_request::command_version, cros_ec_calc_checksum(), cros_ec_dump_data(), ec_command_v3::data, ec_host_request::data_len, EC_HOST_REQUEST_VERSION, EC_RES_REQUEST_TRUNCATED, ec_command_v3::header, memcpy(), printk, ec_host_request::reserved, and ec_host_request::struct_version.

Referenced by send_command_proto3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cros_ec_calc_checksum()

static int cros_ec_calc_checksum ( const uint8_t data,
int  size 
)
static

Definition at line 44 of file crosec_proto.c.

Referenced by create_proto3_request(), and handle_proto3_response().

Here is the caller graph for this function:

◆ cros_ec_dump_data()

static void cros_ec_dump_data ( const char *  name,
int  cmd,
const uint8_t data,
int  len 
)
static

Definition at line 25 of file crosec_proto.c.

References BIOS_DEBUG, name, and printk.

Referenced by create_proto3_request(), and handle_proto3_response().

Here is the caller graph for this function:

◆ crosec_command_proto()

int crosec_command_proto ( struct chromeec_command cec_command,
crosec_io_t  crosec_io,
void context 
)

Definition at line 240 of file crosec_proto.c.

Referenced by google_chromeec_command().

Here is the caller graph for this function:

◆ crosec_command_proto_v3()

static int crosec_command_proto_v3 ( struct chromeec_command cec_command,
crosec_io_t  crosec_io,
void context 
)
static

Definition at line 229 of file crosec_proto.c.

References send_command_proto3().

Here is the call graph for this function:

◆ crosec_get_buffer()

void* __weak crosec_get_buffer ( size_t  size,
int  req 
)

Definition at line 12 of file crosec_proto.c.

References BIOS_DEBUG, NULL, and printk.

Referenced by send_command_proto3().

Here is the caller graph for this function:

◆ handle_proto3_response()

static int handle_proto3_response ( struct ec_response_v3 resp,
struct chromeec_command cec_command 
)
static

Handle a protocol version 3 response packet.

The packet must already be stored in the response buffer.

Parameters
respResponse buffer.
cec_commandCommand structure to receive valid response.
Returns
number of bytes of response data, or <0 if error

Definition at line 139 of file crosec_proto.c.

References BIOS_ERR, cros_ec_calc_checksum(), cros_ec_dump_data(), ec_response_v3::data, ec_host_response::data_len, EC_HOST_RESPONSE_VERSION, EC_RES_INVALID_CHECKSUM, EC_RES_INVALID_RESPONSE, EC_RES_RESPONSE_TOO_BIG, ec_response_v3::header, memcpy(), printk, ec_host_response::reserved, ec_host_response::result, and ec_host_response::struct_version.

Referenced by send_command_proto3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepare_proto3_response_buffer()

static int prepare_proto3_response_buffer ( const struct chromeec_command cec_command,
struct ec_response_v3 resp 
)
static

Prepare the device to receive a protocol version 3 response.

Parameters
cec_commandCommand description.
respResponse buffer.
Returns
maximum expected number of bytes in response, or <0 if error.

Definition at line 113 of file crosec_proto.c.

References BIOS_ERR, EC_RES_RESPONSE_TOO_BIG, ec_response_v3::header, and printk.

Referenced by send_command_proto3().

Here is the caller graph for this function:

◆ send_command_proto3()

static int send_command_proto3 ( struct chromeec_command cec_command,
crosec_io_t  crosec_io,
void context 
)
static

Definition at line 193 of file crosec_proto.c.

References BIOS_ERR, create_proto3_request(), crosec_get_buffer(), EC_RES_ERROR, handle_proto3_response(), NULL, prepare_proto3_response_buffer(), and printk.

Referenced by crosec_command_proto_v3().

Here is the call graph for this function:
Here is the caller graph for this function: