Kernel: Add very simple BGA driver
Only thing this is currently helpful is qemu when booting with -kernel flag as that does not provide framebuffer info in multiboot headers
This commit is contained in:
@@ -6,15 +6,22 @@
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
class BGAController;
|
||||
|
||||
class FramebufferDevice : public CharacterDevice
|
||||
{
|
||||
public:
|
||||
static BAN::ErrorOr<BAN::RefPtr<FramebufferDevice>> create(paddr_t paddr, uint32_t width, uint32_t height, uint32_t pitch, uint8_t bpp);
|
||||
static BAN::ErrorOr<BAN::RefPtr<FramebufferDevice>> create(BAN::RefPtr<BGAController>);
|
||||
static BAN::ErrorOr<BAN::RefPtr<FramebufferDevice>> create_from_boot_framebuffer();
|
||||
static BAN::RefPtr<FramebufferDevice> boot_framebuffer();
|
||||
~FramebufferDevice();
|
||||
|
||||
uint32_t width() const { return m_width; }
|
||||
uint32_t height() const { return m_height; }
|
||||
uint8_t bpp() const { return m_bpp; }
|
||||
|
||||
BAN::ErrorOr<void> set_bga_controller(BAN::RefPtr<BGAController>);
|
||||
|
||||
uint32_t get_pixel(uint32_t x, uint32_t y) const;
|
||||
void set_pixel(uint32_t x, uint32_t y, uint32_t rgb);
|
||||
@@ -50,14 +57,16 @@ namespace Kernel
|
||||
private:
|
||||
const BAN::String m_name;
|
||||
|
||||
vaddr_t m_video_memory_vaddr { 0 };
|
||||
const paddr_t m_video_memory_paddr;
|
||||
const uint32_t m_width;
|
||||
const uint32_t m_height;
|
||||
const uint32_t m_pitch;
|
||||
const uint8_t m_bpp;
|
||||
vaddr_t m_video_memory_vaddr { 0 };
|
||||
paddr_t m_video_memory_paddr { 0 };
|
||||
|
||||
uint32_t m_width { 0 };
|
||||
uint32_t m_height { 0 };
|
||||
uint32_t m_pitch { 0 };
|
||||
uint8_t m_bpp { 0 };
|
||||
|
||||
BAN::UniqPtr<VirtualRange> m_video_buffer;
|
||||
BAN::RefPtr<BGAController> m_bga_controller;
|
||||
|
||||
friend class FramebufferMemoryRegion;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <BAN/RefPtr.h>
|
||||
#include <kernel/Lock/SpinLock.h>
|
||||
#include <kernel/PCI.h>
|
||||
|
||||
#include <sys/framebuffer.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
class BGAController : public BAN::RefCounted<BGAController>
|
||||
{
|
||||
public:
|
||||
static BAN::ErrorOr<BAN::RefPtr<BGAController>> create(PCI::Device&);
|
||||
|
||||
fb_fix_info get_fb_fix_info() const;
|
||||
fb_var_info get_fb_var_info() const;
|
||||
BAN::ErrorOr<void> set_fb_var_info(const fb_var_info&);
|
||||
|
||||
private:
|
||||
BGAController(PCI::Device&);
|
||||
BAN::ErrorOr<void> initialize();
|
||||
|
||||
void write_reg(uint16_t reg, uint16_t value);
|
||||
uint16_t read_reg(uint16_t reg);
|
||||
|
||||
private:
|
||||
mutable RecursiveSpinLock m_lock;
|
||||
PCI::Device& m_pci_device;
|
||||
BAN::UniqPtr<PCI::BarRegion> m_lfb_bar;
|
||||
|
||||
fb_fix_info m_fix_info {};
|
||||
fb_var_info m_var_info {};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -53,6 +53,8 @@ namespace Kernel
|
||||
|
||||
virtual bool master_has_closed() const { return false; }
|
||||
|
||||
virtual bool is_vtty() const { return false; }
|
||||
|
||||
protected:
|
||||
TTY(termios termios, mode_t mode, uid_t uid, gid_t gid);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Kernel
|
||||
|
||||
void clear() override;
|
||||
|
||||
bool is_vtty() const override { return true; }
|
||||
BAN::ErrorOr<void> set_terminal_driver(BAN::RefPtr<TerminalDriver>);
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user