diff options
Diffstat (limited to 'tools/ddcprobe/ddcxinfos.c')
-rw-r--r-- | tools/ddcprobe/ddcxinfos.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/ddcprobe/ddcxinfos.c b/tools/ddcprobe/ddcxinfos.c index 4aec99d29..04ab260cf 100644 --- a/tools/ddcprobe/ddcxinfos.c +++ b/tools/ddcprobe/ddcxinfos.c @@ -21,6 +21,8 @@ int main(void) struct vbe_edid1_info *edid; struct vbe_modeline *modelines; #if KERNEL_BOOT_INFO + u_int32_t vga_bios_base, vga_bios_size; + u_int32_t page_size; int dev_mem_fd; char *mem; #endif @@ -34,13 +36,15 @@ int main(void) perror("open /dev/mem"); return 1; } - if ((mem = (char *)mmap(0, VGA_BIOS_SIZE, PROT_READ, MAP_PRIVATE, dev_mem_fd, VGA_BIOS_BASE)) == MAP_FAILED) { - perror("mmap /dev/mem at VGA_BIOS_BASE"); + page_size = getpagesize(); + vga_bios_base = vbe_info->mode_list.base & ~0xffff; + vga_bios_size = (vbe_info->mode_list.base - vga_bios_base + page_size - 1) & -page_size; + mem = malloc(vga_bios_size); + if (lseek(dev_mem_fd, vga_bios_base, SEEK_SET) != vga_bios_base) return 1; - } - - if ((vbe_info->mode_list.base & ~0xffff) != VGA_BIOS_BASE) return 1; - mode_list = (u_int16_t *)(mem + vbe_info->mode_list.base - VGA_BIOS_BASE); + if (read(dev_mem_fd, mem, vga_bios_size) != vga_bios_size) + return 1; + mode_list = (u_int16_t *)(mem + vbe_info->mode_list.base - vga_bios_base); #endif #if defined(__i386__) mode_list = (u_int16_t *)vbe_info->mode_list.ptr; @@ -60,7 +64,7 @@ int main(void) printf("\n"); #if KERNEL_BOOT_INFO - munmap(mem, VGA_BIOS_SIZE); + free(mem); close(dev_mem_fd); #endif |