hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2021 Rockchip Electronics Co. Ltd.
 */
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <rktest.h>
 
/*
 * You can enable or disable the OTP test functions here.
 * BE CAUTION:
 * OTP means One Time Programmable Memory.
 * You can read OTP memory many times, but you can only write it once.
 * The "otp_write" program will try to write one byte to OTP memory (offset 0).
 */
#ifndef OTP_TEST
#define OTP_TEST DISABLE
#endif
 
 
static const struct{
   const char *word;
   enum_func main_cmd;
} keyword[] = {
   {"transfer_data",        TRANSFER_DATA},
   {"storage",            STORAGE},
   {"storage_speed",        STORAGE_SPEED},
   {"property",            PROPERTY},
   {"crypto_sha",            CRYPTO_SHA},
   {"crypto_aes",            CRYPTO_AES},
   {"crypto_rsa",            CRYPTO_RSA},
#if (OTP_TEST == ENABLE)
   {"otp_read",            OTP_READ},
   {"otp_write",            OTP_WRITE},
   {"otp_size",            OTP_SIZE},
#endif
   {"trng",            TRNG_READ},
   {NULL,                TEST_NULL},
};
 
 
static void printf_main_cmd(void)
{
   printf("Please entry one correct parameter when excuting the app!\n");
   printf("The correct parameters list:\n");
   for (int i = 0; keyword[i].word; i++)
       printf("    %s\n", keyword[i].word);
}
 
static enum_func config_main_cmd(const char *cp)
{
   for (int i = 0; keyword[i].word; i++)
       if (strcasecmp(cp, keyword[i].word) == 0)
           return keyword[i].main_cmd;
 
   printf_main_cmd();
   return TEST_NULL;
}
 
int main(int argc, char *argv[])
{
   uint32_t invokeCommand = TEST_NULL;
 
   if (argc != 2) {
       printf_main_cmd();
       return 0;
   }
 
   invokeCommand = config_main_cmd(argv[1]);
   return rk_test(invokeCommand);
}