Return-path: Received: from e28smtp05.in.ibm.com ([59.145.155.5] helo=e28esmtp05.in.ibm.com) by bombadil.infradead.org with esmtps (Exim 4.68 #1 (Red Hat Linux)) id 1K7Da4-0007Nq-Aq for kexec@lists.infradead.org; Fri, 13 Jun 2008 18:01:05 +0000 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by e28esmtp05.in.ibm.com (8.13.1/8.13.1) with ESMTP id m5DI0Rf5011345 for ; Fri, 13 Jun 2008 23:30:27 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m5DHxgSf864398 for ; Fri, 13 Jun 2008 23:29:42 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.13.1/8.13.3) with ESMTP id m5DI0Qag011424 for ; Fri, 13 Jun 2008 23:30:27 +0530 From: Chandru Subject: [RFC][PATCH 3/3] kexec-tools: add support for dynamic reconfiguration memory Date: Fri, 13 Jun 2008 23:30:21 +0530 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200806132330.21758.chandru@in.ibm.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: kexec-bounces@lists.infradead.org Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: kexec@lists.infradead.org Cc: bwalle@suse.de, vgoyal@redhat.com, maneesh@in.ibm.com The add_dyn_reconf_usable_mem_property() appends the entry number from ibm,dynamic-memory to 'linux,usable-memory' string. Signed-off-by: Chandru Siddalingappa = base && loc_end <= end) { + ranges[rlen++] = loc_base; + ranges[rlen++] = loc_end - loc_base; + } else if (base < loc_end && end > loc_base) { + if (loc_base < base) + loc_base = base; + if (loc_end > end) + loc_end = end; + ranges[rlen++] = loc_base; + ranges[rlen++] = loc_end - loc_base; + } + } + + if (!rlen) { + /* + * User did not pass any ranges for this region. + * Hence, write (0,0) duple in linux,usable-memory + * property such that this region will be ignored. + */ + ranges[rlen++] = 0; + ranges[rlen++] = 0; + } + + rlen = rlen * sizeof(unsigned long); + /* + * Add linux,usable-memory property. + */ + *dt++ = 3; + *dt++ = rlen; + strcpy(tbuf, "linux,usable-memory"); + sprintf(t, "%d", i); + strcat(tbuf, t); + *dt++ = propnum((const char *)tbuf); + if ((rlen >= 8) && ((unsigned long)dt & 0x4)) + dt++; + memcpy(dt, &ranges, rlen); + dt += (rlen + 3)/4; + } +} static void add_usable_mem_property(int fd, int len) { char fname[MAXPATH], *bname; unsigned long long buf[2]; unsigned long ranges[2*MAX_MEMORY_RANGES]; unsigned long long base, end, loc_base, loc_end; - int range, rlen = 0; + int range, rlen = 0, i; strcpy(fname, pathname); - bname = strrchr(fname,'/'); + bname = strrchr(fname, '/'); bname[0] = '\0'; - bname = strrchr(fname,'/'); + bname = strrchr(fname, '/'); if (strncmp(bname, "/memory@", 8)) return; @@ -171,7 +243,7 @@ static void add_usable_mem_property(int if (!rlen) { /* - * User did not pass any ranges for thsi region. Hence, write + * User did not pass any ranges for this region. Hence, write * (0,0) duple in linux,usable-memory property such that * this region will be ignored. */ @@ -190,6 +262,7 @@ static void add_usable_mem_property(int dt++; memcpy(dt,&ranges,rlen); dt += (rlen + 3)/4; + } /* put all properties (files) in the property structure */ @@ -267,6 +340,9 @@ static void putprops(char *fn, struct di dt += (len + 3)/4; if (!strcmp(dp->d_name, "reg") && usablemem_rgns.size) add_usable_mem_property(fd, len); + if (!strcmp(dp->d_name, "ibm,dynamic-memory") && + usablemem_rgns.size) + add_dyn_reconf_usable_mem_property(fd); close(fd); } _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec