diff options
author | trimill <trimill@trimillxyz.org> | 2024-02-03 21:05:27 -0500 |
---|---|---|
committer | trimill <trimill@trimillxyz.org> | 2024-02-03 21:08:36 -0500 |
commit | 85a94437048e85aa97991899abbdd0cc927ca671 (patch) | |
tree | 2cb682af2be6ec7e94ebc3f010a780d1b4037c93 /src/arch/amd64/drivers/bochs.c | |
parent | fix lib (diff) | |
download | corn-85a94437048e85aa97991899abbdd0cc927ca671.tar.gz corn-85a94437048e85aa97991899abbdd0cc927ca671.tar.bz2 corn-85a94437048e85aa97991899abbdd0cc927ca671.zip |
formatting
Diffstat (limited to 'src/arch/amd64/drivers/bochs.c')
-rw-r--r-- | src/arch/amd64/drivers/bochs.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/arch/amd64/drivers/bochs.c b/src/arch/amd64/drivers/bochs.c index 1abb927..b3908f9 100644 --- a/src/arch/amd64/drivers/bochs.c +++ b/src/arch/amd64/drivers/bochs.c @@ -30,44 +30,44 @@ #define BOCHS_PCI_DEVICE 0x1111 static void write(uint16_t index, uint16_t data) { - outw(INDEX, index); - outw(DATA, data); + outw(INDEX, index); + outw(DATA, data); } static uint16_t read(uint16_t value) { - outw(INDEX, value); - return inw(DATA); + outw(INDEX, value); + return inw(DATA); } static int is_available(void) { - return (read(INDEX_ID) == 0xB0C5); + return (read(INDEX_ID) == 0xB0C5); } 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_XRES, width); - write(INDEX_YRES, height); - write(INDEX_BPP, bit_depth); - write(INDEX_ENABLE, DATA_DISP_ENABLE | - (lfb ? DATA_LFB_ENABLE : 0) | - (clear ? 0 : DATA_NO_CLEAR_MEM)); + write(INDEX_ENABLE, DATA_DISP_DISABLE); + write(INDEX_XRES, width); + write(INDEX_YRES, height); + write(INDEX_BPP, bit_depth); + write(INDEX_ENABLE, DATA_DISP_ENABLE | + (lfb ? DATA_LFB_ENABLE : 0) | + (clear ? 0 : DATA_NO_CLEAR_MEM)); } -volatile uint32_t* bochs_init(uint16_t width, uint16_t height, uint8_t bit_depth) { +volatile uint32_t *bochs_init(uint16_t width, uint16_t height, uint8_t bit_depth) { set_mode(width, height, bit_depth, true, true); if (!is_available()) - return NULL; + return NULL; - struct pci_device bochs = {0}; - bool found = pci_findby_id(&bochs, BOCHS_PCI_DEVICE, BOCHS_PCI_VENDOR, NULL); - if (!found) - return NULL; + struct pci_device bochs = {0}; + bool found = pci_findby_id(&bochs, BOCHS_PCI_DEVICE, BOCHS_PCI_VENDOR, NULL); + if (!found) + return NULL; - uint32_t bar0 = pci_rcfg_d(bochs, PCI_BAR0_D); - uint32_t *addr = (uint32_t*) (uintptr_t) bar0; - addr = mmap(addr, width * height * bit_depth); + uint32_t bar0 = pci_rcfg_d(bochs, PCI_BAR0_D); + uint32_t *addr = (uint32_t *) (uintptr_t) bar0; + addr = mmap(addr, width * height * bit_depth); - return addr; + return addr; } |