blob: 5995c588115f25e297d315bc9386433b10403451 [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
Andrew Sculle029d572017-09-15 11:38:28 +010021#ifdef __cplusplus
22extern "C" {
23#endif
24
Andrew Scull1c02d642017-09-11 17:54:56 +010025/****************************************************************************/
26/*
27 * APP_ID_NUGGET uses the Transport API:
28 *
29 * uint32_t call_application(uint8_t app_id, uint16_t app_param,
30 * uint8_t *args, uint16_t arg_len,
31 * uint8_t *reply, uint16_t *reply_len);
32 *
33 * Refer to application.h for details.
34 */
35/****************************************************************************/
36
37/* App-specific errors */
38enum {
39 NUGGET_ERROR_LOCKED = APP_SPECIFIC_ERROR,
40 NUGGET_ERROR_RETRY,
41};
42
43/****************************************************************************/
44/* Application functions */
45
46#define NUGGET_PARAM_VERSION 0x0000
47/*
48 * Return the current build string
49 *
50 * @param args <none>
51 * @param arg_len 0
52 * @param reply Null-terminated ASCII string
53 * @param reply_len Max length to return
54 *
55 * @errors APP_ERROR_TOO_MUCH
56 */
57
58/****************************************************************************/
59/* Firmware upgrade stuff */
60
61struct nugget_app_flash_block {
62 uint32_t block_digest; /* first 4 bytes of sha1 of the rest */
63 uint32_t offset; /* from start of flash */
64 uint8_t payload[CHIP_FLASH_BANK_SIZE]; /* data to write */
65} __packed;
66
67#define NUGGET_PARAM_FLASH_BLOCK 0x0001
68/*
69 * Erase and write a single flash block.
70 *
71 * @param args struct nugget_app_flash_block
72 * @param arg_len sizeof(struct nugget_app_flash_block)
73 * @param reply <none>
74 * @param reply_len 0
75 *
76 * @errors NUGGET_ERROR_LOCKED, NUGGET_ERROR_RETRY
77 */
78
79#define NUGGET_PARAM_REBOOT 0x0002
80/*
81 * Reboot Citadel
82 *
83 * @param args uint8_t hard 0 = soft reboot, 1 = hard reboot
84 * @param arg_len sizeof(uint8_t)
85 * @param reply <none>
86 * @param reply_len 0
87 */
88
89/****************************************************************************/
90/* These are bringup / debug functions only.
91 *
92 * TODO(b/65067435): Remove all of these.
93 */
94
95#define NUGGET_PARAM_REVERSE 0xbeef
96/*
97 * Reverse a sequence of bytes, just to have something to demonstrate.
98 *
99 * @param args any arbitrary bytes
100 * @param arg_len any arbitrary length, within reason
101 * @param reply input bytes, in reverse order
102 * @param reply_len same as arg_len
103 *
104 * @errors APP_ERROR_TOO_MUCH
105 */
106
107#define NUGGET_PARAM_READ32 0xF000
108/*
109 * Read a 32-bit value from memory.
110 *
111 * DANGER, WILL ROBINSON! DANGER! There is NO sanity checking on this AT ALL.
112 * Read the wrong address, and Bad Things(tm) WILL happen.
113 *
114 * @param args uint32_t address
115 * @param arg_len sizeof(uint32_t)
116 * @param reply uint32_t value
117 * @param reply_len sizeof(uint32_t)
118 */
119
120struct nugget_app_write32 {
121 uint32_t address;
122 uint32_t value;
123} __packed;
124
125#define NUGGET_PARAM_WRITE32 0xF001
126/*
127 * Write a 32-bit value to memory
128 *
129 * DANGER, WILL ROBINSON! DANGER! There is NO sanity checking on this AT ALL.
130 * Write the wrong values to the wrong address, and Bad Things(tm) WILL happen.
131 *
132 * @param args struct nugget_app_write32
133 * @param arg_len sizeof(struct nugget_app_write32)
134 * @param reply <none>
135 * @param reply_len 0
136 */
137
Andrew Sculle029d572017-09-15 11:38:28 +0100138#ifdef __cplusplus
139}
140#endif
141
Andrew Scull1c02d642017-09-11 17:54:56 +0100142#endif /* __CROS_EC_INCLUDE_APP_NUGGET_H */