Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | /* |
| 3 | * Copyright (c) 2022, Linaro Limited |
| 4 | */ |
| 5 | |
| 6 | #include <command.h> |
| 7 | #include <dm.h> |
| 8 | #include <fwu.h> |
| 9 | #include <fwu_mdata.h> |
| 10 | #include <log.h> |
| 11 | #include <stdio.h> |
| 12 | #include <stdlib.h> |
| 13 | |
| 14 | #include <linux/types.h> |
| 15 | |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 16 | static void print_mdata(struct fwu_data *data) |
Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 17 | { |
| 18 | int i, j; |
| 19 | struct fwu_image_entry *img_entry; |
| 20 | struct fwu_image_bank_info *img_info; |
| 21 | |
| 22 | printf("\tFWU Metadata\n"); |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 23 | printf("crc32: %#x\n", data->crc32); |
| 24 | printf("version: %#x\n", data->version); |
Michal Simek | d8d53db | 2024-06-05 16:58:27 +0200 | [diff] [blame] | 25 | printf("size: %#x\n", data->metadata_size); |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 26 | printf("active_index: %#x\n", data->active_index); |
| 27 | printf("previous_active_index: %#x\n", data->previous_active_index); |
| 28 | |
| 29 | if (data->version == 2) { |
| 30 | for (i = 0; i < 4; i++) |
| 31 | printf("bank_state[%d]: %#x\n", |
| 32 | i, data->bank_state[i]); |
| 33 | } |
Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 34 | |
| 35 | printf("\tImage Info\n"); |
| 36 | for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) { |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 37 | img_entry = &data->fwu_images[i]; |
Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 38 | printf("\nImage Type Guid: %pUL\n", |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 39 | &img_entry->image_type_guid); |
| 40 | printf("Location Guid: %pUL\n", &img_entry->location_guid); |
Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 41 | for (j = 0; j < CONFIG_FWU_NUM_BANKS; j++) { |
| 42 | img_info = &img_entry->img_bank_info[j]; |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 43 | printf("Image Guid: %pUL\n", &img_info->image_guid); |
Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 44 | printf("Image Acceptance: %s\n", |
| 45 | img_info->accepted == 0x1 ? "yes" : "no"); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag, |
| 51 | int argc, char * const argv[]) |
| 52 | { |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 53 | struct fwu_data *data = fwu_get_data(); |
Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 54 | |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 55 | print_mdata(data); |
Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 56 | |
Sughosh Ganu | 90ec245 | 2024-03-22 16:27:27 +0530 | [diff] [blame] | 57 | return CMD_RET_SUCCESS; |
Sughosh Ganu | 0f951fd | 2022-10-21 18:16:04 +0530 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | U_BOOT_CMD( |
| 61 | fwu_mdata_read, 1, 1, do_fwu_mdata_read, |
| 62 | "Read and print FWU metadata", |
| 63 | "" |
| 64 | ); |