summaryrefslogtreecommitdiff
path: root/src/sys/io/video/fbdev.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-09-29 20:00:21 -0400
committerIan Moffett <ian@osmora.org>2025-09-29 20:03:42 -0400
commit528f1e253d6f8dac0db4a8b27f07e5067b69e445 (patch)
tree85a9a6721a3ad18e0bd6c10daba7f4a6423fc606 /src/sys/io/video/fbdev.c
parentb43aa48e5e54db5bb917cc33cd13105f36b3ba2c (diff)
kern: fbdev: Create namespace object for fbdev
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/io/video/fbdev.c')
-rw-r--r--src/sys/io/video/fbdev.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/sys/io/video/fbdev.c b/src/sys/io/video/fbdev.c
index 51abea3..1464f0c 100644
--- a/src/sys/io/video/fbdev.c
+++ b/src/sys/io/video/fbdev.c
@@ -28,13 +28,20 @@
*/
#include <sys/bootvars.h>
+#include <sys/errno.h>
#include <sys/proc.h>
#include <sys/mman.h>
#include <sys/types.h>
+#include <sys/fbdev.h>
+#include <os/kalloc.h>
+#include <os/module.h>
+#include <os/ns.h>
#include <io/video/fbdev.h>
#include <vm/map.h>
#include <vm/mmu.h>
+static struct fb_info info;
+
/*
* Map the framebuffer, we'll decided how many bytes
* is mapped.
@@ -80,6 +87,39 @@ fbdev_map(struct mac_border *mbp, struct mac_map_args *args)
return args->len;
}
+static int
+fbdev_init(struct module *modp)
+{
+ struct bootvar_fb *fbvar;
+ struct bootvars bv;
+ struct ns_obj *obj;
+ int error;
+
+ obj = kalloc(sizeof(*obj));
+ if (obj == NULL) {
+ return -EINVAL;
+ }
+
+ /* Grab the bootvars */
+ error = bootvars_read(&bv, 0);
+ if (error < 0) {
+ return error;
+ }
+
+ fbvar = &bv.fbvars;
+ info.width = fbvar->width;
+ info.height = fbvar->height;
+ info.pitch = fbvar->pitch;
+
+ /* Initialize the object */
+ if ((error = ns_obj_init(obj)) < 0) {
+ return error;
+ }
+
+ obj->data = &info;
+ return ns_obj_enter(0, obj, FBDEV_NSO);
+}
+
static struct mac_ops ops = {
.map = fbdev_map,
.sync = NULL,
@@ -90,3 +130,5 @@ struct mac_border g_fbdev_border = {
.level = MAC_RESTRICTED,
.ops = &ops
};
+
+MODULE_EXPORT("fbdev", MODTYPE_GENERIC, fbdev_init);