Kernel/Graphics: Be more consistent about arguments passing

This fixes a bug that was reported on this discord server by
@ElectrodeYT - due to the confusion of passing arguments in different
orders, we messed up and triggered a page fault due to faulty sizes.
This commit is contained in:
Liav A 2021-05-17 00:02:47 +03:00 committed by Linus Groh
parent ca9101e5f0
commit 02b73cb93d
Notes: sideshowbarker 2024-07-18 17:58:27 +09:00
8 changed files with 18 additions and 18 deletions

View file

@ -17,13 +17,13 @@
namespace Kernel { namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<BochsFramebufferDevice> BochsFramebufferDevice::create(const BochsGraphicsAdapter& adapter, PhysicalAddress framebuffer_address, size_t pitch, size_t width, size_t height) UNMAP_AFTER_INIT NonnullRefPtr<BochsFramebufferDevice> BochsFramebufferDevice::create(const BochsGraphicsAdapter& adapter, PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
{ {
return adopt_ref(*new BochsFramebufferDevice(adapter, framebuffer_address, pitch, width, height)); return adopt_ref(*new BochsFramebufferDevice(adapter, framebuffer_address, pitch, width, height));
} }
UNMAP_AFTER_INIT BochsFramebufferDevice::BochsFramebufferDevice(const BochsGraphicsAdapter& adapter, PhysicalAddress framebuffer_address, size_t pitch, size_t width, size_t height) UNMAP_AFTER_INIT BochsFramebufferDevice::BochsFramebufferDevice(const BochsGraphicsAdapter& adapter, PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
: FramebufferDevice(framebuffer_address, pitch, width, height) : FramebufferDevice(framebuffer_address, width, height, pitch)
, m_bochs_adapter(adapter) , m_bochs_adapter(adapter)
{ {
m_bochs_adapter->set_safe_resolution(); m_bochs_adapter->set_safe_resolution();

View file

@ -63,7 +63,7 @@ UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::Address pci_add
UNMAP_AFTER_INIT void BochsGraphicsAdapter::initialize_framebuffer_devices() UNMAP_AFTER_INIT void BochsGraphicsAdapter::initialize_framebuffer_devices()
{ {
// FIXME: Find a better way to determine default resolution... // FIXME: Find a better way to determine default resolution...
m_framebuffer_device = BochsFramebufferDevice::create(*this, PhysicalAddress(PCI::get_BAR0(pci_address()) & 0xfffffff0), 1024 * 4, 1024, 768); m_framebuffer_device = BochsFramebufferDevice::create(*this, PhysicalAddress(PCI::get_BAR0(pci_address()) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32));
m_framebuffer_device->initialize(); m_framebuffer_device->initialize();
} }

View file

@ -14,13 +14,13 @@
namespace Kernel::Graphics { namespace Kernel::Graphics {
class FramebufferConsole final : public Console { class FramebufferConsole final : public Console {
public: public:
static NonnullRefPtr<FramebufferConsole> initialize(PhysicalAddress, size_t width, size_t height, size_t bpp); static NonnullRefPtr<FramebufferConsole> initialize(PhysicalAddress, size_t width, size_t height, size_t pitch);
virtual size_t bytes_per_base_glyph() const override; virtual size_t bytes_per_base_glyph() const override;
virtual size_t chars_per_line() const override; virtual size_t chars_per_line() const override;
virtual size_t max_column() const { return m_width / 8; } virtual size_t max_column() const override { return m_width / 8; }
virtual size_t max_row() const { return m_height / 8; } virtual size_t max_row() const override { return m_height / 8; }
virtual bool is_hardware_paged_capable() const override { return false; } virtual bool is_hardware_paged_capable() const override { return false; }
virtual bool has_hardware_cursor() const override { return false; } virtual bool has_hardware_cursor() const override { return false; }
@ -41,7 +41,7 @@ public:
protected: protected:
void clear_glyph(size_t x, size_t y) const; void clear_glyph(size_t x, size_t y) const;
FramebufferConsole(PhysicalAddress, size_t width, size_t height, size_t bpp); FramebufferConsole(PhysicalAddress, size_t width, size_t height, size_t pitch);
OwnPtr<Region> m_framebuffer_region; OwnPtr<Region> m_framebuffer_region;
PhysicalAddress m_framebuffer_address; PhysicalAddress m_framebuffer_address;
size_t m_pitch; size_t m_pitch;

View file

@ -94,7 +94,7 @@ UNMAP_AFTER_INIT void FramebufferDevice::initialize()
VERIFY(m_swapped_framebuffer_region); VERIFY(m_swapped_framebuffer_region);
} }
UNMAP_AFTER_INIT FramebufferDevice::FramebufferDevice(PhysicalAddress addr, size_t pitch, size_t width, size_t height) UNMAP_AFTER_INIT FramebufferDevice::FramebufferDevice(PhysicalAddress addr, size_t width, size_t height, size_t pitch)
: BlockDevice(29, GraphicsManagement::the().allocate_minor_device_number()) : BlockDevice(29, GraphicsManagement::the().allocate_minor_device_number())
, m_framebuffer_address(addr) , m_framebuffer_address(addr)
, m_framebuffer_pitch(pitch) , m_framebuffer_pitch(pitch)

View file

@ -66,9 +66,9 @@ UNMAP_AFTER_INIT RefPtr<GraphicsDevice> GraphicsManagement::determine_graphics_d
dmesgln("Graphics: Using a preset resolution from the bootloader"); dmesgln("Graphics: Using a preset resolution from the bootloader");
return VGACompatibleAdapter::initialize_with_preset_resolution(address, return VGACompatibleAdapter::initialize_with_preset_resolution(address,
PhysicalAddress((u32)(multiboot_info_ptr->framebuffer_addr)), PhysicalAddress((u32)(multiboot_info_ptr->framebuffer_addr)),
multiboot_info_ptr->framebuffer_pitch,
multiboot_info_ptr->framebuffer_width, multiboot_info_ptr->framebuffer_width,
multiboot_info_ptr->framebuffer_height); multiboot_info_ptr->framebuffer_height,
multiboot_info_ptr->framebuffer_pitch);
} }
return VGACompatibleAdapter::initialize(address); return VGACompatibleAdapter::initialize(address);
} }

View file

@ -625,7 +625,7 @@ void IntelNativeGraphicsAdapter::initialize_framebuffer_devices()
VERIFY(m_framebuffer_pitch != 0); VERIFY(m_framebuffer_pitch != 0);
VERIFY(m_framebuffer_height != 0); VERIFY(m_framebuffer_height != 0);
VERIFY(m_framebuffer_width != 0); VERIFY(m_framebuffer_width != 0);
m_framebuffer_device = RawFramebufferDevice::create(*this, address, m_framebuffer_pitch, m_framebuffer_width, m_framebuffer_height); m_framebuffer_device = RawFramebufferDevice::create(*this, address, m_framebuffer_width, m_framebuffer_height, m_framebuffer_pitch);
m_framebuffer_device->initialize(); m_framebuffer_device->initialize();
} }
} }

View file

@ -8,12 +8,12 @@
namespace Kernel { namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<RawFramebufferDevice> RawFramebufferDevice::create(const GraphicsDevice&, PhysicalAddress framebuffer_address, size_t pitch, size_t width, size_t height) UNMAP_AFTER_INIT NonnullRefPtr<RawFramebufferDevice> RawFramebufferDevice::create(const GraphicsDevice&, PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
{ {
return adopt_ref(*new RawFramebufferDevice(framebuffer_address, pitch, width, height)); return adopt_ref(*new RawFramebufferDevice(framebuffer_address, width, height, pitch));
} }
UNMAP_AFTER_INIT RawFramebufferDevice::RawFramebufferDevice(PhysicalAddress framebuffer_address, size_t pitch, size_t width, size_t height) UNMAP_AFTER_INIT RawFramebufferDevice::RawFramebufferDevice(PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
: FramebufferDevice(framebuffer_address, pitch, width, height) : FramebufferDevice(framebuffer_address, width, height, pitch)
{ {
} }

View file

@ -19,12 +19,12 @@ class RawFramebufferDevice : public FramebufferDevice {
friend class GraphicsDevice; friend class GraphicsDevice;
public: public:
static NonnullRefPtr<RawFramebufferDevice> create(const GraphicsDevice&, PhysicalAddress, size_t pitch, size_t width, size_t height); static NonnullRefPtr<RawFramebufferDevice> create(const GraphicsDevice&, PhysicalAddress, size_t width, size_t height, size_t pitch);
virtual ~RawFramebufferDevice() {}; virtual ~RawFramebufferDevice() {};
private: private:
RawFramebufferDevice(PhysicalAddress, size_t pitch, size_t width, size_t height); RawFramebufferDevice(PhysicalAddress, size_t width, size_t height, size_t pitch);
virtual const char* class_name() const override { return "RawFramebuffer"; } virtual const char* class_name() const override { return "RawFramebuffer"; }
}; };