]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/s_record.h
NAND: Fix integer overflow in ONFI detection of chips >= 4GiB
[people/ms/u-boot.git] / include / s_record.h
CommitLineData
4a5b6a35
WD
1/*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*--------------------------------------------------------------------------
25 *
26 * Motorola S-Record Format:
27 *
28 * Motorola S-Records are an industry-standard format for
29 * transmitting binary files to target systems and PROM
30 * programmers. LSI Logic have extended this standard to include
31 * an S4-record containing an address and a symbol.
32 *
33 * The extended S-record standard is as follows:
34 *
35 * S<type><length><address><data....><checksum>
36 * S4<length><address><name>,<checksum>
37 *
38 * Where:
39 *
40 * type
41 * is the record type. Where:
42 *
43 * 0 starting record (optional)
44 * 1 data record with 16-bit address
45 * 2 data record with 24-bit address
46 * 3 data record with 32-bit address
47 * 4 symbol record (LSI extension)
48 * 5 number of data records in preceeding block
49 * 6 unused
50 * 7 ending record for S3 records
51 * 8 ending record for S2 records
52 * 9 ending record for S1 records
53 *
54 * length
55 * is two hex characters. This defines the length of the
56 * record in bytes (not characters). It includes the address
57 * field, the data field, and the checksum field.
58 *
59 * address
60 * is 4, 6, or 8 characters. Corresponding to a 16-, 24-, or
61 * 32-bit address. The address field for S4 records is
62 * always 32 bits.
63 *
64 * data
65 *
66 * Are the data bytes. Each pair of hex characters represent
67 * one byte in memory.
68 *
69 * name
70 * Is the symbol name. The symbol is terminated by a ','.
71 *
72 * checksum
73 * Is the one's complement of the 8-bit checksum.
74 *
75 * Example
76 *
77 * S0030000FC
78 * .
79 * .
80 * S325000004403C0880018D08DD900000000011000026000000003C0880012508DC50C50000B401
81 * S32500000460C50100B8C50200BCC50300C0C50400C4C50500C8C50600CCC50700D0C50800D4FA
82 * S32500000480C50900D8C50A00DCC50B00E0C50C00E4C50D00E8C50E00ECC50F00F0C51000F49A
83 * S325000004A0C51100F8C51200FCC5130100C5140104C5150108C516010CC5170110C518011434
84 * .
85 * .
86 * S70500000000FA
87 *
88 * The S0 record starts the file. The S3 records contain the
89 * data. The S7 record contains the entry address and terminates
90 * the download.
91 *
92 *--------------------------------------------------------------------------
93 */
94
95#define SREC_START 0 /* Start Record (module name) */
96#define SREC_DATA2 1 /* Data Record with 2 byte address */
97#define SREC_DATA3 2 /* Data Record with 3 byte address */
98#define SREC_DATA4 3 /* Data Record with 4 byte address */
99#define SREC_COUNT 5 /* Count Record (previously transmitted) */
53677ef1
WD
100#define SREC_END4 7 /* End Record with 4 byte start address */
101#define SREC_END3 8 /* End Record with 3 byte start address */
102#define SREC_END2 9 /* End Record with 2 byte start address */
4a5b6a35
WD
103#define SREC_EMPTY 10 /* Empty Record without any data */
104
105#define SREC_REC_OK SREC_EMPTY /* last code without error condition */
106
107#define SREC_E_BADTYPE -1 /* no valid S-Record */
108#define SREC_E_NOSREC -2 /* line format differs from s-record */
109#define SREC_E_BADCHKS -3 /* checksum error in an s-record line */
110
111#define SREC_MAXRECLEN (512 + 4) /* max ASCII record length */
112#define SREC_MAXBINLEN 255 /* resulting binary length */
113
114int srec_decode (char *input, int *count, ulong *addr, char *data);