mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 20:05:06 +00:00

This device is supposed to be used in microvm and ISA-PC machine types, and we assume that if we are able to probe for the QEMU BGA version of 0xB0C5, then we have an existing ISA Bochs VGA adapter to utilize. To ensure we don't instantiate the driver for non isa-vga devices, we try to ensure that PCI is disabled because hardware IO test probe failed so we can be sure that we use this special handling code only in the QEMU microvm and ISA-PC machine types. Unfortunately, this means that if for some reason the isa-vga device is attached for the i440FX or Q35 machine types, we simply are not able to drive the device in such setups at all. To determine the amount of VRAM being available, we read VBE register at offset 0xA. That register holds the amount of VRAM divided by 64K, so we need to multiply the value in our code to use the actual VRAM size value again. The isa-vga device requires us to hardcode the framebuffer physical address to 0xE0000000, and that address is not expected to change in the future as many other projects rely on the isa-vga framebuffer to be present at that physical memory address.
58 lines
2 KiB
C++
58 lines
2 KiB
C++
/*
|
|
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Try.h>
|
|
#include <Kernel/Graphics/Bochs/Definitions.h>
|
|
#include <Kernel/Graphics/Console/GenericFramebufferConsole.h>
|
|
#include <Kernel/Graphics/DisplayConnector.h>
|
|
#include <Kernel/Library/LockRefPtr.h>
|
|
#include <Kernel/Locking/Spinlock.h>
|
|
#include <Kernel/Memory/TypedMapping.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class BochsDisplayConnector
|
|
: public DisplayConnector {
|
|
friend class BochsGraphicsAdapter;
|
|
friend class DeviceManagement;
|
|
friend class GraphicsManagement;
|
|
|
|
public:
|
|
AK_TYPEDEF_DISTINCT_ORDERED_ID(u16, IndexID);
|
|
|
|
static LockRefPtr<BochsDisplayConnector> try_create_for_vga_isa_connector();
|
|
|
|
static NonnullLockRefPtr<BochsDisplayConnector> must_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, bool virtual_box_hardware);
|
|
|
|
private:
|
|
IndexID index_id() const;
|
|
|
|
ErrorOr<void> create_attached_framebuffer_console();
|
|
|
|
BochsDisplayConnector(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size);
|
|
|
|
virtual bool mutable_mode_setting_capable() const override final { return true; }
|
|
virtual bool double_framebuffering_capable() const override { return false; }
|
|
virtual ErrorOr<void> set_mode_setting(ModeSetting const&) override;
|
|
virtual ErrorOr<void> set_safe_mode_setting() override final;
|
|
virtual ErrorOr<void> set_y_offset(size_t y) override;
|
|
virtual ErrorOr<void> unblank() override;
|
|
|
|
virtual bool partial_flush_support() const override final { return false; }
|
|
virtual bool flush_support() const override final { return false; }
|
|
// Note: Paravirtualized hardware doesn't require a defined refresh rate for modesetting.
|
|
virtual bool refresh_rate_support() const override final { return false; }
|
|
|
|
virtual ErrorOr<void> flush_first_surface() override final;
|
|
|
|
virtual void enable_console() override final;
|
|
virtual void disable_console() override final;
|
|
|
|
LockRefPtr<Graphics::GenericFramebufferConsole> m_framebuffer_console;
|
|
};
|
|
}
|