FreeCalypso > hg > freecalypso-reveng
annotate fluid-mnf/machine.c @ 381:ca75ac283888
compal/audio: analysis of handheld mode omr readouts
made by Das Signal
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 09 Nov 2021 18:49:09 +0000 |
parents | b4fb0c7dfdf4 |
children |
rev | line source |
---|---|
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * FLUID (Flash Loader Utility Independent of Device) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * Copyright Texas Instruments, 2001. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Mads Meisner-Jensen, mmj@ti.com. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * Original state-machine logic by Delta Technologies, Copyright, 2001. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * Core functionality. State machines and support functions. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * $Id: machine.c 1.35.1.37 Mon, 28 Apr 2003 08:49:16 +0200 tsj $ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "fluid.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "flash.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "target.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "fileio.h" |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
18 #include "protocol.h" |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "misc.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "lz.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "trace.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 // Secure Calypso Plus |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
23 #include "calplus/ram_load.h" |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
24 #include "calplus/secure_types.h" |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #include <stdio.h> |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 #include <malloc.h> |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include <stdlib.h> |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include <string.h> |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 * Constants and typedefs |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 // Due to memory wrap/mirror used in flash_read_machine(), IMAGE_SIZE_MAX |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 // *must* be a power of two. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 #define IMAGE_SIZE_MAX (8 * 1024 * 1024) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 #define IMAGE_CHUNK_SIZE 8192 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 #define ERASE_LIST_SIZE_MAX 256 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 #define SECTOR_MAP_SIZE_MAX 256 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 #define TARGET_PROGRAM_SIZE_MAX (8 * 1024) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 #define READ_LIST_SIZE_MAX 40 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 #define RETRIES_MAX 30 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 // Default target receive delay in milli-seconds. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 #define TARGET_RECV_DELAY 250 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 #define TARGET_RECV_LONG_DELAY 1000 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 // Default target reset delay in milli-seconds. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 #define TARGET_RESET_DELAY 200 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 // CS_MODE 0: Flash at 0x04000000 @ CS5 on E-Sample |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 #define CALP_OFFSET 0x04000000 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * Globals |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 T_RAM_LOADER d_ram_loader; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 T_FRAME d_frame; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 UWORD16 d_certificate_length = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 char a_certified_cmd_file_name[] = "cmdp_cert.m0"; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 struct target_s { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 uint32 cmd_load_addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 uint32 method_load_addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 const char type; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 const char *name; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 const char *prefix; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 }; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 // Note that the ROM bootloader of Calypso rev. A devices are unable to |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 // write the bottom 128kB of internal RAM. Therefore the address have been |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 // changed from 0x804000 to 0x0820000 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 const struct target_s target[] = |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 { 0x0000000, 0x0000000, 'u', "Unknown", "oops" }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 { 0x0000000, 0x0000000, 'u', "Unknown1", "oops1" }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 { 0x0000000, 0x0000000, 'G', "Gemini?", "gem?" }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 { 0x3004000, 0x3000000, 'U', "Ulysses", "uly" }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 { 0x0820000, 0x0800000, 'C', "Calypso", "cal" }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 { 0x0804000, 0x0800000, 'c', "Calypso Lite", "cal_l" }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 { 0x8020000, 0x8000100, 'P', "Calypso Plus", "cal_p" } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 }; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 int target_type; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 int target_clk; // 13000000 or 14745600 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 struct device_s *device; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 uint8 target_program[TARGET_PROGRAM_SIZE_MAX]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 int target_program_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 int target_fifo_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 uint8 image[IMAGE_SIZE_MAX]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 int image_size; // size of image buffer |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 int image_chunk_size; // number of bytes in each chunk |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 int image_size_in_chunks; // size of image buffer in chunks |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 // Each byte in the image_map represents one chunk of the image. Each byte |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 // can have one of the following values: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 // '\0' = no data in this chunk |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 // 's' = skip this chunk when programming |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 // 'c' = chunk checksum ok, skip this chunk when programming |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 // 'x' = used |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 uint8 image_map[IMAGE_SIZE_MAX / IMAGE_CHUNK_SIZE]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 int image_map_size; // number of entries in image_map |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 // Each byte in the sector_map represents one sector. Each byte can have one |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 // of the following values: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 // '\0' = sector unused (don't erase) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 // 'c' = sector already empty/erased (don't erase) (not used) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 // 's' = skip this sector when erasing (due to erase override) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 // 'X' = force erase this sector (due to erase override) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 // 'x' = erase this sector (normal case --- sector is covered by image) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 int sector_map[SECTOR_MAP_SIZE_MAX]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 int sector_map_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 int erase_list[ERASE_LIST_SIZE_MAX]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 int erase_list_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 struct image_part_s read_list[READ_LIST_SIZE_MAX]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 int read_list_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 int read_total_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 int image_map_count_used_chunks(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 int image_map_update(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 int sector_map_init(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 void image_map_show(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 void sector_map_show(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 void target_timers_show(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 void parse_arg_erase_override(char *p); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 void parse_arg_read(char *p); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 void parse_arg_write(char *p); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 void error_proto(char ch, char ch_expected); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 int target_type_set(uint16 code); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 void f_print_signalling_response(int level); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 void f_print_certificate_platform_data(int level, T_MANUFACTURER_CERTIFICATE_PLATFORM_DATA *p_certificate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 void f_print_certificate(int level, T_MANUFACTURER_CERTIFICATE_FLASH_PROGRAMMER *p_certificate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 void f_print_parameter_nack_status(int level, UWORD8 d_parameter_nack_sts); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 void f_print_write_nack_status(int level, UWORD8 d_write_nack_sts); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 UWORD8 f_convert_uart_baud_rate(UWORD32 d_baud_rate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 void target_imei_protection(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 * Main |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 void bootloader_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 void cmd_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 void flash_checksum_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 void flash_detect_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 void method_download_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 void flash_program_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 void flash_read_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 void target_reset_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 void fluid_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 int error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 |
353
3aecf9bc1bf3
fluid-mnf/machine.c: bogus reset code removed
Mychaela Falconia <falcon@freecalypso.org>
parents:
348
diff
changeset
|
172 /* |
3aecf9bc1bf3
fluid-mnf/machine.c: bogus reset code removed
Mychaela Falconia <falcon@freecalypso.org>
parents:
348
diff
changeset
|
173 * MNF change: the following reset-by-pin-wiggling code has been |
3aecf9bc1bf3
fluid-mnf/machine.c: bogus reset code removed
Mychaela Falconia <falcon@freecalypso.org>
parents:
348
diff
changeset
|
174 * removed because it was already broken in TI's original version: |
3aecf9bc1bf3
fluid-mnf/machine.c: bogus reset code removed
Mychaela Falconia <falcon@freecalypso.org>
parents:
348
diff
changeset
|
175 * because it runs before the serial port is opened, it cannot |
3aecf9bc1bf3
fluid-mnf/machine.c: bogus reset code removed
Mychaela Falconia <falcon@freecalypso.org>
parents:
348
diff
changeset
|
176 * possibly ever work. |
3aecf9bc1bf3
fluid-mnf/machine.c: bogus reset code removed
Mychaela Falconia <falcon@freecalypso.org>
parents:
348
diff
changeset
|
177 */ |
3aecf9bc1bf3
fluid-mnf/machine.c: bogus reset code removed
Mychaela Falconia <falcon@freecalypso.org>
parents:
348
diff
changeset
|
178 #if 0 |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 // If user has specifically asked fluid just to reset the target, we do |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 // that and only that! This way, we can use fluid just to reset the |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 // target without doing anything else! |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 if (arg_target_reset == 2 && arg_dry_run) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 flowf(VERBOSE, "Resetting target: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 target_reset(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 target_wait(0, TARGET_RESET_DELAY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 target_reset(1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 flowf(VERBOSE, "ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 } |
353
3aecf9bc1bf3
fluid-mnf/machine.c: bogus reset code removed
Mychaela Falconia <falcon@freecalypso.org>
parents:
348
diff
changeset
|
189 #endif |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 file_read_devices("devices.txt"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 if (arg_list_devices) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 devices_list(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 exit(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 image_size = IMAGE_SIZE_MAX; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 image_chunk_size = IMAGE_CHUNK_SIZE; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 image_map_size = IMAGE_SIZE_MAX / image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 image_size_in_chunks = |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 (image_size + image_chunk_size - 1) / image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 // Read the flash image file(s) unless user wants to read from the flash |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 if (*arg_read == 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 file_read_image(image, IMAGE_SIZE_MAX, image_map, image_chunk_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 // Optionally overwrite image with values given on the command-line |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 parse_arg_write(arg_write); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 if (arg_image_map_show) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 image_map_show(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 |
348
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
340
diff
changeset
|
215 if ((error = target_driver_init(arg_uart_ttyport, 115200)) < 0) |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 if (target_type_set(arg_target_type) != 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 flowf(VERBOSE, "Target type '%s' selected.\n", target[target_type].name); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 // Conditionally disable tracing |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 if (arg_debug_trace_pe) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 tr_enable(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 if (arg_debug_resume) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 // If resuming in command interpreter, we should set the baudrate |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 // because we do not pass through the code that normally sets it. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 if ((error = target_driver_baudrate(arg_uart_baudrate)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 bootloader_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 cmd_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 if (*arg_read != 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 parse_arg_read(arg_read); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 flash_read_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 file_write_image(image, image_size, read_list); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 if (arg_checksum) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 flash_checksum_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 flash_detect_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 if (!arg_debug_resume) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 method_download_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 tr_enable(1); // Ensure full tracing is on |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 flash_program_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 if (*arg_imeisv && *arg_platform_certificate_addr) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 target_imei_protection(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 if (arg_timers_show) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 target_timers_show(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 if (arg_target_reset == 1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 target_reset_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 * Bootloader (TI Target Monitor) Access |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 // Invoke the Fluid bootloader embedded in the TI bootloader/target-monitor |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 // code. The command to enter the loader is 0xAA 0x01 0xDD, which must be |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 // received by the phone within 50ms from reset. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 int bootloader_is_rom; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 int bootloader_is_secure_rom; // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 int bootloader_blocksize_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 void bootloader_fluid_init(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 void bootloader_rom_init(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 void bootloader_secure_rom_init(void); // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 void bootloader_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 // FIXME: why do we have to send an additional char (0) ? |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 uint8 sendbuf_rom[3] = { '<', 'i', 0x0 }; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 uint8 sendbuf_fluid[3] = { 0xAA, 0x01, 0xDD }; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 int i, error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 char ch1, ch2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 UWORD16 d_j; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 target_trace_enable(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 flowf(NORMAL, "Bootloader: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 // Wait a short while with power removed, then flush receive buffer. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 target_power(1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 target_reset(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 target_wait(0, TARGET_RESET_DELAY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 target_reset(1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 target_recv_reset(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 // Continuously send Fluid Bootloader escape sequence until we get an |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 // acknowledgement. Note that we have to establish contact within 50ms |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 // from reset, otherwise we lose our chance! Note that we actually wait |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 // up to 500ms because the target may take some time to reset. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 i = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 flowf(DEBUG, "(ROM/fluid-delay = %d/%d, ", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 arg_boot_delay_rom, arg_boot_delay_fluid); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 switch (arg_rom_bootloader) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 case -1: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 if ((error = target_driver_baudrate(115200)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 case +1: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 if ((error = target_driver_baudrate(19200)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 while (1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 target_recv_reset(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 // If we are allowed to try fluid bootloader... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 if (arg_rom_bootloader != +1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 // If we should ONLY try fluid bootloader... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 flowf(DEBUG, "F"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 if (arg_rom_bootloader == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 if ((error = target_driver_baudrate(115200)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 target_send(sendbuf_fluid, 3); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 if (target_wait(1, arg_boot_delay_fluid) > 0 && |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 target_getchar() == PROTO_HELLO) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 bootloader_is_rom = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 bootloader_is_secure_rom = 0; // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 // If we are allowed to try ROM bootloader... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 if (arg_rom_bootloader != -1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 flowf(DEBUG, "R"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 if (arg_rom_bootloader == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 if ((error = target_driver_baudrate(19200)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 target_send(sendbuf_rom, 3); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 if (target_wait(1, arg_boot_delay_rom) >= 1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 ch1 = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 if (ch1 == '>') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 if (target_wait(1, arg_boot_delay_rom) >= 1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 ch2 = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 if (ch2 == 'i') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 bootloader_is_rom = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 if (target_wait(2, arg_boot_delay_rom) < 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 flowf(DEBUG, ", Non-secure boot ROM code"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 flowf(DEBUG, ", Secure Calypso Plus ROM)"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 ch1 = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 ch2 = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 d_ram_loader.d_romcode_version = (UWORD16)(ch1) & 0xFF; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 d_ram_loader.d_romcode_version |= ((UWORD16)(ch2 & 0xFF)) << 8; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 //d_ram_loader.d_romcode_version |= (((UWORD16)ch2) << 8) & 0xFF00; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 if (d_ram_loader.d_romcode_version == 0x0410 || d_ram_loader.d_romcode_version == 0x0411) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 bootloader_is_secure_rom = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 if (target_wait((C_WORD32LGB * C_MD5HASHLG), TARGET_RECV_DELAY) < (C_WORD32LGB * C_MD5HASHLG)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 for (d_j = 0 ; d_j < (C_WORD32LGB * C_MD5HASHLG) ; d_j++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 d_ram_loader.a_hash_man_pub_key[d_j] = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 if (target_wait((C_WORD32LGB * C_DIE_ID_SIZE), TARGET_RECV_DELAY) < (C_WORD32LGB * C_DIE_ID_SIZE)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 for (d_j = 0 ; d_j < (C_WORD32LGB * C_DIE_ID_SIZE) ; d_j++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 d_ram_loader.a_die_id[d_j] = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 // SIGNALLING RESPONSE |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 f_print_signalling_response(VERBOSE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 if (*arg_die_id_file_name != 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 if ((error = file_write_die_id(&d_ram_loader.a_die_id[0], arg_die_id_file_name)) < 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 flowf(NORMAL, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 flowf(NORMAL, "\nDie id retrieved and written to %s.\n", arg_die_id_file_name); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 exit(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 flowf(NORMAL, "\nSecure Calypso Plus ROM Code Version 0x%4.4x is not supported by FLUID.\n", d_ram_loader.d_romcode_version); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 main_fatal(E_BOOTLOADER); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 // End Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 flowf(DEBUG, "?"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 // If target is still not responding, we could not control the reset |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 // line, so we ask the user to reset the target |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 if (i++ == RETRIES_MAX) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 flowf (NORMAL, "(reset target) "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 if (!bootloader_is_secure_rom) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 flowf(DEBUG, ") "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 // Read the command interpreter image file. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 if (bootloader_is_secure_rom) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 target_program_size = file_read_cmd(target_program, TARGET_PROGRAM_SIZE_MAX, a_certified_cmd_file_name); |
362
b4fb0c7dfdf4
fluid-mnf: added -oC option to use cmd39.m0 for Calypso C05
Mychaela Falconia <falcon@freecalypso.org>
parents:
357
diff
changeset
|
414 else if (arg_calypso_c05) |
b4fb0c7dfdf4
fluid-mnf: added -oC option to use cmd39.m0 for Calypso C05
Mychaela Falconia <falcon@freecalypso.org>
parents:
357
diff
changeset
|
415 target_program_size = file_read_cmd(target_program, TARGET_PROGRAM_SIZE_MAX, "cmd39.m0"); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 target_program_size = file_read_cmd(target_program, TARGET_PROGRAM_SIZE_MAX, "cmd.m0"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 if (target_program_size == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 main_error(E_FILE_EMPTY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 if (bootloader_is_secure_rom) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 bootloader_secure_rom_init(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 else if (bootloader_is_rom) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 bootloader_rom_init(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 bootloader_fluid_init(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 flowf(NORMAL, ") ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 void bootloader_fluid_init(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 int divider; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 char version; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 uint8 data[4]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 uint16 chip_id_code; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 flowf(NORMAL, "(fluid"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 target_clk = 13000000; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 // Now send baudrate to make the target stop sending 'H'ello. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 divider = target_uart_baudrate_divider_get(target_clk, 115200); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 flowf(DEBUG, ", baudrate = "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 target_putchar(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 target_putchar((char) divider); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 flowf(DEBUG, "%d, ", 115200); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 // Wait a short while before flushing receive buffer. Then make sure |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 // that the target is indeed silent |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 target_wait(0, 10); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 target_recv_reset(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 if (target_wait(1, 50) > 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 main_fatal(E_RECV_ANTITIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 // NOTEME: The sequence below to query the Bootloader VERSION *has* to |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 // have 100ms + 100ms delays. It seems as unnecessarily large delays but |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 // practice shows that they cannot be shorter. To be investigated... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 // Get version of bootloader |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 target_putchar(PROTO_VERSION); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 if (target_wait(1, TARGET_RECV_DELAY) < 1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 version = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 flowf(NORMAL, ", version %c", version); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 // Bootloader revision 3 and upwards supports generic query |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 if (version < '3') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 main_fatal(E_BOOTLOADER); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 target_trace_enable(1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 target_putchar(PROTO_QUERY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 target_putchar(PROTO_QUERY_CHIP); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 if (target_wait(4, TARGET_RECV_DELAY) < 4) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 target_recv(data, 4); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 chip_id_code = data[0] + (data[1] << 8); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 if (target_type_set(chip_id_code) == 0 || arg_verbose >= VERBOSE) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 flowf(VERBOSE, ", chipid = 0x%04X", chip_id_code); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 if (target_type_set(chip_id_code) == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 main_fatal(E_TARGET_TYPE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 flowf(VERBOSE, ", %s", target[target_type].name); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 void bootloader_rom_init(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 int error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 char ch, version = '?'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 // Initialization: 115200 bps, 39 MHz DPLL, no timeout |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 uint8 sendbuf[11] = { '<', 'p', 0x00, 0x0D, 0x14, 0x25, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 0x22, 0x00, 0x00, 0x00, 0x00}; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 // Initialization: 115200 bps, 13 MHz DPLL, no timeout. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 //uint8 sendbuf[11] = { '<', 'p', 0x00, 0x00, 0x1C, 0xE7, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 // 0x22, 0x00, 0x00, 0x00, 0x00 }; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 flowf(NORMAL, "(ROM"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 // Configure/init the ROM bootloader |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 flowf(VERBOSE, ", baudrate = %d", 115200); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 target_send(sendbuf, 11); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 // Wait until DPLL is settled and target responds |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 if (target_wait(4, 300) < 4) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 if ((ch = target_getchar ()) != '>') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 error_proto(ch, '>'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 if ((ch = target_getchar ()) != 'p') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 error_proto(ch, 'p'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 // Receive maximum blocksize |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 bootloader_blocksize_max = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 bootloader_blocksize_max += target_getchar() << 8; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 bootloader_blocksize_max -= 10; // Subtract the block header |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 flowf(DEBUG, ", blocksize = %iB", bootloader_blocksize_max); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 if ((error = target_driver_baudrate (115200)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 flowf(NORMAL, ", version %c", version); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 // NOTEME: Can we be sure that it is always a Calypso type? |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 target_type_set('c'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 void bootloader_secure_rom_init(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 int error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 UWORD8 d_char; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 UWORD16 d_j; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 // cmdp_cert.m0 has been 16 bit aligned using hex470, so the memory width |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 // parameter is set to 2 bytes. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 buffer_endian_convert(target_program, target_program_size, 2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 // Check if firmware manufacturer certificate stored in flash is requested |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 if (arg_request_certificate) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 // Clear the request |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 arg_request_certificate = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 d_ram_loader.b_certificate_request = C_FALSE; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 // Certificate Request |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 d_frame.a_data[0] = '<'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 d_frame.a_data[1] = 'c'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 d_frame.d_max_byte = 2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 target_send(&d_frame.a_data[0], d_frame.d_max_byte); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 // Certificate Response |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 target_expect_char('>', arg_boot_delay_rom); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 target_expect_char('c', arg_boot_delay_rom); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 if (target_wait(2, TARGET_RECV_DELAY) < 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 d_ram_loader.u_firm_cert.a_firm_cert[0] = target_getchar (); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 d_ram_loader.u_firm_cert.a_firm_cert[1] = target_getchar (); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 d_certificate_length = (UWORD16)(d_ram_loader.u_firm_cert.a_firm_cert[0]) & 0xFF; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 d_certificate_length |= ((UWORD16)(d_ram_loader.u_firm_cert.a_firm_cert[1]) << 8) & 0xFF00; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 // We have already read two bytes of the certificate for the CERT_SIZE |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 // and the certificate signature is handled later. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 for (d_j = 2 ; d_j < d_certificate_length - (C_WORD32LGB * C_MANUF_SIG_SIZE); d_j++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 if (target_wait(1, arg_boot_delay_rom * 4) > 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 d_ram_loader.u_firm_cert.a_firm_cert[d_j] = target_getchar (); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 for (d_j = 0; d_j < (C_WORD32LGB * C_MANUF_SIG_SIZE); d_j++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 if (target_wait(1, arg_boot_delay_rom * 4) > 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 d_ram_loader.a_Certsig[d_j] = target_getchar (); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 d_ram_loader.u_firm_cert.a_firm_cert[d_j + sizeof(T_MANUFACTURER_CERTIFICATE_PLATFORM_DATA) - (C_WORD32LGB * C_MANUF_SIG_SIZE)] = d_ram_loader.a_Certsig[d_j]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 f_print_certificate_platform_data(NORMAL, &d_ram_loader.u_firm_cert.d_firm_cert); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 // Parameter Request |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 d_ram_loader.d_baud_rate = f_convert_uart_baud_rate(arg_uart_baudrate_during_cmd_download); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 d_ram_loader.d_uart_timeout = arg_uart_timeout_configuration; // TODO: Verify that MSB byte is sent in first position. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 d_frame.a_data[0] = '<'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 d_frame.a_data[1] = 'p'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 d_frame.a_data[2] = d_ram_loader.d_baud_rate; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 memcpy(&d_frame.a_data[3], &d_ram_loader.d_uart_timeout, sizeof(UWORD32)); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 d_frame.d_max_byte = 3 + sizeof(UWORD32); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 d_certificate_length = (UWORD16)(target_program[0]) & 0xFF; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 d_certificate_length |= ((UWORD16)(target_program[1]) & 0xFF) << 8; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 for (d_j = 0 ; d_j < d_certificate_length; d_j++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 d_ram_loader.u_code_certificate.a_code_certificate[d_j] = target_program[d_j]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 f_print_certificate(DEBUG, &d_ram_loader.u_code_certificate.d_code_certificate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 // Send the data |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 target_send(&d_frame.a_data[0], d_frame.d_max_byte); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 target_send(&target_program[0], d_certificate_length); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 // Parameter Response |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 if (target_wait(2, TARGET_RECV_DELAY) < 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 if ((d_char = target_getchar ()) != '>') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 error_proto(d_char, '>'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 if ((d_char = target_getchar ()) != 'p') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 if (d_char == 'P') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 // PARAMETER_NACK_RESPONSE |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 if (target_wait(1, arg_boot_delay_rom) >= 1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 d_ram_loader.d_param_req_sts = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 f_print_parameter_nack_status(NORMAL, d_ram_loader.d_param_req_sts); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 error_proto(d_char, 'p'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 // PARAMETER_ACK_RESPONSE |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 flowf(NORMAL, "\n(Secure ROM"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 if ((error = target_driver_baudrate (arg_uart_baudrate_during_cmd_download)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 // Configure/init the ROM bootloader |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 flowf(VERBOSE, ", UART baud rate during download of flash programmer, %s = %d Kbps", a_certified_cmd_file_name, arg_uart_baudrate_during_cmd_download); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 // End Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 * Command Interpreter Download |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 int cmd_baudrate(int baudrate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 void cmd_machine_fluid(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 void cmd_machine_rom(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 void cmd_machine_secure_rom(void); // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 void cmd_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 char ramcs0, ch; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 uint8 count = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 uint16 chip_id; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 flowf(VERBOSE, "Command Interpreter: ("); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
657 target_trace_enable(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
658 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
659 // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
660 if (bootloader_is_secure_rom) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
661 cmd_machine_secure_rom(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
662 else if (bootloader_is_rom) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
663 cmd_machine_rom(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
664 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
665 cmd_machine_fluid(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
666 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
667 // Now send 'H'ello command to target and get the response, such as |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
668 // hardware type etc. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
669 while (count < RETRIES_MAX) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
670 target_putchar(PROTO_HELLO); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
671 if (target_wait(1, TARGET_RECV_DELAY) >= 1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
672 ch = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
673 flowf(DEBUG, ", received %c (0x%2.2x)", ch, ch); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
674 if (ch == PROTO_READY) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
675 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
676 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
677 count++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
678 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
679 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
680 if (count == RETRIES_MAX) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
681 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
682 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
683 if (target_wait(5, TARGET_RECV_DELAY) < 4) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
684 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
685 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
686 chip_id = (target_getchar() & 0xFF); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
687 chip_id |= (target_getchar() & 0xFF) << 8; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
688 ramcs0 = (target_getchar() == 'R'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
689 ch = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
690 flowf(BLABBER, ", SRAM = %dk", (1 << ch) / 1024); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
691 target_fifo_size = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
692 flowf(DEBUG, ", fifo = %d", target_fifo_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
693 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
694 if (target_type_set(chip_id) == 0 || arg_verbose >= VERBOSE) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
695 flowf(BLABBER, ", "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
696 flowf(VERBOSE, "chipid = 0x%04X", chip_id); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
697 if (target_type_set(chip_id) == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
698 main_fatal(E_TARGET_TYPE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
699 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
700 flowf(VERBOSE, ", %s", target[target_type].name); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
701 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
702 if (ramcs0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
703 flowf(VERBOSE, ", RAM"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
704 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
705 // Configure target |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
706 target_putchar(PROTO_INIT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
707 target_putchar(target[target_type].type); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
708 target_expect_char(PROTO_READY, TARGET_RECV_DELAY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
709 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
710 // Change baudrate. First try to change to new baudrate. If this fails, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
711 // try 115.2 Kbps. If this also fails, panic and bail out. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
712 if (arg_uart_baudrate != 115200) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
713 flowf(VERBOSE, ", baudrate = "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
714 flowf(VERBOSE, "%d", arg_uart_baudrate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
715 if (!cmd_baudrate(arg_uart_baudrate)) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
716 arg_uart_baudrate = 115200; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
717 flowf(VERBOSE, " %d", arg_uart_baudrate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
718 if (!cmd_baudrate(arg_uart_baudrate)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
719 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
720 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
721 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
722 flowf(VERBOSE, ") "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
723 flowf(VERBOSE, "ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
724 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
725 // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
726 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
727 // There is a bug in ROM code 0x0410 which means that the secure boot |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
728 // loader cannot boot if the firmware certificate size is greater than the |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
729 // max size of 0xFFF8. A workaround is to change the memory mapping on CS5 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
730 // by initially setting DIP switches 9 and 10 to ON and thereby exchanging |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
731 // the mapping of RAM and flash. While waiting, set the DIP switches back |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
732 // to OFF. See SECURITY.txt and BUG03314 in CALPLUS228. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
733 if (arg_delay_for_changing_cs5 != 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
734 flowf(NORMAL, "\nWaiting %d seconds for changing memory mapping on CS5 or connecting via JTAG...\n", arg_delay_for_changing_cs5); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
735 target_wait(0, arg_delay_for_changing_cs5 * 1000); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
736 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
737 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
738 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
739 int cmd_baudrate(int baudrate) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
740 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
741 int error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
742 int divider; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
743 char xxo; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
744 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
745 target_putchar(PROTO_BAUDRATE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
746 if (baudrate == 230400 || baudrate == 460800 || baudrate == 921600) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
747 // Changing the target clock frequency to 14 MHz |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
748 target_clk = 14745600; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
749 // If we are using a 14 MHz compatible baud rate, we should enable the |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
750 // eXternal Xtal Oscillator of the target |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
751 xxo = PROTO_BAUDRATE_XXO; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
752 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
753 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
754 target_clk = 13000000; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
755 xxo = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
756 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
757 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
758 divider = target_uart_baudrate_divider_get(target_clk, baudrate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
759 target_putchar(xxo); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
760 target_putchar((char) divider); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
761 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
762 if ((error = target_driver_baudrate(baudrate)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
763 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
764 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
765 // Wait for acknowledgement |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
766 if (target_wait(1, 2 * TARGET_RECV_DELAY) >= 1 && |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
767 target_getchar() == PROTO_READY) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
768 return 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
769 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
770 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
771 if ((error = target_driver_baudrate(115200)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
772 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
773 return 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
774 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
775 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
776 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
777 void cmd_machine_fluid(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
778 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
779 uint8 sendbuf[1+4+2]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
780 int error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
781 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
782 // Send 'Download' command header. Then wait for acknowledgement. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
783 buf_put1(&sendbuf[0], PROTO_DOWNLOAD); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
784 buf_put4(&sendbuf[1], target[target_type].cmd_load_addr); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
785 buf_put2(&sendbuf[1+4], (uint16) target_program_size / 2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
786 target_send(sendbuf, 1+4+2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
787 flowf(BLABBER, "0x%X", target[target_type].cmd_load_addr); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
788 if ((error = target_expect_char(PROTO_READY, TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
789 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
790 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
791 // Send data. Then wait for acknowledgement. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
792 target_trace_enable(1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
793 target_send(target_program, target_program_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
794 flowf(BLABBER, ", %d", target_program_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
795 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
796 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
797 void cmd_machine_rom(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
798 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
799 uint8 sendbuf[10], *buf; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
800 int error, i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
801 int block_addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
802 int block_offset = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
803 int block_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
804 uint8 ch, blksum, cksum = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
805 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
806 // NOTEME: Can we be sure that it is always a Calypso type? |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
807 target_type_set('c'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
808 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
809 block_addr = target[target_type].cmd_load_addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
810 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
811 buffer_endian_convert(target_program, target_program_size, 2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
812 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
813 flowf(BLABBER, "0x%X, ", target[target_type].cmd_load_addr); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
814 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
815 // Transfer the target program as blocks |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
816 while (block_offset < target_program_size) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
817 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
818 block_size = target_program_size - block_offset; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
819 if (block_size > bootloader_blocksize_max) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
820 block_size = bootloader_blocksize_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
821 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
822 // Initialize block transfer |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
823 buf = sendbuf; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
824 buf += buf_put1(buf, '<'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
825 buf += buf_put1(buf, 'w'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
826 buf += buf_put1(buf, 0x01); // block index - just use #1 - not important |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
827 buf += buf_put1(buf, 0x01); // block number - just use #1 - not important |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
828 buf += buf_put2no(buf, (uint16) block_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
829 buf += buf_put4no(buf, block_addr + block_offset); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
830 target_send(sendbuf, 10); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
831 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
832 // Send the data |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
833 target_send(&target_program[block_offset], block_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
834 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
835 // Calculate block check-sum |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
836 blksum = 5; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
837 blksum += block_size & 0x00ff; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
838 blksum += (((block_addr + block_offset) & 0xff000000) >> 24); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
839 blksum += (((block_addr + block_offset) & 0x00ff0000) >> 16); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
840 blksum += (((block_addr + block_offset) & 0x0000ff00) >> 8); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
841 blksum += ( (block_addr + block_offset) & 0x000000ff); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
842 for (i = block_offset; i < (block_offset + block_size); i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
843 blksum += target_program[i]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
844 cksum += ~blksum; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
845 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
846 block_offset = block_offset + block_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
847 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
848 if ((error = target_expect_char ('>', TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
849 main_fatal (error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
850 if ((error = target_expect_char ('w', TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
851 main_fatal (error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
852 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
853 flowf(BLABBER, "."); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
854 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
855 flowf(BLABBER, ", %d", target_program_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
856 target_wait(0, 100); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
857 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
858 // Request compare of checksum |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
859 target_putchar('<'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
860 target_putchar('c'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
861 target_putchar((char) ~cksum); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
862 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
863 if ((error = target_expect_char('>', TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
864 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
865 if ((error = target_expect_char('c', TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
866 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
867 if ((error = target_wait(1, TARGET_RECV_DELAY)) < 1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
868 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
869 ch = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
870 flowf(DEBUG, ", cksum = 0x%x (0x%x)", ch, cksum); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
871 if (ch != cksum) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
872 main_fatal(E_SEND_CHECKSUM); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
873 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
874 // Branch to code |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
875 buf = sendbuf; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
876 buf += buf_put1(buf, '<'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
877 buf += buf_put1(buf, 'b'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
878 buf += buf_put4no(buf, target[target_type].cmd_load_addr); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
879 target_send(sendbuf, 6); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
880 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
881 if (target_wait(2, TARGET_RECV_DELAY) < 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
882 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
883 if ((ch = target_getchar()) != '>') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
884 error_proto(ch, '>'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
885 if ((ch = target_getchar()) != 'b') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
886 error_proto(ch, 'b'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
887 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
888 target_wait(0, 100); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
889 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
890 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
891 // Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
892 void cmd_machine_secure_rom(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
893 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
894 UWORD8 d_char; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
895 UWORD16 d_i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
896 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
897 target_type_set('p'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
898 flowf(BLABBER, "0x%X", d_ram_loader.u_code_certificate.d_code_certificate.d_Addcode); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
899 flowf(DEBUG, ")"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
900 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
901 // Prepare the write command |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
902 d_ram_loader.d_nb_byte_in_block = (UWORD32) arg_block_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
903 d_ram_loader.d_nb_byte_sent = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
904 d_ram_loader.d_block_address = d_ram_loader.u_code_certificate.d_code_certificate.d_Addcode; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
905 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
906 while (d_ram_loader.d_nb_byte_sent < d_ram_loader.u_code_certificate.d_code_certificate.d_Codesize) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
907 flowf(DEBUG, "\nCurrent write parameters:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
908 flowf(DEBUG, " Max Number of Bytes in Block: %ld\n", d_ram_loader.d_nb_byte_in_block); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
909 flowf(DEBUG, " Block Address : 0x%8.8lx\n", d_ram_loader.d_block_address); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
910 flowf(DEBUG, " Code Size : %ld\n", d_ram_loader.u_code_certificate.d_code_certificate.d_Codesize); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
911 flowf(DEBUG, " Bytes sent : %ld\n", d_ram_loader.d_nb_byte_sent); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
912 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
913 // Set block size |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
914 d_ram_loader.d_block_size = d_ram_loader.u_code_certificate.d_code_certificate.d_Codesize - d_ram_loader.d_nb_byte_sent; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
915 if (d_ram_loader.d_block_size > d_ram_loader.d_nb_byte_in_block) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
916 d_ram_loader.d_block_size = d_ram_loader.d_nb_byte_in_block; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
917 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
918 flowf(DEBUG, " Block Size : %ld\n", d_ram_loader.d_block_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
919 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
920 // Write Request |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
921 d_frame.a_data[0] = '<'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
922 d_frame.a_data[1] = 'w'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
923 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
924 // Send block size |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
925 for (d_i = 0; d_i < 32; d_i += 8) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
926 d_frame.a_data[2 + d_i / 8] = (UWORD8)(d_ram_loader.d_block_size >> (24 - d_i)); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
927 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
928 // Send block address |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
929 for (d_i = 0; d_i < 32; d_i += 8) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
930 d_frame.a_data[2 + sizeof(UWORD32) + d_i / 8] = (UWORD8)(d_ram_loader.d_block_address >> (24 - d_i)); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
931 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
932 d_frame.d_max_byte = 2 + sizeof(UWORD32) + sizeof(UWORD32); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
933 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
934 // Send the data |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
935 target_send(&d_frame.a_data[0], d_frame.d_max_byte); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
936 target_send(&target_program[d_certificate_length + d_ram_loader.d_nb_byte_sent], d_ram_loader.d_block_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
937 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
938 // Update next block address |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
939 d_ram_loader.d_block_address += d_ram_loader.d_block_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
940 d_ram_loader.d_nb_byte_sent += d_ram_loader.d_block_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
941 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
942 // Write Response |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
943 if (target_wait(2, TARGET_RECV_DELAY) < 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
944 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
945 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
946 if ((d_char = target_getchar ()) != '>') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
947 error_proto(d_char, '>'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
948 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
949 if ((d_char = target_getchar ()) != 'w') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
950 if (d_char == 'W') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
951 // WRITE_NACK_RESPONSE |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
952 if (target_wait(1, arg_boot_delay_rom) >= 1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
953 d_ram_loader.d_write_status = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
954 f_print_write_nack_status(NORMAL, d_ram_loader.d_write_status); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
955 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
956 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
957 error_proto(d_char, 'w'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
958 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
959 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
960 // WRITE_ACK_RESPONSE |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
961 } // End while |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
962 if (arg_verbose == BLABBER) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
963 flowf(BLABBER, ", "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
964 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
965 flowf(DEBUG, "("); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
966 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
967 flowf(BLABBER, "%d", d_ram_loader.d_nb_byte_sent); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
968 target_wait(0, 100); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
969 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
970 // Abort Request |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
971 d_frame.a_data[0] = '<'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
972 d_frame.a_data[1] = 'a'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
973 d_frame.d_max_byte = 2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
974 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
975 target_send(&d_frame.a_data[0], d_frame.d_max_byte); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
976 target_wait(0, 100); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
977 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
978 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
979 void f_print_signalling_response(int level) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
980 UWORD16 d_i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
981 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
982 flowf(level, "\nSignalling Response:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
983 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
984 flowf(level, " ROM Code Version: 0x%4.4x\n", d_ram_loader.d_romcode_version); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
985 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
986 flowf(level, " Hash (ManPubKey): "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
987 for (d_i = 0; d_i < (C_WORD32LGB * C_MD5HASHLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
988 if (d_i == (C_WORD32LGB * C_MD5HASHLG) / 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
989 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
990 flowf(level, "0x%2.2x ", d_ram_loader.a_hash_man_pub_key[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
991 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
992 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
993 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
994 flowf(level, " Die Id : "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
995 for (d_i = 0; d_i < (C_WORD32LGB * C_DIE_ID_SIZE); d_i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
996 flowf(level, "0x%2.2x ", d_ram_loader.a_die_id[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
997 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
998 } /* f_print_signalling_response() */ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
999 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1000 void f_print_certificate_platform_data(int level, T_MANUFACTURER_CERTIFICATE_PLATFORM_DATA *p_certificate) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1001 UWORD16 d_i, d_j, d_max = 4; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1002 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1003 flowf(level, "\nFirmware Manufacturer Certificate:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1004 flowf(level, "----------------------------------\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1005 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1006 flowf(level, " Size of Certificate: %d bytes\n", p_certificate->d_manufacturer_certificate.d_Certsize); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1007 flowf(level, " Type of Certificate: 0x%2.2x\n", p_certificate->d_manufacturer_certificate.d_Certtype); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1008 flowf(level, " Emulation Request : 0x%2.2x\n", p_certificate->d_manufacturer_certificate.d_Debugrequest); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1009 flowf(level, " Address of Code : 0x%8.8lx\n", p_certificate->d_manufacturer_certificate.d_Addcode); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1010 flowf(level, " Size of Code : %ld bytes\n", p_certificate->d_manufacturer_certificate.d_Codesize); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1011 flowf(level, " Entry Point Address: 0x%8.8lx\n", p_certificate->d_manufacturer_certificate.d_CodeStartAdd); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1012 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1013 flowf(level, " Manufacturer Public Key:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1014 flowf(level, " Public Modulus:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1015 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1016 for (d_i = 0; d_i < (C_RSAKEYLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1017 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1018 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1019 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1020 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1021 flowf(level, "0x%8.8lx ", p_certificate->d_manufacturer_certificate.d_Manpubkey.a_Modulus[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1022 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1023 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1024 flowf(level, " Public Modulus Length:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1025 flowf(level, " 0x%8.8lx\n", p_certificate->d_manufacturer_certificate.d_Manpubkey.d_ModulusLength); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1026 flowf(level, " Public Exponent:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1027 flowf(level, " 0x%8.8lx\n", p_certificate->d_manufacturer_certificate.d_Manpubkey.d_Exponent); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1028 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1029 flowf(level, " Originator Public Key:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1030 flowf(level, " Public Modulus:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1031 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1032 for (d_i = 0; d_i < (C_RSAKEYLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1033 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1034 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1035 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1036 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1037 flowf(level, "0x%8.8lx ", p_certificate->d_manufacturer_certificate.d_Origpubkey.a_Modulus[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1038 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1039 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1040 flowf(level, " Public Modulus Length:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1041 flowf(level, " 0x%8.8lx\n", p_certificate->d_manufacturer_certificate.d_Origpubkey.d_ModulusLength); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1042 flowf(level, " Public Exponent:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1043 flowf(level, " 0x%8.8lx\n", p_certificate->d_manufacturer_certificate.d_Origpubkey.d_Exponent); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1044 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1045 flowf(level, " Originator Public Key Signature:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1046 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1047 for (d_i = 0; d_i < (C_RSASIGLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1048 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1049 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1050 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1051 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1052 flowf(level, "0x%8.8lx ", p_certificate->d_manufacturer_certificate.a_Origpubkeysig[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1053 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1054 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1055 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1056 flowf(level, " Software Signature:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1057 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1058 for (d_i = 0; d_i < (C_RSASIGLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1059 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1060 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1061 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1062 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1063 flowf(level, "0x%8.8lx ", p_certificate->d_manufacturer_certificate.a_Swsig[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1064 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1065 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1066 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1067 flowf(level, " Configuration Parameters:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1068 flowf(level, " CONF_CS5 register: %4.4x\n",p_certificate->d_manufacturer_certificate.d_Confparam.d_conf_cs5); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1069 flowf(level, " EXWS_CS5 register: %4.4x\n",p_certificate->d_manufacturer_certificate.d_Confparam.d_exws_cs5); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1070 flowf(level, " EX_CTRL register : %4.4x\n",p_certificate->d_manufacturer_certificate.d_Confparam.d_ex_ctrl); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1071 flowf(level, " CS image request : %4.4x\n",p_certificate->d_manufacturer_certificate.d_Confparam.d_cs_img_req); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1072 flowf(level, " Flash size : %ld bytes\n",p_certificate->d_manufacturer_certificate.d_Confparam.d_flash_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1073 flowf(level, " Granularity : %ld words\n",p_certificate->d_manufacturer_certificate.d_Confparam.d_granularity); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1074 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1075 flowf(level, " Die Id: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1076 for(d_i = 0; d_i < (C_DIE_ID_SIZE); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1077 flowf(level, "0x%8.8lx ", p_certificate->d_manufacturer_certificate.a_die_id[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1078 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1079 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1080 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1081 if (p_certificate->d_manufacturer_certificate.d_Certsize > (sizeof(T_MANUFACTURER_CERTIFICATE) + (C_WORD32LGB * C_MANUF_SIG_SIZE))) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1082 flowf(level, " Platform Data:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1083 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1084 for(d_i = 0; d_i < (p_certificate->d_manufacturer_certificate.d_Certsize - sizeof(T_MANUFACTURER_CERTIFICATE) - (C_WORD32LGB * C_MANUF_SIG_SIZE)) / sizeof(UWORD32); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1085 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1086 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1087 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1088 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1089 flowf(level, "0x%8.8lx ", p_certificate->a_platform_data[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1090 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1091 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1092 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1093 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1094 flowf(level, " Certificate Signature:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1095 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1096 for (d_i = 0; d_i < (C_MANUF_SIG_SIZE); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1097 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1098 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1099 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1100 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1101 flowf(level, "0x%8.8lx ", p_certificate->a_Certsig[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1102 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1103 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1104 } /* f_print_certificate_platform_data() */ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1105 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1106 void f_print_certificate(int level, T_MANUFACTURER_CERTIFICATE_FLASH_PROGRAMMER *p_certificate) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1107 UWORD16 d_i, d_j, d_max = 4; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1108 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1109 flowf(level, "\nFlash Programmer Manufacturer Certificate:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1110 flowf(level, "------------------------------------------\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1111 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1112 flowf(level, " Size of Certificate: %d bytes\n", p_certificate->d_Certsize); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1113 flowf(level, " Type of Certificate: 0x%2.2x\n", p_certificate->d_Certtype); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1114 flowf(level, " Emulation Request : 0x%2.2x\n", p_certificate->d_Debugrequest); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1115 flowf(level, " Address of Code : 0x%8.8lx\n", p_certificate->d_Addcode); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1116 flowf(level, " Size of Code : %ld bytes\n", p_certificate->d_Codesize); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1117 flowf(level, " Entry Point Address: 0x%8.8lx\n", p_certificate->d_CodeStartAdd); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1118 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1119 flowf(level, " Manufacturer Public key:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1120 flowf(level, " Public Modulus:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1121 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1122 for (d_i = 0; d_i < (C_RSAKEYLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1123 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1124 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1125 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1126 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1127 flowf(level, "0x%8.8lx ", p_certificate->d_Manpubkey.a_Modulus[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1128 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1129 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1130 flowf(level, " Public Modulus Length:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1131 flowf(level, " 0x%8.8lx\n", p_certificate->d_Manpubkey.d_ModulusLength); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1132 flowf(level, " Public Exponent:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1133 flowf(level, " 0x%8.8lx\n", p_certificate->d_Manpubkey.d_Exponent); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1134 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1135 flowf(level, " Originator Public key:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1136 flowf(level, " Public Modulus:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1137 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1138 for (d_i = 0; d_i < (C_RSAKEYLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1139 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1140 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1141 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1142 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1143 flowf(level, "0x%8.8lx ", p_certificate->d_Origpubkey.a_Modulus[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1144 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1145 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1146 flowf(level, " Public Modulus Length:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1147 flowf(level, " 0x%8.8lx\n", p_certificate->d_Origpubkey.d_ModulusLength); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1148 flowf(level, " Public Exponent:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1149 flowf(level, " 0x%8.8lx\n", p_certificate->d_Origpubkey.d_Exponent); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1150 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1151 flowf(level, " Originator Public Key Signature:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1152 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1153 for (d_i = 0; d_i < (C_RSASIGLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1154 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1155 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1156 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1157 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1158 flowf(level, "0x%8.8lx ", p_certificate->a_Origpubkeysig[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1159 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1160 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1161 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1162 flowf(level, " Software Signature:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1163 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1164 for (d_i = 0; d_i < (C_RSASIGLG); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1165 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1166 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1167 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1168 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1169 flowf(level, "0x%8.8lx ", p_certificate->a_Swsig[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1170 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1171 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1172 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1173 flowf(level, " Configuration Parameters:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1174 flowf(level, " CONF_CS5 register: %4.4x\n",p_certificate->d_Confparam.d_conf_cs5); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1175 flowf(level, " EXWS_CS5 register: %4.4x\n",p_certificate->d_Confparam.d_exws_cs5); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1176 flowf(level, " EX_CTRL register : %4.4x\n",p_certificate->d_Confparam.d_ex_ctrl); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1177 flowf(level, " CS image request : %4.4x\n",p_certificate->d_Confparam.d_cs_img_req); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1178 flowf(level, " Flash size : %ld bytes\n",p_certificate->d_Confparam.d_flash_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1179 flowf(level, " Granularity : %ld words\n",p_certificate->d_Confparam.d_granularity); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1180 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1181 flowf(level, " Die Id: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1182 for(d_i = 0; d_i < (C_DIE_ID_SIZE); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1183 flowf(level, "0x%8.8lx ", p_certificate->a_die_id[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1184 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1185 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1186 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1187 flowf(level, " Certificate Signature:"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1188 d_j = d_max; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1189 for (d_i = 0; d_i < (C_MANUF_SIG_SIZE); d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1190 if (d_j++ == d_max) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1191 flowf(level, "\n "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1192 d_j = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1193 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1194 flowf(level, "0x%8.8lx ", p_certificate->a_Certsig[d_i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1195 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1196 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1197 } /* f_print_certificate() */ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1198 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1199 void f_print_parameter_nack_status(int level, UWORD8 d_parameter_nack_sts) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1200 flowf(level, "\nParameter NAck Response Status:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1201 flowf(level, " 0x%2.2x", d_parameter_nack_sts); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1202 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1203 switch(d_parameter_nack_sts) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1204 case 0x01 : { flowf(level, " Incorrect baud rate\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1205 case 0x02 : { flowf(level, " Incorrect certificate\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1206 case 0x03 : { flowf(level, " Incorrect code address\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1207 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1208 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1209 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1210 } /* f_print_parameter_nack_status() */ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1211 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1212 void f_print_write_nack_status(int level, UWORD8 d_write_nack_sts) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1213 flowf(level, "\nWrite NAck Response Status:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1214 flowf(level, " 0x%2.2x", d_write_nack_sts); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1215 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1216 switch(d_write_nack_sts) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1217 case 0x01 : { flowf(level, " Incorrect block address\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1218 case 0x02 : { flowf(level, " Non-64 bytes block size\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1219 case 0x03 : { flowf(level, " First block is not code address\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1220 case 0x04 : { flowf(level, " Error in firmware signature check\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1221 case 0x05 : { flowf(level, " Received code size does not match the code size in certificate\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1222 case 0x06 : { flowf(level, " Error during block hashing\n"); break; } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1223 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1224 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1225 flowf(level, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1226 } /* f_print_write_nack_status() */ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1227 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1228 UWORD8 f_convert_uart_baud_rate(UWORD32 d_baud_rate) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1229 UWORD8 d_converted_baud_rate; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1230 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1231 switch (d_baud_rate) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1232 case 0: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1233 case 812: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1234 case 812500: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1235 d_converted_baud_rate = 0x00; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1236 arg_uart_baudrate_during_cmd_download = 812500; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1237 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1238 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1239 case 1: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1240 case 406: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1241 case 406250: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1242 d_converted_baud_rate = 0x01; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1243 arg_uart_baudrate_during_cmd_download = 406250; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1244 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1245 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1246 case 2: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1247 case 203: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1248 case 203125: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1249 d_converted_baud_rate = 0x02; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1250 arg_uart_baudrate_during_cmd_download = 203125; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1251 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1252 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1253 case 3: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1254 case 115: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1255 case 115200: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1256 d_converted_baud_rate = 0x03; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1257 arg_uart_baudrate_during_cmd_download = 115200; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1258 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1259 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1260 case 4: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1261 case 57: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1262 case 57600: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1263 d_converted_baud_rate = 0x04; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1264 arg_uart_baudrate_during_cmd_download = 57600; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1265 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1266 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1267 case 5: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1268 case 38: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1269 case 38400: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1270 d_converted_baud_rate = 0x05; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1271 arg_uart_baudrate_during_cmd_download = 38400; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1272 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1273 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1274 case 6: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1275 case 28: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1276 case 28800: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1277 d_converted_baud_rate = 0x06; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1278 arg_uart_baudrate_during_cmd_download = 28800; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1279 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1280 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1281 case 7: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1282 case 19: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1283 case 19200: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1284 d_converted_baud_rate = 0x07; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1285 arg_uart_baudrate_during_cmd_download = 19200; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1286 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1287 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1288 default: { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1289 d_converted_baud_rate = 0x03; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1290 arg_uart_baudrate_during_cmd_download = 115200; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1291 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1292 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1293 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1294 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1295 return d_converted_baud_rate; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1296 } /* f_convert_uart_baud_rate() */ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1297 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1298 void target_imei_protection(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1299 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1300 uint8 a_imeisv[C_IMEISV_BYTES]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1301 uint8 a_platform_cert_addr[C_PLATFORM_CERT_ADDR_BYTES]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1302 uint8 d_i, d_digit, d_temp; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1303 uint8 d_error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1304 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1305 flowf(NORMAL, "\nIMEI protection: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1306 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1307 if (arg_dry_run) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1308 flowf(NORMAL, "(dry-run) ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1309 return; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1310 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1311 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1312 target_putchar(PROTO_IMEI_PROTECT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1313 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1314 // Send IMEI-SV |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1315 for (d_i = 0; d_i < C_IMEISV_DIGITS; d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1316 sscanf(arg_imeisv++, "%1d", &d_digit); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1317 if (!(d_i & 1)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1318 d_temp = d_digit << 4; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1319 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1320 d_temp |= d_digit; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1321 a_imeisv[d_i / 2] = d_temp; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1322 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1323 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1324 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1325 target_send(a_imeisv, C_IMEISV_BYTES); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1326 target_expect_char(PROTO_READY, TARGET_RECV_DELAY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1327 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1328 // Send platform certificate address |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1329 for (d_i = 0; d_i < C_PLATFORM_CERT_ADDR_DIGITS; d_i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1330 sscanf(arg_platform_certificate_addr++, "%1x", &d_digit); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1331 if (!(d_i & 1)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1332 d_temp = d_digit << 4; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1333 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1334 d_temp |= d_digit; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1335 a_platform_cert_addr[d_i / 2] = d_temp; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1336 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1337 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1338 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1339 target_send(a_platform_cert_addr, C_PLATFORM_CERT_ADDR_BYTES); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1340 target_expect_char(PROTO_READY, TARGET_RECV_DELAY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1341 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1342 // Check if address range is erased |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1343 if (target_wait(1, TARGET_RECV_DELAY) < 1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1344 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1345 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1346 d_error = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1347 if (d_error == PROTO_ERROR_VERIFY) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1348 flowf(NORMAL, "\n The address range for platform certificate and IMEI-SV is not erased.\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1349 main_fatal(E_FLASH_VERIFY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1350 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1351 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1352 if (d_error != PROTO_READY) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1353 error_proto(d_error, PROTO_READY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1354 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1355 // Verify that the binding service call in target has succeeded |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1356 if (target_wait(1, TARGET_RECV_DELAY) < 1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1357 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1358 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1359 d_error = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1360 if (d_error == PROTO_ERROR_ROM_SSERVICE) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1361 flowf(NORMAL, "\n The Run-Time Loader (Binding) Service failed.\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1362 main_fatal(E_ROM_SSERVICE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1363 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1364 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1365 if (d_error != PROTO_FLASH_START) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1366 error_proto(d_error, PROTO_FLASH_START); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1367 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1368 // Receive acknowledgement for programming the platform certificate |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1369 if (target_wait(1, TARGET_RECV_DELAY) < 1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1370 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1371 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1372 d_error = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1373 if (d_error != PROTO_PROGRAM) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1374 flowf(NORMAL, "\n Platform certificate was not stored correctly in flash.\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1375 error_proto(d_error, PROTO_PROGRAM); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1376 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1377 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1378 // Receive acknowledgement for programming the IMEI-SV |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1379 if (target_wait(1, TARGET_RECV_DELAY) < 1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1380 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1381 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1382 d_error = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1383 if (d_error != PROTO_PROGRAM) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1384 flowf(NORMAL, "\n IMEI-SV was not stored correctly in flash.\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1385 error_proto(d_error, PROTO_PROGRAM); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1386 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1387 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1388 flowf(NORMAL, "Platform certificate and IMEI-SV stored in flash.\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1389 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1390 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1391 // End Secure Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1392 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1393 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1394 * Flash Detect |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1395 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1396 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1397 void flash_detect_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1398 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1399 uint8 data[12]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1400 uint16 m0, d0, m1, d1, d1ex1, d1ex2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1401 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1402 flowf(NORMAL, "Flash Detect: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1403 target_trace_enable(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1404 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1405 if (arg_device_id0 != -1 || arg_device_id1 != -1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1406 // Device auto-detection is disabled |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1407 m0 = m1 = arg_device_id0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1408 d0 = d1 = arg_device_id1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1409 flowf(VERBOSE, "(ID override) "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1410 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1411 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1412 target_putchar(PROTO_DETECT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1413 if (target_wait(12, TARGET_RECV_DELAY) < 12) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1414 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1415 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1416 target_recv(data, 12); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1417 m0 = data[0] + (data[1] << 8); // Intel manufacturer id |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1418 d0 = data[2] + (data[3] << 8); // Intel device id |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1419 m1 = data[4] + (data[5] << 8); // AMD manufacturer id |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1420 d1 = data[6] + (data[7] << 8); // AMD device di |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1421 d1ex1 = data[8] + (data[9] << 8); // AMD extended device id |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1422 d1ex2 = data[10] + (data[11] << 8); // AMD extended device id |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1423 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1424 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1425 // Lookup multi-id device |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1426 if ((m1 == MANUFACT_AMD || m1 == MANUFACT_FUJITSU) && d1 == 0x227E) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1427 flowf(NORMAL, "Multi-id device detected: (0x%04X, 0x%04X, 0x%04X)\n" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1428 , d1, d1ex1, d1ex2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1429 d1 = (d1ex1 << 8) | (d1ex2 & 0xFF); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1430 flowf(DEBUG, "Multi-id converted to: 0x%04X\n", d1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1431 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1432 if ((device = device_lookup_by_id(m1, d1)) == NULL) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1433 flowf(NORMAL, "Id not found, lookup default multi-id conf.\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1434 // Backward compatible/keep default multi-id configuration |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1435 device = device_lookup_by_id(m1, 0x227E); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1436 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1437 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1438 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1439 // Lookup device with AMD and Intel ids |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1440 else if ((device = device_lookup_by_id(m1, d1)) == NULL) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1441 device = device_lookup_by_id(m0, d0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1442 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1443 if (device == NULL || arg_verbose >= DEBUG) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1444 flowf(NORMAL, "(0x%02X, 0x%04X, 0x%02X, 0x%04X) ", m0, d0, m1, d1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1445 if (device == NULL) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1446 main_fatal(E_FLASH_UNKNOWN); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1447 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1448 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1449 if (arg_verbose >= NORMAL) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1450 device_print(device, 's'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1451 flowf(NORMAL, " ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1452 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1453 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1454 // Note that device_id is only 0x227E if the Multi-id configuration not |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1455 // is found in device.txt (else device_id will be the 'converted' id) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1456 if (arg_device_id0 == -1 && arg_device_id1 == -1 && |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1457 (device->manufacturer_id == MANUFACT_FUJITSU || |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1458 device->manufacturer_id == MANUFACT_AMD ) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1459 && device->device_id == 0x227E) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1460 flowf(NORMAL, "Warning: Extended device codes are supported when detecting flash devices,\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1461 flowf(NORMAL, " but the detected multi-id configuration is not found in device.txt. \n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1462 flowf(NORMAL, " Update the device.txt manually if the default flash device is invalid.\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1463 flowf(NORMAL, " Currently, %s %s is used as default.\n\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1464 manufacturer_name_lookup_by_id(device->manufacturer_id), device->name); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1465 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1466 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1467 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1468 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1469 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1470 * Method Load |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1471 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1472 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1473 void method_download_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1474 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1475 char sendbuf[1+2+4]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1476 int error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1477 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1478 target_program_size = file_read_method(target_program, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1479 TARGET_PROGRAM_SIZE_MAX, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1480 device); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1481 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1482 flowf(BLABBER, "Method Download: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1483 target_trace_enable(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1484 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1485 // Send 'Download' command header. Then wait for acknowledgement. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1486 buf_put1(&sendbuf[0], PROTO_DOWNLOAD); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1487 buf_put4(&sendbuf[1], target[target_type].method_load_addr); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1488 buf_put2(&sendbuf[1+4], (uint16) target_program_size / 2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1489 target_send(sendbuf, 1+4+2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1490 flowf(BLABBER, "(0x%X", target[target_type].method_load_addr); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1491 if ((error = target_expect_char(PROTO_READY, TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1492 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1493 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1494 // Send data. Then wait for acknowledgement. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1495 target_trace_enable(1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1496 target_send(target_program, target_program_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1497 flowf(BLABBER, ", %d) ", target_program_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1498 if ((error = target_expect_char(PROTO_READY, TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1499 main_fatal(error); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1500 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1501 flowf(BLABBER, "ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1502 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1503 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1504 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1505 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1506 * Flash Checksum |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1507 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1508 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1509 int time_checksum; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1510 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1511 #define CHECKSUMS 8 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1512 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1513 void flash_checksum_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1514 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1515 unsigned char sendbuf[1+1+4+4*CHECKSUMS], *buf; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1516 uint32 addr, cksum, mycksum; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1517 uint16 word; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1518 uint8 data[4]; |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1519 int img_index = 0, chunks, n, i, j; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1520 int line = -1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1521 struct { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1522 uint32 index; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1523 uint32 addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1524 uint32 mycksum; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1525 } block[CHECKSUMS]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1526 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1527 chunks = image_map_count_used_chunks(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1528 flowf(NORMAL, "Checksumming (%d * %dkB = %dkB): ", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1529 chunks, image_chunk_size / 1024, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1530 chunks * image_chunk_size / 1024); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1531 target_trace_enable(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1532 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1533 time_checksum = stopwatch_start(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1534 while (chunks > 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1535 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1536 n = (chunks > CHECKSUMS ? CHECKSUMS : chunks); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1537 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1538 buf = sendbuf; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1539 buf += buf_put1(buf, PROTO_CHECKSUM); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1540 buf += buf_put1(buf, (unsigned char) n); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1541 buf += buf_put4(buf, image_chunk_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1542 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1543 for (i = 0; i < n; i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1544 // Find next used entry in image_map |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1545 while (image_map[img_index] != 'x' && img_index < image_map_size) |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1546 img_index++; |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1547 |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1548 if (img_index == image_map_size) |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1549 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1550 |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1551 addr = img_index * image_chunk_size; |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1552 block[i].index = img_index; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1553 block[i].addr = addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1554 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1555 buf += buf_put4(buf, addr); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1556 |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1557 img_index++; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1558 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1559 target_send(sendbuf, buf - sendbuf); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1560 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1561 // Compute checksums while we wait for reply |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1562 for (i = 0; i < n; i++) { |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1563 img_index = block[i].index; |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1564 addr = block[i].addr; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1565 for (j = 0, mycksum = 0; j < image_chunk_size; j += 2) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1566 word = (image[addr + j + 1] << 8) | image[addr + j + 0]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1567 mycksum += word * ((addr + j) & 0xFFFF); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1568 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1569 block[i].mycksum = mycksum; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1570 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1571 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1572 if (target_wait(4 * n, TARGET_RECV_LONG_DELAY) <= 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1573 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1574 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1575 for (i = 0; i < n; i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1576 target_recv(data, 4); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1577 cksum = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1578 mycksum = block[i].mycksum; |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1579 img_index = block[i].index; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1580 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1581 if (cksum == mycksum) |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1582 image_map[img_index] = 'c'; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1583 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1584 if (arg_checksum_show) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1585 // This is a far from perfect dump of checksums... We don't know |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1586 // the exact block number of each checksum in a line. |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1587 if (line != (int) img_index / 4) { |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1588 flowf(NORMAL, "\n%4d:", img_index); |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1589 line = img_index / 4; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1590 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1591 if (cksum == mycksum) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1592 flowf(NORMAL, "%08X ", cksum); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1593 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1594 flowf(NORMAL, "%08X/%08X ", cksum, mycksum); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1595 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1596 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1597 else if (arg_verbose >= VERBOSE) { |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1598 flowf(VERBOSE, "%c", (image_map[img_index] == 'c' ? 'c' : '.')); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1599 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1600 } |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1601 img_index++; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1602 chunks -= n; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1603 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1604 time_checksum = (stopwatch_stop(time_checksum) + 50) / 100; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1605 flowf(BLABBER, " (%d.%ds)", time_checksum / 10, time_checksum % 10); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1606 flowf(NORMAL, " ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1607 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1608 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1609 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1610 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1611 * Flash Program |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1612 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1613 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1614 int time_program; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1615 int programs_recv, programs_send, erasures; |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1616 int img_index, src_size; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1617 uint32 dst; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1618 char *src; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1619 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1620 void flash_erase_machine(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1621 int flash_operation_wait(int delay); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1622 int flash_program_next(void); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1623 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1624 void flash_program_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1625 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1626 uint8 cksum, sendbuf[1+4+4]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1627 int i, te, tp, tt; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1628 int expected, chunks, total_size, sectors; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1629 int image_chunk_size_old = image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1630 char ch; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1631 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1632 programs_recv = programs_send = erasures = 0; |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1633 img_index = 0; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1634 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1635 // Prepare erase |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1636 erase_list_size = sectors = sector_map_init(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1637 i = image_map_count_used_chunks(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1638 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1639 if (arg_skip_erase) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1640 erase_list_size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1641 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1642 time_compute(device, erase_list_size, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1643 i * image_chunk_size, i, &te, &tp, &tt); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1644 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1645 flowf(BLABBER, "Estimated time (uncompressed) "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1646 if (te + tp > tt) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1647 flowf(BLABBER, "(erase + program = total): %ds + %ds = %ds\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1648 te/1000, tp/1000, te/1000 + tp/1000); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1649 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1650 flowf(BLABBER, "transfer: %ds\n", tt/1000); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1651 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1652 chunks = image_map_count_used_chunks(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1653 flowf(NORMAL, "Program: (%d sectors, %d*%dk=%dk) ", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1654 sectors, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1655 chunks, image_chunk_size / 1024, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1656 chunks * image_chunk_size / 1024); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1657 target_trace_enable(1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1658 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1659 // Expected total number of acknowledgements |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1660 expected = erase_list_size + chunks; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1661 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1662 if (arg_dry_run) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1663 flowf(NORMAL, "(dry-run) "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1664 if (arg_dry_run == 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1665 image_chunk_size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1666 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1667 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1668 if (arg_skip_erase) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1669 flowf(NORMAL, "(skip erase) "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1670 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1671 // Start erase |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1672 flash_erase_machine(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1673 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1674 if (arg_dry_run == 0 || arg_dry_run == 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1675 progress_begin(expected); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1676 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1677 // Start the flash state machine in the target |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1678 target_putchar(PROTO_FLASH_START); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1679 target_putchar(arg_compress ? PROTO_COMPRESS : 0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1680 ch = flash_operation_wait(TARGET_RECV_DELAY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1681 if (ch != PROTO_READY) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1682 error_proto(ch, PROTO_READY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1683 if (arg_compress) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1684 compress_init(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1685 total_size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1686 // Worst case "compressed" buffer is 9/8 of original data size. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1687 if ((src = malloc(9 * image_chunk_size / 8)) == NULL) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1688 main_fatal(E_MEMORY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1689 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1690 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1691 time_program = stopwatch_start(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1692 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1693 if (flash_program_next() && *arg_erase_override == 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1694 //Nothing to program |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1695 target_putchar(PROTO_FLASH_END); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1696 if ((ch = target_expect_char(PROTO_FLASH_END, TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1697 main_fatal(ch); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1698 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1699 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1700 while (programs_recv + erasures < expected) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1701 total_size += src_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1702 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1703 if (arg_progress == 'x') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1704 flowf(NORMAL, "(0x%06X, %d) ", dst, src_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1705 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1706 if (src_size > 0 && |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1707 (arg_dry_run == 0 || arg_dry_run == 2)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1708 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1709 buf_put1(&sendbuf[0], PROTO_PROGRAM); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1710 buf_put4(&sendbuf[1], src_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1711 buf_put4(&sendbuf[1+4], dst); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1712 target_send(sendbuf, 1+4+4); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1713 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1714 for (i = 0, cksum = 0; i < src_size; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1715 cksum += src[i]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1716 cksum = (0x100 - cksum) & 0xFF; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1717 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1718 // Wait for acknowledgement of command start |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1719 //while ((ch = flash_operation_wait(4000)) != PROTO_READY) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1720 // ; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1721 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1722 // Make sure that the target FIFO not is full |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1723 while (programs_send - programs_recv >= target_fifo_size) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1724 flash_operation_wait(4000); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1725 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1726 // Send data bytes and checksum. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1727 target_send(src, src_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1728 target_putchar(cksum); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1729 programs_send++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1730 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1731 if (arg_verbose >= DEBUG) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1732 progress_update_simple('T'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1733 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1734 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1735 // We compress and send next block while sending |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1736 // current block to target |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1737 if (arg_dry_run == 0 || arg_dry_run == 2) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1738 if (flash_program_next()) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1739 // Wait for remaining acknowledgements |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1740 flowf(DEBUG, "W%d", expected - (programs_recv + erasures)); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1741 while (programs_recv + erasures < expected) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1742 flash_operation_wait(4000); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1743 target_putchar(PROTO_FLASH_END); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1744 if ((ch = target_expect_char(PROTO_FLASH_END, TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1745 main_fatal(ch); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1746 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1747 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1748 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1749 // Wait for acknowledgement of data transfer |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1750 while ((ch = flash_operation_wait(4000)) != PROTO_READY) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1751 ; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1752 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1753 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1754 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1755 if (flash_program_next()) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1756 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1757 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1758 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1759 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1760 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1761 if (arg_dry_run == 0 || arg_dry_run == 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1762 progress_end(programs_recv + erasures); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1763 flowf(NORMAL, "ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1764 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1765 time_program = stopwatch_stop(time_program); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1766 flowf(VERBOSE, "Used time: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1767 if (arg_compress && chunks) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1768 image_chunk_size = image_chunk_size_old; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1769 flowf(VERBOSE, "(compressed to %d%%) ", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1770 100 * total_size / (chunks * image_chunk_size)); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1771 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1772 flowf(VERBOSE, "%.1fs ok\n", (double) time_program / 1000); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1773 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1774 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1775 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1776 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1777 * Flash Program sub functions |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1778 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1779 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1780 void flash_erase_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1781 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1782 uint8 sendbuf[1+2+4*256]; // NOTEME: static limit! |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1783 int i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1784 char ch; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1785 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1786 if (arg_dry_run) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1787 erase_list_size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1788 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1789 if (erase_list_size > 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1790 buf_put1(&sendbuf[0], PROTO_ERASE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1791 buf_put2(&sendbuf[1], (uint16) erase_list_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1792 for (i = 0; i < erase_list_size; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1793 buf_put4(&sendbuf[1+2+4*i], erase_list[i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1794 target_send(sendbuf, 1+2+4*erase_list_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1795 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1796 if ((ch = target_expect_char(PROTO_READY, TARGET_RECV_DELAY)) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1797 main_fatal(ch); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1798 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1799 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1800 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1801 // Setup address and size of next block to transfer. Also compress the |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1802 // block. Return non-zero if this was the last block. Otherwise return zero. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1803 int flash_program_next(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1804 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1805 int oldindex; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1806 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1807 // Find next used entry in image_map |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1808 while (img_index < image_map_size && image_map[img_index] != 'x') |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1809 img_index++; |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1810 |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1811 oldindex = img_index; |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1812 |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1813 if (img_index < image_map_size) { |
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1814 dst = img_index * image_chunk_size; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1815 if (arg_compress) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1816 src_size = compress(src, &image[dst], image_chunk_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1817 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1818 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1819 src = &image[dst]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1820 src_size = image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1821 } |
340
435e041897f2
fluid-mnf/machine.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
1822 img_index++; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1823 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1824 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1825 dst = 0xFFFFFFFF; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1826 src_size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1827 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1828 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1829 return (oldindex >= image_map_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1830 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1831 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1832 int flash_operation_wait(int delay) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1833 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1834 int n; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1835 char ch; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1836 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1837 tr(TrMachines, "fow() "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1838 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1839 if ((n = target_wait(1, delay)) < 1) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1840 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1841 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1842 // Minor optimization to avoid waiting for every char... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1843 while (n--) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1844 ch = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1845 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1846 if (ch == PROTO_READY) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1847 if (arg_verbose >= DEBUG) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1848 progress_update_simple('R'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1849 if (programs_send - programs_recv >= target_fifo_size) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1850 progress_update_simple('W'); // Wait target FIFO is full |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1851 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1852 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1853 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1854 switch (ch) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1855 case PROTO_READY: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1856 break; // just return the char |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1857 case PROTO_PROGRAM: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1858 programs_recv++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1859 progress_update_simple('P'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1860 progress_update(programs_recv + erasures); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1861 break; // just return the char |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1862 case PROTO_ERASE: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1863 erasures++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1864 progress_update_simple('E'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1865 progress_update(programs_recv + erasures); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1866 if (arg_progress == 'x') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1867 flowf(NORMAL, "E "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1868 break; // just return the char |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1869 case PROTO_FLASH_END: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1870 progress_update_simple('Z'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1871 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1872 case PROTO_ERROR_CKSUM: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1873 main_fatal(E_SEND_CHECKSUM); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1874 case PROTO_ERROR_MEMORY: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1875 main_fatal(E_MEMORY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1876 case PROTO_ERROR_VERIFY: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1877 main_fatal(E_FLASH_VERIFY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1878 case PROTO_ERROR_FLASH_TIMEOUT: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1879 main_fatal(E_FLASH_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1880 case PROTO_ERROR_FLASH_COMMAND: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1881 main_fatal(E_FLASH_COMMAND); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1882 case PROTO_ERROR_FLASH_VPP: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1883 main_fatal(E_FLASH_VPPRANGE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1884 case PROTO_ERROR_FLASH_LOCKED: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1885 main_fatal(E_FLASH_LOCKED); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1886 case PROTO_ERROR_FLASH_UNKNOWN: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1887 main_fatal(E_FLASH_ERROR); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1888 case PROTO_ERROR_INVALID: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1889 main_fatal(E_INVALID); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1890 case PROTO_ERROR_FIFO_OVERFLOW: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1891 main_fatal(E_FIFO_OVERFLOW); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1892 case PROTO_ERROR: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1893 default: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1894 flowf(NORMAL, "flash_operation_wait() got unexpected char '%c' 0x%02X (%d chars waiting)\n", (' ' <= ch && ch < 127 ? ch : '.'), ch, n); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1895 // main_fatal(E_PROTO_ERROR); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1896 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1897 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1898 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1899 return ch; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1900 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1901 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1902 void target_timers_show(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1903 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1904 int data[8], i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1905 struct { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1906 double erase; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1907 double program; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1908 double recvonly; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1909 double recv; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1910 double comm; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1911 double setup; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1912 double overhead; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1913 double dezip; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1914 double erase_sector; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1915 double program_word; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1916 } timer; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1917 double tmp, total, resolution = (double) (16 * 32 * 1000 / 13e6); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1918 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1919 // Use only 14 MHz for D-/E-Sample specific rates (not for e.g. 812.5K). |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1920 if ((arg_uart_baudrate == 230400) || (arg_uart_baudrate == 460800) || (arg_uart_baudrate == 921600)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1921 resolution = resolution * 13 / 14.746; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1922 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1923 flowf(NORMAL, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1924 "Target Timers:\n" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1925 " (erase + program + recvonly + recv + comm + setup + overhead + dezip)\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1926 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1927 if (arg_dry_run) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1928 for (i = 0; i < 8; i++) data[i] = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1929 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1930 target_putchar(PROTO_TIMERS); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1931 if (target_wait(sizeof(data), TARGET_RECV_DELAY) <= 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1932 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1933 target_recv(&data, sizeof(data)); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1934 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1935 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1936 // Convert all timers to milliseconds |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1937 timer.erase = resolution * data[0]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1938 timer.program = resolution * data[1]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1939 timer.recvonly = resolution * data[2]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1940 timer.recv = resolution * data[3]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1941 timer.comm = resolution * data[4]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1942 timer.setup = resolution * data[5]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1943 timer.overhead = resolution * data[6]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1944 timer.dezip = resolution * data[7]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1945 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1946 // Because we do erase-while-transfer in the target the reported erase |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1947 // time has some inherent tolerance, especially at low baudrates. It |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1948 // might make sense to adjust the sector erase time by half the chunk |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1949 // transfer time, although this is just another approximation!? |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1950 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1951 // total = timer.erase + timer.program + timer.recvonly + timer.recv + timer.comm + timer.setup; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1952 flowf(NORMAL, "%8.0f + %7.0f + %8.0f + %6.0f + %5.0f + %5.0f + %8.0f + %5.0f\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1953 timer.erase, timer.program, timer.recvonly, timer.recv, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1954 timer.comm, timer.setup, timer.overhead, timer.dezip); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1955 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1956 flowf(DEBUG, "resolution = %f, %d, %d, %d, %d, %d, %d, %d, %d\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1957 resolution, data[0], data[1], data[2], data[3], data[4], |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1958 data[5], data[6], data[7]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1959 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1960 if (arg_timers_extended_show) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1961 int chunks, size_total, not_zero = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1962 flowf(NORMAL, "Target Timers Extended:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1963 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1964 if (erase_list_size == 0 || arg_dry_run) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1965 flowf(NORMAL, " Erase time = 0.0ms/sector\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1966 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1967 timer.erase_sector = timer.erase / erase_list_size / 1000; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1968 flowf(NORMAL, " Erase time = %.1fs / %d sectors = %.0fms/sector\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1969 timer.erase / 1000, erase_list_size, timer.erase_sector * 1000); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1970 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1971 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1972 chunks = image_map_count_used_chunks(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1973 size_total = chunks * image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1974 if (size_total == 0 || arg_dry_run) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1975 size_total = 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1976 not_zero = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1977 flowf(NORMAL, " Program time = 0.0us/word = 0ms/MB\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1978 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1979 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1980 timer.program_word = timer.program / 1000 / (size_total / 2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1981 flowf(NORMAL, " Program time = %.1fs / %dkwords = %.2fus/word = %.0fms/MB\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1982 timer.program / 1000, size_total / 1024 / 2, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1983 timer.program_word * 1000000, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1984 timer.program_word * 1000 * 512 * 1024); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1985 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1986 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1987 flowf(NORMAL, " Receive-only time = %.1fs = %.0fms/MB\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1988 timer.recvonly / 1000, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1989 not_zero * timer.recvonly * 1024 * 1024 / size_total); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1990 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1991 flowf(NORMAL, " Overhead time = %.1fs = %.0fms/MB\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1992 timer.overhead / 1000, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1993 not_zero * timer.overhead * 1024 * 1024 / size_total); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1994 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1995 flowf(NORMAL, " Setup time = %.1fs = %.0fms/MB\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1996 timer.setup / 1000, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1997 not_zero * timer.setup * 1024 * 1024 / size_total); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1998 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1999 total = timer.erase + timer.program + timer.recvonly + timer.overhead + |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2000 timer.setup; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2001 flowf(NORMAL, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2002 "Total time: (erase + prog + recvonly + overhead + setup) = %.1fs\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2003 total / 1000); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2004 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2005 flowf(NORMAL, " Receive time = %.1fs = %.0fms/MB\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2006 timer.recv / 1000, timer.recv * 1024 * 1024 / size_total); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2007 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2008 flowf(NORMAL, " Communication time = %.1fs = %.0fms/MB\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2009 timer.comm / 1000, timer.comm * 1024 * 1024 / size_total); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2010 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2011 flowf(NORMAL, " Dezip time = %.1fs = %.0fms/MB\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2012 timer.dezip / 1000, timer.dezip * 1024 * 1024 / size_total); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2013 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2014 // Now compute the overall performance. Note that the theoretical |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2015 // limit compuation is somewhat flawed in that it assumes 64kB |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2016 // sector sizes. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2017 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2018 tmp = (double) not_zero * total / 1000 * 1024 * 1024 / size_total; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2019 flowf(NORMAL, " Performance = %.0fs/MB\n", tmp); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2020 #if 0 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2021 flowf(BLABBER, " (%.1f * min possible, %.1f * theoretical limit)", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2022 time_program / (timer.program + timer.erase), |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2023 tmp / (16 * timer.erase_sector + 512 * 1024 * timer.program_word)); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2024 flowf(NORMAL, "\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2025 #endif |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2026 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2027 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2028 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2029 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2030 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2031 * Flash Read |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2032 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2033 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2034 int time_read; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2035 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2036 void flash_read_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2037 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2038 int i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2039 unsigned char sendbuf[1+4+4]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2040 int size, read_size, done_size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2041 int read_size_max = image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2042 uint32 addr, index = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2043 uint8 cksum, mycksum; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2044 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2045 flowf(NORMAL, "Reading Flash: (%dkB) ", read_total_size / 1024); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2046 target_trace_enable(0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2047 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2048 //read_size_max = 256; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2049 time_read = stopwatch_start(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2050 progress_begin(read_total_size / read_size_max); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2051 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2052 while (read_list[index].size > 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2053 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2054 // Find next range to read |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2055 size = read_list[index].size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2056 addr = read_list[index].addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2057 index++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2058 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2059 while (size > 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2060 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2061 read_size = (size > read_size_max ? read_size_max : size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2062 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2063 // Read address interval is [MIN..MAX[ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2064 // If odd MAX address was specified round up to next even |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2065 if ((read_size % 2 == 1) && (read_size < read_size_max)) read_size++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2066 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2067 if (arg_progress == 'x') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2068 flowf(DEBUG, "(0x%06X, %d) ", addr, read_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2069 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2070 if (!arg_dry_run) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2071 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2072 buf_put1(&sendbuf[0], PROTO_READ); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2073 buf_put4(&sendbuf[1] , read_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2074 buf_put4(&sendbuf[1+4], addr); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2075 target_send(sendbuf, 1+4+4); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2076 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2077 if (target_wait(read_size, TARGET_RECV_LONG_DELAY) <= 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2078 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2079 // Note that we wrap/mirror memory each 'image_size' bytes |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2080 target_recv(&image[addr & (image_size - 1)], read_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2081 for (i = 0, mycksum = 0; i < read_size; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2082 mycksum ^= image[(addr + i) & (image_size - 1)]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2083 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2084 if (target_wait(1, TARGET_RECV_DELAY) <= 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2085 main_fatal(E_RECV_TIMEOUT); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2086 cksum = target_getchar(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2087 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2088 if (cksum != mycksum) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2089 main_fatal(E_RECV_CHECKSUM); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2090 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2091 done_size += read_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2092 size -= read_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2093 addr += read_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2094 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2095 progress_update(done_size / read_size_max); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2096 progress_update_simple('0' + read_size / 1024); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2097 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2098 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2099 progress_end(done_size / read_size_max); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2100 flowf(NORMAL, " ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2101 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2102 time_read = stopwatch_stop(time_read); |
357
ebb9377cf52c
fluid-mnf/machine.c: read operation time report message
Mychaela Falconia <falcon@freecalypso.org>
parents:
353
diff
changeset
|
2103 flowf(VERBOSE, "Used time: %d ms ok\n", time_read); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2104 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2105 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2106 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2107 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2108 * Flash Reset |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2109 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2110 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2111 void target_reset_machine(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2112 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2113 int error; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2114 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2115 flowf(VERBOSE, "Resetting target: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2116 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2117 if (arg_dry_run) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2118 flowf(VERBOSE, "(dry-run) "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2119 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2120 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2121 target_putchar(PROTO_RESET); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2122 target_expect_char(PROTO_READY, TARGET_RECV_DELAY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2123 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2124 flowf(VERBOSE, "ok\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2125 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2126 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2127 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2128 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2129 * Show Functions (dump internal data structures) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2130 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2131 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2132 void image_map_show(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2133 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2134 uint32 addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2135 int i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2136 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2137 flowf(ALWAYS, "image map of %d * %dkB chunks (x = used, s = skip, c = checksum ok):", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2138 image_size_in_chunks, image_chunk_size / 1024); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2139 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2140 // For each chunk of the image usage map... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2141 for (i = 0, addr = 0; i < image_size_in_chunks; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2142 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2143 if ((i % 64) == 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2144 flowf(ALWAYS, "\n%4dkB: ", (int) addr >> 10); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2145 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2146 putchar(image_map[i] != 0 ? image_map[i] : '.'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2147 addr += image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2148 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2149 putchar('\n'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2150 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2151 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2152 void sector_map_show(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2153 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2154 struct sector_s *sectors = device->memmap->sectors; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2155 int i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2156 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2157 char n; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2158 uint32 addr = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2159 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2160 flowf(ALWAYS, "sector map (x = used, s = skip, X = force erase):"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2161 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2162 // For each sector of the device definition... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2163 for (i = 0; i < device->memmap->size; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2164 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2165 if ((addr & 0xFFFFF) == 0) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2166 flowf(ALWAYS, "\n%2dMB: ", (int) addr >> 20); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2167 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2168 n = (sector_map[i] ? sector_map[i] : '.'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2169 putchar(n); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2170 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2171 addr += sectors[i].size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2172 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2173 putchar('\n'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2174 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2175 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2176 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2177 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2178 * Utility Functions |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2179 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2180 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2181 int image_is_within(int start, int end) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2182 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2183 return !(start < 0 || image_size <= start || |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2184 end < 0 || image_size < end || |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2185 end < start); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2186 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2187 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2188 // Set the image usage map in the range [start..end[ as used |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2189 int image_map_set(int start, int end) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2190 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2191 if (!image_is_within(start, end)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2192 return -1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2193 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2194 do { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2195 image_map[start / image_chunk_size] = 'x'; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2196 start += image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2197 } while (start < end); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2198 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2199 return 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2200 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2201 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2202 int target_type_set(uint16 code) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2203 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2204 // If there is an override from the command-line, use that |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2205 if (arg_target_type != 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2206 code = arg_target_type; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2207 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2208 switch (code) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2209 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2210 case 'h': // Hercules |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2211 case 'u': // Ulysses |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2212 case '3': // Chipset 3 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2213 case CHIP_ID_ULYSSES_0: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2214 case CHIP_ID_ULYSSES_A: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2215 case CHIP_ID_HERCULES_A: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2216 case CHIP_ID_HERCULES_B: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2217 target_type = 3; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2218 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2219 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2220 case 'c': // Calypso |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2221 case '4': // Chipset 4 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2222 // case 's': // Samson |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2223 case CHIP_ID_CALYPSO_A: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2224 case CHIP_ID_CALYPSO_B: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2225 case CHIP_ID_CALYPSO_C: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2226 target_type = 4; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2227 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2228 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2229 case 'l': // Calypso Lite |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2230 case CHIP_ID_CALYPSO_L: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2231 target_type = 5; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2232 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2233 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2234 case 'p': // Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2235 case CHIP_ID_CALYPSO_PLUS: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2236 case CHIP_ID_CALYPSO_PLUS_A: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2237 target_type = 6; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2238 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2239 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2240 default: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2241 target_type = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2242 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2243 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2244 return target_type; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2245 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2246 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2247 int image_map_count_used_chunks(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2248 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2249 int used, i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2250 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2251 // For each image chunk |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2252 for (i = 0, used = 0; i < image_size_in_chunks; i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2253 if (image_map[i] == 'x') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2254 used++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2255 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2256 return used; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2257 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2258 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2259 // When the sector_map have been changed, we have to update the image_map |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2260 // such that we don't attempt to program within sectors that are not going |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2261 // to be programmed anyway (due to the erase override). We also have to |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2262 // program chunks contained in sectors that *are* going to be erased, even |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2263 // though the chunks have been check-summed ok. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2264 int image_map_update(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2265 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2266 struct sector_s *sectors = device->memmap->sectors; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2267 int changed, chunks, i, j; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2268 int map_index; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2269 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2270 map_index = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2271 changed = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2272 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2273 // For each sector of the device definition... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2274 for (i = 0; i < device->memmap->size; i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2275 chunks = sectors[i].size / image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2276 // For each image--map-chunk contained in current sector... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2277 for (j = 0; j < chunks; j++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2278 if (!(sector_map[i] == 'x' || sector_map[i] == 'X') && |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2279 image_map[map_index + j] == 'x') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2280 image_map[map_index + j] = 's'; // skip |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2281 changed++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2282 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2283 else if ((sector_map[i] == 'x' || sector_map[i] == 'X') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2284 && image_map[map_index + j] == 'c') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2285 image_map[map_index + j] = 'x'; // include! |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2286 changed++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2287 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2288 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2289 map_index += chunks; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2290 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2291 return changed; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2292 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2293 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2294 int sector_map_init(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2295 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2296 struct sector_s *sectors = device->memmap->sectors; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2297 int map_index; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2298 int used_list_index; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2299 int used, chunks, i, j; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2300 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2301 sector_map_size = SECTOR_MAP_SIZE_MAX; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2302 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2303 memset(sector_map, 0, sector_map_size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2304 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2305 // Generate the sector_map from the image_map |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2306 map_index = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2307 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2308 // For each sector of the device definition... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2309 for (i = 0; i < device->memmap->size; i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2310 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2311 chunks = sectors[i].size / image_chunk_size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2312 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2313 // For each image-usage-map-chunk contained in current sector... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2314 for (j = 0, used = 0; j < chunks; j++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2315 if (image_map[map_index + j] == 'x') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2316 used++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2317 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2318 sector_map[i] = (used ? 'x' : 0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2319 map_index += chunks; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2320 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2321 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2322 parse_arg_erase_override(arg_erase_override); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2323 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2324 // Generate the erase_list |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2325 // For each sector of the device definition... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2326 used_list_index = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2327 for (i = 0; i < device->memmap->size; i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2328 if (sector_map[i] == 'x' || sector_map[i] == 'X') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2329 erase_list[used_list_index++] = sectors[i].addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2330 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2331 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2332 if (arg_sector_map_show) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2333 sector_map_show(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2334 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2335 if (arg_sector_list_show) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2336 flowf(ALWAYS, "sector used list: "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2337 for (i = 0; i < used_list_index; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2338 flowf(ALWAYS, "0x%06X ", erase_list[i]); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2339 putchar('\n'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2340 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2341 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2342 return used_list_index; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2343 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2344 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2345 int parse_range(char *p, char **p_end, int *n1, int *n2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2346 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2347 char *my_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2348 int read_offset_calp = (*arg_read != 0 && target[target_type].type == 'P'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2349 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2350 *n2 = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2351 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2352 *n1 = strtol(p, &my_end, 0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2353 if (p == my_end) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2354 return 0; // error: no chars converted |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2355 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2356 if (*my_end == 'k' || *my_end == 'K') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2357 *n1 <<= 10; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2358 if (read_offset_calp) *n1 += CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2359 my_end++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2360 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2361 else if (*my_end == 'M') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2362 *n1 <<= 20; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2363 if (read_offset_calp) *n1 += CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2364 my_end++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2365 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2366 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2367 *p_end = my_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2368 if (my_end[0] != '.' || my_end[1] != '.') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2369 return 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2370 p = my_end + 2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2371 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2372 *n2 = strtol(p, &my_end, 0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2373 if (p == my_end) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2374 return 0; // error: no chars converted |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2375 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2376 if (*my_end == 'k' || *my_end == 'K') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2377 *n2 <<= 10; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2378 if (read_offset_calp) *n2 += CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2379 my_end++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2380 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2381 else if (*my_end == 'M') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2382 *n2 <<= 20; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2383 if (read_offset_calp) *n2 += CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2384 my_end++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2385 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2386 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2387 *p_end = my_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2388 return 2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2389 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2390 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2391 // Parse and decode the erase override command line option string. The |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2392 // sector_map is updated accordingly. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2393 void parse_arg_erase_override(char *p) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2394 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2395 struct sector_s *sectors = device->memmap->sectors; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2396 int sector_bottom, sector_top; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2397 int changed, i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2398 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2399 tr(TrBegin| TrArgParser, "erase_override:\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2400 while (*p) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2401 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2402 char *p_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2403 int num, sign, n1 = 0, n2 = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2404 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2405 if (*p != '-' && *p != '+') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2406 main_error(E_ERASE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2407 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2408 sign = (*p == '-' ? -1 : +1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2409 p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2410 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2411 if (*p == '*') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2412 sign = sign * 2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2413 p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2414 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2415 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2416 num = parse_range(p, &p_end, &n1, &n2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2417 if (num == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2418 main_error(E_ERASE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2419 p = p_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2420 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2421 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2422 switch (sign) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2423 case -1: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2424 case +1: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2425 if (num == 1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2426 // Support for absolute addresses on Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2427 if (n1 >= CALP_OFFSET) n1 -= CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2428 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2429 if (n1 > sector_map_size) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2430 // For all sectors... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2431 for (i = 0; i < device->memmap->size; i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2432 sector_bottom = sectors[i].addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2433 sector_top = sector_bottom + sectors[i].size - 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2434 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2435 if (n1 >= sector_bottom && n1 < sector_top) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2436 sector_map[i] = (sign > 0 ? 'X' : 's'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2437 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2438 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2439 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2440 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2441 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2442 sector_map[n1] = (sign > 0 ? 'X' : 's'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2443 tr(TrArgParser, "%c%d\n", sign > 0 ? '+' : '-', n1); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2444 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2445 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2446 // Support for absolute addresses on Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2447 if (n1 >= CALP_OFFSET && n2 >= CALP_OFFSET) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2448 n1 -= CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2449 n2 -= CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2450 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2451 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2452 if (n1 > sector_map_size || n2 > sector_map_size) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2453 // n1 and n2 must respresent an address range |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2454 if (n1 >= n2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2455 main_error(E_ERASE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2456 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2457 // For all sectors... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2458 for (i = 0; i < device->memmap->size; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2459 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2460 sector_bottom = sectors[i].addr; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2461 sector_top = sector_bottom + sectors[i].size - 1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2462 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2463 // If either sector bottom or top is contained in |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2464 // [n1..n2[ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2465 if ((n1 <= sector_bottom && sector_bottom < n2) || |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2466 (n1 <= sector_top && sector_top < n2)) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2467 sector_map[i] = (sign > 0 ? 'X' : 's'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2468 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2469 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2470 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2471 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2472 // n1 and n2 must respresent a sector range |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2473 for (i = n1; i < n2; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2474 sector_map[i] = (sign > 0 ? 'X' : 's'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2475 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2476 tr(TrArgParser, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2477 "%c%d..%d\n", sign > 0 ? '+' : '-', n1, n2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2478 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2479 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2480 case -2: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2481 case +2: |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2482 // Fill whole sector_map... |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2483 for (i = 0; i < device->memmap->size; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2484 sector_map[i] = (sign > 0 ? 'X' : 's'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2485 tr(TrArgParser, "%c*\n", sign > 0 ? '+' : '-'); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2486 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2487 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2488 // skip optional comma |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2489 if (*p == ',') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2490 p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2491 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2492 tr(TrEnd| TrArgParser, ""); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2493 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2494 changed = image_map_update(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2495 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2496 // If image map was changed, we trace it again. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2497 if (changed && arg_image_map_show) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2498 image_map_show(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2499 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2500 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2501 void parse_arg_read(char *p) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2502 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2503 read_total_size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2504 read_list_size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2505 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2506 tr(TrArgParser, "parse_arg_read() {\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2507 while (*p) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2508 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2509 char *p_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2510 int num, n1, n2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2511 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2512 if (*p == '*') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2513 n1 = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2514 n2 = 0x1000000; // sufficiently large (16MB) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2515 p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2516 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2517 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2518 num = parse_range(p, &p_end, &n1, &n2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2519 tr(TrArgParser, "parse_range('%s', ...)\n" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2520 " { #%d, p_end = '%s', n1 = 0x%x, n2 = 0x%x } %d\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2521 p, read_list_size, p_end, n1, n2, num); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2522 if (num != 2 || n1 > n2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2523 main_error(E_ADDR_RANGE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2524 p = p_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2525 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2526 read_list[read_list_size].addr = n1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2527 read_list[read_list_size].size = n2 - n1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2528 read_total_size += n2 - n1; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2529 read_list_size++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2530 if (read_list_size >= READ_LIST_SIZE_MAX) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2531 main_error(E_ARG_TOOMANY); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2532 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2533 if (*p == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2534 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2535 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2536 if (*p == ',') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2537 p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2538 else |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2539 main_error(E_READ_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2540 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2541 // Terminate the read_list with zeroes. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2542 read_list[read_list_size].addr = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2543 read_list[read_list_size].size = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2544 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2545 tr(TrArgParser, "}\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2546 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2547 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2548 void parse_arg_write(char *p) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2549 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2550 tr(TrArgParser, "parse_arg_write() {\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2551 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2552 while (*p) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2553 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2554 char bytes[1024]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2555 char *p_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2556 int num, n1, n2; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2557 int index, value, size, i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2558 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2559 num = parse_range(p, &p_end, &n1, &n2); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2560 tr(TrArgParser, "parse_range('%s', ...)\n" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2561 " { p_end = '%s', n1 = 0x%x, n2 = 0x%x } %d\n", |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2562 p, p_end, n1, n2, num); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2563 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2564 if (num < 1 || num > 2) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2565 main_error(E_ADDR_RANGE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2566 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2567 p = p_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2568 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2569 if (*p++ != '=') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2570 main_error(E_WRITE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2571 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2572 tr(TrArgParser, " { "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2573 if (*p == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2574 main_error(E_WRITE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2575 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2576 index = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2577 while (*p) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2578 if (*p == '\"') { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2579 // Collect text string |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2580 p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2581 tr(TrCont|TrArgParser, "'"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2582 while (*p) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2583 if (*p == '\"') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2584 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2585 if (p[0] == '\\' && p[1] == '\"') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2586 p++; // skip leading backslash |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2587 if (p[0] == '\\' && p[1] == '\\') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2588 p++; // skip leading backslash |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2589 tr(TrCont|TrArgParser, "%c", *p); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2590 bytes[index] = *p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2591 if (index++ >= sizeof(bytes)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2592 main_error(E_WRITE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2593 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2594 if (*p++ != '\"') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2595 main_error(E_WRITE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2596 tr(TrCont|TrArgParser, "' "); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2597 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2598 else { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2599 // Collect byte string |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2600 value = strtol(p, &p_end, 0); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2601 if (p == p_end) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2602 main_error(E_WRITE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2603 if (value < 0 || 255 < value) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2604 main_error(E_WRITE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2605 bytes[index] = value; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2606 if (index++ >= sizeof(bytes)) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2607 main_error(E_WRITE_SPEC); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2608 p = p_end; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2609 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2610 tr(TrCont|TrArgParser, "0x%x ", value); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2611 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2612 if (*p == ':' || *p == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2613 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2614 if (*p == ',') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2615 p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2616 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2617 size = index; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2618 tr(TrArgParser, "} %d\n", size); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2619 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2620 if (num == 1) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2621 // Support for absolute addresses on Calypso Plus |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2622 if (n1 >= CALP_OFFSET) n1 -= CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2623 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2624 n2 = n1 + size; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2625 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2626 else if (n1 >= CALP_OFFSET && n2 >= CALP_OFFSET) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2627 n1 -= CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2628 n2 -= CALP_OFFSET; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2629 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2630 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2631 if (image_map_set(n1, n2) < 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2632 main_error(E_ADDR_RANGE); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2633 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2634 index = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2635 for (i = n1; i < n2; i++) { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2636 image[i] = bytes[index++]; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2637 if (index >= size) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2638 index = 0; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2639 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2640 if (*p == ':') |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2641 p++; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2642 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2643 tr(TrArgParser, "}\n"); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2644 } |