Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Multiboot VBE framebuffer support
  • Loading branch information
djphoenix committed May 23, 2019
1 parent 4b56b72 commit 3b0685a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/boot/bootstrap.s
Expand Up @@ -12,15 +12,16 @@ _start:
.align 4
multiboot_header:
.long 0x1BADB002
.long 0x00010003
.long -(0x1BADB002+0x00010003)
.long 0x00010005
.long -(0x1BADB002+0x00010005)

.long multiboot_header
.long __text_start__
.long __bss_start__
.long __bss_end__ + 0x80000
.long multiboot_entry

.long 0, 800, 600, 8

multiboot_entry:
cli
Expand Down
11 changes: 11 additions & 0 deletions src/kernlib/display.cpp
Expand Up @@ -3,6 +3,7 @@

#include "kernlib.hpp"
#include "efi.hpp"
#include "multiboot_info.hpp"
#include "pagetable.hpp"
#include "font-8x16.hpp"

Expand Down Expand Up @@ -203,6 +204,16 @@ void Display::setup() {
instance = new FramebufferDisplay(fb->base, fb->width, fb->height, pixelFormat);
return;
}
const struct Multiboot::Payload *mb = Multiboot::getPayload();
if (mb && (mb->flags & Multiboot::FLAG_VBETAB)) {
const Multiboot::VBEModeInfo *mode = reinterpret_cast<const Multiboot::VBEModeInfo*>(mb->vbe.pmode_info);
if (mode && mode->lfb_ptr) {
instance = new FramebufferDisplay(
reinterpret_cast<void*>(mode->lfb_ptr),
mode->h_res, mode->v_res, PixelFormatBGRX);
return;
}
}

// Fallback
instance = new ConsoleDisplay();
Expand Down
12 changes: 12 additions & 0 deletions src/platform/pagetable.cpp
Expand Up @@ -348,6 +348,18 @@ void Pagetable::init() {
mmap += ent->size + sizeof(ent->size);
}
}
if (multiboot->flags & Multiboot::FLAG_VBETAB) {
if (multiboot->vbe.pcontrol_info < 0x80000)
multiboot->vbe.pcontrol_info += bss_end;
if (multiboot->vbe.pmode_info < 0x80000)
multiboot->vbe.pmode_info += bss_end;
Multiboot::VBEInfo *vbe = reinterpret_cast<Multiboot::VBEInfo*>(multiboot->vbe.pcontrol_info);
map(vbe); map(vbe+1);
const char *vendor = reinterpret_cast<const char*>(vbe->vendor_string);
map(vendor);
Multiboot::VBEModeInfo *mode = reinterpret_cast<Multiboot::VBEModeInfo*>(multiboot->vbe.pmode_info);
map(mode); map(mode + 1);
}
}
}

Expand Down

0 comments on commit 3b0685a

Please sign in to comment.