From e264544c00270ad2b7aa522aec50969d52059b49 Mon Sep 17 00:00:00 2001 From: Amit Mahajan Date: Wed, 14 Oct 2009 00:27:58 +0530 Subject: [PATCH] Taking Linux's Rootfs address from user --- config/cml/container_ruleset.template | 3 +++ config/configuration.py | 3 +++ scripts/linux/build_rootfs.py | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/config/cml/container_ruleset.template b/config/cml/container_ruleset.template index 2f0a0de..f36d698 100644 --- a/config/cml/container_ruleset.template +++ b/config/cml/container_ruleset.template @@ -42,6 +42,7 @@ CONT%(cn)d_PAGER_UTCB_END 'Container %(cn)d UTCB Mappings Region End' CONT%(cn)d_LINUX_ZRELADDR 'Container %(cn)d Linux ZRELADDR parameter' CONT%(cn)d_LINUX_PAGE_OFFSET 'Container %(cn)d Linux PAGE_OFFSET Parameter' CONT%(cn)d_LINUX_PHYS_OFFSET 'Container %(cn)d Linux PHYS_OFFSET Parameter' +CONT%(cn)d_LINUX_ROOTFS_ADDRESS 'Container %(cn)d Linux ROOTFS Address' CONT%(cn)d_LINUX_MAPSIZE 'Container %(cn)d Linux Initial Kernel Map Size Parameter' default CONT%(cn)d_PAGER_LMA from 0x0 @@ -56,6 +57,7 @@ default CONT%(cn)d_PAGER_UTCB_END from 0x0 default CONT%(cn)d_LINUX_ZRELADDR from 0x0 default CONT%(cn)d_LINUX_PAGE_OFFSET from 0x0 default CONT%(cn)d_LINUX_PHYS_OFFSET from 0x0 +default CONT%(cn)d_LINUX_ROOTFS_ADDRESS from 0x0 default CONT%(cn)d_LINUX_MAPSIZE from 0x0 default CONT%(cn)d_VIRTMEM_REGIONS from 1 @@ -149,6 +151,7 @@ menu cont%(cn)d_linux_pager_params CONT%(cn)d_LINUX_ZRELADDR@ CONT%(cn)d_LINUX_PAGE_OFFSET@ CONT%(cn)d_LINUX_PHYS_OFFSET@ + CONT%(cn)d_LINUX_ROOTFS_ADDRESS@ CONT%(cn)d_LINUX_MAPSIZE@ menu cont%(cn)d_virtmem_list diff --git a/config/configuration.py b/config/configuration.py index 975ed11..8853f2e 100644 --- a/config/configuration.py +++ b/config/configuration.py @@ -22,6 +22,7 @@ class Container: self.linux_zreladdr = 0 self.linux_page_offset = 0 self.linux_phys_offset = 0 + self.linux_rootfs_address = 0 self.linux_mapsize = 0 self.physmem = {} self.physmem["START"] = {} @@ -123,6 +124,8 @@ class configuration: self.containers[id].pager_lma += int(val, 0) elif param[:len("LINUX_ZRELADDR")] == "LINUX_ZRELADDR": self.containers[id].linux_zreladdr += int(val, 0) + elif param[:len("LINUX_ROOTFS_ADDRESS")] == "LINUX_ROOTFS_ADDRESS": + self.containers[id].linux_rootfs_address += int(val, 0) elif re.match(r"(VIRT|PHYS){1}([0-9]){1}(_){1}(START|END){1}", param): matchobj = re.match(r"(VIRT|PHYS){1}([0-9]){1}(_){1}(START|END){1}", param) virtphys, regionidstr, discard1, startend = matchobj.groups() diff --git a/scripts/linux/build_rootfs.py b/scripts/linux/build_rootfs.py index f30b5b2..2f57ae6 100755 --- a/scripts/linux/build_rootfs.py +++ b/scripts/linux/build_rootfs.py @@ -34,7 +34,12 @@ class RootfsBuilder: self.rootfs_lds_in = join(self.LINUX_ROOTFSDIR, "rootfs.lds.in") self.rootfs_lds_out = join(self.LINUX_ROOTFS_BUILDDIR, "rootfs.lds") + + self.rootfs_h_in = join(self.LINUX_ROOTFSDIR, "rootfs.h.in") + self.rootfs_h_out = join(self.LINUX_ROOTFS_BUILDDIR, "rootfs.h") + self.rootfs_elf_out = join(self.LINUX_ROOTFS_BUILDDIR, "rootfs.elf") + self.cont_id = container.id def build_rootfs(self): print 'Building the root filesystem...' @@ -43,8 +48,14 @@ class RootfsBuilder: os.chdir(LINUX_ROOTFSDIR) if not os.path.exists(self.LINUX_ROOTFS_BUILDDIR): os.makedirs(self.LINUX_ROOTFS_BUILDDIR) - os.system("arm-none-linux-gnueabi-cpp -P " + \ - "%s > %s" % (self.rootfs_lds_in, self.rootfs_lds_out)) + + with open(self.rootfs_h_out, 'w+') as output: + with open(self.rootfs_h_in, 'r') as input: + output.write(input.read() % {'cn' : self.cont_id}) + + os.system("arm-none-linux-gnueabi-cpp -I%s -P %s > %s" % \ + (self.LINUX_ROOTFS_BUILDDIR, self.rootfs_lds_in, \ + self.rootfs_lds_out)) os.system("arm-none-linux-gnueabi-gcc " + \ "-nostdlib -o %s -T%s rootfs.S" % (self.rootfs_elf_out, \ self.rootfs_lds_out))