FreeCalypso > hg > freecalypso-sw
annotate loadtools/flcmplboot.c @ 413:1ed2d78f150c
loadtools: boot-reflash-hack hwparam setting hooked in
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 17 Jun 2014 05:11:25 +0000 |
parents | bf49e348576b |
children | a2df77833c21 |
rev | line source |
---|---|
412
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This module contains the implementation of the flash erase-program-boot |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * hack for brickable Compal phones. |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/types.h> |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <ctype.h> |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdio.h> |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdint.h> |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <string.h> |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include <strings.h> |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include <stdlib.h> |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "flash.h" |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 static int hack_enabled; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 static uint32_t boot_sector_size; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 static uint32_t ram_buffer_addr; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 /* called from hwparam.c config file parser */ |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 void |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 set_boot_reflash_hack(arg, filename_for_errs, lineno_for_errs) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 char *arg; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 char *filename_for_errs; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 int lineno_for_errs; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 { |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 char *cp, *np, *ep; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 if (hack_enabled) { |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 fprintf(stderr, |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 "%s line %d: duplicate boot-reflash-hack setting\n", |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 filename_for_errs, lineno_for_errs); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 exit(1); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 for (cp = arg; isspace(*cp); cp++) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 ; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 if (!*cp || *cp == '#') { |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 too_few_arg: fprintf(stderr, |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 "%s line %d: boot-reflash-hack setting: too few arguments\n", |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 filename_for_errs, lineno_for_errs); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 exit(1); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 } |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 for (np = cp; *cp && !isspace(*cp); cp++) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 ; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 if (!*cp) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 goto too_few_arg; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 *cp++ = '\0'; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 ram_buffer_addr = strtoul(np, &ep, 16); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 if (*ep) { |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 invhex: fprintf(stderr, |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 "%s line %d: syntax error (hex arguments expected)\n", |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 filename_for_errs, lineno_for_errs); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 exit(1); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 while (isspace(*cp)) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 cp++; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 if (!*cp || *cp == '#') |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 goto too_few_arg; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 for (np = cp; *cp && !isspace(*cp); cp++) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 ; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 if (*cp) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 *cp++ = '\0'; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 boot_sector_size = strtoul(np, &ep, 16); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 if (*ep) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 goto invhex; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 while (isspace(*cp)) |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 cp++; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 if (*cp && *cp != '#') { |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 fprintf(stderr, |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 "%s line %d: boot-reflash-hack setting: too many arguments\n", |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 filename_for_errs, lineno_for_errs); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 exit(1); |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 } |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 hack_enabled = 1; |
bf49e348576b
fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 } |