ladybird/Kernel/Graphics/Bochs/GraphicsAdapter.h
Brian Gianforcaro bb58a4d943 Kernel: Make all Spinlocks use u8 for storage, remove template
The default template argument is only used in one place, and it
looks like it was probably just an oversight. The rest of the Kernel
code all uses u8 as the type. So lets make that the default and remove
the unused template argument, as there doesn't seem to be a reason to
allow the size to be customizable.
2021-09-05 20:46:02 +02:00

67 lines
2.2 KiB
C++

/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
#include <AK/Types.h>
#include <Kernel/Bus/PCI/Device.h>
#include <Kernel/Graphics/Console/GenericFramebufferConsole.h>
#include <Kernel/Graphics/FramebufferDevice.h>
#include <Kernel/Graphics/GraphicsDevice.h>
#include <Kernel/Memory/TypedMapping.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {
class GraphicsManagement;
struct BochsDisplayMMIORegisters;
class BochsGraphicsAdapter final : public GraphicsDevice
, public PCI::Device {
AK_MAKE_ETERNAL
friend class GraphicsManagement;
public:
static NonnullRefPtr<BochsGraphicsAdapter> initialize(PCI::Address);
virtual ~BochsGraphicsAdapter() = default;
virtual bool framebuffer_devices_initialized() const override { return !m_framebuffer_device.is_null(); }
virtual bool modesetting_capable() const override { return true; }
virtual bool double_framebuffering_capable() const override { return true; }
private:
// ^GraphicsDevice
virtual bool try_to_set_resolution(size_t output_port_index, size_t width, size_t height) override;
virtual bool set_y_offset(size_t output_port_index, size_t y) override;
virtual void initialize_framebuffer_devices() override;
virtual Type type() const override;
virtual void enable_consoles() override;
virtual void disable_consoles() override;
explicit BochsGraphicsAdapter(PCI::Address);
void set_safe_resolution();
void unblank();
bool validate_setup_resolution(size_t width, size_t height);
u32 find_framebuffer_address();
void set_resolution_registers(size_t width, size_t height);
void set_resolution_registers_via_io(size_t width, size_t height);
bool validate_setup_resolution_with_io(size_t width, size_t height);
void set_y_offset(size_t);
PhysicalAddress m_mmio_registers;
Memory::TypedMapping<BochsDisplayMMIORegisters volatile> m_registers;
RefPtr<FramebufferDevice> m_framebuffer_device;
RefPtr<Graphics::GenericFramebufferConsole> m_framebuffer_console;
Spinlock m_console_mode_switch_lock;
bool m_console_enabled { false };
bool m_io_required { false };
};
}