21 #include "pedigree/kernel/machine/x86_common/Bios.h" 22 #include "pedigree/kernel/processor/PhysicalMemoryManager.h" 23 #include "pedigree/kernel/processor/VirtualAddressSpace.h" 24 #include "pedigree/kernel/utilities/utility.h" 26 X86Vga::X86Vga(uint32_t nRegisterBase, uint32_t nFramebufferBase)
27 : m_RegisterPort(
"VGA controller"), m_Framebuffer(
"VGA framebuffer"),
28 m_pFramebuffer(reinterpret_cast<uint8_t *>(nFramebufferBase)),
29 m_nWidth(80), m_nHeight(25), m_ModeStack(0), m_nMode(3), m_nControls(0)
37 uint8_t X86Vga::getControls()
40 m_RegisterPort.read8(VGA_INSTAT_READ);
43 m_RegisterPort.write8(VGA_REG_ATTR_MODE_CTL | VGA_PAS, VGA_AC_INDEX);
44 return m_RegisterPort.read8(VGA_AC_READ);
47 void X86Vga::setControls(uint8_t newControls)
52 m_RegisterPort.read8(VGA_INSTAT_READ);
55 m_RegisterPort.write8(VGA_REG_ATTR_MODE_CTL | VGA_PAS, VGA_AC_INDEX);
61 uint8_t current = getControls();
62 current |= 1 <<
static_cast<uint8_t
>(which);
68 uint8_t current = getControls();
69 current &= ~(1 <<
static_cast<uint8_t
>(which));
134 if (m_Framebuffer ==
true)
135 MemoryCopy(m_Framebuffer.virtualAddress(), pBuffer, nBufLen);
137 MemoryCopy(m_pFramebuffer, pBuffer, nBufLen);
142 if (m_Framebuffer ==
true)
143 MemoryCopy(pBuffer, m_Framebuffer.virtualAddress(), nBufLen);
145 MemoryCopy(pBuffer, m_pFramebuffer, nBufLen);
155 m_RegisterPort.write8(14, VGA_CRTC_INDEX);
156 m_RegisterPort.write8(tmp >> 8, VGA_CRTC_DATA);
157 m_RegisterPort.write8(15, VGA_CRTC_INDEX);
158 m_RegisterPort.write8(tmp, VGA_CRTC_DATA);
161 bool X86Vga::initialise()
164 if (m_RegisterPort.allocate(VGA_BASE, 0x1B) ==
false)
175 reinterpret_cast<uintptr_t>(m_pFramebuffer));
virtual void restoreMode()
virtual void peekBuffer(uint8_t *pBuffer, size_t nBufLen)
static PhysicalMemoryManager & instance()
virtual void moveCursor(size_t nX, size_t nY)
static const size_t continuous
virtual void pokeBuffer(uint8_t *pBuffer, size_t nBufLen)
virtual void clearControl(VgaControl which)
static const size_t WriteThrough
void executeInterrupt(int interrupt)
static const size_t Write
static const size_t KernelMode
virtual bool isMode(size_t nCols, size_t nRows, bool bIsText, size_t nBpp=0)
virtual bool isLargestTextMode()
virtual void setControl(VgaControl which)
virtual bool setMode(int mode)
virtual bool allocateRegion(MemoryRegion &Region, size_t cPages, size_t pageConstraints, size_t Flags, physical_uintptr_t start=-1)=0
virtual bool setLargestTextMode()
static const size_t nonRamMemory
virtual void rememberMode()