changeset 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 44cdfc4fed4c
children cf7bd5e705ed
files loadtools/Makefile loadtools/flmisc.c loadtools/flprotreg.c
diffstat 3 files changed, 42 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/Makefile	Fri Jun 05 06:46:21 2020 +0000
+++ b/loadtools/Makefile	Fri Jun 05 07:29:59 2020 +0000
@@ -16,9 +16,9 @@
 
 LOADTOOL_OBJS=	compalload.o crc32tab.o defpath.o flashid.o flashops.o \
 		flcmplboot.o flconf.o fldevs.o flerase.o flmain.o flmisc.o \
-		flprogbin.o flprogsrec.o flutil.o hexdecode.o hwparam.o \
-		labaud.o lacrc32.o ltdispatch.o ltdump.o ltexit.o lthelp.o \
-		ltmain.o ltmisc.o ltpassthru.o ltscript.o romload.o \
+		flprogbin.o flprogsrec.o flprotreg.o flutil.o hexdecode.o \
+		hwparam.o labaud.o lacrc32.o ltdispatch.o ltdump.o ltexit.o \
+		lthelp.o ltmain.o ltmisc.o ltpassthru.o ltscript.o romload.o \
 		srecreader.o tpinterf.o tpinterf2.o tpinterf3.o tpinterfb.o
 
 XRAM_OBJS=	chainload.o clmain.o compalload.o crc32tab.o defexitstub.o \
--- a/loadtools/flmisc.c	Fri Jun 05 06:46:21 2020 +0000
+++ b/loadtools/flmisc.c	Fri Jun 05 07:29:59 2020 +0000
@@ -121,31 +121,6 @@
 				format);
 }
 
-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);
-}
-
 flashcmd_quickprog(argc, argv, bank)
 	char **argv;
 {
--- /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);
+}