aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2024-10-28 22:31:59 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2024-10-28 22:32:20 +0100
commitfeb63046b5ebd0d882a3adbcd6ff30786ac6ad03 (patch)
tree42b1a4c54db99ffc1c550c3d5d37abc64cfcb644
parent9d620b992b0bb822d61837275c91c1b72c3dfc25 (diff)
downloadhurd-feb63046b5ebd0d882a3adbcd6ff30786ac6ad03.tar.gz
hurd-feb63046b5ebd0d882a3adbcd6ff30786ac6ad03.tar.bz2
hurd-feb63046b5ebd0d882a3adbcd6ff30786ac6ad03.zip
console-client: Isolate fb driver even more from vga
-rw-r--r--console-client/fb.c41
-rw-r--r--console-client/fb.h11
-rw-r--r--console-client/vga.c40
3 files changed, 45 insertions, 47 deletions
diff --git a/console-client/fb.c b/console-client/fb.c
index a7cc87b4..c93a6ae0 100644
--- a/console-client/fb.c
+++ b/console-client/fb.c
@@ -48,13 +48,13 @@
#define DEFAULT_VGA_FONT DEFAULT_VGA_FONT_DIR "vga-system.bdf"
static char *fb_display_font;
-off_t fb_ptr;
+static off_t fb_ptr;
int fb_type;
-int fb_width;
-int fb_height;
-int fb_bpp;
-int fb_wc;
-int fb_hc;
+static int fb_width;
+static int fb_height;
+static int fb_bpp;
+static int fb_wc;
+static int fb_hc;
static unsigned char question_mark[32] = {
0x7E, /* ****** */
@@ -97,6 +97,8 @@ static int current_bg = 0;
#define CURSOR_GLYPH 0x2581
#define CURSOR_COLOUR 7
+struct display_ops fb_display_ops;
+
error_t
@@ -237,7 +239,7 @@ fb_fini(void)
}
/* Start the driver. */
-error_t
+static error_t
fb_display_start (void *handle)
{
error_t err;
@@ -285,7 +287,7 @@ fb_display_start (void *handle)
}
/* Destroy the display HANDLE. */
-error_t
+static error_t
fb_display_fini (void *handle, int force)
{
struct fb_display *disp = handle;
@@ -636,3 +638,26 @@ struct display_ops fb_display_ops =
fb_set_mousecursor_pos,
fb_set_mousecursor_status
};
+
+error_t
+fb_display_init (void **handle, struct driver_ops *ops)
+{
+ struct fb_display *fbdisp;
+
+ /* Linear framebuffer! */
+ fbdisp = calloc (1, sizeof *fbdisp);
+ if (!fbdisp)
+ return ENOMEM;
+
+ fbdisp->width = fb_width;
+ fbdisp->height = fb_height;
+
+ /* dynamically switch drivers */
+ ops->start = fb_display_start;
+ ops->fini = fb_display_fini;
+ ops->restore_status = NULL;
+
+ *handle = fbdisp;
+
+ return 0;
+}
diff --git a/console-client/fb.h b/console-client/fb.h
index c32947ad..123ef978 100644
--- a/console-client/fb.h
+++ b/console-client/fb.h
@@ -32,19 +32,10 @@
#define FONT_PIXELS_W 8
#define FONT_PIXELS_H 16
-extern struct display_ops fb_display_ops;
-
-extern off_t fb_ptr;
extern int fb_type;
-extern int fb_width;
-extern int fb_height;
-extern int fb_bpp;
-extern int fb_wc;
-extern int fb_hc;
error_t fb_get_multiboot_params (void);
-error_t fb_display_start (void *handle);
-error_t fb_display_fini (void *handle, int force);
+error_t fb_display_init (void **handle, struct driver_ops *ops);
struct multiboot_framebuffer_info {
uint64_t framebuffer_addr;
diff --git a/console-client/vga.c b/console-client/vga.c
index ec63330c..ec4f39dd 100644
--- a/console-client/vga.c
+++ b/console-client/vga.c
@@ -283,7 +283,6 @@ vga_display_init (void **handle, int no_exit, int argc, char *argv[],
{
error_t err;
struct vga_display *vgadisp;
- struct fb_display *fbdisp;
int pos = 1;
fb_get_multiboot_params();
@@ -300,37 +299,20 @@ vga_display_init (void **handle, int no_exit, int argc, char *argv[],
if (err && err != EINVAL)
return err;
- if (fb_type == MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT)
- {
- /* EGA text mode */
- vgadisp = calloc (1, sizeof *vgadisp);
- if (!vgadisp)
- return ENOMEM;
+ if (fb_type != MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT)
+ return fb_display_init (handle, &driver_vga_ops);
- vgadisp->df_size = vga_display_max_glyphs ? 512 : 256;
- vgadisp->df_width = vga_display_font_width;
- vgadisp->width = VGA_DISP_WIDTH;
- vgadisp->height = VGA_DISP_HEIGHT;
+ /* EGA text mode */
+ vgadisp = calloc (1, sizeof *vgadisp);
+ if (!vgadisp)
+ return ENOMEM;
- *handle = vgadisp;
- }
- else
- {
- /* Linear framebuffer! */
- fbdisp = calloc (1, sizeof *fbdisp);
- if (!fbdisp)
- return ENOMEM;
+ vgadisp->df_size = vga_display_max_glyphs ? 512 : 256;
+ vgadisp->df_width = vga_display_font_width;
+ vgadisp->width = VGA_DISP_WIDTH;
+ vgadisp->height = VGA_DISP_HEIGHT;
- fbdisp->width = fb_width;
- fbdisp->height = fb_height;
-
- /* dynamically switch drivers */
- driver_vga_ops.start = fb_display_start;
- driver_vga_ops.fini = fb_display_fini;
- driver_vga_ops.restore_status = NULL;
-
- *handle = fbdisp;
- }
+ *handle = vgadisp;
return 0;
}