43#include "debug/PL111.hh"
44#include "debug/Uart.hh"
60 :
AmbaDmaDevice(
p, 0x10000), lcdTiming0(0), lcdTiming1(0), lcdTiming2(0),
61 lcdTiming3(0), lcdUpbase(0), lcdLpbase(0), lcdControl(0), lcdImsc(0),
63 clcdCrsrCtrl(0), clcdCrsrConfig(0), clcdCrsrPalette0(0),
64 clcdCrsrPalette1(0), clcdCrsrXY(0), clcdCrsrClip(0), clcdCrsrImsc(0),
65 clcdCrsrIcr(0), clcdCrsrRis(0), clcdCrsrMis(0),
66 pixelClock(
p.pixel_clock),
68 vnc(
p.vnc), bmp(&
fb), pic(NULL),
69 width(LcdMaxWidth), height(LcdMaxHeight),
70 bytesPerPixel(4), startTime(0), startAddr(0), maxAddr(0), curAddr(0),
71 waterMark(0), dmaPendingNum(0),
73 fillFifoEvent([
this]{ fillFifo(); },
name()),
74 dmaDoneEventAll(maxOutstandingDma,
this),
75 dmaDoneEventFree(maxOutstandingDma),
76 intEvent([
this]{ generateInterrupt(); },
name()),
77 enableCapture(
p.enable_capture)
79 dmaBuffer =
new uint8_t[buffer_size];
81 memset(lcdPalette, 0,
sizeof(lcdPalette));
82 memset(cursorImage, 0,
sizeof(cursorImage));
83 memset(dmaBuffer, 0, buffer_size);
85 for (
int i = 0;
i < maxOutstandingDma; ++
i)
86 dmaDoneEventFree[
i] = &dmaDoneEventAll[
i];
89 vnc->setFrameBuffer(&
fb);
111 DPRINTF(PL111,
" read register %#x size=%d\n", daddr, pkt->
getSize());
145 panic(
"LCD register at offset %#x is Write-Only\n", daddr);
175 panic(
"CLCD register at offset %#x is Write-Only\n", daddr);
188 }
else if (daddr >=
CrsrImage && daddr <= 0xBFC) {
194 }
else if (daddr >=
LcdPalette && daddr <= 0x3FC) {
201 panic(
"Tried to read CLCD register at offset %#x that "
202 "doesn't exist\n", daddr);
226 DPRINTF(PL111,
" write register %#x value %#x size=%d\n", daddr,
248 DPRINTF(PL111,
"####### Upper panel base set to: %#x #######\n",
lcdUpbase);
251 warn_once(
"LCD dual screen mode not supported\n");
273 panic(
"Interrupting on vcomp not supported\n");
282 panic(
"LCD register at offset %#x is Read-Only\n", daddr);
285 panic(
"LCD register at offset %#x is Read-Only\n", daddr);
296 panic(
"LCD register at offset %#x is Read-Only\n", daddr);
299 panic(
"LCD register at offset %#x is Read-Only\n", daddr);
326 panic(
"CLCD register at offset %#x is Read-Only\n", daddr);
329 panic(
"CLCD register at offset %#x is Read-Only\n", daddr);
332 if (daddr >=
CrsrImage && daddr <= 0xBFC) {
338 }
else if (daddr >=
LcdPalette && daddr <= 0x3FC) {
345 panic(
"Tried to write PL111 register at offset %#x that "
346 "doesn't exist\n", daddr);
379 panic(
"Unimplemented video mode\n");
385 offsets[2], offsets[1], offsets[0],
391 offsets[0], offsets[1], offsets[2],
459 assert(!
event->scheduled());
483 warn(
"CLCD controller buffer underrun, took %d ticks when should"
496 DPRINTF(PL111,
"-- write out frame buffer into bmp\n");
526 DPRINTF(PL111,
"Serializing ARM PL111\n");
546 uint8_t lcdImsc_serial =
lcdImsc;
549 uint8_t lcdRis_serial =
lcdRis;
552 uint8_t lcdMis_serial =
lcdMis;
589 Tick int_event_time = 0;
590 Tick read_event_time = 0;
591 Tick fill_fifo_event_time = 0;
616 DPRINTF(PL111,
"Unserializing ARM PL111\n");
618 uint32_t lcdTiming0_serial;
622 uint32_t lcdTiming1_serial;
626 uint32_t lcdTiming2_serial;
630 uint32_t lcdTiming3_serial;
637 uint32_t lcdControl_serial;
641 uint8_t lcdImsc_serial;
645 uint8_t lcdRis_serial;
649 uint8_t lcdMis_serial;
663 uint8_t clcdCrsrImsc_serial;
667 uint8_t clcdCrsrIcr_serial;
671 uint8_t clcdCrsrRis_serial;
675 uint8_t clcdCrsrMis_serial;
691 Tick int_event_time = 0;
692 Tick read_event_time = 0;
693 Tick fill_fifo_event_time = 0;
703 if (fill_fifo_event_time)
711 if (dma_done_event_tick[
x])
729 DPRINTF(PL111,
"Generate Interrupt: lcdImsc=0x%x lcdRis=0x%x lcdMis=0x%x\n",
735 DPRINTF(PL111,
" -- Generated\n");
This is a base class for AMBA devices that have to respond to Device and Implementer ID calls.
Base class for ARM GIC implementations.
bool readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
ArmInterruptPin *const interrupt
virtual void clear()=0
Clear a signalled interrupt.
virtual void raise()=0
Signal an interrupt.
void write(std::ostream &bmp) const override
Write the frame buffer data into the provided ostream.
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Cycles ticksToCycles(Tick t) const
void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, uint8_t *data, Tick delay, Request::Flags flag=0)
void copyIn(const uint8_t *fb, const PixelConverter &conv)
Fill the frame buffer with pixel data from an external buffer of the same width and height as this fr...
void resize(unsigned width, unsigned height)
Resize the frame buffer.
virtual std::string name() const
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
std::ostream * stream() const
Get the output underlying output stream.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setUintX(uint64_t w, ByteOrder endian)
Set the value in the word w after truncating it to the length of the packet and then byteswapping it ...
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
void makeAtomicResponse()
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
Configurable RGB pixel converter.
void dmaDone()
DMA done event.
static const int LcdLpCurr
static const int ClcdCrsrCtrl
Addr curAddr
Frame buffer current address.
EventFunctionWrapper readEvent
DMA framebuffer read event.
static const int ClcdCrsrXY
uint32_t clcdCrsrClip
Cursor clip position register.
Addr startAddr
Frame buffer base address.
ControlReg lcdControl
Control register.
uint32_t clcdCrsrXY
Cursor XY position register.
static const int LcdTiming3
uint32_t clcdCrsrPalette1
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
InterruptReg clcdCrsrMis
Cursor masked interrupt status register - const.
uint32_t clcdCrsrPalette0
Cursor palette registers.
void serialize(CheckpointOut &cp) const override
Serialize an object.
static const int LcdControl
TimingReg2 lcdTiming2
Clock and signal polarity control register.
TimingReg1 lcdTiming1
Vertical axis panel control register.
Addr maxAddr
Frame buffer max address.
static const int LcdLpBase
static const int LcdPaletteSize
uint8_t * dmaBuffer
CLCDC supports up to 1024x768.
static const int ClcdCrsrConfig
InterruptReg clcdCrsrRis
Cursor raw interrupt status register - const.
Tick startTime
Start time for frame buffer dma read.
uint32_t lcdUpbase
Upper panel frame base address register.
static const int maxOutstandingDma
InterruptReg lcdImsc
Interrupt mask set/clear register.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
uint16_t width
Frame buffer width - pixels per line.
static const int ClcdCrsrMis
uint8_t bytesPerPixel
Bytes per pixel.
std::vector< DmaDoneEvent > dmaDoneEventAll
All pre-allocated DMA done events.
static const int LcdUpBase
static const int LcdTiming2
uint16_t height
Frame buffer height - lines per panel.
EventFunctionWrapper fillFifoEvent
Fill fifo.
TimingReg3 lcdTiming3
Line end control register.
std::vector< DmaDoneEvent * > dmaDoneEventFree
Unused DMA done events that are ready to be scheduled.
uint32_t cursorImage[CrsrImageSize]
Cursor image RAM register 256-word wide values defining images overlaid by the hw cursor mechanism.
uint32_t clcdCrsrCtrl
Cursor control register.
InterruptReg clcdCrsrImsc
Cursor interrupt mask set/clear register.
InterruptReg lcdMis
Masked interrupt status register.
InterruptReg clcdCrsrIcr
Cursor interrupt clear register.
uint32_t lcdPalette[LcdPaletteSize]
256x16-bit color palette registers 256 palette entries organized as 128 locations of two entries per ...
static const int LcdUpCurr
uint32_t lcdLpbase
Lower panel frame base address register.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const int ClcdCrsrRis
static const int CrsrImage
void readFramebuffer()
DMA framebuffer read.
Tick pixelClock
Pixel clock.
static const int ClcdCrsrPalette1
uint32_t clcdCrsrConfig
Cursor configuration register.
static const int LcdTiming0
ARM PL111 register map.
VncInput * vnc
VNC server.
static const int LcdTiming1
PixelConverter pixelConverter() const
EventFunctionWrapper intEvent
Wrapper to create an event out of the interrupt.
static const int CrsrImageSize
uint32_t waterMark
DMA FIFO watermark.
static const int LcdPalette
static const int buffer_size
uint32_t dmaPendingNum
Number of pending dma reads.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void generateInterrupt()
Function to generate interrupt.
void startDma()
start the dmas off after power is enabled
static const int ClcdCrsrIcr
BmpWriter bmp
Helper to write out bitmaps.
void fillFifo()
fillFIFO event
static const int ClcdCrsrImsc
EndBitUnion(ControlReg) class DmaDoneEvent TimingReg0 lcdTiming0
Event wrapper for dmaDone()
OutputStream * pic
Picture of what the current frame buffer looks like.
InterruptReg lcdRis
Raw interrupt status register - const.
static const uint64_t AMBA_ID
static const int ClcdCrsrPalette0
static const int ClcdCrsrClip
void updateVideoParams()
Send updated parameters to the vnc server.
@ UNCACHEABLE
The request is to an uncacheable address.
AddrRange RangeSize(Addr start, Addr size)
bool scheduled() const
Determine if the current event is scheduled.
void schedule(Event &event, Tick when)
Tick when() const
Get the time that the event is scheduled.
#define panic(...)
This implements a cprintf based panic() function.
#define UNSERIALIZE_CONTAINER(member)
#define UNSERIALIZE_ARRAY(member, size)
#define SERIALIZE_ARRAY(member, size)
#define SERIALIZE_CONTAINER(member)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
std::string csprintf(const char *format, const Args &...args)
Declaration of the Packet class.
Implementiation of a PL111 CLCD controller.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)
const std::string & name()