summaryrefslogtreecommitdiff
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
parentb43aa48e5e54db5bb917cc33cd13105f36b3ba2c (diff)
kern: fbdev: Create namespace object for fbdev
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--src/sys/include/sys/fbdev.h46
-rw-r--r--src/sys/io/video/fbdev.c42
2 files changed, 88 insertions, 0 deletions
diff --git a/src/sys/include/sys/fbdev.h b/src/sys/include/sys/fbdev.h
new file mode 100644
index 0000000..b0f3fb1
--- /dev/null
+++ b/src/sys/include/sys/fbdev.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2025 Ian Marco Moffett and L5 engineers
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _FBDEV_H_
+#define _FBDEV_H_ 1
+
+#include <sys/types.h>
+#if !defined(_KERNEL)
+#include <stdint.h>
+#endif /* !_KERNEL */
+
+#define FBDEV_NSO "system:video:attr"
+
+struct fb_info {
+ uint32_t width;
+ uint32_t height;
+ uint32_t pitch;
+};
+
+#endif /* !_FBDEV_H_ */
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);