mirror of
https://codeberg.org/canoeboot/cbmk.git
synced 2025-07-01 19:17:19 +01:00

I fixed the AHCI bug, with a patch that I wrote. It works by restoring the old SeaBIOS AHCI initialisation behaviour, whereby the AHCI controller is enabled from its current state; the patch that broke AHCI in coreboot (tested on ThinkPad T420), changed AHCI initialisation behaviour so that the controller's state is first reset, prior to enablement. However, my patch also retains the new AHCI initialisation behaviour, when a CSM is in use. The AHCI reset patch was done, by the author, specifically for SeaBIOS in CSM mode, so it makes sense to only change the behaviour conditionally according to that. This reverts commit 8245f0b3211812ac818adadd6526b0b39c63f3f0. Signed-off-by: Leah Rowe <leah@libreboot.org>
86 lines
2.8 KiB
Diff
86 lines
2.8 KiB
Diff
From 04e972e14191f3a480e569e972c195ba8eb53a30 Mon Sep 17 00:00:00 2001
|
|
From: Riku Viitanen <riku.viitanen@protonmail.com>
|
|
Date: Sat, 10 Feb 2024 21:23:33 +0200
|
|
Subject: [PATCH 1/4] romfile: implement a generic loader
|
|
|
|
romfile_loadfile_g:
|
|
Based on romfile_loadfile but more flexible. User has to supply pointer
|
|
to a malloc function and the number of trailing padding bytes. Thus, any
|
|
memory region may be used.
|
|
|
|
romfile_loadfile:
|
|
It is now a wrapper around romfile_loadfile_g. Functionality is the same.
|
|
|
|
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
|
|
---
|
|
src/romfile.c | 25 ++++++++++++++++++++-----
|
|
src/romfile.h | 2 ++
|
|
2 files changed, 22 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/romfile.c b/src/romfile.c
|
|
index 8072a915..f4d5f82d 100644
|
|
--- a/src/romfile.c
|
|
+++ b/src/romfile.c
|
|
@@ -47,10 +47,12 @@ romfile_find(const char *name)
|
|
return __romfile_findprefix(name, strlen(name) + 1, NULL);
|
|
}
|
|
|
|
-// Helper function to find, malloc_tmphigh, and copy a romfile. This
|
|
-// function adds a trailing zero to the malloc'd copy.
|
|
+// Generic function to find romfile, malloc (using provided function
|
|
+// pointer), and copy a romfile. add_len specifies how many additional
|
|
+// trailing bytes to reserve. The extra bytes will not be initialised.
|
|
void *
|
|
-romfile_loadfile(const char *name, int *psize)
|
|
+romfile_loadfile_g(const char *name, int *psize,
|
|
+ void *(*malloc_fn)(u32), int add_len)
|
|
{
|
|
struct romfile_s *file = romfile_find(name);
|
|
if (!file)
|
|
@@ -60,7 +62,7 @@ romfile_loadfile(const char *name, int *psize)
|
|
if (!filesize)
|
|
return NULL;
|
|
|
|
- char *data = malloc_tmphigh(filesize+1);
|
|
+ char *data = malloc_fn(filesize+add_len);
|
|
if (!data) {
|
|
warn_noalloc();
|
|
return NULL;
|
|
@@ -74,7 +76,20 @@ romfile_loadfile(const char *name, int *psize)
|
|
}
|
|
if (psize)
|
|
*psize = filesize;
|
|
- data[filesize] = '\0';
|
|
+
|
|
+ return data;
|
|
+}
|
|
+
|
|
+// Helper function to find, malloc_tmphigh, and copy a romfile. This
|
|
+// function adds a trailing zero to the malloc'd copy.
|
|
+void *
|
|
+romfile_loadfile(const char *name, int *psize)
|
|
+{
|
|
+ char *data = romfile_loadfile_g(name, psize, &malloc_tmphigh, 1);
|
|
+ if (!data)
|
|
+ return NULL;
|
|
+
|
|
+ data[*psize] = '\0';
|
|
return data;
|
|
}
|
|
|
|
diff --git a/src/romfile.h b/src/romfile.h
|
|
index ae2f4ac7..f62b2fee 100644
|
|
--- a/src/romfile.h
|
|
+++ b/src/romfile.h
|
|
@@ -13,6 +13,8 @@ struct romfile_s {
|
|
void romfile_add(struct romfile_s *file);
|
|
struct romfile_s *romfile_findprefix(const char *prefix, struct romfile_s *prev);
|
|
struct romfile_s *romfile_find(const char *name);
|
|
+void *romfile_loadfile_g(const char *name, int *psize,
|
|
+ void *(*malloc_fn)(u32), int add_len);
|
|
void *romfile_loadfile(const char *name, int *psize);
|
|
u64 romfile_loadint(const char *name, u64 defval);
|
|
u32 romfile_loadbool(const char *name, u32 defval);
|
|
--
|
|
2.39.5
|
|
|