Orion
Barry Keyboard/Mouse drivers + POSIX names for structs 1628fcf (2 years, 4 months ago)diff --git a/drivers/vga/bga.c b/drivers/vga/bga.c index aff91aa..4548593 100644 --- a/drivers/vga/bga.c +++ b/drivers/vga/bga.c @@ -16,10 +16,12 @@ size_t bga_write(File *file, char *buf, size_t size, off_t offset); int bga_ioctl(File *file, unsigned long request, uintptr_t argp); +void bga_mmap(File *file, void *addr, size_t len, off_t offset); FileOps bgaFileOps = { .write = bga_write, .ioctl = bga_ioctl, + .mmap = bga_mmap, }; Driver bgaDriver = { @@ -129,3 +131,25 @@ bga_ioctl(File *file, unsigned long request, uintptr_t argp) return 0; } } + +/* Map the linear frame buffer into memory */ +void +bga_mmap(File *file, void *addr, size_t len, off_t offset) +{ + if (offset >= bgaWidth*bgaHeight*(bgaBpp/8)) + return; + if (len + offset > bgaWidth*bgaHeight*(bgaBpp/8)) + len = (bgaWidth*bgaHeight*(bgaBpp/8)) - offset; + + page_t *pg, new; + size_t max, count = 0; + while (len) { + max = (len < 0x1000) ? len : 0x1000; + pg = get_page(addr + count); + new = PG_ATTR(*pg); + free_page(pg); + alloc_page(pg, PG_ATTR(new), 0xFD000000 + offset + count); + count += max; + len -= max; + } +}