The Pedigree Project  0.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
X86Vga Class Reference

#include <Vga.h>

+ Inheritance diagram for X86Vga:
+ Collaboration diagram for X86Vga:

Public Member Functions

 X86Vga (uint32_t nRegisterBase, uint32_t nFramebufferBase)
 
virtual void setControl (VgaControl which)
 
virtual void clearControl (VgaControl which)
 
virtual bool setMode (int mode)
 
virtual bool setLargestTextMode ()
 
virtual bool isMode (size_t nCols, size_t nRows, bool bIsText, size_t nBpp=0)
 
virtual bool isLargestTextMode ()
 
virtual size_t getNumCols ()
 
virtual size_t getNumRows ()
 
virtual void rememberMode ()
 
virtual void restoreMode ()
 
virtual void pokeBuffer (uint8_t *pBuffer, size_t nBufLen)
 
virtual void peekBuffer (uint8_t *pBuffer, size_t nBufLen)
 
virtual void moveCursor (size_t nX, size_t nY)
 
bool initialise ()
 
 operator uint16_t * () const
 

Private Member Functions

 X86Vga (const X86Vga &)
 
X86Vgaoperator= (const X86Vga &)
 
uint8_t getControls ()
 
void setControls (uint8_t newControls)
 

Private Attributes

IoPort m_RegisterPort
 
MemoryMappedIo m_Framebuffer
 
uint8_t * m_pFramebuffer
 
size_t m_nWidth
 
size_t m_nHeight
 
int m_ModeStack
 
int m_nMode
 
uint8_t m_nControls
 

Additional Inherited Members

- Public Types inherited from Vga
enum  VgaControl { LineGraphics = 2, Blink = 3 }
 

Detailed Description

Vga device abstraction.

Definition at line 60 of file kernel/machine/mach_pc/Vga.h.

Member Function Documentation

void X86Vga::clearControl ( Vga::VgaControl  which)
virtual

Clears the given attribute mode control.

Implements Vga.

Definition at line 66 of file kernel/machine/mach_pc/Vga.cc.

virtual size_t X86Vga::getNumCols ( )
inlinevirtual
Returns
The number of columns in the current mode.

Implements Vga.

Definition at line 100 of file kernel/machine/mach_pc/Vga.h.

References m_nWidth.

virtual size_t X86Vga::getNumRows ( )
inlinevirtual
Returns
The number of rows in the current mode.

Implements Vga.

Definition at line 108 of file kernel/machine/mach_pc/Vga.h.

References m_nHeight, m_pFramebuffer, moveCursor(), peekBuffer(), pokeBuffer(), rememberMode(), restoreMode(), and MemoryRegion::virtualAddress().

bool X86Vga::isLargestTextMode ( )
virtual

Tests if the current video mode is the largest text mode.

Returns
True if the current video mode is equal to the largest text mode.

Implements Vga.

Definition at line 89 of file kernel/machine/mach_pc/Vga.cc.

bool X86Vga::isMode ( size_t  nCols,
size_t  nRows,
bool  bIsText,
size_t  nBpp = 0 
)
virtual

Tests the current video mode.

Returns
True if the current mode matches the given arguments.

Implements Vga.

Definition at line 84 of file kernel/machine/mach_pc/Vga.cc.

void X86Vga::moveCursor ( size_t  nX,
size_t  nY 
)
virtual

Moves the cursor to the position specified by the parameters.

Parameters
nXThe column to move to.
nYThe row to move to.

Implements Vga.

Definition at line 148 of file kernel/machine/mach_pc/Vga.cc.

References PhysicalMemoryManager::allocateRegion(), PhysicalMemoryManager::continuous, PhysicalMemoryManager::instance(), VirtualAddressSpace::KernelMode, HostedVga::m_nControls, HostedVga::m_nWidth, PhysicalMemoryManager::nonRamMemory, VirtualAddressSpace::Write, and VirtualAddressSpace::WriteThrough.

Referenced by getNumRows().

+ Here is the caller graph for this function:

void X86Vga::peekBuffer ( uint8_t *  pBuffer,
size_t  nBufLen 
)
virtual

Copies the current framebuffer into the given buffer.

The buffer is assumed to be in the correct format for directly copying from video memory. This will obviously depend on the current mode (text/graphical) as well as resolution and bits per pixel (graphics mode only).

Parameters
pBufferA pointer to the buffer.
nBufLenThe length of pBuffer.

Implements Vga.

Definition at line 140 of file kernel/machine/mach_pc/Vga.cc.

Referenced by getNumRows().

+ Here is the caller graph for this function:

void X86Vga::pokeBuffer ( uint8_t *  pBuffer,
size_t  nBufLen 
)
virtual

Copies the given buffer into video memory, replacing the current framebuffer.

The buffer is assumed to be in the correct format for directly copying into video memory. This will obviously depend on the current mode (text/graphical) as well as resolution and bits per pixel (graphics mode only).

Parameters
pBufferA pointer to the buffer to swap into video memory.
nBufLenThe length of pBuffer.

Implements Vga.

Definition at line 130 of file kernel/machine/mach_pc/Vga.cc.

Referenced by getNumRows().

+ Here is the caller graph for this function:

void X86Vga::rememberMode ( )
virtual

Stores the current video mode.

Implements Vga.

Definition at line 94 of file kernel/machine/mach_pc/Vga.cc.

References Bios::executeInterrupt(), Bios::instance(), HostedVga::m_ModeStack, HostedVga::m_nControls, Bios::setAx(), Bios::setBx(), Bios::setDi(), and Bios::setEs().

Referenced by getNumRows().

+ Here is the caller graph for this function:

void X86Vga::restoreMode ( )
virtual

Restores the saved video mode from a rememberMode() call.

Implements Vga.

Definition at line 111 of file kernel/machine/mach_pc/Vga.cc.

References Bios::executeInterrupt(), Bios::instance(), HostedVga::m_ModeStack, HostedVga::m_nControls, HostedVga::m_nMode, Bios::setAx(), Bios::setBx(), Bios::setDi(), and Bios::setEs().

Referenced by getNumRows().

+ Here is the caller graph for this function:

void X86Vga::setControl ( Vga::VgaControl  which)
virtual

Sets the given attribute mode control.

Implements Vga.

Definition at line 59 of file kernel/machine/mach_pc/Vga.cc.

bool X86Vga::setLargestTextMode ( )
virtual

Sets the largest possible text mode.

Returns
True on success, false on failure.

Implements Vga.

Definition at line 79 of file kernel/machine/mach_pc/Vga.cc.

bool X86Vga::setMode ( int  mode)
virtual

Changes the mode the VGA device is in.

Parameters
nColsThe number of columns required.
nRowsThe number of rows required.
bIsTextTrue if the caller requires a text mode, false if graphical.
nBppOnly applicable for graphics modes - the number of bits per pixel.
Returns
True on success, false on failure.

Implements Vga.

Definition at line 73 of file kernel/machine/mach_pc/Vga.cc.

References HostedVga::m_nMode.

Member Data Documentation

int X86Vga::m_ModeStack
private

We keep a count of the number of times we've entered the debugger without leaving it - when we enter the debugger, we increment this. When we leave, we decrement. If we leave and it reaches zero, we change out of mode 0x3 into the current video mode.

Definition at line 198 of file kernel/machine/mach_pc/Vga.h.

uint8_t X86Vga::m_nControls
private

Most recent VGA controls (as these get reset on mode change).

Definition at line 208 of file kernel/machine/mach_pc/Vga.h.

size_t X86Vga::m_nHeight
private

The height of the current mode.

Definition at line 190 of file kernel/machine/mach_pc/Vga.h.

Referenced by getNumRows().

int X86Vga::m_nMode
private

Current video mode.

Definition at line 203 of file kernel/machine/mach_pc/Vga.h.

size_t X86Vga::m_nWidth
private

The width of the current mode.

Definition at line 185 of file kernel/machine/mach_pc/Vga.h.

Referenced by getNumCols().

uint8_t* X86Vga::m_pFramebuffer
private

The framebuffer.

Definition at line 180 of file kernel/machine/mach_pc/Vga.h.

Referenced by getNumRows(), PPCVga::initialise(), and PPCVga::peekBuffer().

IoPort X86Vga::m_RegisterPort
private

The IoPort to access control registers.

Definition at line 173 of file kernel/machine/mach_pc/Vga.h.


The documentation for this class was generated from the following files: