git: 757dc8ab1245 - main - kboot: Move seg code into libkboot
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Apr 2025 21:17:52 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=757dc8ab1245118bd3861ee2853b42c3476c1ed4 commit 757dc8ab1245118bd3861ee2853b42c3476c1ed4 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2025-04-09 21:16:55 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2025-04-09 21:16:55 +0000 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 --- stand/kboot/include/seg.h | 24 ++++++++++++++++++++++++ stand/kboot/kboot/Makefile | 1 - stand/kboot/kboot/kboot.h | 20 ++------------------ stand/kboot/libkboot/Makefile | 1 + stand/kboot/{kboot => libkboot}/seg.c | 2 +- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/stand/kboot/include/seg.h b/stand/kboot/include/seg.h new file mode 100644 index 000000000000..5ca30670bdd1 --- /dev/null +++ b/stand/kboot/include/seg.h @@ -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); diff --git a/stand/kboot/kboot/Makefile b/stand/kboot/kboot/Makefile index 064d43701ebd..0f6bb994711d 100644 --- a/stand/kboot/kboot/Makefile +++ b/stand/kboot/kboot/Makefile @@ -25,7 +25,6 @@ SRCS= \ hostfs.c \ init.c \ main.c \ - seg.c \ util.c \ vers.c diff --git a/stand/kboot/kboot/kboot.h b/stand/kboot/kboot/kboot.h index 49e5dea25b12..2a6e98ae5513 100644 --- a/stand/kboot/kboot/kboot.h +++ b/stand/kboot/kboot/kboot.h @@ -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 */ diff --git a/stand/kboot/libkboot/Makefile b/stand/kboot/libkboot/Makefile index 7cdb3db51939..7acec951107a 100644 --- a/stand/kboot/libkboot/Makefile +++ b/stand/kboot/libkboot/Makefile @@ -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" diff --git a/stand/kboot/kboot/seg.c b/stand/kboot/libkboot/seg.c similarity index 99% rename from stand/kboot/kboot/seg.c rename to stand/kboot/libkboot/seg.c index 558cac501224..395c593bcabf 100644 --- a/stand/kboot/kboot/seg.c +++ b/stand/kboot/libkboot/seg.c @@ -5,7 +5,7 @@ */ #include "stand.h" -#include "kboot.h" +#include "seg.h" #include <sys/param.h>