aboutsummaryrefslogtreecommitdiffstats
path: root/vbe.c
diff options
context:
space:
mode:
authorAnssi Hannula <anssi@mandriva.org>2010-01-02 02:15:23 +0000
committerAnssi Hannula <anssi@mandriva.org>2010-01-02 02:15:23 +0000
commit02eba4f24bcb783e733c51f675d8fb49e37ba94e (patch)
treeb68de4db7c88ab5e53cc554998b1e6976166043f /vbe.c
parent11d91cb12cd80cd8bd6b3ab55b4a3fc3bfb5ad64 (diff)
downloadmonitor-edid-02eba4f24bcb783e733c51f675d8fb49e37ba94e.tar
monitor-edid-02eba4f24bcb783e733c51f675d8fb49e37ba94e.tar.gz
monitor-edid-02eba4f24bcb783e733c51f675d8fb49e37ba94e.tar.bz2
monitor-edid-02eba4f24bcb783e733c51f675d8fb49e37ba94e.tar.xz
monitor-edid-02eba4f24bcb783e733c51f675d8fb49e37ba94e.zip
Fix the retrieval of VBE vendor strings when using the LRMI interface.
Diffstat (limited to 'vbe.c')
-rw-r--r--vbe.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/vbe.c b/vbe.c
index 0aeadf9..23faad1 100644
--- a/vbe.c
+++ b/vbe.c
@@ -48,29 +48,30 @@ static char *canon_str(char *s, int len)
return start;
}
-static unsigned segofs2addr(unsigned char *segofs)
+static unsigned segofs2addr(char *segofs)
{
return segofs[0] + (segofs[1] << 8) + (segofs[2] << 4)+ (segofs[3] << 12);
}
+#define VBE_BLOCK_SIZE 0x200
-static unsigned get_data(unsigned char *buf, unsigned buf_size, unsigned addr)
+static unsigned get_data(char *buf, unsigned buf_size, char *bufferaddr, unsigned addr)
{
- unsigned bufferaddr = 0x7e00;
unsigned len;
+ char *real_addr = (char *) LRMI_base_addr() + addr;
*buf = 0;
len = 0;
- if(addr >= bufferaddr && addr < bufferaddr + 0x200) {
- len = bufferaddr + 0x200 - addr;
+ if(real_addr >= bufferaddr && real_addr < bufferaddr + VBE_BLOCK_SIZE) {
+ len = bufferaddr + VBE_BLOCK_SIZE - real_addr;
if(len >= buf_size) len = buf_size - 1;
- memcpy(buf, addr + (char *) 0, len);
+ memcpy(buf, real_addr, len);
}
else if(addr >= 0x0c0000 && addr < 0x100000) {
len = 0x100000 - addr;
if(len >= buf_size) len = buf_size - 1;
- memcpy(buf, addr + (char *) 0, len);
+ memcpy(buf, (char *) LRMI_base_addr() + addr, len);
}
buf[len] = 0;
@@ -78,17 +79,17 @@ static unsigned get_data(unsigned char *buf, unsigned buf_size, unsigned addr)
return len;
}
-static char *get_str(unsigned char *buf, unsigned buf_size, char *v)
+static char *get_str(char *buf, unsigned buf_size, char *v, int offset)
{
- int len = get_data(buf, buf_size, segofs2addr(v));
+ int len = get_data(buf, buf_size, v, segofs2addr(v + offset));
return canon_str(buf, len);
}
#define GET_WORD(ADDR, OFS) ((ADDR)[OFS] + ((ADDR)[(OFS) + 1] << 8))
-static void parse_vbe_info(unsigned char *v)
+static void parse_vbe_info(char *v)
{
- unsigned char tmp[1024];
+ char tmp[1024];
/* Parse VBE block */
int version = GET_WORD(v, 0x04);
@@ -98,10 +99,10 @@ static void parse_vbe_info(unsigned char *v)
version >> 8, version & 0xff, oem_version >> 8, oem_version & 0xff);
log_err("Memory: %uk\n", memory_size >> 10);
- log_err("OEM name: %s\n", get_str(tmp, sizeof tmp, v + 0x06));
- log_err("Vendor name: %s\n", get_str(tmp, sizeof tmp, v + 0x16));
- log_err("Product name: %s\n", get_str(tmp, sizeof tmp, v + 0x1a));
- log_err("Product revision: %s\n", get_str(tmp, sizeof tmp, v + 0x1e));
+ log_err("OEM name: %s\n", get_str(tmp, sizeof tmp, v, 0x06));
+ log_err("Vendor name: %s\n", get_str(tmp, sizeof tmp, v, 0x16));
+ log_err("Product name: %s\n", get_str(tmp, sizeof tmp, v, 0x1a));
+ log_err("Product revision: %s\n", get_str(tmp, sizeof tmp, v, 0x1e));
}
static void parse_ddc_info(int port, int info)
@@ -116,8 +117,7 @@ static void parse_ddc_info(int port, int info)
static int vbe_check_vbe_info(void)
{
int i;
- unsigned char *mem;
- unsigned char v[0x200];
+ char *mem;
struct LRMI_regs regs;
/* initialize LRMI */
@@ -127,18 +127,18 @@ static int vbe_check_vbe_info(void)
}
/* allocate a chunk of memory */
- mem = LRMI_alloc_real(sizeof(v));
+ mem = LRMI_alloc_real(VBE_BLOCK_SIZE);
if (mem == NULL) {
log_err("VBE: could allocate real memory\n");
return 0;
}
- memset(mem, 0, sizeof(v));
+ memset(mem, 0, VBE_BLOCK_SIZE);
/* set up registers for the interrupt call. */
memset(&regs, 0, sizeof(regs));
regs.eax = 0x4f00;
- regs.es = ((u_int32_t)mem) >> 4;
- regs.edi = ((u_int32_t)mem) & 0x0f;
+ regs.es = (u_int32_t)(mem - LRMI_base_addr()) >> 4;
+ regs.edi = (u_int32_t)(mem - LRMI_base_addr()) & 0x0f;
memcpy(mem, "VBE2", 4);
/* do it. */
@@ -157,11 +157,8 @@ static int vbe_check_vbe_info(void)
return 0;
}
- /* get memory to return the information */
- memcpy(v, mem, sizeof(v));
+ parse_vbe_info(mem);
LRMI_free_real(mem);
-
- parse_vbe_info(v);
return 1;
}
@@ -234,8 +231,8 @@ static int vbe_get_edid_info(char *edid, int port)
regs.eax = 0x4f15;
regs.ebx = 0x0001;
regs.ecx = port;
- regs.es = ((u_int32_t)mem) >> 4;
- regs.edi = ((u_int32_t)mem) & 0x0f;
+ regs.es = (u_int32_t)(mem - LRMI_base_addr()) >> 4;
+ regs.edi = (u_int32_t)(mem - LRMI_base_addr()) & 0x0f;
/* do it. */
iopl(3);