Skip to content

Commit 751413a

Browse files
Move host command to protocol/ (#73)
* Move host command structure to protocol layer * Header file path from root, fix meson build * fix meson project
1 parent ca1cb9d commit 751413a

30 files changed

+331
-378
lines changed

BUILD

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,3 @@ genrule(
1212
tools = [":print_version_header.sh"],
1313
stamp = 1,
1414
)
15-
16-
cc_library(
17-
name = "libhoth",
18-
srcs = ["libhoth.c"],
19-
hdrs = ["libhoth.h"],
20-
deps = [
21-
"//transports:libhoth_device",
22-
],
23-
)

examples/BUILD

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ cc_library(
66
"host_commands.h",
77
"authorization_record.h",
88
],
9+
deps = [
10+
"//protocol:host_cmd",
11+
],
912
)
1013

1114
cc_library(
@@ -23,15 +26,6 @@ cc_library(
2326
],
2427
)
2528

26-
cc_library(
27-
name = "ec_util",
28-
srcs = [
29-
"ec_util.c",
30-
],
31-
hdrs = ["ec_util.h"],
32-
deps = [":host_commands"],
33-
)
34-
3529
config_setting(
3630
name = "dbus_backend",
3731
define_values = {
@@ -44,8 +38,6 @@ cc_binary(
4438
srcs = [
4539
"authorization_record.h",
4640
"authorization_record.c",
47-
"ec_util.c",
48-
"ec_util.h",
4941
"host_commands.h",
5042
"htool.c",
5143
"htool.h",
@@ -87,11 +79,10 @@ cc_binary(
8779
],
8880
deps = [
8981
":authorization_record",
90-
":ec_util",
9182
":host_commands",
9283
":srtm",
9384
"//:git_version",
94-
"//:libhoth",
85+
"//protocol:host_cmd",
9586
"//transports:libhoth_device",
9687
"//transports:libhoth_mtd",
9788
"//transports:libhoth_spi",

examples/ec_util.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

examples/host_commands.h

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,79 +18,12 @@
1818
#include <stdint.h>
1919

2020
#include "authorization_record.h"
21+
#include "protocol/host_cmd.h"
2122

2223
#ifdef __cplusplus
2324
extern "C" {
2425
#endif
2526

26-
#ifndef __packed
27-
#define __packed __attribute__((packed))
28-
#endif
29-
#ifndef __aligned
30-
#define __aligned(x) __attribute__((aligned(x)))
31-
#endif
32-
33-
#define __ec_align1 __packed
34-
#define __ec_align2 __packed __aligned(2)
35-
#define __ec_align4 __packed __aligned(4)
36-
37-
enum ec_status {
38-
EC_RES_SUCCESS = 0,
39-
EC_RES_INVALID_COMMAND = 1,
40-
EC_RES_ERROR = 2,
41-
EC_RES_INVALID_PARAM = 3,
42-
EC_RES_ACCESS_DENIED = 4,
43-
EC_RES_INVALID_RESPONSE = 5,
44-
EC_RES_INVALID_VERSION = 6,
45-
EC_RES_INVALID_CHECKSUM = 7,
46-
EC_RES_IN_PROGRESS = 8,
47-
EC_RES_UNAVAILABLE = 9,
48-
EC_RES_TIMEOUT = 10,
49-
EC_RES_OVERFLOW = 11,
50-
EC_RES_INVALID_HEADER = 12,
51-
EC_RES_REQUEST_TRUNCATED = 13,
52-
EC_RES_RESPONSE_TOO_BIG = 14,
53-
EC_RES_BUS_ERROR = 15,
54-
EC_RES_BUSY = 16,
55-
EC_RES_INVALID_HEADER_VERSION = 17,
56-
EC_RES_INVALID_HEADER_CRC = 18,
57-
EC_RES_INVALID_DATA_CRC = 19,
58-
EC_RES_DUP_UNAVAILABLE = 20,
59-
EC_RES_MAX = UINT16_MAX
60-
} __packed;
61-
62-
#define EC_HOST_REQUEST_VERSION 3
63-
64-
struct ec_host_request {
65-
// Should be EC_HOST_REQUEST_VERSION
66-
uint8_t struct_version;
67-
// Checksum of request and data; sum of all bytes including checksum should
68-
// total to 0.
69-
uint8_t checksum;
70-
// Command to send (EC_CMD_...)
71-
uint16_t command;
72-
// Command version
73-
uint8_t command_version;
74-
uint8_t reserved;
75-
// Length of data that follows this header
76-
uint16_t data_len;
77-
} __ec_align4;
78-
79-
#define EC_HOST_RESPONSE_VERSION 3
80-
81-
struct ec_host_response {
82-
// Should be EC_HOST_RESPONSE_VERSION
83-
uint8_t struct_version;
84-
// Checksum of request and data; sum of all bytes including checksum should
85-
// total to 0.
86-
uint8_t checksum;
87-
// One of the EC_RES_* status codes
88-
uint16_t result;
89-
// Length of data which follows this header.
90-
uint16_t data_len;
91-
uint16_t reserved;
92-
} __ec_align4;
93-
9427
#define EC_CMD_GET_VERSION 0x0002
9528

9629
enum ec_image {

0 commit comments

Comments
 (0)