forked from Spritetm/hadbadge2019_fpgasoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decode_status_reg.c
71 lines (70 loc) · 2.31 KB
/
decode_status_reg.c
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
/*
* Copyright 2019 Jeroen Domburg <[email protected]>
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the software. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
int main(int argc, char **argv) {
int r=strtol(argv[1], NULL, 0);
printf("%x:\n", r);
if (r&(1<<0)) printf("Transparent mode\n");
int cfg=(r>>1)&7;
printf("Config: ");
if (cfg==0) {
printf("SRAM\n");
} else if (cfg==1) {
printf("SRAM\n");
} else {
printf("Unknown!\n");
}
if (r&(1<<4)) printf("JTAG active\n");
if (r&(1<<5)) printf("PWD protected\n");
if (r&(1<<7)) printf("Decrypt enable\n");
if (r&(1<<8)) printf("DONE bit set\n");
if (r&(1<<9)) printf("ISC enable\n");
if (r&(1<<10)) printf("Write enable\n");
if (r&(1<<11)) printf("Read enable\n");
if (r&(1<<12)) printf("Busy\n");
if (r&(1<<13)) printf("Fail\n");
if (r&(1<<14)) printf("FEA OTP\n");
if (r&(1<<15)) printf("Decrypt only\n");
if (r&(1<<16)) printf("PWD enable\n");
if (r&(1<<20)) printf("Encrypt preamble\n");
if (r&(1<<21)) printf("Std preamble\n");
if (r&(1<<22)) printf("SPIm fail 1\n");
printf("BSE error:");
int bse=(r>>23)&7;
if (bse==0) {
printf("No error\n");
} else if (bse==1) {
printf("ID error\n");
} else if (bse==2) {
printf("Illegal cmd\n");
} else if (bse==3) {
printf("CRC error\n");
} else if (bse==4) {
printf("Preamble error\n");
} else if (bse==5) {
printf("User aborted configuration\n");
} else if (bse==6) {
printf("Data overflow error\n");
} else if (bse==7) {
printf("Bitstream > size of sram error\n");
}
if (r&(1<<26)) printf("Execution error\n");
if (r&(1<<27)) printf("ID error\n");
if (r&(1<<28)) printf("Invalid command\n");
if (r&(1<<29)) printf("SED error\n");
if (r&(1<<30)) printf("Device is in bypass mode\n");
if (r&(1<<31)) printf("Device is in flow-through mode\n");
}