Skip to contentSkip to conversation

Change lmb to use phys_size_t/phys_addr_t

PATCH New Becky Bruce 2 participants 2 messages Jun 10, 2008 – Jun 11, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 Change lmb to use phys_size_t/phys_addr_t

This updates the lmb code to use phys_size_t and phys_addr_t instead of unsigned long. Other code which interacts with this code, like getenv_bootm_size() is also updated.

Booted on MPC8641HPCN, build-tested ppc, arm, mips.

---
 common/cmd_bootm.c |    5 ++-
 common/image.c     |   17 ++++++++----
 include/image.h    |    2 +-
 include/lmb.h      |   22 +++++++++-------
 lib_generic/lmb.c  |   69 ++++++++++++++++++++++++++-------------------------
 lib_ppc/bootm.c    |   16 +++++++-----
 6 files changed, 71 insertions(+), 60 deletions(-)
common/cmd_bootm.c +3 -2
index 0d67132..959689e 100644
@@ -127,7 +127,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	ulong		os_data, os_len;
 	ulong		image_start, image_end;
 	ulong		load_start, load_end;
-	ulong		mem_start, mem_size;
+	ulong		mem_start;
+	phys_size_t	mem_size;
 
 	struct lmb lmb;
 
@@ -141,7 +142,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	mem_start = getenv_bootm_low();
 	mem_size = getenv_bootm_size();
 
-	lmb_add(&lmb, mem_start, mem_size);
+	lmb_add(&lmb, (phys_addr_t)mem_start, mem_size);
 
 	board_lmb_reserve(&lmb);
 
common/image.c +11 -6
index 9188024..ddd9e8b 100644
@@ -435,11 +435,16 @@ ulong getenv_bootm_low(void)
 #endif
 }
 
-ulong getenv_bootm_size(void)
+phys_size_t getenv_bootm_size(void)
 {
 	char *s = getenv ("bootm_size");
 	if (s) {
-		ulong tmp = simple_strtoul (s, NULL, 16);
+		phys_size_t tmp;
+#ifdef CFG_64BIT_STRTOUL
+		tmp = (phys_size_t)simple_strtoull (s, NULL, 16);
+#else
+		tmp = (phys_size_t)simple_strtoul (s, NULL, 16);
+#endif
 		return tmp;
 	}
 
@@ -1034,9 +1039,9 @@ int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
 			lmb_reserve(lmb, rd_data, rd_len);
 		} else {
 			if (initrd_high)
-				*initrd_start = lmb_alloc_base (lmb, rd_len, 0x1000, initrd_high);
+				*initrd_start = (ulong)lmb_alloc_base (lmb, rd_len, 0x1000, initrd_high);
 			else
-				*initrd_start = lmb_alloc (lmb, rd_len, 0x1000);
+				*initrd_start = (ulong)lmb_alloc (lmb, rd_len, 0x1000);
 
 			if (*initrd_start == 0) {
 				puts ("ramdisk - allocation error\n");
@@ -1089,7 +1094,7 @@ int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
 	char *cmdline;
 	char *s;
 
-	cmdline = (char *)lmb_alloc_base(lmb, CFG_BARGSIZE, 0xf,
+	cmdline = (char *)(ulong)lmb_alloc_base(lmb, CFG_BARGSIZE, 0xf,
 					 CFG_BOOTMAPSZ + bootmap_base);
 
 	if (cmdline == NULL)
@@ -1125,7 +1130,7 @@ int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
  */
 int boot_get_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base)
 {
-	*kbd = (bd_t *)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
+	*kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
 				      CFG_BOOTMAPSZ + bootmap_base);
 	if (*kbd == NULL)
 		return -1;
include/image.h +1 -1
index 664e51e..46138fa 100644
@@ -379,7 +379,7 @@ int image_check_dcrc (image_header_t *hdr);
 #ifndef USE_HOSTCC
 int getenv_yesno (char *var);
 ulong getenv_bootm_low(void);
-ulong getenv_bootm_size(void);
+phys_size_t getenv_bootm_size(void);
 void memmove_wd (void *to, void *from, size_t len, ulong chunksz);
 #endif
 
include/lmb.h +12 -10
index cc64cbb..03d7667 100644
@@ -17,13 +17,13 @@
 #define MAX_LMB_REGIONS 8
 
 struct lmb_property {
-	ulong base;
-	ulong size;
+	phys_addr_t base;
+	phys_size_t size;
 };
 
 struct lmb_region {
 	unsigned long cnt;
-	ulong size;
+	phys_size_t size;
 	struct lmb_property region[MAX_LMB_REGIONS+1];
 };
 
@@ -35,16 +35,18 @@ struct lmb {
 extern struct lmb lmb;
 
 extern void lmb_init(struct lmb *lmb);
-extern long lmb_add(struct lmb *lmb, ulong base, ulong size);
-extern long lmb_reserve(struct lmb *lmb, ulong base, ulong size);
-extern ulong lmb_alloc(struct lmb *lmb, ulong size, ulong align);
-extern ulong lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr);
-extern ulong __lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr);
-extern int lmb_is_reserved(struct lmb *lmb, ulong addr);
+extern long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size);
+extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size);
+extern phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align);
+extern phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
+			    phys_addr_t max_addr);
+extern phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
+			      phys_addr_t max_addr);
+extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr);
 
 extern void lmb_dump_all(struct lmb *lmb);
 
-static inline ulong
+static inline phys_size_t
 lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
 {
 	return type->region[region_nr].size;
lib_generic/lmb.c +35 -34

171 lines not on this page · raw message

lib_ppc/bootm.c +9 -7
index 9194fd8..f184619 100644
@@ -71,6 +71,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	ulong	initrd_start, initrd_end;
 	ulong	rd_data_start, rd_data_end, rd_len;
 	ulong	size;
+	phys_size_t bootm_size;
 
 	ulong	cmd_start, cmd_end, bootmap_base;
 	bd_t	*kbd;
@@ -85,22 +86,23 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 #endif
 
 	bootmap_base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	bootm_size = getenv_bootm_size();
 
 #ifdef DEBUG
-	if (((u64)bootmap_base + size) > (CFG_SDRAM_BASE + (u64)gd->ram_size))
+	if (((u64)bootmap_base + bootm_size) >
+	    (CFG_SDRAM_BASE + (u64)gd->ram_size))
 		puts("WARNING: bootm_low + bootm_size exceed total memory\n");
-	if ((bootmap_base + size) > get_effective_memsize())
+	if ((bootmap_base + bootm_size) > get_effective_memsize())
 		puts("WARNING: bootm_low + bootm_size exceed eff. memory\n");
 #endif
 
-	size = min(size, get_effective_memsize());
+	size = min(bootm_size, get_effective_memsize());
 	size = min(size, CFG_LINUX_LOWMEM_MAX_SIZE);
 
-	if (size < getenv_bootm_size()) {
+	if (size < bootm_size) {
 		ulong base = bootmap_base + size;
 		printf("WARNING: adjusting available memory to %x\n", size);
-		lmb_reserve(lmb, base, getenv_bootm_size() - size);
+		lmb_reserve(lmb, base, bootm_size - size);
 	}
 
 	/*
@@ -725,7 +727,7 @@ static int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base,
 		ulong of_start;
 
 		/* position on a 4K boundary before the alloc_current */
-		of_start = lmb_alloc_base(lmb, of_len, 0x1000,
+		of_start = (unsigned long)lmb_alloc_base(lmb, of_len, 0x1000,
 					 (CFG_BOOTMAPSZ + bootmap_base));
 
 		if (of_start == 0) {
Signature · 1 line
1.5.4.1
#1 lore raw

PATCH 4/4 Change lmb to use phys_size_t/phys_addr_t

Quoted 8 lines · In message <[email protected]> you…

This updates the lmb code to use phys_size_t and phys_addr_t instead of unsigned long. Other code which interacts with this code, like getenv_bootm_size() is also updated.

Booted on MPC8641HPCN, build-tested ppc, arm, mips.

Quoted 8 lines
---
 common/cmd_bootm.c |    5 ++-
 common/image.c     |   17 ++++++++----
 include/image.h    |    2 +-
 include/lmb.h      |   22 +++++++++-------
 lib_generic/lmb.c  |   69 ++++++++++++++++++++++++++-------------------------
 lib_ppc/bootm.c    |   16 +++++++-----
 6 files changed, 71 insertions(+), 60 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I used to think that the brain was the most wonderful  organ  in  my
body. Then I realized who was telling me this."        - Emo Phillips