FreeCalypso > hg > freecalypso-tools
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadtools/flprotreg.c Fri Jun 05 07:29:59 2020 +0000 @@ -0,0 +1,39 @@ +/* + * This module implements commands dealing with Intel flash protection + * register, which holds the IMEI on Compal phones. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdint.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include "flash.h" + +extern struct flash_bank_info flash_bank_info[2]; + +flashcmd_protreg(argc, argv, bank) + char **argv; +{ + struct flash_bank_info *bi; + uint16_t data[9]; + int rc; + + if (argc > 2) { + fprintf(stderr, "error: too many arguments\n"); + return(-1); + } + if (flash_detect(bank, 0) < 0) + return(-1); + bi = flash_bank_info + bank; + rc = bi->ops->read_prot_reg(bi, data); + if (rc) + return(rc); + printf("Lock word: %04X\n", data[0]); + printf("Factory words: %04X %04X %04X %04X\n", data[1], data[2], + data[3], data[4]); + printf("User words: %04X %04X %04X %04X\n", data[5], data[6], data[7], + data[8]); + return(0); +}