FreeCalypso > hg > freecalypso-tools
comparison loadtools/flprotreg.c @ 712:a167d7b376b7
fc-loadtool code: flprotreg.c factored out
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 05 Jun 2020 07:29:59 +0000 |
parents | |
children | cf7bd5e705ed |
comparison
equal
deleted
inserted
replaced
711:44cdfc4fed4c | 712:a167d7b376b7 |
---|---|
1 /* | |
2 * This module implements commands dealing with Intel flash protection | |
3 * register, which holds the IMEI on Compal phones. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include <stdint.h> | |
9 #include <string.h> | |
10 #include <strings.h> | |
11 #include <stdlib.h> | |
12 #include "flash.h" | |
13 | |
14 extern struct flash_bank_info flash_bank_info[2]; | |
15 | |
16 flashcmd_protreg(argc, argv, bank) | |
17 char **argv; | |
18 { | |
19 struct flash_bank_info *bi; | |
20 uint16_t data[9]; | |
21 int rc; | |
22 | |
23 if (argc > 2) { | |
24 fprintf(stderr, "error: too many arguments\n"); | |
25 return(-1); | |
26 } | |
27 if (flash_detect(bank, 0) < 0) | |
28 return(-1); | |
29 bi = flash_bank_info + bank; | |
30 rc = bi->ops->read_prot_reg(bi, data); | |
31 if (rc) | |
32 return(rc); | |
33 printf("Lock word: %04X\n", data[0]); | |
34 printf("Factory words: %04X %04X %04X %04X\n", data[1], data[2], | |
35 data[3], data[4]); | |
36 printf("User words: %04X %04X %04X %04X\n", data[5], data[6], data[7], | |
37 data[8]); | |
38 return(0); | |
39 } |