kboot: Move seg code into libkboot

This code is really generic segment processing and should live here. It
also interfaces primarily with Linux APIs, so it's also appropriate for
this if we have a version of that runs as a FreeBSD binary using FreeBSD
system calls and APIs, though that's in the future somehow...

Sponsored by:		Netflix
This commit is contained in:
Warner Losh
2025-04-09 15:16:55 -06:00
parent 5b30473577
commit 757dc8ab12
5 changed files with 28 additions and 20 deletions
+24
View File
@@ -0,0 +1,24 @@
/*-
* Copyright (c) 2024, Netflix, Inc.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
struct memory_segments
{
uint64_t start;
uint64_t end;
uint64_t type; /* MD defined */
};
#define SYSTEM_RAM 1
void init_avail(void);
void need_avail(int n);
void add_avail(uint64_t start, uint64_t end, uint64_t type);
void remove_avail(uint64_t start, uint64_t end, uint64_t type);
uint64_t first_avail(uint64_t align, uint64_t min_size, uint64_t type);
void print_avail(void);
bool populate_avail_from_iomem(void);
uint64_t space_avail(uint64_t start);
-1
View File
@@ -25,7 +25,6 @@ SRCS= \
hostfs.c \
init.c \
main.c \
seg.c \
util.c \
vers.c
+2 -18
View File
@@ -9,13 +9,6 @@
#define DEVT_HOSTDISK 1234
struct memory_segments
{
uint64_t start;
uint64_t end;
uint64_t type; /* MD defined */
};
bool enumerate_memory_arch(void);
struct preloaded_file;
void bi_loadsmap(struct preloaded_file *kfp);
@@ -40,19 +33,10 @@ const char *hostdisk_gen_probe(void);
void hostdisk_zfs_probe(void);
bool hostdisk_zfs_find_default(void);
/* seg.c */
#define SYSTEM_RAM 1
void init_avail(void);
void need_avail(int n);
void add_avail(uint64_t start, uint64_t end, uint64_t type);
void remove_avail(uint64_t start, uint64_t end, uint64_t type);
uint64_t first_avail(uint64_t align, uint64_t min_size, uint64_t type);
void print_avail(void);
bool populate_avail_from_iomem(void);
uint64_t space_avail(uint64_t start);
/* util.c */
bool file2str(const char *fn, char *buffer, size_t buflen);
bool file2u64(const char *fn, uint64_t *val);
#include "seg.h"
#endif /* KBOOT_H */
+1
View File
@@ -9,6 +9,7 @@ CFLAGS+=-I${.CURDIR} -I${.CURDIR}/arch/${MACHINE_ARCH}
SRCS= crt1.c
SRCS+= host_syscall.S
SRCS+= host_syscalls.c
SRCS+= seg.c
SRCS+= termios.c
.sinclude "${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.inc"
@@ -5,7 +5,7 @@
*/
#include "stand.h"
#include "kboot.h"
#include "seg.h"
#include <sys/param.h>