mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:57:35 +00:00
Kernel: Add ioctls to BochsVGADevice for mode setting and page flipping.
Use these in WindowServer instead of poking at the BochsVGADevice directly.
This commit is contained in:
parent
799177feda
commit
468113422f
6 changed files with 50 additions and 16 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <Kernel/PCI.h>
|
||||
#include <Kernel/MemoryManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
#define VBE_DISPI_IOPORT_INDEX 0x01CE
|
||||
#define VBE_DISPI_IOPORT_DATA 0x01CF
|
||||
|
@ -21,6 +22,13 @@
|
|||
#define VBE_DISPI_ENABLED 0x01
|
||||
#define VBE_DISPI_LFB_ENABLED 0x40
|
||||
|
||||
#define BXVGA_DEV_IOCTL_SET_Y_OFFSET 1982
|
||||
#define BXVGA_DEV_IOCTL_SET_RESOLUTION 1985
|
||||
struct BXVGAResolution {
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
static BochsVGADevice* s_the;
|
||||
|
||||
BochsVGADevice& BochsVGADevice::the()
|
||||
|
@ -87,6 +95,24 @@ dword BochsVGADevice::find_framebuffer_address()
|
|||
return framebuffer_address;
|
||||
}
|
||||
|
||||
int BochsVGADevice::ioctl(Process& process, unsigned int request, unsigned int arg)
|
||||
{
|
||||
switch (request) {
|
||||
case BXVGA_DEV_IOCTL_SET_Y_OFFSET:
|
||||
set_y_offset(arg);
|
||||
return 0;
|
||||
case BXVGA_DEV_IOCTL_SET_RESOLUTION: {
|
||||
auto* resolution = (const BXVGAResolution*)arg;
|
||||
if (!process.validate_read_typed(resolution))
|
||||
return -EFAULT;
|
||||
set_resolution(resolution->width, resolution->height);
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return -EINVAL;
|
||||
};
|
||||
}
|
||||
|
||||
bool BochsVGADevice::can_read(Process&) const
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
void set_resolution(int width, int height);
|
||||
void set_y_offset(int);
|
||||
|
||||
|
||||
virtual int ioctl(Process&, unsigned request, unsigned arg) override;
|
||||
virtual Region* mmap(Process&, LinearAddress preferred_laddr, size_t offset, size_t) override;
|
||||
|
||||
size_t framebuffer_size_in_bytes() const { return m_framebuffer_size.area() * sizeof(dword) * 2; }
|
||||
|
|
|
@ -1786,9 +1786,9 @@ int Process::sys$ioctl(int fd, unsigned request, unsigned arg)
|
|||
*pid = descriptor->socket()->origin_pid();
|
||||
return 0;
|
||||
}
|
||||
if (!descriptor->is_character_device())
|
||||
if (!descriptor->is_device())
|
||||
return -ENOTTY;
|
||||
return descriptor->character_device()->ioctl(*this, request, arg);
|
||||
return descriptor->device()->ioctl(*this, request, arg);
|
||||
}
|
||||
|
||||
int Process::sys$getdtablesize()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue