blob: 9e13463285142ef3a3cb8c660a5f46b492b4febd [file] [log] [blame]
nagendra modadugu24ba5132017-09-14 11:12:30 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Andrew Scull1c02d642017-09-11 17:54:56 +010015 */
16#ifndef __CROS_EC_INCLUDE_APP_NUGGET_H
17#define __CROS_EC_INCLUDE_APP_NUGGET_H
18#include "application.h"
19#include "config.h"
20
21/****************************************************************************/
22/*
23 * APP_ID_NUGGET uses the Transport API:
24 *
25 * uint32_t call_application(uint8_t app_id, uint16_t app_param,
26 * uint8_t *args, uint16_t arg_len,
27 * uint8_t *reply, uint16_t *reply_len);
28 *
29 * Refer to application.h for details.
30 */
31/****************************************************************************/
32
33/* App-specific errors */
34enum {
35 NUGGET_ERROR_LOCKED = APP_SPECIFIC_ERROR,
36 NUGGET_ERROR_RETRY,
37};
38
39/****************************************************************************/
40/* Application functions */
41
42#define NUGGET_PARAM_VERSION 0x0000
43/*
44 * Return the current build string
45 *
46 * @param args <none>
47 * @param arg_len 0
48 * @param reply Null-terminated ASCII string
49 * @param reply_len Max length to return
50 *
51 * @errors APP_ERROR_TOO_MUCH
52 */
53
54/****************************************************************************/
55/* Firmware upgrade stuff */
56
57struct nugget_app_flash_block {
58 uint32_t block_digest; /* first 4 bytes of sha1 of the rest */
59 uint32_t offset; /* from start of flash */
60 uint8_t payload[CHIP_FLASH_BANK_SIZE]; /* data to write */
61} __packed;
62
63#define NUGGET_PARAM_FLASH_BLOCK 0x0001
64/*
65 * Erase and write a single flash block.
66 *
67 * @param args struct nugget_app_flash_block
68 * @param arg_len sizeof(struct nugget_app_flash_block)
69 * @param reply <none>
70 * @param reply_len 0
71 *
72 * @errors NUGGET_ERROR_LOCKED, NUGGET_ERROR_RETRY
73 */
74
75#define NUGGET_PARAM_REBOOT 0x0002
76/*
77 * Reboot Citadel
78 *
79 * @param args uint8_t hard 0 = soft reboot, 1 = hard reboot
80 * @param arg_len sizeof(uint8_t)
81 * @param reply <none>
82 * @param reply_len 0
83 */
84
85/****************************************************************************/
86/* These are bringup / debug functions only.
87 *
88 * TODO(b/65067435): Remove all of these.
89 */
90
91#define NUGGET_PARAM_REVERSE 0xbeef
92/*
93 * Reverse a sequence of bytes, just to have something to demonstrate.
94 *
95 * @param args any arbitrary bytes
96 * @param arg_len any arbitrary length, within reason
97 * @param reply input bytes, in reverse order
98 * @param reply_len same as arg_len
99 *
100 * @errors APP_ERROR_TOO_MUCH
101 */
102
103#define NUGGET_PARAM_READ32 0xF000
104/*
105 * Read a 32-bit value from memory.
106 *
107 * DANGER, WILL ROBINSON! DANGER! There is NO sanity checking on this AT ALL.
108 * Read the wrong address, and Bad Things(tm) WILL happen.
109 *
110 * @param args uint32_t address
111 * @param arg_len sizeof(uint32_t)
112 * @param reply uint32_t value
113 * @param reply_len sizeof(uint32_t)
114 */
115
116struct nugget_app_write32 {
117 uint32_t address;
118 uint32_t value;
119} __packed;
120
121#define NUGGET_PARAM_WRITE32 0xF001
122/*
123 * Write a 32-bit value to memory
124 *
125 * DANGER, WILL ROBINSON! DANGER! There is NO sanity checking on this AT ALL.
126 * Write the wrong values to the wrong address, and Bad Things(tm) WILL happen.
127 *
128 * @param args struct nugget_app_write32
129 * @param arg_len sizeof(struct nugget_app_write32)
130 * @param reply <none>
131 * @param reply_len 0
132 */
133
134#endif /* __CROS_EC_INCLUDE_APP_NUGGET_H */