gem5 v24.0.0.0
Loading...
Searching...
No Matches
hdlcd.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2013, 2015, 2017 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
73#ifndef __DEV_ARM_HDLCD_HH__
74#define __DEV_ARM_HDLCD_HH__
75
76#include <fstream>
77#include <memory>
78#include <vector>
79
80#include "base/framebuffer.hh"
81#include "base/imgwriter.hh"
82#include "base/output.hh"
84#include "dev/pixelpump.hh"
85#include "sim/serialize.hh"
86
87namespace gem5
88{
89
90class VncInput;
91struct HDLcdParams;
92class HDLcdPixelPump;
93
94class HDLcd: public AmbaDmaDevice
95{
96 public:
97 HDLcd(const HDLcdParams &p);
98
99 void serialize(CheckpointOut &cp) const override;
100 void unserialize(CheckpointIn &cp) override;
101
102 void drainResume() override;
103
104 public: // IO device interface
105 Tick read(PacketPtr pkt) override;
106 Tick write(PacketPtr pkt) override;
107
108 AddrRangeList getAddrRanges() const override { return addrRanges; }
109
110 protected: // Parameters
115 const bool enableCapture;
118
119 protected: // Register handling
122 {
123 Version = 0x0000,
124 Int_RawStat = 0x0010,
125 Int_Clear = 0x0014,
126 Int_Mask = 0x0018,
127 Int_Status = 0x001C,
128 Fb_Base = 0x0100,
132 Bus_Options = 0x0110,
133 V_Sync = 0x0200,
134 V_Back_Porch = 0x0204,
135 V_Data = 0x0208,
137 H_Sync = 0x0210,
138 H_Back_Porch = 0x0214,
139 H_Data = 0x0218,
141 Polarities = 0x0220,
142 Command = 0x0230,
143 Pixel_Format = 0x0240,
144 Red_Select = 0x0244,
145 Green_Select = 0x0248,
146 Blue_Select = 0x024C,
147 };
148
150 static constexpr size_t BUS_OPTIONS_RESETV = 0x408;
151
153 static constexpr size_t VERSION_RESETV = 0x1CDC0000;
154
156 static constexpr size_t AXI_PORT_WIDTH = 8;
157
159 static constexpr size_t MAX_BURST_LEN = 16;
160
162 static constexpr size_t MAX_PIXEL_SIZE = 4;
163
169 BitUnion32(VersionReg)
170 Bitfield<7,0> version_minor;
171 Bitfield<15,8> version_major;
172 Bitfield<31,16> product_id;
173 EndBitUnion(VersionReg)
174
175 static constexpr uint32_t INT_DMA_END = (1UL << 0);
176 static constexpr uint32_t INT_BUS_ERROR = (1UL << 1);
177 static constexpr uint32_t INT_VSYNC = (1UL << 2);
178 static constexpr uint32_t INT_UNDERRUN = (1UL << 3);
179
180 BitUnion32(FbLineCountReg)
181 Bitfield<11,0> fb_line_count;
182 Bitfield<31,12> reserved_31_12;
183 EndBitUnion(FbLineCountReg)
184
185 BitUnion32(BusOptsReg)
186 Bitfield<4,0> burst_len;
187 Bitfield<7,5> reserved_7_5;
188 Bitfield<11,8> max_outstanding;
189 Bitfield<31,12> reserved_31_12;
190 EndBitUnion(BusOptsReg)
191
192 BitUnion32(TimingReg)
193 Bitfield<11,0> val;
194 Bitfield<31,12> reserved_31_12;
195 EndBitUnion(TimingReg)
196
197 BitUnion32(PolaritiesReg)
198 Bitfield<0> vsync_polarity;
199 Bitfield<1> hsync_polarity;
200 Bitfield<2> dataen_polarity;
201 Bitfield<3> data_polarity;
202 Bitfield<4> pxlclk_polarity;
203 Bitfield<31,5> reserved_31_5;
204 EndBitUnion(PolaritiesReg)
205
206 BitUnion32(CommandReg)
207 Bitfield<0> enable;
208 Bitfield<31,1> reserved_31_1;
209 EndBitUnion(CommandReg)
210
211 BitUnion32(PixelFormatReg)
212 Bitfield<2,0> reserved_2_0;
213 Bitfield<4,3> bytes_per_pixel;
214 Bitfield<30,5> reserved_30_5;
215 Bitfield<31> big_endian;
216 EndBitUnion(PixelFormatReg)
217
218 BitUnion32(ColorSelectReg)
219 Bitfield<4,0> offset;
220 Bitfield<7,5> reserved_7_5;
221 Bitfield<11,8> size;
222 Bitfield<15,12> reserved_15_12;
223 Bitfield<23,16> default_color;
224 Bitfield<31,24> reserved_31_24;
225 EndBitUnion(ColorSelectReg)
233 const VersionReg version = VERSION_RESETV;
235 uint32_t int_rawstat = 0;
236 uint32_t int_mask = 0;
237 uint32_t fb_base = 0;
238 uint32_t fb_line_length = 0;
240 FbLineCountReg fb_line_count = 0;
241 int32_t fb_line_pitch = 0;
244 TimingReg v_sync = 0;
245 TimingReg v_back_porch = 0;
246 TimingReg v_data = 0;
247 TimingReg v_front_porch = 0;
248 TimingReg h_sync = 0;
249 TimingReg h_back_porch = 0;
250 TimingReg h_data = 0;
251 TimingReg h_front_porch = 0;
252 PolaritiesReg polarities = 0;
253 CommandReg command = 0;
254 PixelFormatReg pixel_format = 0;
255 ColorSelectReg red_select = 0;
256 ColorSelectReg green_select = 0;
257 ColorSelectReg blue_select = 0;
261
262 uint32_t readReg(Addr offset);
263 void writeReg(Addr offset, uint32_t value);
264
267
268 void createDmaEngine();
269
270 void cmdEnable();
271 void cmdDisable();
272
273 bool enabled() const { return command.enable; }
274
275 public: // Pixel pump callbacks
276 bool pxlNext(Pixel &p);
277 size_t lineNext(std::vector<Pixel>::iterator pixel_it, size_t line_length);
278 void pxlVSyncBegin();
279 void pxlVSyncEnd();
280 void pxlUnderrun();
281 void pxlFrameDone();
282
283 protected: // Interrupt handling
295 void setInterrupts(uint32_t ints, uint32_t mask);
296
304
311 void
312 intRaise(uint32_t ints)
313 {
315 }
316
323 void
324 intClear(uint32_t ints)
325 {
327 }
328
330 uint32_t intStatus() const { return int_rawstat & int_mask; }
331
332 protected: // Pixel output
334 {
335 public:
336 PixelPump(HDLcd &p, ClockDomain &pxl_clk, unsigned pixel_chunk)
337 : BasePixelPump(p, pxl_clk, pixel_chunk), parent(p)
338 {}
339
340 void dumpSettings();
341
342 protected:
343 bool nextPixel(Pixel &p) override { return parent.pxlNext(p); }
344 size_t
346 size_t line_length) override
347 {
348 return parent.lineNext(pixel_it, line_length);
349 }
350
351 void onVSyncBegin() override { return parent.pxlVSyncBegin(); }
352 void onVSyncEnd() override { return parent.pxlVSyncEnd(); }
353
354 void
355 onUnderrun(unsigned x, unsigned y) override
356 {
358 }
359
360 void onFrameDone() override { parent.pxlFrameDone(); }
361
362 protected:
364 };
365
367
369 void virtRefresh();
371
373 std::unique_ptr<ImgWriter> imgWriter;
374
376 enums::ImageFormat imgFormat;
377
379 OutputStream *pic = nullptr;
380
383
385
386 protected: // DMA handling
387 class DmaEngine : public DmaReadFifo
388 {
389 public:
390 DmaEngine(HDLcd &_parent, size_t size,
391 unsigned request_size, unsigned max_pending,
392 size_t line_size, ssize_t line_pitch, unsigned num_lines);
393
394 void startFrame(Addr fb_base);
395 void abortFrame();
396 void dumpSettings();
397
398 void serialize(CheckpointOut &cp) const override;
399 void unserialize(CheckpointIn &cp) override;
400
401 protected:
402 void onEndOfBlock() override;
403 void onIdle() override;
404
406 const size_t lineSize;
407 const ssize_t linePitch;
408 const unsigned numLines;
409
412 };
413
414 std::unique_ptr<DmaEngine> dmaEngine;
415
416 protected: // Statistics
422};
423
424} // namespace gem5
425
426#endif
This is a base class for AMBA devices that have to respond to Device and Implementer ID calls.
#define BitUnion32(name)
Definition bitunion.hh:495
Timing generator for a pixel-based display.
Definition pixelpump.hh:166
The ClockDomain provides clock to group of clocked objects bundled under the same clock domain.
Buffered DMA engine helper class.
size_t size() const
Get the amount of data stored in the FIFO.
const size_t lineSize
Definition hdlcd.hh:406
void startFrame(Addr fb_base)
Definition hdlcd.cc:633
const ssize_t linePitch
Definition hdlcd.hh:407
DmaEngine(HDLcd &_parent, size_t size, unsigned request_size, unsigned max_pending, size_t line_size, ssize_t line_pitch, unsigned num_lines)
Definition hdlcd.cc:602
void onIdle() override
Last response received callback.
Definition hdlcd.cc:672
void onEndOfBlock() override
End of block callback.
Definition hdlcd.cc:659
const unsigned numLines
Definition hdlcd.hh:408
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition hdlcd.cc:624
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition hdlcd.cc:615
PixelPump(HDLcd &p, ClockDomain &pxl_clk, unsigned pixel_chunk)
Definition hdlcd.hh:336
size_t nextLine(std::vector< Pixel >::iterator pixel_it, size_t line_length) override
Get the next line of pixels directly from memory.
Definition hdlcd.hh:345
bool nextPixel(Pixel &p) override
Get the next pixel from the scan line buffer.
Definition hdlcd.hh:343
void onVSyncBegin() override
First pixel clock of the first VSync line.
Definition hdlcd.hh:351
void onVSyncEnd() override
Callback on the first pixel of the line after the end VSync region (typically the first pixel of the ...
Definition hdlcd.hh:352
void onUnderrun(unsigned x, unsigned y) override
Buffer underrun occurred on a frame.
Definition hdlcd.hh:355
void onFrameDone() override
Finished displaying the visible region of a frame.
Definition hdlcd.hh:360
void pxlFrameDone()
Definition hdlcd.cc:558
static constexpr size_t VERSION_RESETV
Reset value for Version register.
Definition hdlcd.hh:153
EventFunctionWrapper virtRefreshEvent
Definition hdlcd.hh:370
PolaritiesReg polarities
Polarities register.
Definition hdlcd.hh:252
Bitfield< 30, 5 > reserved_30_5
Definition hdlcd.hh:214
void pxlUnderrun()
Definition hdlcd.cc:549
std::unique_ptr< ImgWriter > imgWriter
Helper to write out bitmaps.
Definition hdlcd.hh:373
void drainResume() override
Resume execution after a successful drain.
Definition hdlcd.cc:182
TimingReg v_sync
Vertical sync width register.
Definition hdlcd.hh:244
TimingReg v_data
Vertical data width register.
Definition hdlcd.hh:246
BusOptsReg bus_options
Bus options register.
Definition hdlcd.hh:242
Bitfield< 31, 12 > reserved_31_12
Definition hdlcd.hh:182
void writeReg(Addr offset, uint32_t value)
Definition hdlcd.cc:293
OutputStream * pic
Picture of what the current frame buffer looks like.
Definition hdlcd.hh:379
std::unique_ptr< DmaEngine > dmaEngine
Definition hdlcd.hh:414
uint32_t int_rawstat
Interrupt raw status register.
Definition hdlcd.hh:235
ColorSelectReg blue_select
Blue color select register.
Definition hdlcd.hh:257
static constexpr size_t BUS_OPTIONS_RESETV
Reset value for Bus_Options register.
Definition hdlcd.hh:150
Bitfield< 2 > dataen_polarity
Definition hdlcd.hh:200
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition hdlcd.hh:108
const Addr pixelBufferSize
Definition hdlcd.hh:116
void cmdDisable()
Definition hdlcd.cc:487
static constexpr size_t MAX_PIXEL_SIZE
Maximum number of bytes per pixel.
Definition hdlcd.hh:162
Bitfield< 31, 24 > reserved_31_24
Definition hdlcd.hh:224
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition hdlcd.cc:131
gem5::HDLcd::HDLcdStats stats
const AddrRangeList addrRanges
Definition hdlcd.hh:114
std::vector< uint8_t > lineBuffer
Definition hdlcd.hh:260
void intMask(uint32_t mask)
Convenience function to update the interrupt mask.
Definition hdlcd.hh:303
PixelPump pixelPump
Definition hdlcd.hh:384
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition hdlcd.cc:235
Bitfield< 15, 8 > version_major
Definition hdlcd.hh:171
VncInput * vnc
Definition hdlcd.hh:111
TimingReg v_back_porch
Vertical back porch width register.
Definition hdlcd.hh:245
void createDmaEngine()
Definition hdlcd.cc:446
uint32_t fb_line_length
Frame buffer Line length register.
Definition hdlcd.hh:238
Bitfield< 31, 5 > reserved_31_5
Definition hdlcd.hh:203
Bitfield< 31, 16 > product_id
Definition hdlcd.hh:172
const bool workaroundSwapRB
Definition hdlcd.hh:112
BitUnion32(VersionReg) Bitfield< 7
bool enabled() const
Definition hdlcd.hh:273
CommandReg command
Command register.
Definition hdlcd.hh:253
ColorSelectReg red_select
Red color select register.
Definition hdlcd.hh:255
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition hdlcd.cc:94
enums::ImageFormat imgFormat
Image Format.
Definition hdlcd.hh:376
Bitfield< 23, 16 > default_color
Definition hdlcd.hh:223
TimingReg h_data
Horizontal data width register.
Definition hdlcd.hh:250
Bitfield< 15, 12 > reserved_15_12
Definition hdlcd.hh:222
Bitfield< 7, 5 > reserved_7_5
Definition hdlcd.hh:187
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition hdlcd.cc:215
void intRaise(uint32_t ints)
Convenience function to raise a new interrupt.
Definition hdlcd.hh:312
Bitfield< 4 > pxlclk_polarity
Definition hdlcd.hh:202
TimingReg h_sync
Horizontal sync width register.
Definition hdlcd.hh:248
void pxlVSyncBegin()
Definition hdlcd.cc:531
size_t lineNext(std::vector< Pixel >::iterator pixel_it, size_t line_length)
Definition hdlcd.cc:512
PixelConverter conv
Cached pixel converter, set when the converter is enabled.
Definition hdlcd.hh:382
DisplayTimings displayTimings() const
Definition hdlcd.cc:437
TimingReg v_front_porch
Vertical front porch width register.
Definition hdlcd.hh:247
Bitfield< 11, 8 > size
Definition hdlcd.hh:221
uint32_t fb_base
Frame buffer base address register.
Definition hdlcd.hh:237
Bitfield< 11, 8 > max_outstanding
Definition hdlcd.hh:188
TimingReg h_front_porch
Horizontal front porch width reg.
Definition hdlcd.hh:251
TimingReg h_back_porch
Horizontal back porch width reg.
Definition hdlcd.hh:249
const bool workaroundDmaLineCount
Definition hdlcd.hh:113
Bitfield< 1 > hsync_polarity
Definition hdlcd.hh:199
Bitfield< 3 > data_polarity
Definition hdlcd.hh:201
void pxlVSyncEnd()
Definition hdlcd.cc:538
void virtRefresh()
Handler for fast frame refresh in KVM-mode.
Definition hdlcd.cc:207
Addr bypassLineAddress
Definition hdlcd.hh:366
int32_t fb_line_pitch
Frame buffer Line pitch register.
Definition hdlcd.hh:241
uint32_t readReg(Addr offset)
Definition hdlcd.cc:254
Bitfield< 31 > big_endian
Definition hdlcd.hh:215
uint32_t intStatus() const
Masked interrupt status register.
Definition hdlcd.hh:330
void setInterrupts(uint32_t ints, uint32_t mask)
Assign new interrupt values and update interrupt signals.
Definition hdlcd.cc:588
static constexpr size_t AXI_PORT_WIDTH
AXI port width in bytes.
Definition hdlcd.hh:156
static constexpr uint32_t INT_VSYNC
Definition hdlcd.hh:177
static constexpr size_t MAX_BURST_LEN
max number of beats delivered in one dma burst
Definition hdlcd.hh:159
const bool enableCapture
Definition hdlcd.hh:115
bool pxlNext(Pixel &p)
Definition hdlcd.cc:499
const Tick virtRefreshRate
Definition hdlcd.hh:117
uint32_t int_mask
Interrupt mask register.
Definition hdlcd.hh:236
void cmdEnable()
Definition hdlcd.cc:471
PixelConverter pixelConverter() const
Definition hdlcd.cc:414
RegisterOffset
ARM HDLcd register offsets.
Definition hdlcd.hh:122
@ Fb_Line_Count
Definition hdlcd.hh:130
@ Fb_Line_Length
Definition hdlcd.hh:129
@ V_Front_Porch
Definition hdlcd.hh:136
@ Blue_Select
Definition hdlcd.hh:146
@ Pixel_Format
Definition hdlcd.hh:143
@ Green_Select
Definition hdlcd.hh:145
@ V_Back_Porch
Definition hdlcd.hh:134
@ H_Front_Porch
Definition hdlcd.hh:140
@ H_Back_Porch
Definition hdlcd.hh:138
@ Bus_Options
Definition hdlcd.hh:132
@ Fb_Line_Pitch
Definition hdlcd.hh:131
@ Int_RawStat
Definition hdlcd.hh:124
void intClear(uint32_t ints)
Convenience function to clear interrupts.
Definition hdlcd.hh:324
PixelFormatReg pixel_format
Pixel format register.
Definition hdlcd.hh:254
Bitfield< 31, 1 > reserved_31_1
Definition hdlcd.hh:208
Bitfield< 4, 3 > bytes_per_pixel
Definition hdlcd.hh:213
ColorSelectReg green_select
Green color select register.
Definition hdlcd.hh:256
static constexpr uint32_t INT_UNDERRUN
Definition hdlcd.hh:178
static constexpr uint32_t INT_BUS_ERROR
Definition hdlcd.hh:176
HDLcd(const HDLcdParams &p)
Definition hdlcd.cc:60
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Configurable RGB pixel converter.
Definition pixel.hh:92
static const PixelConverter rgba8888_le
Predefined 32-bit RGB (red in least significant bits, 8 bits/channel, little endian) conversion helpe...
Definition pixel.hh:203
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
STL vector class.
Definition stl.hh:37
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 0 > p
Bitfield< 3 > x
Definition pagetable.hh:73
Bitfield< 11 > enable
Definition misc.hh:1086
Bitfield< 15, 8 > vector
Definition intmessage.hh:48
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81
HDLcdStats(statistics::Group *parent)
Definition hdlcd.cc:83
statistics::Scalar underruns
Definition hdlcd.hh:420
Internal gem5 representation of a Pixel.
Definition pixel.hh:59

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0