aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/include/framebuffer.h19
-rw-r--r--src/common/include/proto/fb.h33
-rw-r--r--src/common/include/proto/fs.h (renamed from src/common/include/fs.h)0
-rw-r--r--src/common/include/proto/mmap.h (renamed from src/common/include/mmap.h)0
-rw-r--r--src/common/include/proto/proc.h (renamed from src/common/include/proc.h)0
-rw-r--r--src/common/include/proto/syscall.h (renamed from src/common/include/syscallproto.h)4
-rw-r--r--src/common/include/proto/token.h (renamed from src/common/include/token.h)0
-rw-r--r--src/kernel/dev/vesa.c37
-rw-r--r--src/kernel/include/ipc.h3
-rw-r--r--src/kernel/include/process.h4
-rw-r--r--src/kernel/include/sct.h2
-rw-r--r--src/kernel/include/vfs.h2
-rw-r--r--src/lib/include/syscall.h8
13 files changed, 77 insertions, 35 deletions
diff --git a/src/common/include/framebuffer.h b/src/common/include/framebuffer.h
deleted file mode 100644
index febbfaa..0000000
--- a/src/common/include/framebuffer.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-
-typedef struct {
- uint32_t width, height;
- uint32_t pitch; // bytes per line
- uint32_t bpp;
-} framebuffer_info_t;
-
-typedef struct {
- int mode_number;
- framebuffer_info_t geom;
-} fbdev_mode_info_t;
-
-#define IOCTL_FBDEV_GET_MODE_INFO 10
-#define IOCTL_FBDEV_SET_MODE 11
-
-#define IOCTL_FB_GET_INFO 12
-
-/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/src/common/include/proto/fb.h b/src/common/include/proto/fb.h
new file mode 100644
index 0000000..0519554
--- /dev/null
+++ b/src/common/include/proto/fb.h
@@ -0,0 +1,33 @@
+#pragma once
+
+// Framebuffer-related data structures
+
+#include <stdint.h>
+#include <stddef.h>
+
+#define FB_MM_RGB16 1 // 2 bytes (16 bits) per pixel, blue 0-4, green 5-9, red 10-14
+#define FB_MM_BGR16 2 // 2 bytes (16 bits) per pixel, red 0-4, green 5-9, blue 10-14
+#define FB_MM_RGB24 3 // 3 bytes (24 bits) per pixel, blue 0-7, green 8-15, red 16-23
+#define FB_MM_BGR24 4 // 3 bytes (24 bits) per pixel, red 0-7, green 8-15, blue 16-23
+#define FB_MM_RGB32 5 // 4 bytes (32 bits) per pixel, blue 0-7, green 8-15, red 16-23
+#define FB_MM_BGR32 6 // 4 bytes (32 bits) per pixel, red 0-7, green 8-15, blue 16-23
+#define FB_MM_GREY8 10 // 1 byte (8 bits) per pixel greyscale
+
+typedef struct {
+ uint32_t width, height;
+ uint32_t pitch; // bytes per line
+ uint32_t bpp;
+ uint32_t memory_model;
+} framebuffer_info_t;
+
+typedef struct {
+ int mode_number;
+ framebuffer_info_t geom;
+} fbdev_mode_info_t;
+
+#define IOCTL_FBDEV_GET_MODE_INFO 10
+#define IOCTL_FBDEV_SET_MODE 11
+
+#define IOCTL_FB_GET_INFO 12
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/src/common/include/fs.h b/src/common/include/proto/fs.h
index e70ff55..e70ff55 100644
--- a/src/common/include/fs.h
+++ b/src/common/include/proto/fs.h
diff --git a/src/common/include/mmap.h b/src/common/include/proto/mmap.h
index 3134403..3134403 100644
--- a/src/common/include/mmap.h
+++ b/src/common/include/proto/mmap.h
diff --git a/src/common/include/proc.h b/src/common/include/proto/proc.h
index 29b5b91..29b5b91 100644
--- a/src/common/include/proc.h
+++ b/src/common/include/proto/proc.h
diff --git a/src/common/include/syscallproto.h b/src/common/include/proto/syscall.h
index 9f300d3..a671c65 100644
--- a/src/common/include/syscallproto.h
+++ b/src/common/include/proto/syscall.h
@@ -1,7 +1,7 @@
#pragma once
-#include <proc.h>
-#include <fs.h>
+#include <proto/proc.h>
+#include <proto/fs.h>
typedef struct { fd_t a, b; } fd_pair_t;
diff --git a/src/common/include/token.h b/src/common/include/proto/token.h
index 9ec1aff..9ec1aff 100644
--- a/src/common/include/token.h
+++ b/src/common/include/proto/token.h
diff --git a/src/kernel/dev/vesa.c b/src/kernel/dev/vesa.c
index 1880740..2a7b876 100644
--- a/src/kernel/dev/vesa.c
+++ b/src/kernel/dev/vesa.c
@@ -1,6 +1,6 @@
#include <string.h>
-#include <framebuffer.h> // common header
+#include <proto/fb.h>
#include <vfs.h>
#include <nullfs.h>
@@ -184,9 +184,9 @@ typedef struct {
uint8_t memory_model, bank_size, image_pages;
uint8_t reserved0;
- uint8_t red_mask, red_position;
- uint8_t green_mask, green_position;
- uint8_t blue_mask, blue_position;
+ uint8_t red_mask_sz, red_position;
+ uint8_t green_mask_sz, green_position;
+ uint8_t blue_mask_sz, blue_position;
uint8_t rsv_mask, rsv_position;
uint8_t directcolor_attributes;
@@ -241,6 +241,19 @@ fs_node_ops_t vesa_fs_ops = {
.dispose = 0,
};
+static struct fb_memory_model {
+ int bpp, rp, gp, bp, rs, gs, bs, mm;
+} fb_memory_models[8] = {
+ { 15, 10, 5, 0, 5, 5, 5, FB_MM_RGB16 },
+ { 16, 10, 5, 0, 5, 5, 5, FB_MM_RGB16 },
+ { 15, 0, 5, 10, 5, 5, 5, FB_MM_BGR16 },
+ { 16, 0, 5, 10, 5, 5, 5, FB_MM_BGR16 },
+ { 24, 16, 8, 0, 8, 8, 8, FB_MM_RGB24 },
+ { 24, 0, 8, 16, 8, 8, 8, FB_MM_BGR24 },
+ { 32, 16, 8, 0, 8, 8, 8, FB_MM_RGB32 },
+ { 32, 0, 8, 16, 8, 8, 8, FB_MM_BGR32 },
+};
+
void vesa_detect(fs_t *iofs) {
if (!v86_begin_session()) return;
@@ -280,13 +293,27 @@ void vesa_detect(fs_t *iofs) {
if (!v86_bios_int(0x10) || v86_regs.ax != 0x004F) continue;
if ((mi->attributes & 0x90) != 0x90) continue; // not linear framebuffer
- if (mi->memory_model != 4 && mi->memory_model != 6) continue;
+ if (mi->memory_model != 6) continue;
int x = mode_data_c;
mode_data[x].info.width = mi->Xres;
mode_data[x].info.height = mi->Yres;
mode_data[x].info.bpp = mi->bpp;
mode_data[x].info.pitch = mi->pitch;
+
+ mode_data[x].info.memory_model = 0;
+ for (int j = 0; j < 8; j++) {
+ struct fb_memory_model m = fb_memory_models[j];
+ if (mi->bpp == m.bpp
+ && mi->red_mask_sz == m.rs && mi->red_position == m.rp
+ && mi->green_mask_sz == m.gs && mi->green_position == m.gp
+ && mi->blue_mask_sz == m.bs && mi->blue_position == m.bp)
+ mode_data[x].info.memory_model = m.mm;
+ }
+ if (mode_data[x].info.memory_model == 0) continue;
+
+ dbg_printf("VESA mode: %dx%dx%d (%d)\n", mi->Xres, mi->Yres, mi->bpp, mode_data[x].info.memory_model);
+
mode_data[x].phys_fb_addr = (void*)mi->physbase;
mode_data[x].vesa_mode_id = *mode;
mode_data_c++;
diff --git a/src/kernel/include/ipc.h b/src/kernel/include/ipc.h
index 0feddf2..05d14a8 100644
--- a/src/kernel/include/ipc.h
+++ b/src/kernel/include/ipc.h
@@ -1,6 +1,7 @@
#pragma once
-#include <token.h>
+#include <proto/token.h>
+
#include <vfs.h>
// ---- Communication channels
diff --git a/src/kernel/include/process.h b/src/kernel/include/process.h
index 3b98451..d4fcfc3 100644
--- a/src/kernel/include/process.h
+++ b/src/kernel/include/process.h
@@ -17,8 +17,8 @@
#include <vfs.h>
#include <pager.h>
-#include <mmap.h> // common header for mmaps
-#include <proc.h> // common header defining process statuses
+#include <proto/mmap.h>
+#include <proto/proc.h>
#define USERSTACK_ADDR 0xB8000000
#define USERSTACK_SIZE 0x00020000 // 32 KB - it is allocated on demand so no worries
diff --git a/src/kernel/include/sct.h b/src/kernel/include/sct.h
index 2d6acd5..8f675b1 100644
--- a/src/kernel/include/sct.h
+++ b/src/kernel/include/sct.h
@@ -1,7 +1,7 @@
#pragma once
#include <idt.h>
-#include <syscallproto.h>
+#include <proto/syscall.h>
void setup_syscall_table();
diff --git a/src/kernel/include/vfs.h b/src/kernel/include/vfs.h
index 3d225c5..c22ec9a 100644
--- a/src/kernel/include/vfs.h
+++ b/src/kernel/include/vfs.h
@@ -6,7 +6,7 @@
#include <hashtbl.h>
#include <mutex.h>
-#include <fs.h> // common header
+#include <proto/fs.h>
#include <pager.h>
diff --git a/src/lib/include/syscall.h b/src/lib/include/syscall.h
index 79e930f..f66b759 100644
--- a/src/lib/include/syscall.h
+++ b/src/lib/include/syscall.h
@@ -4,12 +4,12 @@
#include <stdint.h>
#include <stdbool.h>
-#include <syscallproto.h>
-#include <mmap.h>
+#include <proto/syscall.h>
+#include <proto/mmap.h>
+#include <proto/fs.h>
+#include <proto/token.h>
-#include <fs.h>
#include <debug.h>
-#include <token.h>
typedef void (*entry_t)(void*);