blob: 1bada461dbccbf1137ed03cae5cded889d4cfd4f [file] [log] [blame]
you.chen21458442023-08-21 17:48:27 +08001#include <stdio.h>
2#include "lynq_misc.h"
3#include "log/log.h"
4
5#undef LOG_TAG
6#define LOG_TAG "MISC"
7
8int lynq_get_security_boot_flag(int * enabled_flag)
9{
10 int value, ret;
11 if (enabled_flag == NULL)
12 {
13 RLOGE("input param is null ptr");
14 return -1;
15 }
16 *enabled_flag = 0;
17 FILE *pfile=fopen("/proc/device-tree/chosen/atag,devinfo", "r");
18 if (pfile == NULL)
19 {
20 RLOGE("open devinfo fail");
21 return -1;
22 }
23 ret = fseek(pfile, 0x428, 0);
24 if (ret != 0)
25 {
26 RLOGE("seek file fail");
27 fclose(pfile);
28 return -1;
29 }
30 ret = fread(&value, sizeof (value), 1, pfile);
31 if (ret != 1)
32 {
33 RLOGE("read file fail");
34 fclose(pfile);
35 return -1;
36 }
37 fclose(pfile);
38
39 // the third bit of 32bits at 0x428 (big endian?), 1 for enabled, 0 not enabled
40 *enabled_flag = (value & 0x20) == 0 ? 0 : 1;
41 return 0;
42}