From 4ab8b6206b1ba36cbf4db4a416e04304bbd7ebc0 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 10 Mar 2015 17:27:55 +0100 Subject: Implement VESA ioctl (not tested). --- src/kernel/dev/vesa.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/kernel') diff --git a/src/kernel/dev/vesa.c b/src/kernel/dev/vesa.c index f1a87d8..e60cc98 100644 --- a/src/kernel/dev/vesa.c +++ b/src/kernel/dev/vesa.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -366,7 +367,36 @@ void vesa_close(fs_handle_t *f) { } int vesa_ioctl(fs_handle_t *h, int command, void* data) { - // TODO + vesa_driver_t *d = (vesa_driver_t*)h->node->data; + + if (command == IOCTL_FBDEV_GET_MODE_INFO) { + fbdev_mode_info_t *m = (fbdev_mode_info_t*)data; + + if ((void*)m < (void*)K_HIGHHALF_ADDR) probe_for_write(m, sizeof(fbdev_mode_info_t)); + + if (m->mode_number >= 0 && m->mode_number < d->nmodes) { + memcpy(&m->geom, &d->modes[m->mode_number].info, sizeof(framebuffer_info_t)); + return 1; + } + } else if (command == IOCTL_FBDEV_SET_MODE) { + fbdev_mode_info_t *m = (fbdev_mode_info_t*)data; + + if ((void*)m < (void*)K_HIGHHALF_ADDR) probe_for_read(m, sizeof(fbdev_mode_info_t)); + + if (m->mode_number >= 0 && m->mode_number < d->nmodes) { + if (vesa_set_mode(d, m->mode_number)) return 1; + } + } else if (command == IOCTL_FB_GET_INFO) { + if (d->current_mode != -1) { + framebuffer_info_t *i = (framebuffer_info_t*)data; + + if ((void*)i < (void*)K_HIGHHALF_ADDR) probe_for_write(i, sizeof(framebuffer_info_t)); + memcpy(i, &d->modes[d->current_mode].info, sizeof(framebuffer_info_t)); + + return 1; + } + } + return 0; } -- cgit v1.2.3