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