Changeset View
Changeset View
Standalone View
Standalone View
stand/kboot/main.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
ssize_t kboot_readin(readin_handle_t fd, vm_offset_t dest, const size_t len); | ssize_t kboot_readin(readin_handle_t fd, vm_offset_t dest, const size_t len); | ||||
int kboot_autoload(void); | int kboot_autoload(void); | ||||
uint64_t kboot_loadaddr(u_int type, void *data, uint64_t addr); | uint64_t kboot_loadaddr(u_int type, void *data, uint64_t addr); | ||||
static void kboot_kseg_get(int *nseg, void **ptr); | static void kboot_kseg_get(int *nseg, void **ptr); | ||||
static void kboot_zfs_probe(void); | static void kboot_zfs_probe(void); | ||||
extern int command_fdt_internal(int argc, char *argv[]); | extern int command_fdt_internal(int argc, char *argv[]); | ||||
static uint64_t commit_limit; | |||||
kevans: `static` these for now? I /think/ the later use is isolated in main.c, probably another one to… | |||||
static uint64_t committed_as; | |||||
static uint64_t mem_avail; | |||||
static void | |||||
memory_limits(void) | |||||
{ | |||||
int fd; | |||||
char buf[128]; | |||||
/* | /* | ||||
* To properly size the slabs, we need to find how much memory we can | |||||
* commit to using. commit_limit is the max, while commited_as is the | |||||
* current total. We can use these later to allocate the largetst amount | |||||
* of memory possible so we can support larger ram disks than we could | |||||
* by using fixed segment sizes. We also grab the memory available so | |||||
* we don't use more than 49% of that. | |||||
*/ | |||||
fd = open("host:/proc/meminfo", O_RDONLY); | |||||
if (fd != -1) { | |||||
while (fgetstr(buf, sizeof(buf), fd) > 0) { | |||||
if (strncmp(buf, "MemAvailable:", 13) == 0) { | |||||
Not Done Inline ActionsThe indentation here seems to be a bit funky kevans: The indentation here seems to be a bit funky | |||||
mem_avail = strtoll(buf + 13, NULL, 0); | |||||
mem_avail <<= 10; /* Units are kB */ | |||||
} else if (strncmp(buf, "CommitLimit:", 12) == 0) { | |||||
commit_limit = strtoll(buf + 13, NULL, 0); | |||||
commit_limit <<= 10; /* Units are kB */ | |||||
} else if (strncmp(buf, "Committed_AS:", 13) == 0) { | |||||
committed_as = strtoll(buf + 14, NULL, 0); | |||||
committed_as <<= 10; /* Units are kB */ | |||||
} | |||||
} | |||||
} | |||||
printf("Commit limit: %lld Committed bytes %lld Available %lld\n", | |||||
(long long)commit_limit, (long long)committed_as, | |||||
(long long)mem_avail); | |||||
close(fd); | |||||
} | |||||
/* | |||||
* NB: getdev should likely be identical to this most places, except maybe | * NB: getdev should likely be identical to this most places, except maybe | ||||
* we should move to storing the length of the platform devdesc. | * we should move to storing the length of the platform devdesc. | ||||
*/ | */ | ||||
int | int | ||||
kboot_getdev(void **vdev, const char *devspec, const char **path) | kboot_getdev(void **vdev, const char *devspec, const char **path) | ||||
{ | { | ||||
int rv; | int rv; | ||||
struct devdesc **dev = (struct devdesc **)vdev; | struct devdesc **dev = (struct devdesc **)vdev; | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
printf("Boot device: %s with hostfs_root %s\n", bootdev, hostfs_root); | printf("Boot device: %s with hostfs_root %s\n", bootdev, hostfs_root); | ||||
printf("\n%s", bootprog_info); | printf("\n%s", bootprog_info); | ||||
setenv("LINES", "24", 1); | setenv("LINES", "24", 1); | ||||
setenv("usefdt", "1", 1); | setenv("usefdt", "1", 1); | ||||
memory_limits(); | |||||
/* | /* | ||||
* Find acpi, if it exists | * Find acpi, if it exists | ||||
*/ | */ | ||||
find_acpi(); | find_acpi(); | ||||
interact(); /* doesn't return */ | interact(); /* doesn't return */ | ||||
▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines |
static these for now? I /think/ the later use is isolated in main.c, probably another one to double-check against your branch