Compare commits

...

38 Commits

Author SHA1 Message Date
wash 1ec33767ab meta: replace cmake mono-build system with a custom build co-ordinator
every system component now has its own self-contained build system, and a
seed file describing the component and its build system and dependencies.

a new tool, meadow, collects and uses these seed files to build the
components into a full system. meadow also manages the target system root
and a host prefix where toolchain tools are installed to.

the build system has also been updated to use a new $ARCH-rosetta-gcc
compiler, and the patches files necessary to build it have been
added to toolchain/cross-compiler.
2026-07-19 13:34:32 +01:00
wash 59034be9e6 toolchain: xpcg: update fx path api usage 2026-07-19 13:33:05 +01:00
wash 7c2f59c7b1 herdd: update fx serial api includes 2026-07-19 13:32:19 +01:00
wash 810f741442 libc: pthread: implement mutexes 2026-07-19 13:31:22 +01:00
wash 6317060138 libc: runtime: add more required runtime objects 2026-07-19 13:30:49 +01:00
wash 34b3b8359b libc: add headers and definitions required by libgcc 2026-07-19 13:30:19 +01:00
wash 8aa76b5b7f libc: core: implement strrchr 2026-07-19 13:29:14 +01:00
wash 67b460e4e1 libc: io: implement puts 2026-07-19 13:28:49 +01:00
wash 9e20e0032d libc: io: implement putchar 2026-07-19 13:28:33 +01:00
wash 5c9ab75dbc libc: io: fix ringbuf_read/write not returning the correct values 2026-07-19 13:27:57 +01:00
wash 12df8d517d meta: update kernel 2026-06-07 13:50:01 +01:00
wash 55f5a8e82a librosetta: add a bootstrap channel marker for a namespace channel 2026-06-07 13:49:53 +01:00
wash 98343f1e12 libc: core: add mitigation for a potential bochs issue in strtoll 2026-06-07 13:49:32 +01:00
wash 46cb969019 interface: fs: add function for mounting a filesystem service into a namespace 2026-06-07 13:49:03 +01:00
wash 3f9e0abc49 toolchain: mxdbg: fix incorrect memory allocation size for packets 2026-06-07 13:48:24 +01:00
wash 9af5aa2acf toolchain: mxdbg: fix extra context threads hanging on exit 2026-06-07 13:48:04 +01:00
wash 01ee992791 toolchain: mxdbg: link client to threading library 2026-06-07 13:47:03 +01:00
wash bd3caddbf7 x86_64: cmake: add rules to start the kernel under magenta_debug debugging 2026-06-06 17:54:50 +01:00
wash a6bdcc6c49 toolchain: add new debugging tool using magenta_debug 2026-06-06 17:54:20 +01:00
wash 5bb36a916c meta: update kernel 2026-06-06 17:54:05 +01:00
wash a092ce555f meta: update clang-format config 2026-06-06 17:53:57 +01:00
wash 54d5d9dca7 services: add a test service to test bshell 2026-05-31 17:35:30 +01:00
wash 82b3c597f1 programs: add Bshell command interpreter 2026-05-31 17:34:50 +01:00
wash 000cb5c35d cmake: rosetta_wrap_library now handles target prefix and soname configuration 2026-05-31 17:29:53 +01:00
wash 616ad0d0cc cmake: support services that are not based on cmake executable targets 2026-05-31 17:29:06 +01:00
wash 4b917550f4 herdd: support updated service config layout 2026-05-31 17:27:55 +01:00
wash a4ca7058d1 services: exec key in service manifest is now an array of executable arguments 2026-05-31 17:26:50 +01:00
wash e492ac7974 ld: get_dynsym can now resolve references to global symbols 2026-05-31 17:25:53 +01:00
wash 9af325cdee lib: update libfx 2026-05-31 17:25:09 +01:00
wash 5888136db7 libc: io: formatting cleanup 2026-05-31 17:23:23 +01:00
wash 2dc68a33ab libc: malloc: fix heap_expand being called with a size measured in pages rather than bytes 2026-05-31 17:23:12 +01:00
wash 1b7c3b1b0d libc: malloc: store the global heap in a fixed region of virtual memory 2026-05-31 17:22:47 +01:00
wash b773439aa1 libc: io: temporarily switch stderr to line-buffered mode
no-buffering isn't compatible with kern_log (used by bootstrap), as it
automatically appends a newline to every string written. this will
be switched back once kern_log isn't being used anymore.
2026-05-31 17:21:15 +01:00
wash d47260dd13 libc: io: implement (v)fprintf 2026-05-31 17:20:57 +01:00
wash c9a87457b8 libc: core: set up NSD remote channel on startup 2026-05-31 17:20:31 +01:00
wash 474f228c98 libc: core: print error message on assertion failure 2026-05-31 17:20:00 +01:00
wash 64dd5d15a8 meta: move target definition files to services/targets/ 2026-05-30 19:48:20 +01:00
wash 277d87adb0 herdd: rename runlevels to targets 2026-05-30 19:47:49 +01:00
204 changed files with 10055 additions and 604 deletions
+9 -125
View File
@@ -1,7 +1,5 @@
BasedOnStyle: WebKit
IndentWidth: 8
---
Language: C
DerivePointerAlignment: false
PointerAlignment: Right
ColumnLimit: 80
@@ -27,7 +25,7 @@ AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: OnePerLine
BinPackParameters: false
ExperimentalAutoDetectBinPacking: false
BitFieldColonSpacing: Both
BreakBeforeBraces: Linux
@@ -46,131 +44,17 @@ ReflowComments: true
SpacesBeforeTrailingComments: 3
TabWidth: 8
UseTab: AlignWithSpaces
PenaltyReturnTypeOnItsOwnLine: 1000000
PenaltyExcessCharacter: 999999999
PenaltyBreakOpenParenthesis: 5
PenaltyBreakBeforeFirstCallParameter: 5
BreakAfterReturnType: Automatic
PenaltyBreakAssignment: 0
PenaltyReturnTypeOnItsOwnLine: 100000000
PenaltyExcessCharacter: 10000
PenaltyBreakOpenParenthesis: 0
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyIndentedWhitespace: 0
AttributeMacros:
- FX_API
ForEachMacros:
- fx_btree_foreach
- fx_queue_foreach
MacroBlockBegin: "FX_TYPE_.*_BEGIN"
MacroBlockEnd: "FX_TYPE_.*_END"
---
Language: ObjC
DerivePointerAlignment: false
PointerAlignment: Right
ColumnLimit: 80
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignEscapedNewlines: Right
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: true
ExperimentalAutoDetectBinPacking: false
BitFieldColonSpacing: Both
BreakBeforeBraces: Linux
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
IncludeBlocks: Regroup
SortIncludes: true
IndentRequires: true
NamespaceIndentation: Inner
ReflowComments: true
SpacesBeforeTrailingComments: 3
TabWidth: 8
UseTab: AlignWithSpaces
PenaltyReturnTypeOnItsOwnLine: 1000000
PenaltyExcessCharacter: 5
PenaltyBreakOpenParenthesis: 5
PenaltyBreakBeforeFirstCallParameter: 5
PenaltyIndentedWhitespace: 0
AttributeMacros:
- FX_API
ForEachMacros:
- fx_btree_foreach
- fx_queue_foreach
MacroBlockBegin: "FX_TYPE_.*_BEGIN"
MacroBlockEnd: "FX_TYPE_.*_END"
---
Language: Cpp
DerivePointerAlignment: false
PointerAlignment: Right
ColumnLimit: 80
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignEscapedNewlines: Right
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: OnePerLine
ExperimentalAutoDetectBinPacking: false
BitFieldColonSpacing: Both
BreakBeforeBraces: Linux
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
IncludeBlocks: Regroup
SortIncludes: true
IndentRequires: true
NamespaceIndentation: Inner
ReflowComments: true
SpacesBeforeTrailingComments: 3
TabWidth: 8
UseTab: AlignWithSpaces
PenaltyReturnTypeOnItsOwnLine: 1000000
PenaltyExcessCharacter: 9999999
PenaltyBreakOpenParenthesis: 5
PenaltyBreakBeforeFirstCallParameter: 5
PenaltyIndentedWhitespace: 0
AttributeMacros:
- FX_API
ForEachMacros:
- fx_btree_foreach
- fx_queue_foreach
MacroBlockBegin: "FX_TYPE_.*_BEGIN"
MacroBlockEnd: "FX_TYPE_.*_END"
MacroBlockBegin: "FX_(TYPE|ASSEMBLY).*_BEGIN"
MacroBlockEnd: "FX_(TYPE|ASSEMBLY).*_END"
+2 -2
View File
@@ -243,7 +243,6 @@ docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
@@ -341,5 +340,6 @@ pyrightconfig.json
# End of https://www.toptal.com/developers/gitignore/api/c,vim,linux,macos,windows,cmake,python
build*
build
build-native
.cache
+3
View File
@@ -7,3 +7,6 @@
[submodule "lib/libfx"]
path = lib/libfx
url = https://g.wash.red/wash/fx.git
[submodule "programs/bshell"]
path = programs/bshell
url = https://g.wash.red/wash/bshell.git
+1 -1
View File
@@ -16,6 +16,7 @@ include(BSP)
include(Arch)
include(Msg-Interface)
include(Templates)
include(Service)
bsp_reset()
sysroot_reset()
@@ -28,7 +29,6 @@ add_subdirectory(interface)
add_subdirectory(sys)
add_subdirectory(lib)
add_subdirectory(services)
add_subdirectory(runlevel)
add_subdirectory(programs)
sysroot_add_program(NAME ${kernel_name} BIN_DIR /boot)
+35 -5
View File
@@ -1,10 +1,12 @@
set(CMAKE_SYSTEM_NAME Rosetta)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
#set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
find_program(C_COMPILER x86_64-elf-gcc REQUIRED)
find_program(CXX_COMPILER x86_64-elf-g++ REQUIRED)
find_program(C_COMPILER x86_64-rosetta-gcc REQUIRED)
find_program(CXX_COMPILER x86_64-rosetta-g++ REQUIRED)
#find_program(ASM_COMPILER x86_64-elf-as REQUIRED)
add_compile_definitions(__magenta__=1 __rosetta__=1)
@@ -13,17 +15,45 @@ set(CMAKE_C_COMPILER ${C_COMPILER})
set(CMAKE_CXX_COMPILER ${CXX_COMPILER})
#set(CMAKE_ASM_COMPILER ${ASM_COMPILER})
SET(CMAKE_C_FLAGS "-ffreestanding -nostdlib -z max-page-size=0x1000 -m64 -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -D_64BIT -DBYTE_ORDER=1234" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-shared" CACHE STRING "" FORCE)
SET(CMAKE_C_FLAGS "-z max-page-size=0x1000 -m64 -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -D_64BIT -DBYTE_ORDER=1234" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "-shared" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--unresolved-symbols=report-all,--dynamic-linker=/lib/ld64.so" CACHE STRING "" FORCE)
set(CMAKE_C_LINK_OPTIONS_PIE "-pie")
set(CMAKE_C_LINK_PIE_SUPPORTED TRUE)
set(CMAKE_C_LINK_NO_PIE_SUPPORTED TRUE)
SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
if ("$ENV{ROSETTA_SYSROOT}" STREQUAL "")
message(FATAL_ERROR "No system root has been specified. Please define the $ROSETTA_SYSROOT environment variable")
endif ()
set(CMAKE_SYSROOT $ENV{ROSETTA_SYSROOT})
set(CMAKE_SYSTEM_LIBRARY_PATH
$ENV{ROSETTA_SYSROOT}/lib
$ENV{ROSETTA_SYSROOT}/usr/lib)
set(CMAKE_C_OUTPUT_EXTENSION .o)
set(CMAKE_CXX_OUTPUT_EXTENSION .o)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_DL_LIBS "dl")
set(CMAKE_INSTALL_RPATH \$ORIGIN/../lib)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
#set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
#set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED TRUE)
set(CMAKE_C_LINK_GROUP_USING_cross_refs
"LINKER:--start-group"
"LINKER:--end-group"
)
set(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1)
link_libraries(-lgcc)
+22
View File
@@ -6,6 +6,9 @@ endif ()
find_program(LLDB lldb)
find_program(GDB gdb)
find_program(MXDBG
NAMES mxdbg
HINTS ${BUILD_TOOLS_DIR})
set(patched_kernel ${CMAKE_CURRENT_BINARY_DIR}/kernel/${kernel_name}.elf32)
set(generic_flags -m 128M -cpu qemu64,+rdrand)
@@ -63,6 +66,23 @@ if (image_cdrom)
DEPENDS ${image_cdrom})
endif ()
if (MXDBG)
message(STATUS "QEMU: Enable debugging with MXDBG")
add_custom_target(debug-kernel-mxdbg
COMMAND
nohup ${QEMU}
-kernel ${patched_kernel}
-initrd ${sys_dir}/${bsp_name}
--append kernel.enable-debugger
-serial tcp::7720,server,nowait & disown
COMMAND sleep 0.5
&& ${MXDBG}
-r 127.0.0.1 7720
&& killall qemu-system-${TARGET_ARCH}
USES_TERMINAL
DEPENDS ${patched_kernel} bsp)
endif ()
if (LLDB)
message(STATUS "QEMU: Enable direct-kernel debug with LLDB")
add_custom_target(debug-kernel
@@ -71,6 +91,8 @@ if (LLDB)
-kernel ${patched_kernel}
-initrd ${sys_dir}/${bsp_name}
${generic_flags}
--append kernel.enable-debugger
-serial tcp::7720,server,nowait
-s -S &
${LLDB}
-o "file ${CMAKE_BINARY_DIR}/kernel/${kernel_name}.debug"
+7
View File
@@ -0,0 +1,7 @@
[seed]
name = 'cdrom'
[build]
build_system = 'cmake'
# vim: ft=toml
+5
View File
@@ -0,0 +1,5 @@
[command]
name = 'debug'
description = 'Run the system under a debugger'
# vim: ft=toml
+12
View File
@@ -0,0 +1,12 @@
[command]
name = 'run-kernel'
description = 'Run the kernel image directly under QEMU'
[dependency]
commands = [ 'qemu-system-x86_64' ]
seeds = [ 'magenta', 'bsp' ]
[exec]
args = [ 'src:run-kernel.py']
# vim: ft=toml
+30
View File
@@ -0,0 +1,30 @@
import os
import shutil
import subprocess
sysroot = os.environ['MEADOW_SYSROOT']
native_root = os.environ['MEADOW_NATIVE_ROOT']
tmp = os.environ['MEADOW_TEMP']
bsp = os.path.join(sysroot, 'boot', 'rosetta-system.bsp')
kernel_exe = os.path.join(sysroot, 'boot', 'magenta_kernel')
kernel_exe_elf32 = os.path.join(tmp, 'magenta_kernel.elf32')
e64patch = os.path.join(native_root, 'bin', 'e64patch')
shutil.copyfile(kernel_exe, kernel_exe_elf32)
subprocess.run([ e64patch, kernel_exe_elf32 ])
qemu_args = [
'qemu-system-x86_64',
'-m', '128M',
'-cpu', 'qemu64,+rdrand',
'-kernel', kernel_exe_elf32,
'-initrd', bsp,
'-serial', 'stdio',
'--append', 'kernel.early-console=ttyS0'
]
try:
subprocess.run(qemu_args)
except KeyboardInterrupt:
pass
+19
View File
@@ -0,0 +1,19 @@
[platform]
name = 'x86_64-pc'
arch = 'x86_64'
[cmake]
module_paths = [ '.' ]
system_name = 'Rosetta'
toolchain_file = 'Platform/Rosetta.cmake'
[extension]
commands = [
'command/run-kernel.command',
]
seeds = [
'cdrom.seed'
]
# vim: ft=toml
+15
View File
@@ -0,0 +1,15 @@
[seed]
name = 'base'
[dependency]
no_standard_dependencies = true
[build]
build_system = 'source-only'
build_for = 'target'
watch_files = [ 'src:**' ]
[install]
"/" = [ 'src:boot' ]
# vim: ft=toml
+29 -5
View File
@@ -115,19 +115,43 @@ function(bsp_add_service)
get_property(bsp_targets GLOBAL PROPERTY bsp_target_list)
get_property(cfg_file TARGET ${arg_NAME} PROPERTY service_cfg_path)
get_property(file_list TARGET ${arg_NAME} PROPERTY service_file_list)
get_property(target_type TARGET ${arg_NAME} PROPERTY TYPE)
list(LENGTH bsp_targets nr_bsp_targets)
list(LENGTH file_list nr_service_files)
if (${nr_bsp_targets} GREATER 0)
math(EXPR serialiser_index "${nr_bsp_targets}-1")
list(GET bsp_targets ${serialiser_index} serialiser)
endif ()
add_custom_target(${bsp_target_name}
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
add-binary ${bsp_manifest} ${target_name}
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>
set(commands
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
add-binary ${bsp_manifest} ${target_name}-cfg
${arg_SVC_DIR} ${cfg_file}
${arg_SVC_DIR} ${cfg_file})
if (target_type STREQUAL "EXECUTABLE")
set(commands ${commands}
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
add-binary ${bsp_manifest} ${target_name}
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>)
endif ()
if (nr_service_files GREATER 0)
math(EXPR nr_service_files "${nr_service_files}-1")
foreach (i RANGE 0 ${nr_service_files} 2)
math(EXPR i2 "${i}+1")
list(GET file_list ${i} src_file)
list(GET file_list ${i2} dest_dir)
set(commands ${commands}
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
add-binary ${bsp_manifest} ${target_name}-${i}
${dest_dir} ${src_file})
endforeach (i)
endif ()
add_custom_target(${bsp_target_name}
${commands}
COMMENT "Preparing bsp component: ${target_name}"
DEPENDS ${target_name} ${serialiser})
+1
View File
@@ -37,6 +37,7 @@ function(add_interface)
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(iflib-${arg_NAME} ifgen-${arg_NAME})
add_library(interface::${arg_NAME} ALIAS iflib-${arg_NAME})
install(FILES ${header_path} DESTINATION include/${arg_PARENT_DIR})
endfunction(add_interface)
function(iface_get_header_path)
+52
View File
@@ -0,0 +1,52 @@
function(rosetta_add_service)
set(options)
set(one_value_args NAME CFG_FILE)
set(multi_value_args SOURCES)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${options}"
"${one_value_args}"
"${multi_value_args}")
set(exec_name ${arg_NAME})
get_property(programs GLOBAL PROPERTY rosetta_program_list)
set_property(GLOBAL PROPERTY rosetta_program_list ${programs} ${exec_name})
message(STATUS "Building service ${exec_name}")
add_executable(${exec_name} ${arg_SOURCES})
set_target_properties(${exec_name} PROPERTIES
POSITION_INDEPENDENT_CODE ON
service_cfg_path ${arg_CFG_FILE})
install(TARGETS ${exec_name}
DESTINATION ${arg_SYSROOT_PATH})
endfunction(rosetta_add_service)
function(rosetta_add_misc_service)
set(options)
set(one_value_args NAME CFG_FILE)
set(multi_value_args SOURCES)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${options}"
"${one_value_args}"
"${multi_value_args}")
message(STATUS "Building service ${arg_NAME}")
add_custom_target(${arg_NAME})
set_target_properties(${arg_NAME} PROPERTIES
service_cfg_path ${arg_CFG_FILE})
endfunction(rosetta_add_misc_service)
function(rosetta_service_add_file)
set(options)
set(one_value_args NAME SRC_FILE DEST_DIR)
set(multi_value_args)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${options}"
"${one_value_args}"
"${multi_value_args}")
get_property(file_list TARGET ${arg_NAME} PROPERTY service_file_list)
set(file_list ${file_list} ${arg_SRC_FILE} ${arg_DEST_DIR})
set_property(TARGET ${arg_NAME} PROPERTY service_file_list ${file_list})
endfunction(rosetta_service_add_file)
+30 -5
View File
@@ -170,19 +170,44 @@ function(sysroot_add_service)
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)
get_property(cfg_file TARGET ${arg_NAME} PROPERTY service_cfg_path)
get_property(file_list TARGET ${arg_NAME} PROPERTY service_file_list)
get_property(target_type TARGET ${arg_NAME} PROPERTY TYPE)
list(LENGTH sysroot_targets nr_sysroot_targets)
list(LENGTH file_list nr_service_files)
if (${nr_sysroot_targets} GREATER 0)
math(EXPR serialiser_index "${nr_sysroot_targets}-1")
list(GET sysroot_targets ${serialiser_index} serialiser)
endif ()
add_custom_target(${sysroot_target_name}
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
add-binary ${sysroot_manifest} ${target_name}
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>
set(commands
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
add-binary ${sysroot_manifest} ${target_name}-cfg
${arg_SVC_DIR} ${cfg_file}
${arg_SVC_DIR} ${cfg_file})
if (target_type STREQUAL "EXECUTABLE")
set(commands ${commands}
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
add-binary ${sysroot_manifest} ${target_name}
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>)
endif ()
if (nr_service_files GREATER 0)
math(EXPR nr_service_files "${nr_service_files}-1")
foreach (i RANGE 0 ${nr_service_files} 2)
math(EXPR i2 "${i}+1")
list(GET file_list ${i} src_file)
list(GET file_list ${i2} dest_dir)
set(commands ${commands}
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
add-binary ${sysroot_manifest} ${target_name}-${i}
${dest_dir} ${src_file})
endforeach (i)
endif ()
add_custom_target(${sysroot_target_name}
${commands}
COMMENT "Preparing sysroot component: ${target_name}"
DEPENDS ${target_name} ${serialiser})
+6 -25
View File
@@ -32,29 +32,6 @@ function(rosetta_add_executable)
DESTINATION ${arg_SYSROOT_PATH})
endfunction(rosetta_add_executable)
function(rosetta_add_service)
set(options)
set(one_value_args NAME CFG_FILE)
set(multi_value_args SOURCES)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${options}"
"${one_value_args}"
"${multi_value_args}")
set(exec_name ${arg_NAME})
get_property(programs GLOBAL PROPERTY rosetta_program_list)
set_property(GLOBAL PROPERTY rosetta_program_list ${programs} ${exec_name})
message(STATUS "Building service ${exec_name}")
add_executable(${exec_name} ${arg_SOURCES})
set_target_properties(${exec_name} PROPERTIES
POSITION_INDEPENDENT_CODE ON
service_cfg_path ${arg_CFG_FILE})
install(TARGETS ${exec_name}
DESTINATION ${arg_SYSROOT_PATH})
endfunction(rosetta_add_service)
function(rosetta_add_library)
set(options STATIC SHARED)
set(one_value_args NAME)
@@ -156,7 +133,7 @@ endfunction(rosetta_add_object_library)
function(rosetta_wrap_library)
set(options)
set(one_value_args NAME)
set(one_value_args NAME SONAME PREFIX)
set(multi_value_args
PUBLIC_INCLUDE_DIRS)
cmake_parse_arguments(PARSE_ARGV 0 arg
@@ -174,10 +151,14 @@ function(rosetta_wrap_library)
PATH ${arg_PUBLIC_INCLUDE_DIRS})
endif ()
if (arg_SONAME)
target_link_options(${lib_name} PRIVATE -Wl,--soname,${arg_SONAME}.so)
endif ()
set_target_properties(${lib_name} PROPERTIES
POSITION_INDEPENDENT_CODE ON
src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include
PREFIX "")
PREFIX "${arg_PREFIX}")
endfunction(rosetta_wrap_library)
function(rosetta_add_object_library)
+12
View File
@@ -0,0 +1,12 @@
[seed]
name = 'libmagenta'
[dependency]
no_standard_dependencies = true
[build]
build_system = 'cmake'
source_dir = 'kernel/libmagenta'
watch_files = [ 'src:**/*.c', 'src:**/*.h' ]
# vim: ft=toml
+22
View File
@@ -0,0 +1,22 @@
[seed]
name = 'magenta-headers'
[dependency]
no_standard_dependencies = true
[build]
build_system = 'source-only'
build_for = 'target'
source_dir = 'kernel/libmagenta'
watch_files = [
'src:include/magenta/*.h',
'src:include-user/magenta/*.h',
]
[install]
"/usr/include/magenta" = [
'src:include/magenta/*.h',
'src:include-user/magenta/*.h',
]
# vim: ft=toml
+15
View File
@@ -0,0 +1,15 @@
[seed]
name = 'magenta-tools'
[dependency]
no_standard_dependencies = true
[build]
build_for = 'host'
build_system = 'cmake'
source_dir = 'kernel/tools'
[publish]
path = [ 'install:bin/' ]
# vim: ft=toml
+18
View File
@@ -0,0 +1,18 @@
[seed]
name = 'magenta'
[dependency]
no_standard_dependencies = true
seeds = [
'magenta-tools'
]
[build]
build_system = 'cmake'
source_dir = 'kernel'
watch_files = [ 'src:**/*.c', 'src:**/*.h' ]
[install]
prefix = "/"
# vim: ft=toml
+5 -1
View File
@@ -1,7 +1,11 @@
cmake_minimum_required(VERSION 3.31)
project(rosetta-interface)
include(Msg-Interface)
file(GLOB if_files *.xpc)
foreach (file ${if_files})
get_filename_component(name ${file} NAME_WLE)
add_interface(NAME ${name} PATH ${file} PARENT_DIR rosetta)
sysroot_add_interface(NAME ${name} DEST_DIR /usr/include)
endforeach (file)
+1
View File
@@ -11,3 +11,4 @@ func seek[4](offset: offset, origin: int) -> (err: int, new_pos: offset);
func map[5](prot: int, flags: int) -> (err: int, vmo: handle);
func getdents[6]() -> (err: int, dents: buffer);
func mount[7](path: string, nd: int, pid: int, chid: int) -> (err: int);
+13
View File
@@ -0,0 +1,13 @@
[seed]
name = 'librosetta-interface'
[dependency]
no_standard_dependencies = true
seeds = [ 'xpcg' ]
[build]
build_system = 'cmake'
watch_files = [ 'src:*.xpc' ]
module_paths = [ 'root-src:cmake/' ]
# vim: ft=toml
+1 -1
Submodule kernel updated: c90ee285cc...a14d0173c8
+2 -1
View File
@@ -31,9 +31,10 @@ endforeach (item)
foreach (assembly ${fx_assemblies})
target_link_libraries(${assembly} libc libpthread)
target_link_options(${assembly} PRIVATE -Wl,--soname,lib${assembly}.so)
# target_link_options(${assembly} PRIVATE -Wl,--soname,lib${assembly}.so)
rosetta_wrap_library(
NAME ${assembly}
SONAME lib${assembly}
PUBLIC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/libfx/${module}/include)
set_target_properties(${assembly} PROPERTIES
PREFIX "lib")
+15
View File
@@ -0,0 +1,15 @@
[seed]
name = 'libfx-host'
[dependency]
no_standard_dependencies = true
[build]
build_for = 'host'
build_system = 'cmake'
source_dir = 'lib/libfx'
[publish.cmake]
module_paths = [ 'src:cmake/' ]
# vim: ft=toml
+16
View File
@@ -0,0 +1,16 @@
[seed]
name = 'libfx'
[build]
build_system = 'cmake'
source_dir = 'lib/libfx'
configure_args = [
'-Dfx_assemblies=fx.runtime;fx.collections;fx.serial;fx.io;fx.term;fx.cmdline',
'-Dfx_enable_floating_point=0',
'-Dfx_enable_tests=0',
]
[publish.cmake]
module_paths = [ 'src:cmake/' ]
# vim: ft=toml
+12 -21
View File
@@ -1,10 +1,12 @@
cmake_minimum_required(VERSION 3.31)
project(libc C ASM)
set(source_dirs core malloc io exec)
set(LIBC_STANDALONE FALSE)
set(public_include_dirs
${CMAKE_CURRENT_SOURCE_DIR}/include)
add_subdirectory(runtime)
foreach (dir ${source_dirs})
add_subdirectory(${dir})
set(sources ${sources} ${component_sources})
@@ -12,22 +14,11 @@ foreach (dir ${source_dirs})
set(public_include_dirs ${public_include_dirs} ${component_public_include_dirs})
endforeach (dir)
rosetta_add_library(SHARED
NAME libc
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
SOURCES ${sources}
HEADERS ${headers})
sysroot_add_library(
NAME libc
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
bsp_add_library(
NAME libc
LIB_DIR /usr/lib)
target_link_libraries(libc PRIVATE librosetta libxpc-static liblaunch-static interface::fs)
target_link_libraries(libc PUBLIC libmagenta)
target_compile_definitions(libc PRIVATE ENABLE_GLOBAL_HEAP=1)
add_subdirectory(pthread)
add_library(libc SHARED ${sources} ${headers})
target_include_directories(libc PUBLIC ${public_include_dirs})
target_link_libraries(libc PRIVATE rosetta libxpc.a liblaunch.a libmagenta.a)
target_compile_options(libc PRIVATE -ffreestanding -nostdlib)
target_link_options(libc PRIVATE -ffreestanding -nostdlib)
target_compile_definitions(libc PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_SHARED=1)
set_target_properties(libc PROPERTIES PREFIX "")
install(TARGETS libc)
+16 -13
View File
@@ -1,3 +1,8 @@
if (LIBC_STANDALONE)
cmake_minimum_required(VERSION 3.31)
project(libc-core C ASM)
endif ()
set(source_dirs assert stdio stdlib string errno ctype wctype unistd)
foreach (dir ${source_dirs})
@@ -12,18 +17,16 @@ file(GLOB sys_sources
${CMAKE_CURRENT_SOURCE_DIR}/sys/${CMAKE_SYSTEM_PROCESSOR}/*.c
${CMAKE_CURRENT_SOURCE_DIR}/sys/${CMAKE_SYSTEM_PROCESSOR}/*.S)
set(component_sources ${sources} ${sys_sources} PARENT_SCOPE)
set(component_headers ${headers} PARENT_SCOPE)
rosetta_add_library(STATIC
NAME libc-core
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
SOURCES ${sources} ${sys_sources}
HEADERS ${headers})
sysroot_add_library(
NAME libc-core
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
if (NOT LIBC_STANDALONE)
set(component_sources ${sources} ${sys_sources} PARENT_SCOPE)
set(component_headers ${headers} PARENT_SCOPE)
return ()
endif ()
add_library(libc-core STATIC ${sources} ${sys_sources} ${headers})
target_include_directories(libc-core PUBLIC ${public_include_dirs})
target_link_libraries(libc-core PRIVATE libmagenta librosetta)
target_compile_definitions(libc-core PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_STATIC=1)
set_target_properties(libc-core PROPERTIES
PREFIX "")
install(TARGETS libc-core)
+3
View File
@@ -1,3 +1,5 @@
#include <magenta/log.h>
#include <stdio.h>
#include <stdlib.h>
extern void __libc_assert_failed(
@@ -6,5 +8,6 @@ extern void __libc_assert_failed(
const char *func,
const char *cond)
{
kern_logf("ASSERT: %s failed (%s in %s:%d)", cond, func, file, line);
abort();
}
+18
View File
@@ -0,0 +1,18 @@
[seed]
name = 'libc-core'
[dependency]
no_standard_dependencies = true
seeds = [
'libc-headers',
'libmagenta',
'librosetta'
]
[build]
build_system = 'cmake'
configure_args = [
'-DLIBC_STANDALONE=TRUE'
]
# vim: ft=toml
+29 -6
View File
@@ -28,14 +28,14 @@
* SUCH DAMAGE.
*/
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <magenta/log.h>
#include <stdio.h>
long long strtoll(
const char *restrict ptr,
char **restrict endptr,
register int base)
long long strtoll(const char *restrict ptr, char **restrict endptr, int base)
{
const char *s = ptr;
long long acc;
@@ -64,8 +64,31 @@ long long strtoll(
base = c == '0' ? 8 : 10;
}
cutoff = (long long)LLONG_MAX / (long long)base;
cutlim = (long long)LLONG_MAX % (long long)base;
/* XXX cannot just divide by base here. Doing so results in a #DE
* exception when running under Bochs. Not sure if this is a bug in the
* kernel or in Bochs, but this switch statement is here as a workaround
* until the issue is resolved. */
switch (base) {
case 2:
cutoff = (long long)LLONG_MAX / (long long)2;
cutlim = (long long)LLONG_MAX % (long long)2;
break;
case 8:
cutoff = (long long)LLONG_MAX / (long long)8;
cutlim = (long long)LLONG_MAX % (long long)8;
break;
case 10:
cutoff = (long long)LLONG_MAX / (long long)10;
cutlim = (long long)LLONG_MAX % (long long)10;
break;
case 16:
cutoff = (long long)LLONG_MAX / (long long)16;
cutlim = (long long)LLONG_MAX % (long long)16;
break;
default:
return -1;
}
for (acc = 0, any = 0;; c = *s++) {
if (isdigit(c)) {
c -= '0';
+14
View File
@@ -0,0 +1,14 @@
#include <string.h>
char *strrchr(const char *str, int c)
{
size_t len = strlen(str);
for (int i = len - 1; i > 0; i--) {
if (str[i] == c) {
return (char *)&str[i];
}
}
return NULL;
}
+3 -1
View File
@@ -1,7 +1,8 @@
#include <errno.h>
#include <magenta/log.h>
#include <rosetta/bootstrap.h>
#include <stdio.h>
#include <errno.h>
#include <sys/remote.h>
extern int main(int, const char **, const char **);
@@ -13,6 +14,7 @@ void *__attribute__((weak)) pthread_self(void)
int __libc_init(const struct rosetta_bootstrap *bsinfo)
{
sys_remote_set(SYS_REMOTE_NSD, 0, 0);
(volatile void)pthread_self();
__set_errno(SUCCESS);
return 0;
+16 -15
View File
@@ -1,5 +1,10 @@
set(source_dirs unistd spawn)
if (LIBC_STANDALONE)
cmake_minimum_required(VERSION 3.31)
project(libc-exec C ASM)
endif ()
file(GLOB sources *.c *.h)
foreach (dir ${source_dirs})
@@ -13,21 +18,17 @@ endforeach (dir)
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
set(headers ${headers} ${sub_headers})
set(component_sources ${sources} PARENT_SCOPE)
set(component_headers ${headers} PARENT_SCOPE)
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
if (NOT LIBC_STANDALONE)
set(component_sources ${sources} PARENT_SCOPE)
set(component_headers ${headers} PARENT_SCOPE)
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
endif ()
rosetta_add_library(STATIC
NAME libc-exec
PUBLIC_INCLUDE_DIRS
add_library(libc-exec STATIC ${sources} ${headers})
target_include_directories(libc-exec PUBLIC
${public_include_dirs}
${CMAKE_CURRENT_SOURCE_DIR}/include
SOURCES ${sources}
HEADERS ${headers})
sysroot_add_library(
NAME libc-exec
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(libc-exec libc-core libc-io libmagenta liblaunch-static)
target_compile_definitions(libc-exec PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_STATIC=1)
set_target_properties(libc-exec PROPERTIES PREFIX "")
install(TARGETS libc-exec)
+18
View File
@@ -0,0 +1,18 @@
[seed]
name = 'libc-exec'
[dependency]
seeds = [
'libc-core',
'libc-io',
'libmagenta',
'liblaunch-static',
]
[build]
build_system = 'cmake'
configure_args = [
'-DLIBC_STANDALONE=TRUE'
]
# vim: ft=toml
+8
View File
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.31)
project(libc-headers C)
file(GLOB headers *.h)
file(GLOB sys_headers sys/*.h)
install(FILES ${headers} DESTINATION include)
install(FILES ${sys_headers} DESTINATION include/sys)
+45
View File
@@ -1,6 +1,8 @@
#ifndef FCNTL_H_
#define FCNTL_H_
#include <sys/types.h>
#define O_RDONLY 0x0000 /* open for reading only */
#define O_WRONLY 0x0001 /* open for writing only */
#define O_RDWR 0x0002 /* open for reading and writing */
@@ -50,4 +52,47 @@
#define AT_SYMLINK_NOFOLLOW_ANY \
0x0800 /* Path should not contain any symlinks */
#define S_IRWXU 00700
#define S_IRUSR 00400
#define S_IWUSR 00200
#define S_IXUSR 00100
#define S_IRWXG 00070
#define S_IRGRP 00040
#define S_IWGRP 00020
#define S_IXGRP 00010
#define S_IRWXO 00007
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
#define S_ISUID 0004000
#define S_ISGID 0002000
#define S_ISVTX 0001000
#define R_OK 4
#define W_OK 2
#define X_OK 1
#define F_OK 0
#define F_RDLCK 0
#define F_WRLCK 1
#define F_SETLKW 7
struct flock {
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
};
struct flock64 {
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
};
extern int fcntl(int fd, int op, ...);
#endif
+16
View File
@@ -0,0 +1,16 @@
[seed]
name = 'libc-headers'
[dependency]
no_standard_dependencies = true
[build]
build_system = 'source-only'
build_for = 'target'
watch_files = [ 'src:**' ]
[install]
"/usr/include" = [ 'src:*.h' ]
"/usr/include/sys" = [ 'src:sys/*.h' ]
# vim: ft=toml
+6
View File
@@ -25,6 +25,8 @@ typedef struct __opaque_file FILE;
extern int printf(const char *format, ...);
extern int vprintf(const char *format, va_list arg);
extern int fprintf(FILE *stream, const char *format, ...);
extern int vfprintf(FILE *stream, const char *format, va_list arg);
extern int sprintf(char *buffer, const char *format, ...);
extern int snprintf(char *buffer, size_t count, const char *format, ...);
extern int vsnprintf(
char *buffer,
@@ -33,6 +35,8 @@ extern int vsnprintf(
va_list va);
extern FILE *fopen(const char *path, const char *mode);
extern FILE *fdopen(int fildes, const char *mode);
extern int fclose(FILE *stream);
extern int feof(FILE *stream);
@@ -52,12 +56,14 @@ static inline int putc(int c, FILE *stream)
{
return fputc(c, stream);
}
extern int putchar(int c);
extern char *fgets(char *restrict str, int count, FILE *restrict stream);
extern int fputs(const char *restrict str, FILE *restrict stream);
extern long ftell(FILE *stream);
extern int fseek(FILE *stream, long offset, int origin);
extern int fflush(FILE *stream);
extern int sscanf(
const char *restrict buffer,
+5
View File
@@ -8,6 +8,11 @@ extern void abort(void);
extern void exit(int result);
extern int atexit(void (*func)(void));
extern int abs(int v);
extern int atoi(const char *str);
extern char *getenv(const char *name);
extern void *malloc(size_t count);
extern void *calloc(size_t count, size_t size);
extern void *realloc(void *p, size_t count);
+2
View File
@@ -10,7 +10,9 @@ extern size_t strlen(const char *s);
extern size_t strcspn(const char *dest, const char *src);
extern char *strcat(char *dest, const char *src);
extern char *strchr(const char *str, int c);
extern char *strrchr(const char *str, int ch);
extern int strcmp(const char *s1, const char *s2);
extern int strncmp(const char *s1, const char *s2, unsigned long n);
+8
View File
@@ -0,0 +1,8 @@
#ifndef SYS_STAT_H_
#define SYS_STAT_H_
#include <sys/types.h>
extern int mkdir(const char *path, mode_t mode);
#endif
+1 -1
View File
@@ -8,7 +8,7 @@
#define SEEK_END 2
typedef size_t ino_t;
typedef long pid_t;
typedef int pid_t;
typedef long mode_t;
struct dentry {
+7 -1
View File
@@ -4,12 +4,14 @@
#include <stddef.h>
#include <sys/types.h>
extern int open(const char *path, int flags);
extern int open(const char *path, int flags, ...);
extern int close(int fd);
extern int read(int fd, void *buf, size_t count);
extern int write(int fd, const void *buf, size_t count);
extern int access(const char *path, int mode);
extern off_t lseek(int fd, off_t offset, int whence);
extern long getdents(int fd, struct dentry *dirp, unsigned int count);
@@ -20,7 +22,11 @@ extern int execl(const char *path, const char *arg, ...);
extern int execlp(const char *file, const char *arg, ...);
extern int execle(const char *path, const char *arg, ...);
extern int execv(const char *path, char *const argv[]);
extern int execve(const char *path, char *const argv[], char *const envp[]);
extern int execvp(const char *file, char *const argv[]);
extern int execvpe(const char *file, char *const argv[], char *const envp[]);
extern pid_t getpid(void);
extern pid_t getppid(void);
#endif
+18 -16
View File
@@ -1,5 +1,10 @@
set(source_dirs unistd stdio)
if (LIBC_STANDALONE)
cmake_minimum_required(VERSION 3.31)
project(libc-io C ASM)
endif ()
file(GLOB sources *.c *.h)
foreach (dir ${source_dirs})
@@ -13,21 +18,18 @@ endforeach (dir)
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
set(headers ${headers} ${sub_headers})
set(component_sources ${sources} PARENT_SCOPE)
set(component_headers ${headers} PARENT_SCOPE)
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
if (NOT LIBC_STANDALONE)
set(component_sources ${sources} PARENT_SCOPE)
set(component_headers ${headers} PARENT_SCOPE)
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
return ()
endif ()
rosetta_add_library(STATIC
NAME libc-io
PUBLIC_INCLUDE_DIRS
add_library(libc-io STATIC ${sources} ${headers})
target_include_directories(libc-io PUBLIC
${public_include_dirs}
${CMAKE_CURRENT_SOURCE_DIR}/include
SOURCES ${sources}
HEADERS ${headers})
sysroot_add_library(
NAME libc-io
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
target_link_libraries(libc-io libc-core interface::fs libxpc-static libmagenta)
${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(libc-io libc-core libxpc.a libmagenta)
target_compile_definitions(libc-io PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_STATIC=1)
set_target_properties(libc-io PROPERTIES PREFIX "")
install(TARGETS libc-io)
+19
View File
@@ -0,0 +1,19 @@
[seed]
name = 'libc-io'
[dependency]
no_standard_dependencies = true
seeds = [
'libmagenta',
'libc-core',
'librosetta-interface',
'libxpc-static'
]
[build]
build_system = 'cmake'
configure_args = [
'-DLIBC_STANDALONE=TRUE'
]
# vim: ft=toml
+1
View File
@@ -57,6 +57,7 @@ int __libc_dir_refill(struct __opaque_dir *d)
int __libc_dir_move_next(struct __opaque_dir *d)
{
if (d->d_fd < 0) {
return -EBADF;
}
+8 -1
View File
@@ -1,6 +1,13 @@
#include "file.h"
#include <stdio.h>
int fprintf(struct __opaque_file *stream, const char *format, ...)
{
return 0;
va_list arg;
va_start(arg, format);
int ret = vfprintf(stream, format, arg);
va_end(arg);
return ret;
}
+1 -1
View File
@@ -5,7 +5,7 @@ int printf(const char *format, ...)
{
va_list arg;
va_start(arg, format);
int ret = vprintf(format, arg);
int ret = vfprintf(stdout, format, arg);
va_end(arg);
return ret;
+6
View File
@@ -0,0 +1,6 @@
#include <stdio.h>
int putchar(int c)
{
return fputc(c, stdout);
}
+36
View File
@@ -0,0 +1,36 @@
#include "file.h"
#include <stdio.h>
extern int __fputc(int c, struct __opaque_file *stream);
int puts(const char *restrict str)
{
struct __opaque_file *stream = stdout;
__libc_file_lock(stream);
if (stream->f_flags & (FILE_EOF | FILE_ERR)) {
__libc_file_unlock(stream);
return EOF;
}
size_t i = 0;
int err = 0;
for (i = 0; str[i]; i++) {
err = __fputc(str[i], stream);
if (err < 0) {
break;
}
}
if (err >= 0) {
err = __fputc('\n', stream);
}
__libc_file_unlock(stream);
if (i > 0) {
return i;
}
return err;
}
+2 -2
View File
@@ -145,7 +145,7 @@ long __libc_ringbuf_read(struct ringbuf *buf, void *p, size_t count)
memcpy(dest, src, to_copy);
nr_read += available;
nr_read += to_copy;
__libc_ringbuf_put_read_buffer(buf, &src, &to_copy);
}
@@ -183,7 +183,7 @@ long __libc_ringbuf_write(struct ringbuf *buf, const void *p, size_t count)
memcpy(dest, src, to_copy);
nr_written += available;
nr_written += to_copy;
__libc_ringbuf_put_write_buffer(buf, &dest, &to_copy);
}
+3 -1
View File
@@ -5,7 +5,9 @@
static struct __opaque_file __stderr = {
.f_fd = 2,
.f_flags = FILE_STATIC,
.f_buffer_mode = _IONBF,
/* TODO change this back to _IONBF once we're no longer using kern_log()
* in bootstrap */
.f_buffer_mode = _IOLBF,
};
extern struct __opaque_file *__libc_file_stderr(void)
+35
View File
@@ -0,0 +1,35 @@
#include "file.h"
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
extern int __libc_fctprintf(
int (*out)(char character, void *arg),
void *arg,
const char *format,
va_list va);
extern int __fputc(int c, struct __opaque_file *stream);
static inline int _out_file(char character, void *arg)
{
FILE *fp = arg;
return __fputc(character, fp);
}
int vfprintf(FILE *fp, const char *format, va_list arg)
{
__libc_file_lock(fp);
int ret = __libc_fctprintf(_out_file, fp, format, arg);
if (errno != SUCCESS) {
ret = -1;
}
if (ferror(fp)) {
ret = -1;
}
__libc_file_unlock(fp);
return ret;
}
+2 -14
View File
@@ -1,7 +1,7 @@
#include "file.h"
#include <stddef.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
extern int __libc_fctprintf(
@@ -19,17 +19,5 @@ static inline int _out_file(char character, void *arg)
int vprintf(const char *format, va_list arg)
{
__libc_file_lock(stdout);
int ret = __libc_fctprintf(_out_file, stdout, format, arg);
if (errno != SUCCESS) {
ret = -1;
}
if (ferror(stdout)) {
ret = -1;
}
__libc_file_unlock(stdout);
return ret;
return vfprintf(stdout, format, arg);
}
+17
View File
@@ -0,0 +1,17 @@
[seed]
name = 'libc'
[dependency]
seeds = [
'libc-headers',
'libmagenta',
'librosetta',
'libxpc-static',
'liblaunch-static',
'librosetta-interface'
]
[build]
build_system = 'cmake'
# vim: ft=toml
+17 -17
View File
@@ -1,5 +1,10 @@
set(source_dirs stdlib string)
if (LIBC_STANDALONE)
cmake_minimum_required(VERSION 3.31)
project(libc-malloc C ASM)
endif ()
file(GLOB sources *.c *.h)
foreach (dir ${source_dirs})
@@ -13,22 +18,17 @@ endforeach (dir)
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
set(headers ${headers} ${sub_headers})
set(component_sources ${sources} PARENT_SCOPE)
set(component_headers ${headers} PARENT_SCOPE)
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
if (NOT LIBC_STANDALONE)
set(component_sources ${sources} PARENT_SCOPE)
set(component_headers ${headers} PARENT_SCOPE)
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
endif ()
rosetta_add_library(STATIC
NAME libc-malloc
PUBLIC_INCLUDE_DIRS
${public_include_dirs}
${CMAKE_CURRENT_SOURCE_DIR}/include
SOURCES ${sources}
HEADERS ${headers})
sysroot_add_library(
NAME libc-malloc
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
target_compile_definitions(libc-malloc PRIVATE ENABLE_GLOBAL_HEAP=1)
add_library(libc-malloc STATIC ${sources} ${headers})
target_compile_definitions(libc-malloc PRIVATE LIBC_STATIC=1 ENABLE_GLOBAL_HEAP=1)
target_include_directories(libc-malloc PUBLIC ${public_include_dirs} include)
target_compile_definitions(libc-malloc PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_STATIC=1)
target_link_libraries(libc-malloc libc-core libmagenta)
set_target_properties(libc-malloc PROPERTIES PREFIX "")
install(TARGETS libc-malloc)
install(FILES ${sub_headers} DESTINATION include/heap)
+7 -1
View File
@@ -8,6 +8,12 @@
#include <magenta/vm.h>
#include <stdio.h>
#if defined(LIBC_STATIC)
#define HEAP_REGION_BASE 0x20000000000
#else
#define HEAP_REGION_BASE 0x60000000000
#endif
#define HEAP_REGION_SIZE 0x40000000
#define HEAP_EXPAND_INCREMENT 0x100000
@@ -40,7 +46,7 @@ static kern_status_t init_heap_region(heap_t *heap)
kern_status_t status = address_space_reserve(
address_space,
MAP_ADDRESS_ANY,
HEAP_REGION_BASE,
HEAP_REGION_SIZE,
&heap->heap_base);
+14 -8
View File
@@ -1,5 +1,10 @@
#include "liballoc.h"
#include <magenta/config.h>
#include <magenta/types.h>
#include <stdio.h>
#include <string.h>
/** Durand's Amazing Super Duper Memory functions. */
#define VERSION "1.1"
@@ -206,6 +211,8 @@ static struct liballoc_major *allocate_new_page(heap_t *heap, unsigned int size)
return NULL; // uh oh, we ran out of memory.
}
memset(maj, 0x0, sizeof *maj);
maj->prev = NULL;
maj->next = NULL;
maj->pages = st;
@@ -455,12 +462,10 @@ void *PREFIX(malloc)(heap_t *heap, size_t req_size)
if (diff
>= (size + sizeof(struct liballoc_minor))) {
// yay....
min->next
= (struct liballoc_minor
min->next = (struct liballoc_minor
*)((uintptr_t)min
+ sizeof(
struct
liballoc_minor)
struct liballoc_minor)
+ min->size);
min->next->prev = min;
min = min->next;
@@ -506,8 +511,7 @@ void *PREFIX(malloc)(heap_t *heap, size_t req_size)
new_min = (struct liballoc_minor
*)((uintptr_t)min
+ sizeof(
struct
liballoc_minor)
struct liballoc_minor)
+ min->size);
new_min->magic = LIBALLOC_MAGIC;
@@ -822,9 +826,11 @@ int liballoc_unlock(heap_t *heap)
return 0;
}
void *liballoc_alloc(heap_t *heap, size_t sz)
void *liballoc_alloc(heap_t *heap, size_t nr_pages)
{
return heap_expand(heap, sz);
size_t page_size = 0;
kern_config_get(KERN_CFG_PAGE_SIZE, &page_size, sizeof page_size);
return heap_expand(heap, nr_pages * page_size);
}
int liballoc_free(heap_t *heap, void *p, size_t sz)
+17
View File
@@ -0,0 +1,17 @@
[seed]
name = 'libc-malloc'
[dependency]
no_standard_dependencies = true
seeds = [
'libmagenta',
'libc-core'
]
[build]
build_system = 'cmake'
configure_args = [
'-DLIBC_STANDALONE=TRUE'
]
# vim: ft=toml
+27 -27
View File
@@ -1,4 +1,7 @@
set(pthread_source_dirs thread)
cmake_minimum_required(VERSION 3.31)
project(libc-pthread C ASM)
set(pthread_source_dirs thread mutex)
foreach (dir ${pthread_source_dirs})
file(GLOB dir_sources ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*.c)
@@ -17,30 +20,27 @@ set(pthread_sources ${pthread_sources} ${pthread_sys_sources})
set(pthread_headers ${pthread_headers} ${CMAKE_CURRENT_SOURCE_DIR}/include/pthread.h)
set(pthread_public_include_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
rosetta_add_library(STATIC
NAME libc-pthread
PUBLIC_INCLUDE_DIRS ${pthread_public_include_dir}
SOURCES ${pthread_sources}
HEADERS ${pthread_headers})
rosetta_add_library(SHARED
NAME libpthread
PUBLIC_INCLUDE_DIRS ${pthread_public_include_dir}
SOURCES ${pthread_sources}
HEADERS ${pthread_headers})
if (PTHREAD_STATIC)
add_library(libc-pthread STATIC ${pthread_sources} ${pthread_headers})
target_link_libraries(libc-pthread PRIVATE libc-io libmagenta)
target_include_directories(libc-pthread PUBLIC
${public_include_dirs}
${CMAKE_CURRENT_SOURCE_DIR}/include)
set_target_properties(libc-pthread PROPERTIES PREFIX "")
target_compile_definitions(libc-pthread PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_STATIC=1)
install(TARGETS libc-pthread)
else ()
add_library(libpthread SHARED ${pthread_sources} ${pthread_headers})
target_link_libraries(libpthread PRIVATE magenta)
target_link_libraries(libpthread PUBLIC c)
target_include_directories(libpthread PUBLIC
${public_include_dirs}
${CMAKE_CURRENT_SOURCE_DIR}/include)
set_target_properties(libpthread PROPERTIES PREFIX "")
target_compile_options(libpthread PRIVATE -ffreestanding -nostdlib)
target_link_options(libpthread PRIVATE -ffreestanding -nostdlib)
target_compile_definitions(libpthread PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_SHARED=1)
install(TARGETS libpthread)
endif ()
sysroot_add_library(
NAME libc-pthread
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
sysroot_add_library(
NAME libpthread
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
bsp_add_library(
NAME libpthread
LIB_DIR /usr/lib)
target_link_libraries(libc-pthread PRIVATE libc-io libmagenta)
target_link_libraries(libpthread PRIVATE libmagenta)
target_link_libraries(libpthread PUBLIC libc)
install(FILES include/pthread.h DESTINATION include)
+6
View File
@@ -5,6 +5,8 @@
#define __PTHREAD_ATTR_SIZE__ 32
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) {.__v = 0})
typedef struct __pthread *pthread_t;
typedef struct __pthread_attr {
@@ -28,4 +30,8 @@ extern int pthread_join(pthread_t thread, void **retval);
extern int pthread_detach(pthread_t thread);
extern void pthread_exit(void *retval);
extern int pthread_mutex_lock(pthread_mutex_t *mut);
extern int pthread_mutex_trylock(pthread_mutex_t *mut);
extern int pthread_mutex_unlock(pthread_mutex_t *mut);
#endif
+17
View File
@@ -0,0 +1,17 @@
[seed]
name = 'libc-pthread'
[dependency]
no_standard_dependencies = true
seeds = [
'libmagenta',
'libc-io'
]
[build]
build_system = 'cmake'
configure_args = [
'-DPTHREAD_STATIC=TRUE'
]
# vim: ft=toml
+7
View File
@@ -0,0 +1,7 @@
[seed]
name = 'libpthread'
[build]
build_system = 'cmake'
# vim: ft=toml
@@ -0,0 +1,24 @@
#include <errno.h>
#include <magenta/futex.h>
#include <pthread.h>
int pthread_mutex_lock(pthread_mutex_t *mut)
{
kern_futex_t expected = 0;
while (1) {
expected = 0;
if (__atomic_compare_exchange_n(
&mut->__v,
&expected,
1,
0,
__ATOMIC_ACQUIRE,
__ATOMIC_ACQUIRE)) {
return 0;
}
futex_wait(&mut->__v, 1, FUTEX_PRIVATE);
}
return __set_errno(EAGAIN);
}
@@ -0,0 +1,18 @@
#include <errno.h>
#include <pthread.h>
int pthread_mutex_trylock(pthread_mutex_t *mut)
{
kern_futex_t expected = 0;
if (__atomic_compare_exchange_n(
&mut->__v,
&expected,
1,
0,
__ATOMIC_ACQUIRE,
__ATOMIC_ACQUIRE)) {
return 0;
}
return __set_errno(EBUSY);
}
@@ -0,0 +1,8 @@
#include <magenta/futex.h>
#include <pthread.h>
int pthread_mutex_unlock(pthread_mutex_t *mut)
{
mut->__v = 0;
futex_wake(&mut->__v, 1, FUTEX_PRIVATE);
}
+12 -6
View File
@@ -1,10 +1,16 @@
cmake_minimum_required(VERSION 3.31)
project(libc-runtime C ASM)
file(GLOB runtime_sources
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/*.s)
rosetta_add_object_library(
NAME libc-runtime STATIC
SOURCES ${runtime_sources})
foreach (s ${runtime_sources})
get_filename_component(object_name ${s} NAME)
get_filename_component(object_basename ${s} NAME_WE)
# TODO find a better way of finding the compiled object files
set(object_path
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/libc-runtime.dir/${CMAKE_SYSTEM_PROCESSOR}/${object_name}.obj)
install(FILES ${object_path} DESTINATION lib RENAME "${object_basename}.o")
endforeach (s)
sysroot_add_object_library(
NAME libc-runtime
LIB_DIR /usr/lib)
add_library(libc-runtime OBJECT ${runtime_sources})
+13
View File
@@ -0,0 +1,13 @@
[seed]
name = 'libc-runtime'
[dependency]
no_standard_dependencies = true
[build]
build_system = 'cmake'
configure_args = [
'-DLIBC_STANDALONE=TRUE'
]
# vim: ft=toml
+22
View File
@@ -0,0 +1,22 @@
.code64
.global _start
.type _start, @function
.extern __libc_init
.type __libc_init, @function
_start:
# %rdi: (struct rosetta_bootstrap *)bs_info
mov %rdi, %rbx
call __libc_init
mov 0(%rbx), %rdi # argc
mov 8(%rbx), %rsi # argv
mov 24(%rbx), %rdx # envp
call main
mov %rax, %rdi
mov $9, %rax
syscall
1: jmp 1b
-23
View File
@@ -1,24 +1 @@
.code64
.global _start
.type _start, @function
.extern __libc_init
.type __libc_init, @function
.extern task_exit
.type task_exit, @function
_start:
# %rdi: (struct rosetta_bootstrap *)bs_info
mov %rdi, %rbx
call __libc_init
mov 0(%rbx), %rdi # argc
mov 8(%rbx), %rsi # argv
mov 24(%rbx), %rdx # envp
call main
mov %rax, %rdi
call task_exit
1: jmp 1b
+22
View File
@@ -0,0 +1,22 @@
.code64
.global _start
.type _start, @function
.extern __libc_init
.type __libc_init, @function
_start:
# %rdi: (struct rosetta_bootstrap *)bs_info
mov %rdi, %rbx
call __libc_init
mov 0(%rbx), %rdi # argc
mov 8(%rbx), %rsi # argv
mov 24(%rbx), %rdx # envp
call main
mov %rax, %rdi
mov $9, %rax
syscall
1: jmp 1b
+7
View File
@@ -0,0 +1,7 @@
.code64
.global _crtbeginS
.type _crtbeginS, @function
_crtbeginS:
ret
+7
View File
@@ -0,0 +1,7 @@
.code64
.global _crtendS
.type _crtendS, @function
_crtendS:
ret
+16 -22
View File
@@ -1,33 +1,27 @@
cmake_minimum_required(VERSION 3.31)
project(fs C ASM)
file(GLOB sources
${CMAKE_CURRENT_SOURCE_DIR}/*.c
${CMAKE_CURRENT_SOURCE_DIR}/interface/*.c)
file(GLOB headers
${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/fs/*.h)
file(GLOB public_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/fs/*.h)
set(public_include_dirs
${CMAKE_CURRENT_SOURCE_DIR}/include)
rosetta_add_library(
NAME libfs SHARED STATIC
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
SOURCES ${sources}
HEADERS ${headers})
if (FS_STATIC)
add_library(fs STATIC ${sources} ${headers})
target_link_libraries(fs magenta libc-core libxpc.a)
set_target_properties(fs PROPERTIES POSITION_INDEPENDENT_CODE FALSE)
else ()
add_library(fs SHARED ${sources} ${headers})
target_link_libraries(fs magenta c xpc)
endif ()
sysroot_add_library(
NAME libfs
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
sysroot_add_library(
NAME libfs-static
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
bsp_add_library(
NAME libfs
LIB_DIR /usr/lib)
target_link_libraries(libfs libmagenta interface::fs libc libxpc)
target_link_libraries(libfs-static libmagenta interface::fs libc-core libxpc-static)
set_target_properties(libfs-static PROPERTIES POSITION_INDEPENDENT_CODE FALSE)
target_include_directories(fs PUBLIC include)
install(TARGETS fs)
install(FILES ${public_headers} DESTINATION include/fs)
+16
View File
@@ -0,0 +1,16 @@
[seed]
name = 'libfs-static'
[dependency]
no_standard_dependencies = true
seeds = [
'libxpc-static',
'liblaunch-static',
'librosetta-interface'
]
[build]
build_system = 'cmake'
configure_args = [ '-DFS_STATIC=TRUE' ]
# vim: ft=toml
+13
View File
@@ -0,0 +1,13 @@
[seed]
name = 'libfs'
[dependency]
seeds = [
'libxpc',
'librosetta-interface'
]
[build]
build_system = 'cmake'
# vim: ft=toml
+15 -15
View File
@@ -1,25 +1,25 @@
cmake_minimum_required(VERSION 3.31)
project(launch C ASM)
file(GLOB sources
${CMAKE_CURRENT_SOURCE_DIR}/*.c)
file(GLOB headers
${CMAKE_CURRENT_SOURCE_DIR}/include/launch.h
${CMAKE_CURRENT_SOURCE_DIR}/*.h)
file(GLOB public_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/launch.h)
set(public_include_dirs
${CMAKE_CURRENT_SOURCE_DIR}/include)
rosetta_add_library(
NAME liblaunch SHARED STATIC
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
SOURCES ${sources}
HEADERS ${headers})
if (LAUNCH_STATIC)
add_library(launch STATIC ${sources} ${headers})
target_link_libraries(launch PRIVATE librosetta libmagenta libc-core)
else ()
add_library(launch SHARED ${sources} ${headers})
target_link_libraries(launch PRIVATE rosetta magenta c)
endif ()
sysroot_add_library(
NAME liblaunch
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
bsp_add_library(
NAME liblaunch
LIB_DIR /usr/lib)
target_link_libraries(liblaunch-static PRIVATE librosetta libmagenta libc-core)
target_link_libraries(liblaunch PRIVATE librosetta libmagenta libc)
target_include_directories(launch PUBLIC include)
install(TARGETS launch)
install(FILES ${public_headers} DESTINATION include)
+16
View File
@@ -0,0 +1,16 @@
[seed]
name = 'liblaunch-static'
[dependency]
no_standard_dependencies = true
seeds = [
'librosetta',
'libmagenta',
'libc-core'
]
[build]
build_system = 'cmake'
configure_args = [ '-DLAUNCH_STATIC=TRUE' ]
# vim: ft=toml
+7
View File
@@ -0,0 +1,7 @@
[seed]
name = 'liblaunch'
[build]
build_system = 'cmake'
# vim: ft=toml
+8 -10
View File
@@ -1,15 +1,13 @@
cmake_minimum_required(VERSION 3.31)
project(librosetta C ASM)
file(GLOB sources *.c)
file(GLOB headers include/rosetta/*.h)
rosetta_add_library(
NAME librosetta STATIC
PUBLIC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
SOURCES ${sources}
HEADERS ${headers})
add_library(rosetta STATIC ${sources} ${headers})
target_include_directories(rosetta PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
sysroot_add_library(
NAME librosetta
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
target_link_libraries(rosetta PRIVATE libmagenta)
target_link_libraries(librosetta PRIVATE libmagenta)
install(TARGETS rosetta)
install(FILES ${headers} DESTINATION include/rosetta)
@@ -12,6 +12,7 @@ enum rosetta_bootstrap_handle_type {
enum rosetta_bootstrap_channel_type {
RSBS_CHANNEL_NONE,
RSBS_CHANNEL_SYSTEM,
RSBS_CHANNEL_NAMESPACE,
};
struct rosetta_bootstrap_handle {
+13
View File
@@ -0,0 +1,13 @@
[seed]
name = 'librosetta'
[dependency]
no_standard_dependencies = true
seeds = [
'libmagenta',
]
[build]
build_system = 'cmake'
# vim: ft=toml
+16 -16
View File
@@ -1,28 +1,28 @@
cmake_minimum_required(VERSION 3.31)
project(xpc C ASM)
file(GLOB sources
${CMAKE_CURRENT_SOURCE_DIR}/*.c)
file(GLOB headers
${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/xpc/*.h)
file(GLOB public_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/xpc/*.h)
set(public_include_dirs
${CMAKE_CURRENT_SOURCE_DIR}/include)
rosetta_add_library(
NAME libxpc SHARED STATIC
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
SOURCES ${sources}
HEADERS ${headers})
if (XPC_STATIC)
add_library(xpc STATIC ${sources} ${headesr})
target_link_libraries(xpc magenta libc-core)
else ()
add_library(xpc SHARED ${sources} ${headesr})
target_link_libraries(xpc magenta c)
endif ()
sysroot_add_library(
NAME libxpc
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
sysroot_add_library(
NAME libxpc-static
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
target_link_libraries(libxpc libmagenta libc)
target_link_libraries(libxpc-static libmagenta libc-core)
target_include_directories(xpc PUBLIC ${public_include_dirs})
install(TARGETS xpc)
install(FILES ${public_headers} DESTINATION include/xpc)
#set_target_properties(libxpc-static PROPERTIES POSITION_INDEPENDENT_CODE FALSE)
+15
View File
@@ -0,0 +1,15 @@
[seed]
name = 'libxpc-static'
[dependency]
no_standard_dependencies = true
seeds = [
'libmagenta',
'libc-core'
]
[build]
build_system = 'cmake'
configure_args = [ '-DXPC_STATIC=TRUE' ]
# vim: ft=toml
+7
View File
@@ -0,0 +1,7 @@
[seed]
name = 'libxpc'
[build]
build_system = 'cmake'
# vim: ft=toml
Executable
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [ ! -d "$SCRIPT_DIR/build" ]; then
mkdir build
fi
if [ ! -d "$SCRIPT_DIR/build/meadow_venv" ]; then
echo 'Initialising meadow...'
python3 -m venv $SCRIPT_DIR/build/meadow_venv
source $SCRIPT_DIR/build/meadow_venv/bin/activate
pip install -r $SCRIPT_DIR/toolchain/meadow/requirements.txt
else
source $SCRIPT_DIR/build/meadow_venv/bin/activate
fi
python3 $SCRIPT_DIR/toolchain/meadow/main.py "$@"
+42
View File
@@ -1,5 +1,10 @@
file(GLOB items *)
set(bshell_interactive 0)
set(bshell_verbose 0)
set(bshell_enable_floating_point 0)
set(bshell_enable_native_commands 0)
foreach(item ${items})
if (NOT IS_DIRECTORY ${item})
continue()
@@ -7,3 +12,40 @@ foreach(item ${items})
add_subdirectory(${item})
endforeach (item)
target_link_libraries(bshell libc libc-runtime libpthread)
target_link_libraries(bshell.core libc libpthread)
target_link_libraries(bshell.runtime libc libpthread)
sysroot_add_program(
NAME bshell
BIN_DIR /usr/bin)
bsp_add_program(
NAME bshell
BIN_DIR /usr/bin)
rosetta_wrap_library(
NAME bshell.runtime
SONAME libbshell.runtime
PREFIX lib
PUBLIC_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/bshell/bshell.runtime/include)
rosetta_wrap_library(
NAME bshell.core
PREFIX lib
SONAME libbshell.core)
sysroot_add_library(
NAME bshell.runtime
HEADER_DIR /usr/include
LIB_DIR /usr/lib)
bsp_add_library(
NAME bshell.runtime
LIB_DIR /usr/lib)
sysroot_add_library(
NAME bshell.core
LIB_DIR /usr/lib)
bsp_add_library(
NAME bshell.core
LIB_DIR /usr/lib)
+1
Submodule programs/bshell added at f189643cf4
+18
View File
@@ -0,0 +1,18 @@
[seed]
name = 'bshell'
[dependency]
seeds = [
'libfx',
]
[build]
build_system = 'cmake'
source_dir = 'programs/bshell'
configure_args = [
'-Dbshell_interactive=FALSE',
'-Dbshell_enable_native_commands=FALSE',
'-Dbshell_enable_floating_point=FALSE',
]
# vim: ft=toml
-12
View File
@@ -1,12 +0,0 @@
file(GLOB runlevels *.runlevel)
foreach (f ${runlevels})
get_filename_component(name ${f} NAME_WLE)
bsp_add_file(
ID runlevel-${name}
SRC_PATH ${f}
DEST_DIR /etc/herdd/runlevels)
sysroot_add_file(
ID runlevel-${name}
SRC_PATH ${f}
DEST_DIR /etc/herdd/runlevels)
endforeach (f)
-8
View File
@@ -1,8 +0,0 @@
# vim ft=toml
[runlevel]
name = "single-user"
description = "Single-User"
requires = [
"nsd",
"devmd"
]
+9
View File
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.31)
project(bshell-test)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/bshell-test.service
DESTINATION etc/herdd/services)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/test.bshell
DESTINATION sbin)
+12
View File
@@ -0,0 +1,12 @@
[seed]
name = 'bshell-test'
[build]
build_system = 'cmake'
[install]
prefix = "/"
'/etc/herdd/services' = [ 'bshell-test.service' ]
'/sbin' = [ 'test.bshell' ]
# vim: ft=toml
+9
View File
@@ -0,0 +1,9 @@
# vim ft=toml
[unit]
description = "BShell Test Script"
[service]
exec = [
"/usr/bin/bshell",
"/sbin/test.bshell"
]
+2
View File
@@ -0,0 +1,2 @@
$x = "Jonh"
echo "Hello, $x!"
+6 -14
View File
@@ -1,15 +1,7 @@
file(GLOB sources *.c)
rosetta_add_service(
NAME devmd
SOURCES ${sources}
CFG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/devmd.service)
target_link_libraries(devmd libc libc-runtime)
cmake_minimum_required(VERSION 3.31)
project(devmd C)
sysroot_add_service(
NAME devmd
BIN_DIR /usr/bin
SVC_DIR /etc/herdd/services)
bsp_add_service(
NAME devmd
BIN_DIR /usr/bin
SVC_DIR /etc/herdd/services)
file(GLOB sources *.c)
add_executable(devmd ${sources})
target_link_libraries(devmd c -l:crt0.o)
install(TARGETS devmd)

Some files were not shown because too many files have changed in this diff Show More