summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2021-09-23 22:38:21 -0400
committerTom Rini <[email protected]>2021-09-23 22:38:21 -0400
commit657668348b5d677afca029673479266ef601f8a6 (patch)
tree88d807a4872e12a0df8eefc8463da8af9b286bd5 /lib
parent7b57e56739ed2c550d17a072a7f4c8326c0c83dc (diff)
parent8e85f36a8fabb4bd5216f6bfcc9a8224adb63496 (diff)
Merge branch '2021-09-23-assorted-updates' into next
- Rework lmb reservation so we have common code for all arches to use - armv8 cache.S cleanups, crc32 speedup - ENV_IS_NOWHWERE, pci io/memory base configuration fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/crc32.c9
-rw-r--r--lib/lmb.c35
2 files changed, 43 insertions, 1 deletions
diff --git a/lib/crc32.c b/lib/crc32.c
index f2acc107fe4..5a3127e03ad 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -84,7 +84,7 @@ static void __efi_runtime make_crc_table(void)
}
crc_table_empty = 0;
}
-#else
+#elif !defined(CONFIG_ARM64_CRC32)
/* ========================================================================
* Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
@@ -184,6 +184,12 @@ const uint32_t * ZEXPORT get_crc_table()
*/
uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
{
+#ifdef CONFIG_ARM64_CRC32
+ crc = cpu_to_le32(crc);
+ while (len--)
+ crc = __builtin_aarch64_crc32b(crc, *buf++);
+ return le32_to_cpu(crc);
+#else
const uint32_t *tab = crc_table;
const uint32_t *b =(const uint32_t *)buf;
size_t rem_len;
@@ -221,6 +227,7 @@ uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
}
return le32_to_cpu(crc);
+#endif
}
#undef DO_CRC
diff --git a/lib/lmb.c b/lib/lmb.c
index 7bd1255f7a4..793647724c3 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -12,6 +12,10 @@
#include <log.h>
#include <malloc.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
#define LMB_ALLOC_ANYWHERE 0
static void lmb_dump_region(struct lmb_region *rgn, char *name)
@@ -113,6 +117,37 @@ void lmb_init(struct lmb *lmb)
lmb->reserved.cnt = 0;
}
+void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align)
+{
+ ulong bank_end;
+ int bank;
+
+ /*
+ * Reserve memory from aligned address below the bottom of U-Boot stack
+ * until end of U-Boot area using LMB to prevent U-Boot from overwriting
+ * that memory.
+ */
+ debug("## Current stack ends at 0x%08lx ", sp);
+
+ /* adjust sp by 4K to be safe */
+ sp -= align;
+ for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+ if (!gd->bd->bi_dram[bank].size ||
+ sp < gd->bd->bi_dram[bank].start)
+ continue;
+ /* Watch out for RAM at end of address space! */
+ bank_end = gd->bd->bi_dram[bank].start +
+ gd->bd->bi_dram[bank].size - 1;
+ if (sp > bank_end)
+ continue;
+ if (bank_end > end)
+ bank_end = end - 1;
+
+ lmb_reserve(lmb, sp, bank_end - sp + 1);
+ break;
+ }
+}
+
static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob)
{
arch_lmb_reserve(lmb);