Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 53738
b: refs/heads/master
c: 0adad17
h: refs/heads/master
v: v3
  • Loading branch information
Rene Herman authored and Andi Kleen committed May 2, 2007
1 parent 0109ab9 commit bf2aae8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0949be35095b53dbaa72db700cb5074c5c249629
refs/heads/master: 0adad171c2334d43fc2fa208f6b45e88f0679427
29 changes: 18 additions & 11 deletions trunk/arch/i386/kernel/e820.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,27 @@ static struct resource standard_io_resources[] = { {

static int __init romsignature(const unsigned char *rom)
{
const unsigned short * const ptr = (const unsigned short *)rom;
unsigned short sig;

return probe_kernel_address((const unsigned short *)rom, sig) == 0 &&
sig == ROMSIGNATURE;
return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE;
}

static int __init romchecksum(unsigned char *rom, unsigned long length)
static int __init romchecksum(const unsigned char *rom, unsigned long length)
{
unsigned char sum;
unsigned char sum, c;

for (sum = 0; length; length--)
sum += *rom++;
return sum == 0;
for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--)
sum += c;
return !length && !sum;
}

static void __init probe_roms(void)
{
const unsigned char *rom;
unsigned long start, length, upper;
unsigned char *rom;
int i;
unsigned char c;
int i;

/* video rom */
upper = adapter_rom_resources[0].start;
Expand All @@ -191,8 +192,11 @@ static void __init probe_roms(void)

video_rom_resource.start = start;

if (probe_kernel_address(rom + 2, c) != 0)
continue;

/* 0 < length <= 0x7f * 512, historically */
length = rom[2] * 512;
length = c * 512;

/* if checksum okay, trust length byte */
if (length && romchecksum(rom, length))
Expand Down Expand Up @@ -226,8 +230,11 @@ static void __init probe_roms(void)
if (!romsignature(rom))
continue;

if (probe_kernel_address(rom + 2, c) != 0)
continue;

/* 0 < length <= 0x7f * 512, historically */
length = rom[2] * 512;
length = c * 512;

/* but accept any length that fits if checksum okay */
if (!length || start + length > upper || !romchecksum(rom, length))
Expand Down

0 comments on commit bf2aae8

Please sign in to comment.