Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142222287
D49864.id153751.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D49864.id153751.diff
View Options
diff --git a/stand/kboot/kboot/arch/amd64/load_addr.c b/stand/kboot/kboot/arch/amd64/load_addr.c
--- a/stand/kboot/kboot/arch/amd64/load_addr.c
+++ b/stand/kboot/kboot/arch/amd64/load_addr.c
@@ -29,117 +29,18 @@
#include "stand.h"
#include "host_syscall.h"
+#include "efi.h"
#include "kboot.h"
#include "bootstrap.h"
-/* Refactor when we do arm64 */
-
-enum types {
- system_ram = 1,
- acpi_tables,
- acpi_nv_storage,
- unusable,
- persistent_old,
- persistent,
- soft_reserved,
- reserved,
-};
-
-struct kv
-{
- uint64_t type;
- char * name;
-} str2type_kv[] = {
- { system_ram, "System RAM" },
- { acpi_tables, "ACPI Tables" },
- { acpi_nv_storage, "ACPI Non-volatile Storage" },
- { unusable, "Unusable memory" },
- { persistent_old, "Persistent Memory (legacy)" },
- { persistent, "Persistent Memory" },
- { soft_reserved, "Soft Reserved" },
- { reserved, "reserved" },
- { 0, NULL },
-};
-
-#define MEMMAP "/sys/firmware/memmap"
-
-static struct memory_segments segs[64]; /* make dynamic later */
-static int nr_seg;
-
-static bool
-str2type(struct kv *kv, const char *buf, uint64_t *value)
-{
- while (kv->name != NULL) {
- if (strcmp(kv->name, buf) == 0) {
- *value = kv->type;
- return true;
- }
- kv++;
- }
-
- return false;
-}
-
bool
enumerate_memory_arch(void)
{
- int n;
- char name[MAXPATHLEN];
- char buf[80];
-
- for (n = 0; n < nitems(segs); n++) {
- snprintf(name, sizeof(name), "%s/%d/start", MEMMAP, n);
- if (!file2u64(name, &segs[n].start))
- break;
- snprintf(name, sizeof(name), "%s/%d/end", MEMMAP, n);
- if (!file2u64(name, &segs[n].end))
- break;
- snprintf(name, sizeof(name), "%s/%d/type", MEMMAP, n);
- if (!file2str(name, buf, sizeof(buf)))
- break;
- if (!str2type(str2type_kv, buf, &segs[n].type))
- break;
- }
-
- nr_seg = n;
-
- return true;
-}
-
-#define BAD_SEG ~0ULL
-
-#define SZ(s) (((s).end - (s).start) + 1)
-
-static uint64_t
-find_ram(struct memory_segments *segs, int nr_seg, uint64_t minpa, uint64_t align,
- uint64_t sz, uint64_t maxpa)
-{
- uint64_t start;
-
- printf("minpa %#jx align %#jx sz %#jx maxpa %#jx\n",
- (uintmax_t)minpa,
- (uintmax_t)align,
- (uintmax_t)sz,
- (uintmax_t)maxpa);
- /* XXX assume segs are sorted in numeric order -- assumed not ensured */
- for (int i = 0; i < nr_seg; i++) {
- if (segs[i].type != system_ram ||
- SZ(segs[i]) < sz ||
- minpa + sz > segs[i].end ||
- maxpa < segs[i].start)
- continue;
- start = roundup(segs[i].start, align);
- if (start < minpa) /* Too small, round up and try again */
- start = (roundup(minpa, align));
- if (start + sz > segs[i].end) /* doesn't fit in seg */
- continue;
- if (start > maxpa || /* Over the edge */
- start + sz > maxpa) /* on the edge */
- break; /* No hope to continue */
- return start;
- }
-
- return BAD_SEG;
+ efi_read_from_sysfs();
+ if (!populate_avail_from_iomem())
+ return (false);
+ print_avail();
+ return (true);
}
uint64_t
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 18, 11:02 AM (1 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27708692
Default Alt Text
D49864.id153751.diff (2 KB)
Attached To
Mode
D49864: kboot/amd64: Use common routines for memory map parsing
Attached
Detach File
Event Timeline
Log In to Comment