gem5  v21.1.0.2
atag.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __ARCH_ARM_LINUX_ATAG_HH__
39 #define __ARCH_ARM_LINUX_ATAG_HH__
40 
41 #include <cstring>
42 #include <string>
43 
44 #include "base/types.hh"
45 
46 namespace gem5
47 {
48 
49 enum
50 {
51  CoreTag = 0x54410001,
52  MemTag = 0x54410002,
53  RevTag = 0x54410007,
54  SerialTag = 0x54410006,
55  CmdTag = 0x54410009,
56  NoneTag = 0x00000000
57 };
58 
60 {
61  protected:
62  uint32_t *storage;
63  uint32_t _size;
64 
65  public:
67  virtual uint32_t tag() = 0;
69  virtual bool null() { return false; }
70 
71  uint32_t size() const { return _size; }
72 
73  AtagHeader(uint32_t s)
74  : _size(s)
75  {
76  storage = new uint32_t[size()];
77  }
78 
79  virtual ~AtagHeader()
80  {
81  delete[] storage;
82  }
83 
84  uint32_t copyOut(uint8_t *p)
85  {
86  storage[0] = null() ? 0 : size();
87  storage[1] = tag();
88  memcpy(p, storage, size() << 2);
89  return size() << 2;
90  }
91 };
92 
93 class AtagCore : public AtagHeader
94 {
95  public:
96  static const uint32_t Size = 5;
97  uint32_t tag() { return CoreTag; }
98 
99  void flags(uint32_t i) { storage[2] = i; }
100  void pagesize(uint32_t i) { storage[3] = i; }
101  void rootdev(uint32_t i) { storage[4] = i; }
103  : AtagHeader(Size)
104  {}
105 };
106 
107 class AtagMem : public AtagHeader
108 {
109  public:
110  static const uint32_t Size = 4;
111  uint32_t tag() { return MemTag; }
112 
113  void memSize(uint32_t i) { storage[2] = i; }
114  void memStart(uint32_t i) { storage[3] = i; }
116  : AtagHeader(Size)
117  {}
118 };
119 
120 class AtagRev : public AtagHeader
121 {
122  public:
123  static const uint32_t Size = 3;
124  uint32_t tag() { return RevTag; }
125 
126  void rev(uint32_t i) { storage[2] = i; }
128  : AtagHeader(Size)
129  {}
130 };
131 
132 
133 class AtagSerial : public AtagHeader
134 {
135  public:
136  static const uint32_t Size = 4;
137  uint32_t tag() { return SerialTag; }
138 
139  void sn(uint64_t i) { storage[2] = (uint32_t)i; storage[3] = i >> 32; }
141  : AtagHeader(Size)
142  {}
143 };
144 
145 class AtagCmdline : public AtagHeader
146 {
147  public:
148  static const uint32_t Size = 3;
149  uint32_t tag() { return CmdTag; }
150 
151  void cmdline(const std::string &s)
152  {
153  // Add one for null terminator
154  int len = s.length() + 1;
155 
156  // 2 + ceiling(len/4)
157  _size = 2 + ((len + 3) >> 2);
158 
159  delete[] storage;
160  storage = new uint32_t[size()];
161  // Initialize the last byte of memory here beacuse it might be slightly
162  // longer than needed and mis-speculation of the NULL in the O3 CPU can
163  // change stats ever so slightly when that happens.
164  storage[size() - 1] = 0;
165  strcpy((char*)&storage[2] , s.c_str());
166  }
168  : AtagHeader(Size)
169  {}
170 };
171 
172 class AtagNone : public AtagHeader
173 {
174  public:
175  static const uint32_t Size = 2;
176  virtual bool null() { return true; }
177  uint32_t tag() { return NoneTag; }
179  : AtagHeader(Size)
180  {}
181 };
182 /*
183 //
184 // example ARM Linux bootloader code
185 // this example is distributed under the BSD licence
186 // Code taken from http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html
188 
189 // list of possible tags
190 #define ATAG_NONE 0x00000000
191 #define ATAG_CORE 0x54410001
192 #define ATAG_MEM 0x54410002
193 #define ATAG_VIDEOTEXT 0x54410003
194 #define ATAG_RAMDISK 0x54410004
195 #define ATAG_INITRD2 0x54420005
196 #define ATAG_SERIAL 0x54410006
197 #define ATAG_REVISION 0x54410007
198 #define ATAG_VIDEOLFB 0x54410008
199 #define ATAG_CMDLINE 0x54410009
200 
201 // structures for each atag
202 struct atag_header
203 {
204  u32 size; // length of tag in words including this header
205  u32 tag; // tag type
206 };
207 
208 struct atag_core
209 {
210  u32 flags;
211  u32 pagesize;
212  u32 rootdev;
213 };
214 
215 struct atag_mem
216 {
217  u32 size;
218  u32 start;
219 };
220 
221 struct atag_videotext
222 {
223  u8 x;
224  u8 y;
225  u16 video_page;
226  u8 video_mode;
227  u8 video_cols;
228  u16 video_ega_bx;
229  u8 video_lines;
230  u8 video_isvga;
231  u16 video_points;
232 };
233 
234 struct atag_ramdisk
235 {
236  u32 flags;
237  u32 size;
238  u32 start;
239 };
240 
241 struct atag_initrd2
242 {
243  u32 start;
244  u32 size;
245 };
246 
247 struct atag_serialnr
248 {
249  u32 low;
250  u32 high;
251 };
252 
253 struct atag_revision
254 {
255  u32 rev;
256 };
257 
258 struct atag_videolfb
259 {
260  u16 lfb_width;
261  u16 lfb_height;
262  u16 lfb_depth;
263  u16 lfb_linelength;
264  u32 lfb_base;
265  u32 lfb_size;
266  u8 red_size;
267  u8 red_pos;
268  u8 green_size;
269  u8 green_pos;
270  u8 blue_size;
271  u8 blue_pos;
272  u8 rsvd_size;
273  u8 rsvd_pos;
274 };
275 
276 struct atag_cmdline
277 {
278  char cmdline[1];
279 };
280 
281 struct atag
282 {
283  struct atag_header hdr;
284  union
285  {
286  struct atag_core core;
287  struct atag_mem mem;
288  struct atag_videotext videotext;
289  struct atag_ramdisk ramdisk;
290  struct atag_initrd2 initrd2;
291  struct atag_serialnr serialnr;
292  struct atag_revision revision;
293  struct atag_videolfb videolfb;
294  struct atag_cmdline cmdline;
295  } u;
296 };
297 */
298 
299 } // namespace gem5
300 
301 #endif // __ARCH_ARM_LINUX_ATAG_HH__
gem5::AtagSerial::Size
static const uint32_t Size
Definition: atag.hh:136
gem5::AtagMem
Definition: atag.hh:107
gem5::AtagSerial::sn
void sn(uint64_t i)
Definition: atag.hh:139
gem5::AtagCore::flags
void flags(uint32_t i)
Definition: atag.hh:99
gem5::ArmISA::len
Bitfield< 18, 16 > len
Definition: misc_types.hh:444
gem5::AtagMem::memStart
void memStart(uint32_t i)
Definition: atag.hh:114
gem5::AtagRev::AtagRev
AtagRev()
Definition: atag.hh:127
gem5::AtagHeader::size
uint32_t size() const
Definition: atag.hh:71
gem5::AtagCmdline::tag
uint32_t tag()
Tag (normally starts with 'T''A' and 16 bits of number.
Definition: atag.hh:149
gem5::AtagHeader::~AtagHeader
virtual ~AtagHeader()
Definition: atag.hh:79
gem5::AtagSerial::AtagSerial
AtagSerial()
Definition: atag.hh:140
gem5::AtagCmdline
Definition: atag.hh:145
gem5::AtagCore::Size
static const uint32_t Size
Definition: atag.hh:96
gem5::AtagHeader::_size
uint32_t _size
Definition: atag.hh:63
gem5::AtagCore::rootdev
void rootdev(uint32_t i)
Definition: atag.hh:101
gem5::AtagHeader
Definition: atag.hh:59
gem5::AtagCore::AtagCore
AtagCore()
Definition: atag.hh:102
gem5::RevTag
@ RevTag
Definition: atag.hh:53
gem5::AtagSerial
Definition: atag.hh:133
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
gem5::AtagHeader::AtagHeader
AtagHeader(uint32_t s)
Definition: atag.hh:73
gem5::AtagNone::AtagNone
AtagNone()
Definition: atag.hh:178
gem5::AtagCore::pagesize
void pagesize(uint32_t i)
Definition: atag.hh:100
gem5::AtagNone::tag
uint32_t tag()
Tag (normally starts with 'T''A' and 16 bits of number.
Definition: atag.hh:177
gem5::AtagCmdline::Size
static const uint32_t Size
Definition: atag.hh:148
gem5::AtagRev::Size
static const uint32_t Size
Definition: atag.hh:123
gem5::AtagRev::tag
uint32_t tag()
Tag (normally starts with 'T''A' and 16 bits of number.
Definition: atag.hh:124
gem5::AtagMem::memSize
void memSize(uint32_t i)
Definition: atag.hh:113
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::ArmISA::s
Bitfield< 4 > s
Definition: misc_types.hh:561
gem5::AtagHeader::tag
virtual uint32_t tag()=0
Tag (normally starts with 'T''A' and 16 bits of number.
gem5::AtagRev
Definition: atag.hh:120
gem5::MemTag
@ MemTag
Definition: atag.hh:52
gem5::AtagHeader::copyOut
uint32_t copyOut(uint8_t *p)
Definition: atag.hh:84
gem5::AtagNone::Size
static const uint32_t Size
Definition: atag.hh:175
gem5::AtagRev::rev
void rev(uint32_t i)
Definition: atag.hh:126
gem5::AtagCore
Definition: atag.hh:93
gem5::AtagCmdline::AtagCmdline
AtagCmdline()
Definition: atag.hh:167
gem5::AtagCmdline::cmdline
void cmdline(const std::string &s)
Definition: atag.hh:151
types.hh
gem5::AtagSerial::tag
uint32_t tag()
Tag (normally starts with 'T''A' and 16 bits of number.
Definition: atag.hh:137
gem5::AtagMem::AtagMem
AtagMem()
Definition: atag.hh:115
gem5::AtagMem::tag
uint32_t tag()
Tag (normally starts with 'T''A' and 16 bits of number.
Definition: atag.hh:111
gem5::CmdTag
@ CmdTag
Definition: atag.hh:55
gem5::AtagNone
Definition: atag.hh:172
gem5::AtagHeader::storage
uint32_t * storage
Definition: atag.hh:62
gem5::AtagMem::Size
static const uint32_t Size
Definition: atag.hh:110
gem5::NoneTag
@ NoneTag
Definition: atag.hh:56
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::AtagCore::tag
uint32_t tag()
Tag (normally starts with 'T''A' and 16 bits of number.
Definition: atag.hh:97
gem5::SerialTag
@ SerialTag
Definition: atag.hh:54
gem5::CoreTag
@ CoreTag
Definition: atag.hh:51

Generated on Tue Sep 21 2021 12:24:36 for gem5 by doxygen 1.8.17