diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-20 11:26:32 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-20 11:26:32 -0400 |
commit | 5e0e6240ab058c490304e0789552b45160f900be (patch) | |
tree | 82e19097301d3914f80e356710438278df24fd36 /kernel/drivers | |
parent | fix code segment (retfq) on long mode edge case (kvm) (diff) | |
download | comus-5e0e6240ab058c490304e0789552b45160f900be.tar.gz comus-5e0e6240ab058c490304e0789552b45160f900be.tar.bz2 comus-5e0e6240ab058c490304e0789552b45160f900be.zip |
fix term/gpu memory OOB error, add dynamic kernel identity map with N_IDENT_PTS
Diffstat (limited to 'kernel/drivers')
-rw-r--r-- | kernel/drivers/gpu.c | 17 | ||||
-rw-r--r-- | kernel/drivers/gpu/bochs.c | 5 |
2 files changed, 15 insertions, 7 deletions
diff --git a/kernel/drivers/gpu.c b/kernel/drivers/gpu.c index 17e7e18..3d79b99 100644 --- a/kernel/drivers/gpu.c +++ b/kernel/drivers/gpu.c @@ -12,20 +12,27 @@ struct gpu *gpu_dev = NULL; int gpu_init(void) { // try to get a gpu device - if (!gpu_dev && gop_init(&gpu_dev) == SUCCESS) { - } - if (!gpu_dev && bochs_init(&gpu_dev) == SUCCESS) { - } + if (gpu_dev == NULL) + gop_init(&gpu_dev); + if (gpu_dev == NULL) + bochs_init(&gpu_dev); // if we did (yay!) resize terminal if (gpu_dev) - term_resize(gpu_dev->width, gpu_dev->height); + term_resize(gpu_dev->width / en_font.width, + gpu_dev->height / en_font.height); return gpu_dev != NULL; } void gpu_set_pixel(uint32_t x, uint32_t y, uint32_t r, uint32_t g, uint32_t b) { + if (gpu_dev == NULL) + return; + + x %= gpu_dev->width; + y %= gpu_dev->height; + // TODO: handle other bpp volatile uint32_t *fb = (volatile uint32_t *)gpu_dev->framebuffer; int offset = y * gpu_dev->width + x; diff --git a/kernel/drivers/gpu/bochs.c b/kernel/drivers/gpu/bochs.c index 3438ab5..f8e5820 100644 --- a/kernel/drivers/gpu/bochs.c +++ b/kernel/drivers/gpu/bochs.c @@ -68,8 +68,9 @@ int bochs_init(struct gpu **gpu_dev) bochs_dev.width = BOCHS_WIDTH; bochs_dev.height = BOCHS_HEIGHT; bochs_dev.bit_depth = BOCHS_BIT_DEPTH; - bochs_dev.framebuffer = kmapaddr( - addr, NULL, BOCHS_WIDTH * BOCHS_HEIGHT * BOCHS_BIT_DEPTH, F_WRITEABLE); + bochs_dev.framebuffer = + kmapaddr(addr, NULL, BOCHS_WIDTH * BOCHS_HEIGHT * (BOCHS_BIT_DEPTH / 8), + F_WRITEABLE); *gpu_dev = &bochs_dev; return 0; |