blob: 5cad0b59cea9e4045b0725d2674872c66e934074 [file] [log] [blame]
Channagoud Kadabi736c4962015-08-21 11:56:52 -07001/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
2
3Redistribution and use in source and binary forms, with or without
4modification, are permitted provided that the following conditions are
5met:
6 * Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8 * Redistributions in binary form must reproduce the above
9 copyright notice, this list of conditions and the following
10 disclaimer in the documentation and/or other materials provided
11 with the distribution.
12 * Neither the name of The Linux Foundation nor the names of its
13 contributors may be used to endorse or promote products derived
14 from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29
30#include <stdlib.h>
31#include <debug.h>
32#include "devinfo.h"
33#include "fastboot.h"
34#include "fastboot_test.h"
35#include <app/tests.h>
Sridhar Parasuram890f5922015-09-28 15:43:57 -070036#include <target.h>
37#include <boot_device.h>
Channagoud Kadabi736c4962015-08-21 11:56:52 -070038#if USE_RPMB_FOR_DEVINFO
39#include <rpmb.h>
40#endif
41/* main function that calls into the tests */
42
43extern void ramdump_table_map();
44extern void kauth_test();
Sridhar Parasuram890f5922015-09-28 15:43:57 -070045extern int ufs_get_boot_lun();
46extern int ufs_set_boot_lun(uint32_t bootlunid);
47extern int fastboot_init();
Channagoud Kadabi736c4962015-08-21 11:56:52 -070048
49void cmd_oem_runtests()
50{
51 dprintf(INFO, "Running LK tests ... \n");
Sridhar Parasuram890f5922015-09-28 15:43:57 -070052
53 // Test boot lun enable for UFS
54 if (!platform_boot_dev_isemmc())
55 {
56 int ret = 0;
57 uint32_t set_lun = 0x2, get_lun;
58 ret = ufs_set_boot_lun(set_lun);
59 if (ret == UFS_SUCCESS)
60 {
61 get_lun = ufs_get_boot_lun();
62 if (get_lun == set_lun)
63 {
64 dprintf(INFO, "UFS Boot LUN En TEST: [ PASS ]\n");
65 set_lun = 0x1; // default is 0x1 LUN A, revert back to 0x1
66 ret = ufs_set_boot_lun(set_lun);
67 }
68 else
69 dprintf(INFO, "UFS Boot LUN En TEST: [ FAIL ]\n");
70 }
71 else
72 dprintf(INFO, "UFS Boot LUN En TEST: [ FAIL ]\n");
73 }
74
75
Channagoud Kadabi736c4962015-08-21 11:56:52 -070076#if LPAE
77 ramdump_table_map();
78#endif
79
80#if USE_RPMB_FOR_DEVINFO
81 dprintf(INFO, "Running RPMB test case, please make sure RPMB key is provisioned ...\n");
82 struct device_info *write_info = memalign(PAGE_SIZE, 4096);
83 struct device_info *read_info = memalign(PAGE_SIZE, 4096);
84 if((read_device_info_rpmb((void*) read_info, PAGE_SIZE)) < 0)
85 dprintf(INFO, "RPMB READ TEST : [ FAIL ]\n");
86
87 write_info->is_unlocked = !read_info->is_unlocked;
88
89 if((write_device_info_rpmb((void*) write_info, PAGE_SIZE)) < 0)
90 dprintf(INFO, "RPMB WRITE TEST : [ FAIL ]\n");
91
92 if((read_device_info_rpmb((void*) read_info, PAGE_SIZE)) < 0)
93 dprintf(INFO, "RPMB READ TEST : [ FAIL ]\n");
94
95 if (read_info->is_unlocked == write_info->is_unlocked)
96 dprintf(INFO, "RPMB READ/WRITE TEST: [ PASS ]\n");
97 else
98 dprintf(INFO, "RPMB READ/WRITE TEST: [ FAIL ]\n");
99
100 free(read_info);
101 free(write_info);
102#endif
103
104#if VERIFIED_BOOT
105 if (!boot_linux_from_mmc())
106 dprintf(INFO, "Verifid Boot authentication test: [ PASS ]\n");
107 else
108 dprintf(INFO, "Verifid Boot authentication test: [ FAIL ]\n");
109
110 kauth_test();
111#endif
112
113 if (!thread_tests())
114 dprintf(INFO, "Thread Test: [ PASS ]\n");
115 else
116 dprintf(INFO, "Thread Test: [ FAIL ]\n");
117
118 printf_tests();
119
120 fastboot_okay("");
121}