3 @@ -208,6 +208,58 @@ static int pstore_set(struct cmd_tbl *cm
7 + * pstore_check() - Check for pstore records
8 + * @cmdtp: Command data struct pointer
9 + * @flag: Command flag
10 + * @argc: Command-line argument count
11 + * @argv: Array of command-line arguments
13 + * Return: 0 if there are records in pstore, 1 otherwise
15 +static int pstore_check(struct cmd_tbl *cmdtp, int flag, int argc,
16 + char * const argv[])
24 + if (pstore_length == 0) {
25 + printf("Please set PStore configuration\n");
26 + return CMD_RET_USAGE;
29 + if (buffer_size == 0)
30 + pstore_init_buffer_size();
32 + buffer = malloc_cache_aligned(buffer_size);
35 + phys_addr_t ptr_end = ptr + pstore_length - pstore_pmsg_size
36 + - pstore_ftrace_size - pstore_console_size;
38 + while (ptr < ptr_end) {
39 + size = pstore_get_buffer(PERSISTENT_RAM_SIG, ptr,
40 + pstore_record_size, buffer);
41 + ptr += pstore_record_size;
46 + header_len = pstore_read_kmsg_hdr(buffer, &compressed);
47 + if (header_len == 0)
59 * pstore_print_buffer() - Print buffer
61 * @buffer: buffer to print
62 @@ -459,6 +511,7 @@ static int pstore_save(struct cmd_tbl *c
64 static struct cmd_tbl cmd_pstore_sub[] = {
65 U_BOOT_CMD_MKENT(set, 8, 0, pstore_set, "", ""),
66 + U_BOOT_CMD_MKENT(check, 1, 0, pstore_check, "", ""),
67 U_BOOT_CMD_MKENT(display, 3, 0, pstore_display, "", ""),
68 U_BOOT_CMD_MKENT(save, 4, 0, pstore_save, "", ""),
70 @@ -560,6 +613,8 @@ U_BOOT_CMD(pstore, 10, 0, do_pstore,
71 " 'pmsg-size' is the size of the user space logs record.\n"
72 " 'ecc-size' enables/disables ECC support and specifies ECC buffer size in\n"
73 " bytes (0 disables it, 1 is a special value, means 16 bytes ECC).\n"
75 + "- Returns true if there are records in pstore.\n"
76 "pstore display [record-type] [nb]\n"
77 "- Display existing records in pstore reserved memory. A 'record-type' can\n"
78 " be given to only display records of this kind. 'record-type' can be one\n"