summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Graphics')
-rw-r--r--Kernel/Graphics/BochsGraphicsAdapter.cpp5
-rw-r--r--Kernel/Graphics/Console/Console.h4
-rw-r--r--Kernel/Graphics/Console/FramebufferConsole.cpp20
-rw-r--r--Kernel/Graphics/Console/FramebufferConsole.h2
-rw-r--r--Kernel/Graphics/FramebufferDevice.cpp10
5 files changed, 29 insertions, 12 deletions
diff --git a/Kernel/Graphics/BochsGraphicsAdapter.cpp b/Kernel/Graphics/BochsGraphicsAdapter.cpp
index b6695216e8..534a665765 100644
--- a/Kernel/Graphics/BochsGraphicsAdapter.cpp
+++ b/Kernel/Graphics/BochsGraphicsAdapter.cpp
@@ -53,11 +53,11 @@ UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::Address pci_add
: PCI::DeviceController(pci_address)
, m_mmio_registers(PCI::get_BAR2(pci_address) & 0xfffffff0)
{
- set_safe_resolution();
// We assume safe resolutio is 1024x768x32
m_framebuffer_console = Graphics::FramebufferConsole::initialize(PhysicalAddress(PCI::get_BAR0(pci_address) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32));
// FIXME: This is a very wrong way to do this...
GraphicsManagement::the().m_console = m_framebuffer_console;
+ set_safe_resolution();
}
UNMAP_AFTER_INIT void BochsGraphicsAdapter::initialize_framebuffer_devices()
@@ -76,6 +76,7 @@ GraphicsDevice::Type BochsGraphicsAdapter::type() const
void BochsGraphicsAdapter::set_safe_resolution()
{
+ VERIFY(m_framebuffer_console);
set_resolution(1024, 768);
}
@@ -105,6 +106,7 @@ bool BochsGraphicsAdapter::try_to_set_resolution(size_t width, size_t height)
bool BochsGraphicsAdapter::set_resolution(size_t width, size_t height)
{
+ VERIFY(m_framebuffer_console);
if (Checked<size_t>::multiplication_would_overflow(width, height, sizeof(u32)))
return false;
@@ -112,6 +114,7 @@ bool BochsGraphicsAdapter::set_resolution(size_t width, size_t height)
return false;
dbgln("BochsGraphicsAdapter: resolution set to {}x{}", width, height);
+ m_framebuffer_console->set_resolution(width, height, width * sizeof(u32));
return true;
}
diff --git a/Kernel/Graphics/Console/Console.h b/Kernel/Graphics/Console/Console.h
index c391dc32fb..448f1c7df6 100644
--- a/Kernel/Graphics/Console/Console.h
+++ b/Kernel/Graphics/Console/Console.h
@@ -74,8 +74,8 @@ protected:
Atomic<bool> m_enabled;
Color m_default_foreground_color { Color::White };
Color m_default_background_color { Color::Black };
- const size_t m_width;
- const size_t m_height;
+ size_t m_width;
+ size_t m_height;
mutable size_t m_x { 0 };
mutable size_t m_y { 0 };
};
diff --git a/Kernel/Graphics/Console/FramebufferConsole.cpp b/Kernel/Graphics/Console/FramebufferConsole.cpp
index 8ae2e3122e..5c960913c9 100644
--- a/Kernel/Graphics/Console/FramebufferConsole.cpp
+++ b/Kernel/Graphics/Console/FramebufferConsole.cpp
@@ -5,6 +5,7 @@
*/
#include <Kernel/Graphics/Console/FramebufferConsole.h>
+#include <Kernel/TTY/ConsoleManagement.h>
namespace Kernel::Graphics {
@@ -204,17 +205,28 @@ NonnullRefPtr<FramebufferConsole> FramebufferConsole::initialize(PhysicalAddress
return adopt_ref(*new FramebufferConsole(framebuffer_address, width, height, pitch));
}
-FramebufferConsole::FramebufferConsole(PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
- : Console(width, height)
- , m_framebuffer_address(framebuffer_address)
- , m_pitch(pitch)
+void FramebufferConsole::set_resolution(size_t width, size_t height, size_t pitch)
{
+ m_width = width;
+ m_height = height;
+ m_pitch = pitch;
+
dbgln("Framebuffer Console: taking {} bytes", page_round_up(pitch * height));
m_framebuffer_region = MM.allocate_kernel_region(m_framebuffer_address, page_round_up(pitch * height), "Framebuffer Console", Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes);
VERIFY(m_framebuffer_region);
// Just to start cleanly, we clean the entire framebuffer
memset(m_framebuffer_region->vaddr().as_ptr(), 0, pitch * height);
+
+ ConsoleManagement::the().resolution_was_changed();
+}
+
+FramebufferConsole::FramebufferConsole(PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
+ : Console(width, height)
+ , m_framebuffer_address(framebuffer_address)
+ , m_pitch(pitch)
+{
+ set_resolution(width, height, pitch);
}
size_t FramebufferConsole::bytes_per_base_glyph() const
diff --git a/Kernel/Graphics/Console/FramebufferConsole.h b/Kernel/Graphics/Console/FramebufferConsole.h
index 48574768b7..7e141cef9a 100644
--- a/Kernel/Graphics/Console/FramebufferConsole.h
+++ b/Kernel/Graphics/Console/FramebufferConsole.h
@@ -16,6 +16,8 @@ class FramebufferConsole final : public Console {
public:
static NonnullRefPtr<FramebufferConsole> initialize(PhysicalAddress, size_t width, size_t height, size_t pitch);
+ void set_resolution(size_t width, size_t height, size_t pitch);
+
virtual size_t bytes_per_base_glyph() const override;
virtual size_t chars_per_line() const override;
diff --git a/Kernel/Graphics/FramebufferDevice.cpp b/Kernel/Graphics/FramebufferDevice.cpp
index aebc9f5b49..1daf3f287e 100644
--- a/Kernel/Graphics/FramebufferDevice.cpp
+++ b/Kernel/Graphics/FramebufferDevice.cpp
@@ -30,16 +30,16 @@ KResultOr<Region*> FramebufferDevice::mmap(Process& process, FileDescription&, c
if (range.size() != page_round_up(framebuffer_size_in_bytes()))
return EOVERFLOW;
- // FIXME: We rely on the fact that only the WindowServer will mmap the framebuffer
- // and only once when starting to work with it. If other program wants to do so, we need to fix this.
- VERIFY(!m_userspace_framebuffer_region);
- VERIFY(!m_userspace_real_framebuffer_vmobject);
-
auto vmobject = AnonymousVMObject::create_for_physical_range(m_framebuffer_address, page_round_up(framebuffer_size_in_bytes()));
if (!vmobject)
return ENOMEM;
m_userspace_real_framebuffer_vmobject = vmobject;
+ m_real_framebuffer_vmobject = AnonymousVMObject::create_for_physical_range(m_framebuffer_address, page_round_up(framebuffer_size_in_bytes()));
+ m_swapped_framebuffer_vmobject = AnonymousVMObject::create_with_size(page_round_up(framebuffer_size_in_bytes()), AllocationStrategy::AllocateNow);
+ m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Region::Access::Read | Region::Access::Write);
+ m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Region::Access::Read | Region::Access::Write);
+
auto result = process.space().allocate_region_with_vmobject(
range,
vmobject.release_nonnull(),