[syslinux:master] memdisk: New parameter (int15maxres) for specifying maximum RAM

syslinux-bot for Gene Cumm gene.cumm at gmail.com
Wed Mar 2 15:12:34 PST 2011


Commit-ID:  3db568e482918d54739cf6d27955a3a5d3d5cd12
Gitweb:     http://syslinux.zytor.com/commit/3db568e482918d54739cf6d27955a3a5d3d5cd12
Author:     Gene Cumm <gene.cumm at gmail.com>
AuthorDate: Sat, 5 Feb 2011 16:56:21 -0500
Committer:  Gene Cumm <gene.cumm at gmail.com>
CommitDate: Sat, 5 Feb 2011 16:56:21 -0500

memdisk: New parameter (int15maxres) for specifying maximum RAM

Add a new parameter, int15maxres, for specifying (in decimal bytes) the
maximum amount of free RAM that different calls will return.  The RAM is
tagged in INT15h AXe820h as reserved in order to satisfy this.


---
 memdisk/setup.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/memdisk/setup.c b/memdisk/setup.c
index 4315189..bf3d5d6 100644
--- a/memdisk/setup.c
+++ b/memdisk/setup.c
@@ -705,6 +705,39 @@ static int stack_needed(void)
   return v;
 }
 
+/*
+ * Specify max RAM by reservation
+ * Adds a reservation to data in INT15h to prevent access to the top of RAM
+ * if there's any above the point specified.
+ */
+void int15maxres(uint32_t restop)
+{
+    uint32_t ramtop;
+
+    if (high_mem) {
+	ramtop = high_mem + (1<<24);
+    } else if (low_mem) {
+	ramtop = low_mem + (1<<20);
+    } else {
+	ramtop = 0;
+    }
+
+    /* printf("  TOP RAM-%08x  RES-%08x", ramtop, restop); */
+    if (restop < ramtop) {
+	/* printf("  (A)"); */
+	insertrange(restop, (ramtop - restop), 3);
+	parse_mem();
+    }
+    if (high_mem) {
+	ramtop = high_mem + (1<<24);
+    } else if (low_mem) {
+	ramtop = low_mem + (1<<20);
+    } else {
+	ramtop = 0;
+    }
+    /* printf("    NOW RAM-%08x\n", ramtop); */
+}
+
 struct real_mode_args rm_args;
 
 /*
@@ -737,6 +770,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
     int no_bpt;			/* No valid BPT presented */
     uint32_t boot_seg = 0;	/* Meaning 0000:7C00 */
     uint32_t boot_len = 512;	/* One sector */
+    const char *p;
 
     /* We need to copy the rm_args into their proper place */
     memcpy(&rm_args, rm_args_ptr, sizeof rm_args);
@@ -942,6 +976,10 @@ void setup(const struct real_mode_args *rm_args_ptr)
 	pptr->cd_pkt.geom3 = (uint8_t)(pptr->heads);
     }
 
+    if ((p = getcmditem("int15maxres")) != CMD_NOTFOUND) {
+	int15maxres(atou(p));
+    }
+
     /* The size is given by hptr->total_size plus the size of the E820
        map -- 12 bytes per range; we may need as many as 2 additional
        ranges (each insertrange() can worst-case turn 1 area into 3)



More information about the Syslinux-commits mailing list