Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.1.0
6 changes: 4 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Built by NBTFoundry from LLVM and picolibc sources; not an LLVM release.
`-objcopy`, `-strip`, `-objdump`, `-readobj`, `-readelf`, `-size`,
`-symbolizer`, `-addr2line`, `-cxxfilt`. Their only target is ARM.
- `armv7a-nbt/include/`: the NBT C library headers (threads, semaphores, the
bridge's sockets, directories), implemented by the SDK's module runtime.
bridge's sockets, directories, anonymous and executable memory mappings,
ARM CPU feature bits), implemented by the SDK's module runtime.
- `armv7a-nbt/aligned/` and `armv7a-nbt/unaligned/`: picolibc, compiler-rt
builtins (with emulated TLS) and libc++, libc++abi and libunwind, built with
builtins (with emulated TLS; `__clear_cache` comes from the SDK's module
runtime) and libc++, libc++abi and libunwind, built with
strict alignment or allowing unaligned accesses. Each `target.mk` holds the
flags code linking that runtime must be compiled with.
- `share/licenses/`: the licences of everything above.
Expand Down
39 changes: 39 additions & 0 deletions libc/include/asm/hwcap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* SPDX-License-Identifier: MPL-2.0 */
/* ARM CPU feature bits, as Linux numbers them for getauxval(AT_HWCAP) and
* getauxval(AT_HWCAP2) (<sys/auxv.h>), so portable feature probes compile.
* The SDK's module runtime reports none of these optional features: code
* takes its baseline paths (ARMv7-A, VFPv3-D16, no NEON). */
#ifndef NBT_MODULE_ASM_HWCAP_H
#define NBT_MODULE_ASM_HWCAP_H

#define HWCAP_SWP (1 << 0)
#define HWCAP_HALF (1 << 1)
#define HWCAP_THUMB (1 << 2)
#define HWCAP_26BIT (1 << 3)
#define HWCAP_FAST_MULT (1 << 4)
#define HWCAP_FPA (1 << 5)
#define HWCAP_VFP (1 << 6)
#define HWCAP_EDSP (1 << 7)
#define HWCAP_JAVA (1 << 8)
#define HWCAP_IWMMXT (1 << 9)
#define HWCAP_CRUNCH (1 << 10)
#define HWCAP_THUMBEE (1 << 11)
#define HWCAP_NEON (1 << 12)
#define HWCAP_VFPv3 (1 << 13)
#define HWCAP_VFPv3D16 (1 << 14)
#define HWCAP_TLS (1 << 15)
#define HWCAP_VFPv4 (1 << 16)
#define HWCAP_IDIVA (1 << 17)
#define HWCAP_IDIVT (1 << 18)
#define HWCAP_VFPD32 (1 << 19)
#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)
#define HWCAP_LPAE (1 << 20)
#define HWCAP_EVTSTRM (1 << 21)

#define HWCAP2_AES (1 << 0)
#define HWCAP2_PMULL (1 << 1)
#define HWCAP2_SHA1 (1 << 2)
#define HWCAP2_SHA2 (1 << 3)
#define HWCAP2_CRC32 (1 << 4)

#endif
12 changes: 12 additions & 0 deletions libc/include/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ typedef struct {
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1

/* Threads take the application's scheduling: the policy and priority
* attributes are accepted and, as POSIX has it under PTHREAD_INHERIT_SCHED,
* unused; PTHREAD_EXPLICIT_SCHED is refused (ENOTSUP). */
#define PTHREAD_INHERIT_SCHED 0
#define PTHREAD_EXPLICIT_SCHED 1

#define PTHREAD_MUTEX_INITIALIZER {0, PTHREAD_MUTEX_NORMAL, 0, 0}
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP {0, PTHREAD_MUTEX_RECURSIVE, 0, 0}
#define PTHREAD_COND_INITIALIZER {0, 0}
Expand All @@ -70,6 +76,12 @@ int pthread_attr_setstacksize(pthread_attr_t* attr, size_t size);
int pthread_attr_getstacksize(const pthread_attr_t* attr, size_t* size);
int pthread_attr_setdetachstate(pthread_attr_t* attr, int state);
int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* state);
int pthread_attr_setinheritsched(pthread_attr_t* attr, int inherit);
int pthread_attr_getinheritsched(const pthread_attr_t* attr, int* inherit);
int pthread_attr_setschedpolicy(pthread_attr_t* attr, int policy);
int pthread_attr_getschedpolicy(const pthread_attr_t* attr, int* policy);
int pthread_attr_setschedparam(pthread_attr_t* attr, const struct sched_param* param);
int pthread_attr_getschedparam(const pthread_attr_t* attr, struct sched_param* param);

int pthread_create(pthread_t* thread, const pthread_attr_t* attr, void* (*fn)(void*), void* arg);
int pthread_join(pthread_t thread, void** result);
Expand Down
38 changes: 38 additions & 0 deletions libc/include/sys/mman.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* SPDX-License-Identifier: MPL-2.0 */
/* Memory mappings for NBT app modules, as JIT compilers use them: anonymous
* private mappings, protection changes (executable pages included) and, from
* the compiler, __clear_cache. The SDK's module runtime implements them over
* the host ABI (sdk/module/runtime/mman.c). There are no file mappings: mmap
* with a descriptor fails with ENODEV, MAP_FIXED with EINVAL, and an address
* hint is ignored. */
#ifndef NBT_MODULE_SYS_MMAN_H
#define NBT_MODULE_SYS_MMAN_H

#include <sys/types.h> /* off_t, size_t */

#ifdef __cplusplus
extern "C" {
#endif

#define PROT_NONE 0x0
#define PROT_READ 0x1
#define PROT_WRITE 0x2
#define PROT_EXEC 0x4

#define MAP_SHARED 0x01
#define MAP_PRIVATE 0x02
#define MAP_FIXED 0x10
#define MAP_ANONYMOUS 0x20
#define MAP_ANON MAP_ANONYMOUS

#define MAP_FAILED ((void*)-1)

void* mmap(void* addr, size_t len, int prot, int flags, int fd, off_t offset);
int munmap(void* addr, size_t len);
int mprotect(void* addr, size_t len, int prot);

#ifdef __cplusplus
}
#endif

#endif
4 changes: 4 additions & 0 deletions scripts/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ EOF
"$LLVM_BIN/clang" --target=$TRIPLE $FLAGS $DEFS $LIBC_INC -O2 -std=gnu11 -fvisibility=hidden -I"$SRC/compiler-rt/lib/builtins" \
-c "$SRC/compiler-rt/lib/builtins/emutls.c" -o "$W/emutls.o"
"$LLVM_BIN/llvm-ar" rs "$V/builtins/libclang_rt.builtins.a" "$W/emutls.o"
# A bare-metal __clear_cache aborts: the module runtime has the real one
# (the host's instruction cache flush), so code linked without it fails to
# link instead of aborting when it first flushes.
"$LLVM_BIN/llvm-ar" d "$V/builtins/libclang_rt.builtins.a" clear_cache.c.obj

# --- libc++, libc++abi, libunwind ---
# Static, over picolibc (which libc++ treats as newlib) and the NBT
Expand Down
2 changes: 1 addition & 1 deletion tests/sdk
Submodule sdk updated 45 files
+42 −0 .claude/skills/port-app/SKILL.md
+53 −0 .claude/skills/port-build/SKILL.md
+32 −0 .claude/skills/port-car-test/SKILL.md
+40 −0 .claude/skills/port-companion/SKILL.md
+39 −0 .claude/skills/port-controls/SKILL.md
+35 −0 .claude/skills/port-libretro/SKILL.md
+36 −0 .claude/skills/port-licence/SKILL.md
+66 −0 .claude/skills/port-module/SKILL.md
+41 −0 .claude/skills/port-native/SKILL.md
+58 −0 .claude/skills/port-package/SKILL.md
+49 −0 .claude/skills/port-perf/SKILL.md
+31 −0 .claude/skills/port-qnx-fixes/SKILL.md
+64 −0 .claude/skills/port-release/SKILL.md
+32 −0 .claude/skills/port-repo/SKILL.md
+33 −0 .claude/skills/port-sdk-gap/SKILL.md
+43 −0 .claude/skills/port-survey/SKILL.md
+44 −0 .claude/skills/port-tests/SKILL.md
+34 −0 .claude/skills/port-upstream/SKILL.md
+43 −0 .github/workflows/ci.yml
+1 −1 Makefile
+3 −1 README.md
+25 −1 docs/api.md
+6 −1 docs/native-apps.md
+82 −0 docs/porting.md
+0 −1 include/nbt/app/audio_route.hpp
+58 −0 include/nbt/app/child.hpp
+8 −7 include/nbt/app/payload.h
+1 −1 module/module.mk
+12 −0 module/runtime/auxv.c
+82 −0 module/runtime/mman.c
+30 −0 module/runtime/pthread.c
+37 −0 module/sdk/child_module.cpp
+3 −0 module/toolchain.sha256
+7 −3 nbt-sdk.mk
+15 −38 runner/nbt_runner.cpp
+1 −1 runner/runner.mk
+12 −54 src/audio_route.cpp
+220 −0 src/child.cpp
+46 −0 src/child_env.cpp
+12 −7 src/payload.c
+76 −1 tests/module/probe.c
+121 −9 tests/sdk_test.cpp
+5 −20 tools/nbt_bundle.py
+52 −0 tools/nbt_payload.py
+28 −0 tools/third_party_notices.py
Loading