diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-08-24 15:36:56 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-08-24 15:36:56 +0200 |
commit | d436b2117e5c054c9977f80cae9c2302ed50a5a6 (patch) | |
tree | ea29213acd0c5b67ccefdd3348cdca9125227a40 /sys/src/9/pc/archmp.c | |
parent | 86f323290c9f99b72e359ff2c37eed528f5b3976 (diff) |
add unified sigsearch() function to look for bios data structures
replace the various functions that searched for bios data structures by
a single sigsearch() one in pc/memory.c that will probe the various bios
data areas.
also, a new checksum() function was added that is to be used to validate
the structures found.
Diffstat (limited to 'sys/src/9/pc/archmp.c')
-rw-r--r-- | sys/src/9/pc/archmp.c | 62 |
1 files changed, 3 insertions, 59 deletions
diff --git a/sys/src/9/pc/archmp.c b/sys/src/9/pc/archmp.c index 7d72e0462..3247e04f5 100644 --- a/sys/src/9/pc/archmp.c +++ b/sys/src/9/pc/archmp.c @@ -354,51 +354,6 @@ pcmpinit(void) mpinit(); } -static _MP_* -mpscan(uchar *addr, int len) -{ - uchar *e, *p, sum; - int i; - - e = addr+len; - for(p = addr; p < e; p += sizeof(_MP_)){ - if(memcmp(p, "_MP_", 4)) - continue; - sum = 0; - for(i = 0; i < sizeof(_MP_); i++) - sum += p[i]; - if(sum == 0) - return (_MP_*)p; - } - return 0; -} - -static _MP_* -mpsearch(void) -{ - uchar *bda; - ulong p; - _MP_ *mp; - - /* - * Search for the MP Floating Pointer Structure: - * 1) in the first KB of the EBDA; - * 2) in the last KB of system base memory; - * 3) in the BIOS ROM between 0xE0000 and 0xFFFFF. - */ - bda = KADDR(0x400); - if((p = (bda[0x0F]<<8)|bda[0x0E])){ - if(mp = mpscan(KADDR(p<<4), 1024)) - return mp; - } - else{ - p = ((bda[0x14]<<8)|bda[0x13])*1024; - if(mp = mpscan(KADDR(p-1024), 1024)) - return mp; - } - return mpscan(KADDR(0xF0000), 0x10000); -} - static int identify(void); PCArch archmp = { @@ -418,8 +373,6 @@ identify(void) { char *cp; _MP_ *_mp_; - uchar *p, sum; - ulong length; if((cp = getconf("*nomp")) != nil && strcmp(cp, "0") != 0) return 1; @@ -431,21 +384,12 @@ identify(void) * if correct, check the version. * To do: check extended table checksum. */ - if((_mp_ = mpsearch()) == 0 || _mp_->physaddr == 0) + if((_mp_ = sigsearch("_MP_")) == 0 || _mp_->physaddr == 0) return 1; pcmp = KADDR(_mp_->physaddr); - if(memcmp(pcmp, "PCMP", 4)){ - pcmp = nil; - return 1; - } - - length = pcmp->length; - sum = 0; - for(p = (uchar*)pcmp; length; length--) - sum += *p++; - - if(sum || (pcmp->version != 1 && pcmp->version != 4)){ + if(memcmp(pcmp, "PCMP", 4) || checksum(pcmp, pcmp->length) || + (pcmp->version != 1 && pcmp->version != 4)) { pcmp = nil; return 1; } |