Reorganize source tree: kernel/, v3/, v4/ split and board infrastructure

Source tree reorganization:
- Move StarForth v3 engine to v3/ (src/, include/, Makefile)
- Move kernel to kernel/ (src/, include/, linker/, Makefile)
- Create v4/ skeleton for F18-ISA golden model (DECOMPOSITION.md, JUSTIFICATION.md)
- Move FABRIC-0..4.md to docs/fabric/
- Move ONTOLOGY.md and ROADMAP.md to docs/

Board infrastructure:
- Add boards/ser5/, boards/raspi/, boards/milkv/, boards/zynq7020/
- Each board has board.mk (ISA, CPU flags, boot recipe) and README.md
- Root Makefile becomes thin dispatcher: boot_image, all, clean, docs take TARGET
- make boot_image TARGET=SER5|RASPI|MILKV builds one GPT/MBR image per board
- ZYNQ7020 target exists but stops with clear error (ARMv7 port not built yet)
- scripts/mkdiskimage.sh builds disk images for all boards

Docs pipeline:
- docs/book/ with LaTeX master (main.tex) and Makefile
- pandoc converts Markdown to LaTeX at build time
- Two Lua filters: table-widths.lua (wide tables wrap), code-breaks.lua (inline code breaks)
- make docs builds single PDF (754 pages, 0 missing characters)
- make docs TARGET=<board> adds board appendix
- build/docs/<book|board>/meta.tex stamps git commit into PDF

Bug fixes:
- 42 include paths that only worked by accident now use correct relative paths
- clang-18 hardcode replaced with configurable CC variable (fixed aarch64 build)
- Pi 5: kernel_2712.img linked at 0x80000, .bss zeroed, memory reserved
- Doxyfile, .clang-tidy, README.md, Kconfig paths updated

Verified:
- Hosted v3 build passes 1012 tests, 0 failures
- SER5 image boots in QEMU (OVMF), POST passes, K exact (65536 = Q48_ONE)
- Milk-V image boots in QEMU (OpenSBI + U-Boot + bootefi), POST passes
- make clean TARGET=<board> removes only that board and its ISA objects
- make all builds all boards, hosted v3, and docs in one run

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
rajames
2026-10-01 15:40:09 -04:00
co-authored by Junie
parent 3c709c115b
commit a8b70e88d3
630 changed files with 2646 additions and 2036 deletions
+177
View File
@@ -0,0 +1,177 @@
/*
StarForth — Steady-State Virtual Machine Runtime
Copyright (c) 2023–2025 Robert A. James
All rights reserved.
This file is part of the StarForth project.
Licensed under the StarForth License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
express or implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose, and noninfringement.
See the License for the specific language governing permissions and
limitations under the License.
StarForth — Steady-State Virtual Machine Runtime
Copyright (c) 2023–2025 Robert A. James
All rights reserved.
This file is part of the StarForth project.
Licensed under the StarForth License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
express or implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose, and noninfringement.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef STARFORTH_PLATFORM_TIME_H
#define STARFORTH_PLATFORM_TIME_H
/*
* StarForth Platform Time Abstraction
*
* Provides portable timing interface for POSIX builds. (HISTORICAL: also
* supported L4Re/StarshipOS through mid-2026; removed as an active target.)
* Uses vtable pattern similar to blkio subsystem.
*
* License: See LICENSE file
*/
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Time representation (nanoseconds since epoch) */
typedef uint64_t sf_time_ns_t;
/* Timestamp string buffer size */
#define SF_TIME_STAMP_SIZE 32
/* Platform time backend vtable */
typedef struct {
/**
* @brief Get monotonic time (for performance measurement)
* @return Nanoseconds since system boot (never decreases)
*/
sf_time_ns_t (*get_monotonic_ns)(void);
/**
* @brief Get wall-clock time
* @return Nanoseconds since Unix epoch (1970-01-01 00:00:00 UTC)
* Returns 0 if RTC unavailable
*/
sf_time_ns_t (*get_realtime_ns)(void);
/**
* @brief Set wall-clock time (may require privileges)
* @param ns_since_epoch Nanoseconds since Unix epoch
* @return 0 on success, -1 on error
*/
int (*set_realtime_ns)(sf_time_ns_t ns_since_epoch);
/**
* @brief Format timestamp as human-readable string
* @param ns_since_epoch Nanoseconds since Unix epoch
* @param buf Output buffer (SF_TIME_STAMP_SIZE bytes)
* @param format_24h Use 24-hour format (1) or 12-hour (0)
* @return 0 on success, -1 on error
*/
int (*format_timestamp)(sf_time_ns_t ns_since_epoch, char *buf, int format_24h);
/**
* @brief Check if real-time clock is available
* @return 1 if RTC available, 0 if not
*/
int (*has_rtc)(void);
} sf_time_backend_t;
/* Global backend pointer (set at initialization) */
extern const sf_time_backend_t *sf_time_backend;
/* Platform-specific backend registration */
extern const sf_time_backend_t sf_time_backend_posix; /* POSIX implementation */
extern const sf_time_backend_t sf_time_backend_l4re; /* HISTORICAL: L4Re/StarshipOS implementation, no longer wired into any build (see src/platform/l4re/time.c) */
/* Convenience wrappers (inline for zero overhead).
* Define PLATFORM_TIME_NO_INLINE before including this header to suppress
* these inline definitions (e.g. when providing concrete implementations).
* When suppressed, non-inline prototypes are declared so callers can link
* to a concrete implementation (e.g. shim.c in the kernel). */
#ifndef PLATFORM_TIME_NO_INLINE
static inline sf_time_ns_t sf_monotonic_ns(void) {
return sf_time_backend->get_monotonic_ns();
}
static inline sf_time_ns_t sf_realtime_ns(void) {
return sf_time_backend->get_realtime_ns();
}
static inline int sf_set_realtime_ns(sf_time_ns_t ns) {
return sf_time_backend->set_realtime_ns(ns);
}
static inline int sf_format_timestamp(sf_time_ns_t ns, char *buf, int format_24h) {
return sf_time_backend->format_timestamp(ns, buf, format_24h);
}
static inline int sf_has_rtc(void) {
return sf_time_backend->has_rtc();
}
#else /* PLATFORM_TIME_NO_INLINE */
/* Non-inline prototypes — provided by the platform's concrete implementation. */
sf_time_ns_t sf_monotonic_ns(void);
sf_time_ns_t sf_realtime_ns(void);
int sf_set_realtime_ns(sf_time_ns_t ns);
int sf_format_timestamp(sf_time_ns_t ns, char *buf, int format_24h);
int sf_has_rtc(void);
#endif /* PLATFORM_TIME_NO_INLINE */
/* Time conversion helpers */
static inline sf_time_ns_t sf_seconds_to_ns(uint64_t seconds) {
return seconds * 1000000000ULL;
}
static inline uint64_t sf_ns_to_seconds(sf_time_ns_t ns) {
return ns / 1000000000ULL;
}
static inline uint64_t sf_ns_to_ms(sf_time_ns_t ns) {
return ns / 1000000ULL;
}
static inline uint64_t sf_ns_to_us(sf_time_ns_t ns) {
return ns / 1000ULL;
}
/* Initialize platform time backend (call once at startup) */
void sf_time_init(void);
#ifdef __cplusplus
}
#endif
#endif /* STARFORTH_PLATFORM_TIME_H */