blob: 99fc5402719d5e702ac6c1b8f30a40f167fcf5af [file] [log] [blame]
Ye Li1c610742022-07-26 16:40:55 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2022 NXP
4 */
5
6#include <common.h>
7#include <command.h>
8#include <errno.h>
9#include <asm/io.h>
10#include <asm/mach-imx/s400_api.h>
11#include <asm/mach-imx/sys_proto.h>
12#include <asm/arch-imx/cpu.h>
13#include <asm/arch/sys_proto.h>
14#include <asm/mach-imx/image.h>
15#include <console.h>
16#include <cpu_func.h>
17#include <asm/mach-imx/ahab.h>
18#include <asm/global_data.h>
19
20DECLARE_GLOBAL_DATA_PTR;
21
Ye Li1c610742022-07-26 16:40:55 +080022#define IMG_CONTAINER_END_BASE (IMG_CONTAINER_BASE + 0xFFFFUL)
23
Ye Lic9e34362023-01-30 18:39:51 +080024#define AHAB_MAX_EVENTS 8
25
26static char *ele_ipc_str[] = {
27 "IPC = MU RTD (0x1)\n",
28 "IPC = MU APD (0x2)\n",
29 "IPC = INVALID\n",
30 NULL
31};
32
33static char *ele_status_str[] = {
34 "STA = ELE_SUCCESS_IND (0xD6)\n",
35 "STA = ELE_FAILURE_IND (0x29)\n",
36 "STA = INVALID\n",
37 NULL
38};
39
40static char *ele_cmd_str[] = {
41 "CMD = ELE_PING_REQ (0x01)\n",
42 "CMD = ELE_FW_AUTH_REQ (0x02)\n",
43 "CMD = ELE_RESTART_RST_TIMER_REQ (0x04)\n",
44 "CMD = ELE_DUMP_DEBUG_BUFFER_REQ (0x21)\n",
45 "CMD = ELE_OEM_CNTN_AUTH_REQ (0x87)\n",
46 "CMD = ELE_VERIFY_IMAGE_REQ (0x88)\n",
47 "CMD = ELE_RELEASE_CONTAINER_REQ (0x89)\n",
48 "CMD = ELE_WRITE_SECURE_FUSE_REQ (0x91)\n",
49 "CMD = ELE_FWD_LIFECYCLE_UP_REQ (0x95)\n",
50 "CMD = ELE_READ_FUSE_REQ (0x97)\n",
51 "CMD = ELE_GET_FW_VERSION_REQ (0x9D)\n",
52 "CMD = ELE_RET_LIFECYCLE_UP_REQ (0xA0)\n",
53 "CMD = ELE_GET_EVENTS_REQ (0xA2)\n",
54 "CMD = ELE_ENABLE_PATCH_REQ (0xC3)\n",
55 "CMD = ELE_RELEASE_RDC_REQ (0xC4)\n",
56 "CMD = ELE_GET_FW_STATUS_REQ (0xC5)\n",
57 "CMD = ELE_ENABLE_OTFAD_REQ (0xC6)\n",
58 "CMD = ELE_RESET_REQ (0xC7)\n",
59 "CMD = ELE_UPDATE_OTP_CLKDIV_REQ (0xD0)\n",
60 "CMD = ELE_POWER_DOWN_REQ (0xD1)\n",
61 "CMD = ELE_ENABLE_APC_REQ (0xD2)\n",
62 "CMD = ELE_ENABLE_RTC_REQ (0xD3)\n",
63 "CMD = ELE_DEEP_POWER_DOWN_REQ (0xD4)\n",
64 "CMD = ELE_STOP_RST_TIMER_REQ (0xD5)\n",
65 "CMD = ELE_WRITE_FUSE_REQ (0xD6)\n",
66 "CMD = ELE_RELEASE_CAAM_REQ (0xD7)\n",
67 "CMD = ELE_RESET_A35_CTX_REQ (0xD8)\n",
68 "CMD = ELE_MOVE_TO_UNSECURED_REQ (0xD9)\n",
69 "CMD = ELE_GET_INFO_REQ (0xDA)\n",
70 "CMD = ELE_ATTEST_REQ (0xDB)\n",
71 "CMD = ELE_RELEASE_PATCH_REQ (0xDC)\n",
72 "CMD = ELE_OTP_SEQ_SWITH_REQ (0xDD)\n",
73 "CMD = INVALID\n",
74 NULL
75};
76
77static char *ele_ind_str[] = {
78 "IND = ELE_ROM_PING_FAILURE_IND (0x0A)\n",
79 "IND = ELE_FW_PING_FAILURE_IND (0x1A)\n",
80 "IND = ELE_BAD_SIGNATURE_FAILURE_IND (0xF0)\n",
81 "IND = ELE_BAD_HASH_FAILURE_IND (0xF1)\n",
82 "IND = ELE_INVALID_LIFECYCLE_IND (0xF2)\n",
83 "IND = ELE_PERMISSION_DENIED_FAILURE_IND (0xF3)\n",
84 "IND = ELE_INVALID_MESSAGE_FAILURE_IND (0xF4)\n",
85 "IND = ELE_BAD_VALUE_FAILURE_IND (0xF5)\n",
86 "IND = ELE_BAD_FUSE_ID_FAILURE_IND (0xF6)\n",
87 "IND = ELE_BAD_CONTAINER_FAILURE_IND (0xF7)\n",
88 "IND = ELE_BAD_VERSION_FAILURE_IND (0xF8)\n",
89 "IND = ELE_INVALID_KEY_FAILURE_IND (0xF9)\n",
90 "IND = ELE_BAD_KEY_HASH_FAILURE_IND (0xFA)\n",
91 "IND = ELE_NO_VALID_CONTAINER_FAILURE_IND (0xFB)\n",
92 "IND = ELE_BAD_CERTIFICATE_FAILURE_IND (0xFC)\n",
93 "IND = ELE_BAD_UID_FAILURE_IND (0xFD)\n",
94 "IND = ELE_BAD_MONOTONIC_COUNTER_FAILURE_IND (0xFE)\n",
95 "IND = ELE_MUST_SIGNED_FAILURE_IND (0xE0)\n",
96 "IND = ELE_NO_AUTHENTICATION_FAILURE_IND (0xEE)\n",
97 "IND = ELE_BAD_SRK_SET_FAILURE_IND (0xEF)\n",
98 "IND = ELE_UNALIGNED_PAYLOAD_FAILURE_IND (0xA6)\n",
99 "IND = ELE_WRONG_SIZE_FAILURE_IND (0xA7)\n",
100 "IND = ELE_ENCRYPTION_FAILURE_IND (0xA8)\n",
101 "IND = ELE_DECRYPTION_FAILURE_IND (0xA9)\n",
102 "IND = ELE_OTP_PROGFAIL_FAILURE_IND (0xAA)\n",
103 "IND = ELE_OTP_LOCKED_FAILURE_IND (0xAB)\n",
104 "IND = ELE_OTP_INVALID_IDX_FAILURE_IND (0xAD)\n",
105 "IND = ELE_TIME_OUT_FAILURE_IND (0xB0)\n",
106 "IND = ELE_BAD_PAYLOAD_FAILURE_IND (0xB1)\n",
107 "IND = ELE_WRONG_ADDRESS_FAILURE_IND (0xB4)\n",
108 "IND = ELE_DMA_FAILURE_IND (0xB5)\n",
109 "IND = ELE_DISABLED_FEATURE_FAILURE_IND (0xB6)\n",
110 "IND = ELE_MUST_ATTEST_FAILURE_IND (0xB7)\n",
111 "IND = ELE_RNG_NOT_STARTED_FAILURE_IND (0xB8)\n",
112 "IND = ELE_CRC_ERROR_IND (0xB9)\n",
113 "IND = ELE_AUTH_SKIPPED_OR_FAILED_FAILURE_IND (0xBB)\n",
114 "IND = ELE_INCONSISTENT_PAR_FAILURE_IND (0xBC)\n",
115 "IND = ELE_RNG_INST_FAILURE_FAILURE_IND (0xBD)\n",
116 "IND = ELE_LOCKED_REG_FAILURE_IND (0xBE)\n",
117 "IND = ELE_BAD_ID_FAILURE_IND (0xBF)\n",
118 "IND = ELE_INVALID_OPERATION_FAILURE_IND (0xC0)\n",
119 "IND = ELE_NON_SECURE_STATE_FAILURE_IND (0xC1)\n",
120 "IND = ELE_MSG_TRUNCATED_IND (0xC2)\n",
121 "IND = ELE_BAD_IMAGE_NUM_FAILURE_IND (0xC3)\n",
122 "IND = ELE_BAD_IMAGE_ADDR_FAILURE_IND (0xC4)\n",
123 "IND = ELE_BAD_IMAGE_PARAM_FAILURE_IND (0xC5)\n",
124 "IND = ELE_BAD_IMAGE_TYPE_FAILURE_IND (0xC6)\n",
125 "IND = ELE_CORRUPTED_SRK_FAILURE_IND (0xD0)\n",
126 "IND = ELE_OUT_OF_MEMORY_IND (0xD1)\n",
127 "IND = ELE_CSTM_FAILURE_IND (0xCF)\n",
128 "IND = ELE_OLD_VERSION_FAILURE_IND (0xCE)\n",
129 "IND = ELE_WRONG_BOOT_MODE_FAILURE_IND (0xCD)\n",
130 "IND = ELE_APC_ALREADY_ENABLED_FAILURE_IND (0xCB)\n",
131 "IND = ELE_RTC_ALREADY_ENABLED_FAILURE_IND (0xCC)\n",
132 "IND = ELE_ABORT_IND (0xFF)\n",
133 "IND = INVALID\n",
134 NULL
135};
136
137static u8 ele_cmd[] = {
138 ELE_PING_REQ,
139 ELE_FW_AUTH_REQ,
140 ELE_RESTART_RST_TIMER_REQ,
141 ELE_DUMP_DEBUG_BUFFER_REQ,
142 ELE_OEM_CNTN_AUTH_REQ,
143 ELE_VERIFY_IMAGE_REQ,
144 ELE_RELEASE_CONTAINER_REQ,
145 ELE_WRITE_SECURE_FUSE_REQ,
146 ELE_FWD_LIFECYCLE_UP_REQ,
147 ELE_READ_FUSE_REQ,
148 ELE_GET_FW_VERSION_REQ,
149 ELE_RET_LIFECYCLE_UP_REQ,
150 ELE_GET_EVENTS_REQ,
151 ELE_ENABLE_PATCH_REQ,
152 ELE_RELEASE_RDC_REQ,
153 ELE_GET_FW_STATUS_REQ,
154 ELE_ENABLE_OTFAD_REQ,
155 ELE_RESET_REQ,
156 ELE_UPDATE_OTP_CLKDIV_REQ,
157 ELE_POWER_DOWN_REQ,
158 ELE_ENABLE_APC_REQ,
159 ELE_ENABLE_RTC_REQ,
160 ELE_DEEP_POWER_DOWN_REQ,
161 ELE_STOP_RST_TIMER_REQ,
162 ELE_WRITE_FUSE_REQ,
163 ELE_RELEASE_CAAM_REQ,
164 ELE_RESET_A35_CTX_REQ,
165 ELE_MOVE_TO_UNSECURED_REQ,
166 ELE_GET_INFO_REQ,
167 ELE_ATTEST_REQ,
168 ELE_RELEASE_PATCH_REQ,
169 ELE_OTP_SEQ_SWITH_REQ
170};
171
172static u8 ele_ind[] = {
173 ELE_ROM_PING_FAILURE_IND,
174 ELE_FW_PING_FAILURE_IND,
175 ELE_BAD_SIGNATURE_FAILURE_IND,
176 ELE_BAD_HASH_FAILURE_IND,
177 ELE_INVALID_LIFECYCLE_IND,
178 ELE_PERMISSION_DENIED_FAILURE_IND,
179 ELE_INVALID_MESSAGE_FAILURE_IND,
180 ELE_BAD_VALUE_FAILURE_IND,
181 ELE_BAD_FUSE_ID_FAILURE_IND,
182 ELE_BAD_CONTAINER_FAILURE_IND,
183 ELE_BAD_VERSION_FAILURE_IND,
184 ELE_INVALID_KEY_FAILURE_IND,
185 ELE_BAD_KEY_HASH_FAILURE_IND,
186 ELE_NO_VALID_CONTAINER_FAILURE_IND,
187 ELE_BAD_CERTIFICATE_FAILURE_IND,
188 ELE_BAD_UID_FAILURE_IND,
189 ELE_BAD_MONOTONIC_COUNTER_FAILURE_IND,
190 ELE_MUST_SIGNED_FAILURE_IND,
191 ELE_NO_AUTHENTICATION_FAILURE_IND,
192 ELE_BAD_SRK_SET_FAILURE_IND,
193 ELE_UNALIGNED_PAYLOAD_FAILURE_IND,
194 ELE_WRONG_SIZE_FAILURE_IND,
195 ELE_ENCRYPTION_FAILURE_IND,
196 ELE_DECRYPTION_FAILURE_IND,
197 ELE_OTP_PROGFAIL_FAILURE_IND,
198 ELE_OTP_LOCKED_FAILURE_IND,
199 ELE_OTP_INVALID_IDX_FAILURE_IND,
200 ELE_TIME_OUT_FAILURE_IND,
201 ELE_BAD_PAYLOAD_FAILURE_IND,
202 ELE_WRONG_ADDRESS_FAILURE_IND,
203 ELE_DMA_FAILURE_IND,
204 ELE_DISABLED_FEATURE_FAILURE_IND,
205 ELE_MUST_ATTEST_FAILURE_IND,
206 ELE_RNG_NOT_STARTED_FAILURE_IND,
207 ELE_CRC_ERROR_IND,
208 ELE_AUTH_SKIPPED_OR_FAILED_FAILURE_IND,
209 ELE_INCONSISTENT_PAR_FAILURE_IND,
210 ELE_RNG_INST_FAILURE_FAILURE_IND,
211 ELE_LOCKED_REG_FAILURE_IND,
212 ELE_BAD_ID_FAILURE_IND,
213 ELE_INVALID_OPERATION_FAILURE_IND,
214 ELE_NON_SECURE_STATE_FAILURE_IND,
215 ELE_MSG_TRUNCATED_IND,
216 ELE_BAD_IMAGE_NUM_FAILURE_IND,
217 ELE_BAD_IMAGE_ADDR_FAILURE_IND,
218 ELE_BAD_IMAGE_PARAM_FAILURE_IND,
219 ELE_BAD_IMAGE_TYPE_FAILURE_IND,
220 ELE_CORRUPTED_SRK_FAILURE_IND,
221 ELE_OUT_OF_MEMORY_IND,
222 ELE_CSTM_FAILURE_IND,
223 ELE_OLD_VERSION_FAILURE_IND,
224 ELE_WRONG_BOOT_MODE_FAILURE_IND,
225 ELE_APC_ALREADY_ENABLED_FAILURE_IND,
226 ELE_RTC_ALREADY_ENABLED_FAILURE_IND,
227 ELE_ABORT_IND
228};
229
230static u8 ele_ipc[] = {
231 ELE_IPC_MU_RTD,
232 ELE_IPC_MU_APD
233};
234
235static u8 ele_status[] = {
236 ELE_SUCCESS_IND,
237 ELE_FAILURE_IND
238};
239
240static inline u32 get_idx(u8 *list, u8 tgt, u32 size)
241{
242 u32 i;
243
244 for (i = 0; i < size; i++) {
245 if (list[i] == tgt)
246 return i;
247 }
248
249 return i; /* last str is invalid */
250}
Ye Li1c610742022-07-26 16:40:55 +0800251
252static void display_ahab_auth_ind(u32 event)
253{
254 u8 resp_ind = (event >> 8) & 0xff;
255
Ye Lic9e34362023-01-30 18:39:51 +0800256 printf("%s\n", ele_ind_str[get_idx(ele_ind, resp_ind, ARRAY_SIZE(ele_ind))]);
Ye Li1c610742022-07-26 16:40:55 +0800257}
258
259int ahab_auth_cntr_hdr(struct container_hdr *container, u16 length)
260{
261 int err;
262 u32 resp;
263
264 memcpy((void *)IMG_CONTAINER_BASE, (const void *)container,
265 ALIGN(length, CONFIG_SYS_CACHELINE_SIZE));
266
267 flush_dcache_range(IMG_CONTAINER_BASE,
268 IMG_CONTAINER_BASE + ALIGN(length, CONFIG_SYS_CACHELINE_SIZE) - 1);
269
270 err = ahab_auth_oem_ctnr(IMG_CONTAINER_BASE, &resp);
271 if (err) {
272 printf("Authenticate container hdr failed, return %d, resp 0x%x\n",
273 err, resp);
274 display_ahab_auth_ind(resp);
275 }
276
277 return err;
278}
279
280int ahab_auth_release(void)
281{
282 int err;
283 u32 resp;
284
285 err = ahab_release_container(&resp);
286 if (err) {
287 printf("Error: release container failed, resp 0x%x!\n", resp);
288 display_ahab_auth_ind(resp);
289 }
290
291 return err;
292}
293
294int ahab_verify_cntr_image(struct boot_img_t *img, int image_index)
295{
296 int err;
297 u32 resp;
298
299 err = ahab_verify_image(image_index, &resp);
300 if (err) {
301 printf("Authenticate img %d failed, return %d, resp 0x%x\n",
302 image_index, err, resp);
303 display_ahab_auth_ind(resp);
304
305 return -EIO;
306 }
307
308 return 0;
309}
310
311static inline bool check_in_dram(ulong addr)
312{
313 int i;
314 struct bd_info *bd = gd->bd;
315
316 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
317 if (bd->bi_dram[i].size) {
318 if (addr >= bd->bi_dram[i].start &&
319 addr < (bd->bi_dram[i].start + bd->bi_dram[i].size))
320 return true;
321 }
322 }
323
324 return false;
325}
326
327int authenticate_os_container(ulong addr)
328{
329 struct container_hdr *phdr;
330 int i, ret = 0;
331 int err;
332 u16 length;
333 struct boot_img_t *img;
334 unsigned long s, e;
335
336 if (addr % 4) {
337 puts("Error: Image's address is not 4 byte aligned\n");
338 return -EINVAL;
339 }
340
341 if (!check_in_dram(addr)) {
342 puts("Error: Image's address is invalid\n");
343 return -EINVAL;
344 }
345
346 phdr = (struct container_hdr *)addr;
347 if (phdr->tag != 0x87 || phdr->version != 0x0) {
348 printf("Error: Wrong container header\n");
349 return -EFAULT;
350 }
351
352 if (!phdr->num_images) {
353 printf("Error: Wrong container, no image found\n");
354 return -EFAULT;
355 }
356
357 length = phdr->length_lsb + (phdr->length_msb << 8);
358
359 debug("container length %u\n", length);
360
361 err = ahab_auth_cntr_hdr(phdr, length);
362 if (err) {
363 ret = -EIO;
364 goto exit;
365 }
366
367 debug("Verify images\n");
368
369 /* Copy images to dest address */
370 for (i = 0; i < phdr->num_images; i++) {
371 img = (struct boot_img_t *)(addr +
372 sizeof(struct container_hdr) +
373 i * sizeof(struct boot_img_t));
374
375 debug("img %d, dst 0x%x, src 0x%lx, size 0x%x\n",
376 i, (uint32_t)img->dst, img->offset + addr, img->size);
377
378 memcpy((void *)img->dst, (const void *)(img->offset + addr),
379 img->size);
380
381 s = img->dst & ~(CONFIG_SYS_CACHELINE_SIZE - 1);
382 e = ALIGN(img->dst + img->size, CONFIG_SYS_CACHELINE_SIZE) - 1;
383
384 flush_dcache_range(s, e);
385
386 ret = ahab_verify_cntr_image(img, i);
387 if (ret)
388 goto exit;
389 }
390
391exit:
392 debug("ahab_auth_release, 0x%x\n", ret);
393 ahab_auth_release();
394
395 return ret;
396}
397
398static int do_authenticate(struct cmd_tbl *cmdtp, int flag, int argc,
399 char *const argv[])
400{
401 ulong addr;
402
403 if (argc < 2)
404 return CMD_RET_USAGE;
405
406 addr = simple_strtoul(argv[1], NULL, 16);
407
408 printf("Authenticate OS container at 0x%lx\n", addr);
409
410 if (authenticate_os_container(addr))
411 return CMD_RET_FAILURE;
412
413 return CMD_RET_SUCCESS;
414}
415
416static void display_life_cycle(u32 lc)
417{
418 printf("Lifecycle: 0x%08X, ", lc);
419 switch (lc) {
420 case 0x1:
421 printf("BLANK\n\n");
422 break;
423 case 0x2:
424 printf("FAB\n\n");
425 break;
426 case 0x4:
427 printf("NXP Provisioned\n\n");
428 break;
429 case 0x8:
430 printf("OEM Open\n\n");
431 break;
Ye Li1c610742022-07-26 16:40:55 +0800432 case 0x20:
433 printf("OEM closed\n\n");
434 break;
435 case 0x40:
436 printf("Field Return OEM\n\n");
437 break;
438 case 0x80:
439 printf("Field Return NXP\n\n");
440 break;
441 case 0x100:
442 printf("OEM Locked\n\n");
443 break;
444 case 0x200:
445 printf("BRICKED\n\n");
446 break;
447 default:
448 printf("Unknown\n\n");
449 break;
450 }
451}
452
453static int confirm_close(void)
454{
455 puts("Warning: Please ensure your sample is in NXP closed state, "
456 "OEM SRK hash has been fused, \n"
457 " and you are able to boot a signed image successfully "
458 "without any SECO events reported.\n"
459 " If not, your sample will be unrecoverable.\n"
460 "\nReally perform this operation? <y/N>\n");
461
462 if (confirm_yesno())
463 return 1;
464
465 puts("Ahab close aborted\n");
466 return 0;
467}
468
469static int do_ahab_close(struct cmd_tbl *cmdtp, int flag, int argc,
470 char *const argv[])
471{
472 int err;
473 u32 resp;
Ye Li6579e522023-01-30 18:39:54 +0800474 u32 lc;
Ye Li1c610742022-07-26 16:40:55 +0800475
476 if (!confirm_close())
477 return -EACCES;
478
Ye Li6579e522023-01-30 18:39:54 +0800479 lc = readl(FSB_BASE_ADDR + 0x41c);
480 lc &= 0x3ff;
481
482 if (lc != 0x8) {
483 puts("Current lifecycle is NOT OEM open, can't move to OEM closed\n");
484 display_life_cycle(lc);
485 return -EPERM;
486 }
487
Ye Li1c610742022-07-26 16:40:55 +0800488 err = ahab_forward_lifecycle(8, &resp);
489 if (err != 0) {
490 printf("Error in forward lifecycle to OEM closed\n");
491 return -EIO;
492 }
493
494 printf("Change to OEM closed successfully\n");
495
496 return 0;
497}
498
499int ahab_dump(void)
500{
501 u32 buffer[32];
502 int ret, i = 0;
503
504 do {
505 ret = ahab_dump_buffer(buffer, 32);
506 if (ret < 0) {
507 printf("Error in dump AHAB log\n");
508 return -EIO;
509 }
510
511 if (ret == 1)
512 break;
513 for (i = 0; i < ret; i++)
514 printf("0x%x\n", buffer[i]);
515 } while (ret >= 21);
516
517 return 0;
518}
519
520static int do_ahab_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
521{
522 return ahab_dump();
523}
524
Ye Lic9e34362023-01-30 18:39:51 +0800525static void display_event(u32 event)
526{
527 printf("\n\t0x%08x\n", event);
528 printf("\t%s", ele_ipc_str[get_idx(ele_ipc,
529 (event >> 24) & 0xFF, ARRAY_SIZE(ele_ipc))]);
530 printf("\t%s", ele_cmd_str[get_idx(ele_cmd,
531 (event >> 16) & 0xFF, ARRAY_SIZE(ele_cmd))]);
532 printf("\t%s", ele_ind_str[get_idx(ele_ind,
533 (event >> 8) & 0xFF, ARRAY_SIZE(ele_ind))]);
534 printf("\t%s", ele_status_str[get_idx(ele_status,
535 event & 0xFF, ARRAY_SIZE(ele_status))]);
536}
537
Ye Li1c610742022-07-26 16:40:55 +0800538static int do_ahab_status(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
539{
Ye Lic9e34362023-01-30 18:39:51 +0800540 u32 lc, i;
541 u32 events[AHAB_MAX_EVENTS];
542 u32 cnt = AHAB_MAX_EVENTS;
543 int ret;
Ye Li1c610742022-07-26 16:40:55 +0800544
545 lc = readl(FSB_BASE_ADDR + 0x41c);
546 lc &= 0x3ff;
547
548 display_life_cycle(lc);
Ye Lic9e34362023-01-30 18:39:51 +0800549
550 ret = ahab_get_events(events, &cnt, NULL);
551 if (ret) {
552 printf("Get ELE EVENTS error %d\n", ret);
553 return CMD_RET_FAILURE;
554 }
555
556 if (!cnt) {
557 puts("\n\tNo Events Found!\n");
558 return 0;
559 }
560
561 for (i = 0; i < cnt; i++)
562 display_event(events[i]);
563
Ye Li1c610742022-07-26 16:40:55 +0800564 return 0;
565}
566
567U_BOOT_CMD(auth_cntr, CONFIG_SYS_MAXARGS, 1, do_authenticate,
568 "autenticate OS container via AHAB",
569 "addr\n"
570 "addr - OS container hex address\n"
571);
572
573U_BOOT_CMD(ahab_close, CONFIG_SYS_MAXARGS, 1, do_ahab_close,
574 "Change AHAB lifecycle to OEM closed",
575 ""
576);
577
578U_BOOT_CMD(ahab_dump, CONFIG_SYS_MAXARGS, 1, do_ahab_dump,
579 "Dump AHAB log for debug",
580 ""
581);
582
583U_BOOT_CMD(ahab_status, CONFIG_SYS_MAXARGS, 1, do_ahab_status,
584 "display AHAB lifecycle only",
585 ""
586);