1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-30 10:32:17 +00:00

Kernel: Much improved BochsVGA (BXVGA) support.

Instead of cowboy-calling the VESA BIOS in the bootloader, find the emulator
VGA adapter by scanning the PCI bus. Then set up the desired video mode by
sending device commands.
This commit is contained in:
Andreas Kling 2019-02-06 10:17:26 +01:00
parent e9f6508ada
commit 731fc5a7c8
16 changed files with 298 additions and 114 deletions

View file

@ -1917,79 +1917,6 @@ clock_t Process::sys$times(tms* times)
return 0;
}
struct vbe_info_structure {
char signature[4]; // must be "VESA" to indicate valid VBE support
word version; // VBE version; high byte is major version, low byte is minor version
dword oem; // segment:offset pointer to OEM
dword capabilities; // bitfield that describes card capabilities
dword video_modes; // segment:offset pointer to list of supported video modes
word video_memory; // amount of video memory in 64KB blocks
word software_rev; // software revision
dword vendor; // segment:offset to card vendor string
dword product_name; // segment:offset to card model name
dword product_rev; // segment:offset pointer to product revision
char reserved[222]; // reserved for future expansion
char oem_data[256]; // OEM BIOSes store their strings in this area
} __attribute__ ((packed));
struct vbe_mode_info_structure {
word attributes; // deprecated, only bit 7 should be of interest to you, and it indicates the mode supports a linear frame buffer.
byte window_a; // deprecated
byte window_b; // deprecated
word granularity; // deprecated; used while calculating bank numbers
word window_size;
word segment_a;
word segment_b;
dword win_func_ptr; // deprecated; used to switch banks from protected mode without returning to real mode
word pitch; // number of bytes per horizontal line
word width; // width in pixels
word height; // height in pixels
byte w_char; // unused...
byte y_char; // ...
byte planes;
byte bpp; // bits per pixel in this mode
byte banks; // deprecated; total number of banks in this mode
byte memory_model;
byte bank_size; // deprecated; size of a bank, almost always 64 KB but may be 16 KB...
byte image_pages;
byte reserved0;
byte red_mask;
byte red_position;
byte green_mask;
byte green_position;
byte blue_mask;
byte blue_position;
byte reserved_mask;
byte reserved_position;
byte direct_color_attributes;
dword framebuffer; // physical address of the linear frame buffer; write here to draw to the screen
dword off_screen_mem_off;
word off_screen_mem_size; // size of memory in the framebuffer but not being displayed on the screen
byte reserved1[206];
} __attribute__ ((packed));
DisplayInfo Process::get_display_info()
{
DisplayInfo info;
//auto* vinfo = reinterpret_cast<vbe_info_structure*>(0xc000);
auto* vmode = reinterpret_cast<vbe_mode_info_structure*>(0x2000);
dbgprintf("VESA framebuffer, %ux%u, %u bpp @ P%x\n", vmode->width, vmode->height, vmode->bpp, vmode->framebuffer);
dbgprintf("Returning display info in %s<%u>\n", name().characters(), pid());
info.width = vmode->width;
info.height = vmode->height;
info.bpp = vmode->bpp;
info.pitch = vmode->pitch;
size_t framebuffer_size = info.pitch * info.height;
if (!m_display_framebuffer_region) {
auto framebuffer_vmo = VMObject::create_framebuffer_wrapper(PhysicalAddress(vmode->framebuffer), framebuffer_size);
m_display_framebuffer_region = allocate_region_with_vmo(LinearAddress(0xe0000000), framebuffer_size, move(framebuffer_vmo), 0, "framebuffer", true, true);
}
info.framebuffer = m_display_framebuffer_region->laddr().as_ptr();
return info;
}
int Process::sys$select(const Syscall::SC_select_params* params)
{
if (!validate_read_typed(params))