dev: boot framebuffer support

This commit is contained in:
2023-06-08 20:46:43 +01:00
parent ff8902ef1c
commit f83ecca490
10 changed files with 163 additions and 67 deletions

View File

@@ -1,7 +1,7 @@
name: vgafb
name: vesafb
description: |
Generic VGA driver.
id: net.doorstuck.socks.vgafb
Boot-time VESA framebuffer driver.
id: net.doorstuck.socks.vesafb
license: BSD-3-Clause
copyright: Copyright © Max Wash 2023
sources:

View File

@@ -0,0 +1,65 @@
#include <socks/printk.h>
#include <socks/device.h>
#include <socks/kext.h>
#include <socks/machine/init.h>
#include <socks/libc/stdio.h>
static struct driver *vesa_driver = NULL;
static struct framebuffer_device *vesafb = NULL;
static kern_status_t set_varinfo(struct device *dev, const struct framebuffer_varinfo *info)
{
return KERN_UNSUPPORTED;
}
static struct framebuffer_device_ops vesa_ops = {
.set_varinfo = set_varinfo,
};
static void init_vesa(struct framebuffer_device *dev)
{
struct framebuffer_varinfo *varinfo = &dev->fb_varinfo;
struct framebuffer_fixedinfo *fixedinfo = &dev->fb_fixedinfo;
memcpy(varinfo, bootfb_varinfo(), sizeof *varinfo);
memcpy(fixedinfo, bootfb_fixedinfo(), sizeof *fixedinfo);
}
static kern_status_t online(struct kext *self)
{
const struct framebuffer_fixedinfo *fixedinfo = bootfb_fixedinfo();
if (!fixedinfo->fb_baseptr) {
/* No VESA information avaiable, cannot create device. */
return KERN_OK;
}
vesa_driver = driver_create(self, "vesafb");
if (!vesa_driver) {
return KERN_NO_MEMORY;
}
driver_register(vesa_driver);
struct framebuffer_device *fb = framebuffer_device_create();
fb->fb_ops = &vesa_ops;
init_vesa(fb);
struct device *fb_base = framebuffer_device_base(fb);
snprintf(fb_base->dev_name, sizeof fb_base->dev_name, "vesafb");
kern_status_t status = device_register(fb_base, vesa_driver, misc_device());
if (status != KERN_OK) {
driver_unregister(vesa_driver);
driver_destroy(vesa_driver);
return status;
}
vesafb = fb;
return KERN_OK;
}
DEFINE_KEXT("net.doorstuck.socks.vesafb",
online, NULL,
KEXT_NO_DEPENDENCIES);

View File

@@ -1,8 +0,0 @@
name: vga16fb
description: |
Legacy VGA textmode framebuffer driver.
id: net.doorstuck.socks.vga16fb
license: BSD-3-Clause
copyright: Copyright © Max Wash 2023
sources:
- main.c

View File

@@ -1,12 +0,0 @@
#include <socks/printk.h>
#include <socks/kext.h>
static kern_status_t online(struct kext *self)
{
printk("vga16fb: online");
return KERN_OK;
}
DEFINE_KEXT("net.doorstuck.socks.vga16fb",
online, NULL,
KEXT_NO_DEPENDENCIES);

View File

@@ -1,36 +0,0 @@
#include <socks/printk.h>
#include <socks/device.h>
#include <socks/kext.h>
#include <socks/libc/stdio.h>
static struct driver *vga_driver = NULL;
static struct framebuffer_device *vgafb = NULL;
static kern_status_t online(struct kext *self)
{
vga_driver = driver_create(self, "vgafb");
if (!vga_driver) {
return KERN_NO_MEMORY;
}
driver_register(vga_driver);
struct framebuffer_device *fb = framebuffer_device_create();
struct device *fb_base = framebuffer_device_base(fb);
snprintf(fb_base->dev_name, sizeof fb_base->dev_name, "vgafb");
kern_status_t status = device_register(fb_base, vga_driver, misc_device());
if (status != KERN_OK) {
driver_unregister(vga_driver);
driver_destroy(vga_driver);
return status;
}
vgafb = fb;
return KERN_OK;
}
DEFINE_KEXT("net.doorstuck.socks.vgafb",
online, NULL,
KEXT_NO_DEPENDENCIES);