Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::drivers::video::VideoElectronicsStandardsAssociation Class Reference

Driver for the VESA video controller, handles the rendering of pixels to the screen using VESA. More...

#include <vesa.h>

Inheritance diagram for MaxOS::drivers::video::VideoElectronicsStandardsAssociation:
MaxOS::drivers::video::VideoDriver MaxOS::drivers::Driver MaxOS::common::GraphicsContext

Public Member Functions

 VideoElectronicsStandardsAssociation (multiboot_tag_framebuffer *framebuffer_info)
 Constructs a new VESA driver object. Maps the framebuffer into the higher half.
 
bool supports_mode (uint32_t width, uint32_t height, uint32_t) final
 Checks if the VESA driver supports the given mode.
 
string vendor_name () final
 The name of the vendor of the VESA standard.
 
string device_name () final
 The name of the device.
 
- Public Member Functions inherited from MaxOS::drivers::video::VideoDriver
bool set_mode (uint32_t width, uint32_t height, uint32_t color_depth)
 Set the mode of the video driver.
 
- Public Member Functions inherited from MaxOS::drivers::Driver
virtual void activate ()
 Activate the driver.
 
virtual void deactivate ()
 Deactivate the driver.
 
virtual void initialise ()
 Initialise the driver.
 
virtual uint32_t reset ()
 Reset the driver.
 
- Public Member Functions inherited from MaxOS::common::GraphicsContext
 GraphicsContext ()
 Constructs a GraphicsContext object and initializes the color palette.
 
uint32_t colour_to_int (const Colour &)
 Converts a colour to an integer value based on the current color depth.
 
Colour int_to_colour (uint32_t)
 Converts an integer value to a colour based on the current color depth.
 
uint32_t width () const
 Gets the width of the screen.
 
uint32_t height () const
 Gets the height of the screen.
 
uint32_t color_depth () const
 Gets the current color depth (bits per pixel)
 
uint64_tframebuffer_address ()
 Gets the address of the context's framebuffer to draw on.
 
void put_pixel (uint32_t x, uint32_t y, const Colour &colour)
 Renders a pixel to the screen (automatically converts the colour to an integer)
 
void put_pixel (uint32_t x, uint32_t y, uint32_t colour)
 Renders a pixel to the screen (automatically converts the colour to an integer), will not render the pixel if it is outside the screen.
 
Colour get_pixel (uint32_t x, uint32_t y)
 Gets the colour of a pixel, or returns black if the pixel is outside the screen.
 
void invert_pixel (uint32_t x, uint32_t y)
 Inverts a pixel.
 
void draw_line (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
 Draws a line on the screen.
 
void draw_line (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour)
 Draws a line on the screen.
 
void draw_rectangle (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
 Draws a rectangle on the screen.
 
void draw_rectangle (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour)
 Draws a rectangle on the screen.
 
void fill_rectangle (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
 Draws a rectangle on the screen, filled with a colour.
 
void fill_rectangle (uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t colour)
 Draws a rectangle on the screen, filled with a colour.
 
void draw_circle (uint32_t x0, uint32_t y0, uint32_t radius, const Colour &colour)
 Draws a circle on the screen.
 
void draw_circle (uint32_t x0, uint32_t y0, uint32_t radius, uint32_t colour)
 Draws a circle on the screen.
 
void fill_circle (uint32_t x0, uint32_t y0, uint32_t radius, const Colour &colour)
 Draws a circle on the screen, filled with a colour.
 
void fill_circle (uint32_t x0, uint32_t y0, uint32_t radius, uint32_t colour)
 Draws a circle on the screen, filled with a colour.
 

Additional Inherited Members

- Protected Member Functions inherited from MaxOS::common::GraphicsContext
virtual void render_pixel (uint32_t x, uint32_t y, uint32_t colour)
 Renders a pixel to the screen based on the current color depth.
 
virtual void render_pixel_8_bit (uint32_t x, uint32_t y, uint8_t colour)
 Renders a pixel to the screen using the 8 bit color depth.
 
virtual void render_pixel_16_bit (uint32_t x, uint32_t y, uint16_t colour)
 Renders a pixel to the screen using the 16 bit color depth.
 
virtual void render_pixel_24_bit (uint32_t x, uint32_t y, uint32_t colour)
 Renders a pixel to the screen using the 24 bit color depth.
 
virtual uint32_t get_rendered_pixel (uint32_t x, uint32_t y)
 Gets the colour of a pixel on the screen, automatically uses the correct color depth.
 
virtual uint8_t get_rendered_pixel_8_bit (uint32_t x, uint32_t y)
 Gets the colour of a pixel on the screen using the 8 bit color depth.
 
virtual uint16_t get_rendered_pixel_16_bit (uint32_t x, uint32_t y)
 Gets the colour of a pixel on the screen using the 16 bit color depth.
 
virtual uint32_t get_rendered_pixel_24_bit (uint32_t x, uint32_t y)
 Gets the colour of a pixel on the screen using the 24 bit color depth.
 
- Protected Attributes inherited from MaxOS::common::GraphicsContext
bool mirror_y_axis
 Should the y axis be mirrored (0,0 is top left if false, bottom left if true)
 
uint32_t m_width { 0 }
 The width of the screen in pixels.
 
uint32_t m_height { 0 }
 The height of the screen in pixels.
 
uint32_t m_color_depth { 0 }
 The color depth of the screen in bits per pixel.
 
Colour m_colour_pallet [256]
 The colour pallet for 8 bit color depth.
 
uint64_tm_framebuffer_address { nullptr }
 The address of the framebuffer.
 

Detailed Description

Driver for the VESA video controller, handles the rendering of pixels to the screen using VESA.

Definition at line 26 of file vesa.h.

Constructor & Destructor Documentation

◆ VideoElectronicsStandardsAssociation()

VideoElectronicsStandardsAssociation::VideoElectronicsStandardsAssociation ( multiboot_tag_framebuffer framebuffer_info)
explicit

Constructs a new VESA driver object. Maps the framebuffer into the higher half.

Parameters
framebuffer_infoThe framebuffer information from multiboot

Definition at line 24 of file vesa.cpp.

25: m_framebuffer_info(framebuffer_info)
26{
27
28 Logger::INFO() << "Setting up VESA driver\n";
29
30 // Save the framebuffer info
31 m_bpp = m_framebuffer_info->common.framebuffer_bpp;
32 m_pitch = m_framebuffer_info->common.framebuffer_pitch;
33 m_framebuffer_size = m_framebuffer_info->common.framebuffer_height * m_pitch;
34 this->set_mode(framebuffer_info->common.framebuffer_width, framebuffer_info->common.framebuffer_height, framebuffer_info->common.framebuffer_bpp);
35 Logger::DEBUG() << "Framebuffer: bpp=" << m_bpp << ", pitch=" << m_pitch << ", size=" << m_framebuffer_size << "\n";
36
37 // Map the frame buffer into the higher half
38 auto physical_address = (uint64_t) m_framebuffer_info->common.framebuffer_addr;
40 PhysicalMemoryManager::s_current_manager->map_area((physical_address_t *) physical_address, m_framebuffer_address, m_framebuffer_size, WRITE | PRESENT);
41
42 // Reserve the physical memory
43 size_t pages = PhysicalMemoryManager::size_to_frames(m_framebuffer_size);
44 PhysicalMemoryManager::s_current_manager->reserve(m_framebuffer_info->common.framebuffer_addr, pages, "Framebuffer");
45
46 // Log info
47 Logger::DEBUG() << "Framebuffer address: physical=0x" << (uint64_t) physical_address << ", virtual=0x" << (uint64_t) m_framebuffer_address << "\n";
48 Logger::DEBUG() << "Framebuffer mapped: 0x" << (uint64_t) m_framebuffer_address << " - 0x" << (uint64_t) (m_framebuffer_address + m_framebuffer_size) << " (pages: " << pages << ")\n";
49
50}
static Logger DEBUG()
Gets active logger set to DEBUG level.
Definition logger.cpp:193
static Logger INFO()
Gets active logger set to info level.
Definition logger.cpp:171
uint64_t * m_framebuffer_address
The address of the framebuffer.
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
bool set_mode(uint32_t width, uint32_t height, uint32_t color_depth)
Set the mode of the video driver.
Definition video.cpp:53
static void * to_dm_region(uintptr_t physical_address)
Converts a physical address to a direct map region address if it is in the lower region using the hig...
Definition physical.cpp:930
static PhysicalMemoryManager * s_current_manager
The current physical memory manager in use.
Definition physical.h:185
static size_t size_to_frames(size_t size)
Converts a size to the number of frames.
Definition physical.cpp:156
@ PRESENT
The page is present in memory.
Definition physical.h:43
@ WRITE
Memory in this page is writable.
Definition physical.h:44
struct multiboot_tag_framebuffer_common common
*copydoc multiboot_tag_framebuffer_common
Definition multiboot.h:357

References multiboot_tag_framebuffer::common, MaxOS::Logger::DEBUG(), MaxOS::Logger::INFO(), MaxOS::common::GraphicsContext::m_framebuffer_address, MaxOS::memory::PRESENT, MaxOS::memory::PhysicalMemoryManager::s_current_manager, MaxOS::drivers::video::VideoDriver::set_mode(), MaxOS::memory::PhysicalMemoryManager::size_to_frames(), MaxOS::memory::PhysicalMemoryManager::to_dm_region(), and MaxOS::memory::WRITE.

Member Function Documentation

◆ device_name()

string VideoElectronicsStandardsAssociation::device_name ( )
finalvirtual

The name of the device.

Returns
The name of the device

Reimplemented from MaxOS::drivers::Driver.

Definition at line 130 of file vesa.cpp.

130 {
131 return "VESA compatible graphics card";
132}

◆ supports_mode()

bool VideoElectronicsStandardsAssociation::supports_mode ( uint32_t  width,
uint32_t  height,
uint32_t  color_depth 
)
finalvirtual

Checks if the VESA driver supports the given mode.

Parameters
widthThe m_width of the screen
heightThe m_height of the screen
color_depthThe color depth of the screen
Returns

Reimplemented from MaxOS::drivers::video::VideoDriver.

Definition at line 79 of file vesa.cpp.

79 {
80
81 // Check if the mode is supported
82 return width == m_framebuffer_info->common.framebuffer_width
83 && height == m_framebuffer_info->common.framebuffer_height
84 && color_depth == m_framebuffer_info->common.framebuffer_bpp;
85}
uint32_t width() const
Gets the width of the screen.
uint32_t height() const
Gets the height of the screen.
uint32_t color_depth() const
Gets the current color depth (bits per pixel)

References MaxOS::common::GraphicsContext::color_depth(), multiboot_tag_framebuffer::common, MaxOS::common::GraphicsContext::height(), and MaxOS::common::GraphicsContext::width().

◆ vendor_name()

string VideoElectronicsStandardsAssociation::vendor_name ( )
finalvirtual

The name of the vendor of the VESA standard.

Returns
The name of the vendor

Reimplemented from MaxOS::drivers::Driver.

Definition at line 119 of file vesa.cpp.

119 {
120
121 // Creator of the VESA standard
122 return "NEC Home Electronics";
123}

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