srecord 1.65.0
 
Loading...
Searching...
No Matches
aomf.h
Go to the documentation of this file.
1//
2// srecord - manipulate eprom load files
3// Copyright (C) 2004, 2006-2008, 2010, 2012 Peter Miller
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation; either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this program. If not, see
17// <http://www.gnu.org/licenses/>.
18//
19
20#ifndef SRECORD_OUTPUT_FILE_AOMF_H
21#define SRECORD_OUTPUT_FILE_AOMF_H
22
23#include <srecord/output/file.h>
24
25namespace srecord
26{
27
28/**
29 * The srecord::output_file_aomf class is used to represent the output
30 * state of a file in Intel Absolute Object Module Format (AOMF).
31 */
32class output_file_aomf:
33 public output_file
34{
35public:
36 /**
37 * The destructor.
38 */
40
41private:
42 /**
43 * A constructor. The input will be read from the named file
44 * (or the standard input if the file name is "-").
45 *
46 * @param file_name
47 * The name of the file to be written.
48 */
49 output_file_aomf(const std::string &file_name);
50
51public:
52 /**
53 * The create class method is used to create new dynamically
54 * allocated instances of this class.
55 *
56 * @param file_name
57 * The file name to open to write data to. The name "-" is
58 * understood to mean the standard output.
59 */
60 static pointer create(const std::string &file_name);
61
62protected:
63 // See base class for documentation.
64 void write(const record &);
65
66 // See base class for documentation.
67 bool preferred_block_size_set(int nbytes);
68
69 // See base class for documentation.
70 int preferred_block_size_get(void) const;
71
72 // See base class for documentation.
73 void line_length_set(int);
74
75 // See base class for documentation.
77
78 // See base class for documentation.
79 const char *format_name(void) const;
80
81private:
82 /**
83 * The emit_record method is used to emit records in the AOMF format.
84 * Each has an 8-but type, a 16-bit little-endian length, a payload,
85 * and an 8-bit 2s complement checksum.
86 */
87 void emit_record(int, const unsigned char *, size_t);
88
89 /**
90 * The module_header_record method is used to write an AOMF Module
91 * Header Record.
92 */
93 void module_header_record(const char*);
94
95 /**
96 * The content_record method is used to write an AOMF Content Record.
97 */
98 void content_record(unsigned long address, const unsigned char *data,
99 size_t length);
100
101 /**
102 * The module_header_record method is used to write an AOMF Module
103 * End Record.
104 */
105 void module_end_record(const char*);
106
107 /**
108 * See base class for documentation. We are over-riding it
109 * because we use raw binary, so we call the #put_char method.
110 * This method also tracks the byte_offset, so that we can
111 * align to specific boundaries. Calls the #checksum_add method.
112 */
113 void put_byte(unsigned char);
114
115 /**
116 * The byte_offset instance variable is used to track the location
117 * in the output file. Maintained by the #put_byte method.
118 */
119 unsigned long byte_offset;
120
121 /**
122 * The module_name instance variable is used to remember the
123 * information form the Module Header Record for reproduction in
124 * the Module End Record (they are required to agree).
125 */
126 std::string module_name;
127
128 /**
129 * The copy constructor. Do not use.
130 */
131 output_file_aomf(const output_file_aomf &);
132
133 /**
134 * The assignment operator. Do not use.
135 */
136 output_file_aomf &operator=(const output_file_aomf &);
137};
138
139};
140
141// vim: set ts=8 sw=4 et :
142#endif // SRECORD_OUTPUT_FILE_AOMF_H
virtual ~output_file_aomf()
The destructor.
const char * format_name(void) const
The format_name method is used to obtain the name of this output format.
void address_length_set(int)
The address_length_set method is used to set the minimum number of bytes to be written for addresses ...
void write(const record &)
The write method is used to write a recordonto an output.
int preferred_block_size_get(void) const
The preferred_block_size_get method is used to get the proferred block size of the output fformat.
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
void line_length_set(int)
The set_line_length method is used to set the maximum length of an output line, for those formats for...
bool preferred_block_size_set(int nbytes)
The preferred_block_size_set method is is to set a precific number of bytes for the preferred block s...
output_file()
The default constructor.
std::shared_ptr< output > pointer
Definition output.h:41
The srecord::record class is used to represent a data record read from a file.
Definition record.h:35