mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] libfile: use different memory types for os and initrd
@ 2025-12-11 20:43 Ahmad Fatoum
  2025-12-15  7:13 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-12-11 20:43 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Ahmad Fatoum <a.fatoum@barebox.org>

An initrd is not directly executable, so lets set the memory attributes
to reflect that.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 common/bootm.c    | 4 ++--
 include/libfile.h | 6 +++---
 lib/libfile.c     | 7 ++++---
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 1fafb2a5cd06..22796b3522ac 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -276,7 +276,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address)
 	if (!data->os_file)
 		return -EINVAL;
 
-	data->os_res = file_to_sdram(data->os_file, load_address);
+	data->os_res = file_to_sdram(data->os_file, load_address, MEMTYPE_LOADER_CODE);
 	if (!data->os_res)
 		return -ENOMEM;
 
@@ -401,7 +401,7 @@ bootm_load_initrd(struct image_data *data, unsigned long load_address)
 		goto done;
 	}
 
-	data->initrd_res = file_to_sdram(data->initrd_file, load_address);
+	data->initrd_res = file_to_sdram(data->initrd_file, load_address, MEMTYPE_LOADER_DATA);
 	if (!data->initrd_res)
 		return ERR_PTR(-ENOMEM);
 
diff --git a/include/libfile.h b/include/libfile.h
index 26571945f678..cdcad4b173d0 100644
--- a/include/libfile.h
+++ b/include/libfile.h
@@ -4,10 +4,9 @@
 
 #include <linux/types.h>
 #include <linux/compiler.h>
+#include <linux/ioport.h>
 #include <linux/bits.h>
 
-struct resource;
-
 int pread_full(int fd, void *buf, size_t size, loff_t offset);
 int pwrite_full(int fd, const void *buf, size_t size, loff_t offset);
 int write_full(int fd, const void *buf, size_t size);
@@ -55,6 +54,7 @@ char *make_temp(const char *template);
 
 int cache_file(const char *path, char **newpath);
 
-struct resource *file_to_sdram(const char *filename, unsigned long adr);
+struct resource *file_to_sdram(const char *filename, unsigned long adr,
+			       enum resource_memtype memtype);
 
 #endif /* __LIBFILE_H */
diff --git a/lib/libfile.c b/lib/libfile.c
index 7ca13a34b41d..a6690b0b904a 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -765,7 +765,8 @@ int cache_file(const char *path, char **newpath)
 
 #define BUFSIZ	(PAGE_SIZE * 32)
 
-struct resource *file_to_sdram(const char *filename, unsigned long adr)
+struct resource *file_to_sdram(const char *filename, unsigned long adr,
+			       enum resource_memtype memtype)
 {
 	struct resource *res;
 	unsigned memattrs;
@@ -786,7 +787,7 @@ struct resource *file_to_sdram(const char *filename, unsigned long adr)
 	while (1) {
 
 		res = request_sdram_region("image", adr, size,
-					   MEMTYPE_LOADER_CODE, memattrs);
+					   memtype, memattrs);
 		if (!res) {
 			printf("unable to request SDRAM 0x%08lx-0x%08lx\n",
 				adr, adr + size - 1);
@@ -816,7 +817,7 @@ struct resource *file_to_sdram(const char *filename, unsigned long adr)
 		if (now < BUFSIZ) {
 			release_sdram_region(res);
 			res = request_sdram_region("image", adr, ofs + now,
-						   MEMTYPE_LOADER_CODE, memattrs);
+						   memtype, memattrs);
 			goto out;
 		}
 
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libfile: use different memory types for os and initrd
  2025-12-11 20:43 [PATCH] libfile: use different memory types for os and initrd Ahmad Fatoum
@ 2025-12-15  7:13 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-12-15  7:13 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: Ahmad Fatoum


On Thu, 11 Dec 2025 21:43:23 +0100, Ahmad Fatoum wrote:
> An initrd is not directly executable, so lets set the memory attributes
> to reflect that.
> 
> 

Applied, thanks!

[1/1] libfile: use different memory types for os and initrd
      https://git.pengutronix.de/cgit/barebox/commit/?id=53be7a7ebeb2 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-15  7:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-11 20:43 [PATCH] libfile: use different memory types for os and initrd Ahmad Fatoum
2025-12-15  7:13 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox