summaryrefslogtreecommitdiff
path: root/memdisk/e820func.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-10-10 12:10:24 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-10-13 12:26:58 -0700
commit652c3057145a41703e5e817d86b2584db9ab806d (patch)
tree003b164e76dad49fe944c2053dad89208e93f7e2 /memdisk/e820func.c
parentef45d17e31d591a579c1d51a5e6a026493465a64 (diff)
downloadsyslinux-652c3057145a41703e5e817d86b2584db9ab806d.tar.gz
Support "extended attributes" for INT 15h, AX=E820h
Some blithering idiot thought it was a good idea to introduce "extended attributes" for INT 15h, AX=E820h, and in doing so, breaking compatibility with ALL E820 users out there. F*cking morons. Implement handling of extended attributes in: - e820 parsing in the core - e820 parsing in libcom32 - e820 parsing *and proxying* in memdisk The latter is the really painful one. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'memdisk/e820func.c')
-rw-r--r--memdisk/e820func.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/memdisk/e820func.c b/memdisk/e820func.c
index 577469b7..a6896745 100644
--- a/memdisk/e820func.c
+++ b/memdisk/e820func.c
@@ -17,7 +17,11 @@
*/
#include <stdint.h>
+#ifdef TEST
+#include <string.h>
+#else
#include "memdisk.h" /* For memset() */
+#endif
#include "e820.h"
#define MAXRANGES 1024
@@ -33,25 +37,28 @@ void e820map_init(void)
ranges[1].type = -1;
}
-static void insertrange_at(int where, uint64_t start, uint32_t type)
+static void insertrange_at(int where, uint64_t start,
+ uint32_t type, uint32_t extattr)
{
int i;
for ( i = nranges ; i > where ; i-- )
ranges[i] = ranges[i-1];
- ranges[where].start = start;
- ranges[where].type = type;
+ ranges[where].start = start;
+ ranges[where].type = type;
+ ranges[where].extattr = extattr;
nranges++;
- ranges[nranges].start = 0ULL;
- ranges[nranges].type = (uint32_t)-1;
+ ranges[nranges].start = 0ULL;
+ ranges[nranges].type = (uint32_t)-1;
+ ranges[nranges].extattr = 0;
}
-void insertrange(uint64_t start, uint64_t len, uint32_t type)
+void insertrange(uint64_t start, uint64_t len, uint32_t type, uint32_t extattr)
{
uint64_t last;
- uint32_t oldtype;
+ uint32_t oldtype, oldattr;
int i, j;
/* Remove this to make len == 0 mean all of memory */
@@ -61,35 +68,42 @@ void insertrange(uint64_t start, uint64_t len, uint32_t type)
last = start+len-1; /* May roll over */
i = 0;
- oldtype = -2;
- while ( start > ranges[i].start && ranges[i].type != -1 ) {
+ oldtype = -2U;
+ oldattr = 0;
+ while ( start > ranges[i].start && ranges[i].type != -1U ) {
oldtype = ranges[i].type;
+ oldattr = ranges[i].extattr;
i++;
}
/* Consider the replacement policy. This current one is "overwrite." */
- if ( start < ranges[i].start || ranges[i].type == -1 )
- insertrange_at(i++, start, type);
+ if ( start < ranges[i].start || ranges[i].type == -1U )
+ insertrange_at(i++, start, type, extattr);
while ( i == 0 || last > ranges[i].start-1 ) {
oldtype = ranges[i].type;
- ranges[i].type = type;
+ oldattr = ranges[i].extattr;
+ ranges[i].type = type;
+ ranges[i].extattr = extattr;
i++;
}
if ( last < ranges[i].start-1 )
- insertrange_at(i, last+1, oldtype);
+ insertrange_at(i, last+1, oldtype, oldattr);
/* Now the map is correct, but quite possibly not optimal. Scan the
map for ranges which are redundant and remove them. */
i = j = 1;
oldtype = ranges[0].type;
+ oldattr = ranges[0].extattr;
while ( i < nranges ) {
- if ( ranges[i].type == oldtype ) {
+ if ( ranges[i].type == oldtype &&
+ ranges[i].extattr == oldattr ) {
i++;
} else {
oldtype = ranges[i].type;
+ oldattr = ranges[i].extattr;
if ( i != j )
ranges[j] = ranges[i];
i++; j++;