srecord  1.65.0
mips_flash.h
Go to the documentation of this file.
1 //
2 // srecord - Manipulate EPROM load files
3 // Copyright (C) 2011, 2013 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // 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 (at your
8 // option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 // 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 <http://www.gnu.org/licenses/>.
17 //
18 
19 #ifndef SRECORD_INPUT_FILE_MIPS_FLASH_H
20 #define SRECORD_INPUT_FILE_MIPS_FLASH_H
21 
22 #include <srecord/endian.h>
23 #include <srecord/input/file.h>
24 
25 namespace srecord {
26 
27 /**
28  * The srecord::input_file_mips_flash class is used to represent the
29  * parse state of a MIPS-Flash formatted input file.
30  */
32  public input_file
33 {
34 public:
35  /**
36  * The destructor.
37  */
39 
40  /**
41  * The create_be class method is used to create new dynamically
42  * allocated instances of this class, big-endian byte order.
43  *
44  * @param file_name
45  * The name of the file to be read.
46  * @returns
47  * smart pointer to new instance
48  */
49  static pointer create_be(const std::string &file_name);
50 
51  /**
52  * The create_le class method is used to create new dynamically
53  * allocated instances of this class, little-endian byte order.
54  * This is used by the --guess format.
55  *
56  * @param file_name
57  * The name of the file to be read.
58  * @returns
59  * smart pointer to new instance
60  */
61  static pointer create_le(const std::string &file_name);
62 
63 protected:
64  // See base class for documentation.
65  bool read(record &record);
66 
67  // See base class for documentation.
68  const char *get_file_format_name(void) const;
69 
70  // See base class for documentation.
71  int format_option_number(void) const;
72 
73 private:
74  /**
75  * The constructor.
76  *
77  * @param file_name
78  * The name of the file to be read.
79  * @param end
80  * The byte order.
81  */
82  input_file_mips_flash(const std::string &file_name,
83  endian_t end = endian_big);
84 
85  /**
86  * The read_inner method is used to read a record from the file.
87  * The read method is a wrapper around it.
88  */
89  bool read_inner(record &);
90 
91  /**
92  * The seen_some_input instance variable is used to remember whether
93  * or not any data has been seen from this file to date.
94  */
95  bool seen_some_input;
96 
97  /**
98  * The endian instance variable is used to remember whether the
99  * file is big-endian or little-endian.
100  */
101  endian_t endian;
102 
103  /**
104  * The address instance variable is used to remember where we are
105  * up to in the input file, for when we build the next data record.
106  */
107  unsigned long address;
108 
109  /**
110  * The tokenizer method is used to determine the next token in the
111  * input token stream. It sets #token and #token_value before
112  * it returns. If it finds an error it will issue a #fatal_error
113  * message and not return.
114  */
115  void tokenizer(void);
116 
117  enum token_t
118  {
119  token_eof,
120  token_at,
121  token_erase,
122  token_lock,
123  token_number,
124  token_reset,
125  token_unlock,
126  };
127 
128  /**
129  * The token instance variable is used to remember the kind of
130  * token was found by the preceeding #tokenizer call.
131  */
132  token_t token;
133 
134  /**
135  * The token_value instance variable is used to remember the value
136  * of the number, if the preceeding #tokenizer call saw a number.
137  * Otherwise, its value is undefined.
138  */
139  unsigned long token_value;
140 
141  /**
142  * The seen_reset instance variable is used to remember
143  * whether or not the initial '!R' token has already been seen.
144  */
145  bool seen_reset;
146 
147  /**
148  * The default constructor. Do not use.
149  */
151 
152  /**
153  * The copy constructor. Do not use.
154  */
156 
157  /**
158  * The assigmne toperator. Do not use.
159  */
160  input_file_mips_flash &operator=(const input_file_mips_flash &);
161 };
162 
163 };
164 
165 // vim: set ts=8 sw=4 et :
166 #endif // SRECORD_INPUT_FILE_MIPS_FLASH_H
The srecord::input_file_mips_flash class is used to represent the parse state of a MIPS-Flash formatt...
Definition: mips_flash.h:33
static pointer create_le(const std::string &file_name)
The create_le class method is used to create new dynamically allocated instances of this class,...
virtual ~input_file_mips_flash()
The destructor.
int format_option_number(void) const
The format_option_number method is used to obtain the option number, which can then be turned into te...
const char * get_file_format_name(void) const
The get_file_format_name method is used to find out the name of the file format being read.
static pointer create_be(const std::string &file_name)
The create_be class method is used to create new dynamically allocated instances of this class,...
bool read(record &record)
The read method is used to read one record from the input.
The srecord::input_file class is used to represent an generic input file.
Definition: file.h:37
std::shared_ptr< input > pointer
Definition: input.h:41
The srecord::record class is used to represent a data record read from a file.
Definition: record.h:35
endian_t
Definition: endian.h:27
@ endian_big
Definition: endian.h:28