1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
/* 855resolution by Alain Poirier
*
* Currently only tested on a Dell 510m with BIOS A04
* *VERY* likely that this won't work yet on any
* other versions or chipsets!!!
*
* This code is based on the techniques used in :
*
* - 855patch. Many thanks to Christian Zietz (czietz gmx net)
* for demonstrating how to shadow the VBIOS into system RAM
* and then modify it.
*
* - 1280patch by Andrew Tipton (andrewtipton null li).
*
* This source code is into the public domain.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define __USE_GNU
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/io.h>
#include "vbios.h"
#define CHIPSET_ID 0x35808086
#define VBIOS_START 0xc0000
#define CFG_SIGNATURE "BIOS_DATA_BLOCK "
#ifndef VBIOS_FILE
#define VBIOS_FILE "/dev/mem"
#define VBIOS_OFFSET_IN_FILE VBIOS_START
#else
#define VBIOS_OFFSET_IN_FILE 0
#endif
unsigned char *bios = 0;
static int biosfd = 0;
static unsigned int get_chipset(void) {
outl(0x80000000, 0xcf8);
return inl(0xcfc);
}
void open_bios(void) {
biosfd = open(VBIOS_FILE, O_RDWR);
if(biosfd < 0) {
perror("Unable to open the BIOS file");
exit(2);
}
bios = mmap((void *)VBIOS_START, VBIOS_SIZE,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED,
biosfd, VBIOS_OFFSET_IN_FILE);
if(bios == NULL) {
fprintf(stderr, "Cannot mmap() the video BIOS\n");
close(biosfd);
exit(2);
}
}
void close_bios(void) {
if(bios == NULL) {
fprintf(stderr, "BIOS should be open already!\n");
exit(2);
}
munmap(bios, VBIOS_SIZE);
close(biosfd);
}
void display_chipset(void) {
unsigned int chipset;
chipset = get_chipset();
printf("Chipset: ");
switch (chipset) {
case 0x25608086:
printf("845G\n");
break;
case 0x35808086:
printf("855GM\n");
break;
case 0x25708086:
printf("865G\n");
break;
default:
printf("Unknown (0x%08x)\n", chipset);
break;
}
}
unsigned char *get_vbios_cfg(void) {
return memmem(bios, VBIOS_SIZE, CFG_SIGNATURE, strlen(CFG_SIGNATURE));
}
|