check for bochs

This commit is contained in:
Freya Murphy 2024-02-02 12:23:48 -05:00
parent 7e62c50138
commit 019de3cb22
Signed by: freya
GPG key ID: 744AB800E383AE52

View file

@ -2,6 +2,7 @@
#include <memory.h> #include <memory.h>
#include <serial.h> #include <serial.h>
#include <stdint.h> #include <stdint.h>
#include <panic.h>
#include "bindings.h" #include "bindings.h"
@ -34,11 +35,11 @@ static uint16_t read(uint16_t value) {
return inw(DATA); return inw(DATA);
} }
int is_available(void) { static int is_available(void) {
return (read(INDEX_ID) >= 0xB0C4); return (read(INDEX_ID) == 0xB0C5);
} }
void set_mode(uint16_t width, uint16_t height, uint16_t bit_depth, int lfb, int clear) { static void set_mode(uint16_t width, uint16_t height, uint16_t bit_depth, int lfb, int clear) {
write(INDEX_ENABLE, DATA_DISP_DISABLE); write(INDEX_ENABLE, DATA_DISP_DISABLE);
write(INDEX_XRES, width); write(INDEX_XRES, width);
write(INDEX_YRES, height); write(INDEX_YRES, height);
@ -48,13 +49,16 @@ void set_mode(uint16_t width, uint16_t height, uint16_t bit_depth, int lfb, int
(clear ? 0 : DATA_NO_CLEAR_MEM)); (clear ? 0 : DATA_NO_CLEAR_MEM));
} }
void set_bank(uint16_t bank) { //static void set_bank(uint16_t bank) {
write(INDEX_BANK, bank); // write(INDEX_BANK, bank);
} //}
int fb_init(uint16_t width, uint16_t height) { int fb_init(uint16_t width, uint16_t height) {
set_mode(width, height, 32, true, true); set_mode(width, height, 32, true, true);
if (!is_available())
panic("bochs framebuffer not avaliable");
return 0; return 0;
} }