Compare commits
38 Commits
97facbed6f
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ec33767ab | |||
| 59034be9e6 | |||
| 7c2f59c7b1 | |||
| 810f741442 | |||
| 6317060138 | |||
| 34b3b8359b | |||
| 8aa76b5b7f | |||
| 67b460e4e1 | |||
| 9e20e0032d | |||
| 5c9ab75dbc | |||
| 12df8d517d | |||
| 55f5a8e82a | |||
| 98343f1e12 | |||
| 46cb969019 | |||
| 3f9e0abc49 | |||
| 9af5aa2acf | |||
| 01ee992791 | |||
| bd3caddbf7 | |||
| a6bdcc6c49 | |||
| 5bb36a916c | |||
| a092ce555f | |||
| 54d5d9dca7 | |||
| 82b3c597f1 | |||
| 000cb5c35d | |||
| 616ad0d0cc | |||
| 4b917550f4 | |||
| a4ca7058d1 | |||
| e492ac7974 | |||
| 9af325cdee | |||
| 5888136db7 | |||
| 2dc68a33ab | |||
| 1b7c3b1b0d | |||
| b773439aa1 | |||
| d47260dd13 | |||
| c9a87457b8 | |||
| 474f228c98 | |||
| 64dd5d15a8 | |||
| 277d87adb0 |
+9
-125
@@ -1,7 +1,5 @@
|
|||||||
BasedOnStyle: WebKit
|
BasedOnStyle: WebKit
|
||||||
IndentWidth: 8
|
IndentWidth: 8
|
||||||
---
|
|
||||||
Language: C
|
|
||||||
DerivePointerAlignment: false
|
DerivePointerAlignment: false
|
||||||
PointerAlignment: Right
|
PointerAlignment: Right
|
||||||
ColumnLimit: 80
|
ColumnLimit: 80
|
||||||
@@ -27,7 +25,7 @@ AlwaysBreakAfterReturnType: None
|
|||||||
AlwaysBreakBeforeMultilineStrings: true
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
AlwaysBreakTemplateDeclarations: Yes
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
BinPackArguments: false
|
BinPackArguments: false
|
||||||
BinPackParameters: OnePerLine
|
BinPackParameters: false
|
||||||
ExperimentalAutoDetectBinPacking: false
|
ExperimentalAutoDetectBinPacking: false
|
||||||
BitFieldColonSpacing: Both
|
BitFieldColonSpacing: Both
|
||||||
BreakBeforeBraces: Linux
|
BreakBeforeBraces: Linux
|
||||||
@@ -46,131 +44,17 @@ ReflowComments: true
|
|||||||
SpacesBeforeTrailingComments: 3
|
SpacesBeforeTrailingComments: 3
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: AlignWithSpaces
|
UseTab: AlignWithSpaces
|
||||||
PenaltyReturnTypeOnItsOwnLine: 1000000
|
BreakAfterReturnType: Automatic
|
||||||
PenaltyExcessCharacter: 999999999
|
PenaltyBreakAssignment: 0
|
||||||
PenaltyBreakOpenParenthesis: 5
|
PenaltyReturnTypeOnItsOwnLine: 100000000
|
||||||
PenaltyBreakBeforeFirstCallParameter: 5
|
PenaltyExcessCharacter: 10000
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 0
|
||||||
PenaltyIndentedWhitespace: 0
|
PenaltyIndentedWhitespace: 0
|
||||||
AttributeMacros:
|
AttributeMacros:
|
||||||
- FX_API
|
- FX_API
|
||||||
ForEachMacros:
|
ForEachMacros:
|
||||||
- fx_btree_foreach
|
- fx_btree_foreach
|
||||||
- fx_queue_foreach
|
- fx_queue_foreach
|
||||||
MacroBlockBegin: "FX_TYPE_.*_BEGIN"
|
MacroBlockBegin: "FX_(TYPE|ASSEMBLY).*_BEGIN"
|
||||||
MacroBlockEnd: "FX_TYPE_.*_END"
|
MacroBlockEnd: "FX_(TYPE|ASSEMBLY).*_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"
|
|
||||||
|
|||||||
+2
-2
@@ -243,7 +243,6 @@ docs/_build/
|
|||||||
|
|
||||||
# PyBuilder
|
# PyBuilder
|
||||||
.pybuilder/
|
.pybuilder/
|
||||||
target/
|
|
||||||
|
|
||||||
# Jupyter Notebook
|
# Jupyter Notebook
|
||||||
.ipynb_checkpoints
|
.ipynb_checkpoints
|
||||||
@@ -341,5 +340,6 @@ pyrightconfig.json
|
|||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/c,vim,linux,macos,windows,cmake,python
|
# End of https://www.toptal.com/developers/gitignore/api/c,vim,linux,macos,windows,cmake,python
|
||||||
|
|
||||||
build*
|
build
|
||||||
|
build-native
|
||||||
.cache
|
.cache
|
||||||
|
|||||||
@@ -7,3 +7,6 @@
|
|||||||
[submodule "lib/libfx"]
|
[submodule "lib/libfx"]
|
||||||
path = lib/libfx
|
path = lib/libfx
|
||||||
url = https://g.wash.red/wash/fx.git
|
url = https://g.wash.red/wash/fx.git
|
||||||
|
[submodule "programs/bshell"]
|
||||||
|
path = programs/bshell
|
||||||
|
url = https://g.wash.red/wash/bshell.git
|
||||||
|
|||||||
+1
-1
@@ -16,6 +16,7 @@ include(BSP)
|
|||||||
include(Arch)
|
include(Arch)
|
||||||
include(Msg-Interface)
|
include(Msg-Interface)
|
||||||
include(Templates)
|
include(Templates)
|
||||||
|
include(Service)
|
||||||
|
|
||||||
bsp_reset()
|
bsp_reset()
|
||||||
sysroot_reset()
|
sysroot_reset()
|
||||||
@@ -28,7 +29,6 @@ add_subdirectory(interface)
|
|||||||
add_subdirectory(sys)
|
add_subdirectory(sys)
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
add_subdirectory(services)
|
add_subdirectory(services)
|
||||||
add_subdirectory(runlevel)
|
|
||||||
add_subdirectory(programs)
|
add_subdirectory(programs)
|
||||||
|
|
||||||
sysroot_add_program(NAME ${kernel_name} BIN_DIR /boot)
|
sysroot_add_program(NAME ${kernel_name} BIN_DIR /boot)
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
set(CMAKE_SYSTEM_NAME Rosetta)
|
set(CMAKE_SYSTEM_NAME Rosetta)
|
||||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
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(C_COMPILER x86_64-rosetta-gcc REQUIRED)
|
||||||
find_program(CXX_COMPILER x86_64-elf-g++ REQUIRED)
|
find_program(CXX_COMPILER x86_64-rosetta-g++ REQUIRED)
|
||||||
#find_program(ASM_COMPILER x86_64-elf-as REQUIRED)
|
#find_program(ASM_COMPILER x86_64-elf-as REQUIRED)
|
||||||
|
|
||||||
add_compile_definitions(__magenta__=1 __rosetta__=1)
|
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_CXX_COMPILER ${CXX_COMPILER})
|
||||||
#set(CMAKE_ASM_COMPILER ${ASM_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_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 "-Wl,-shared" 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_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_OPTIONS_PIE "-pie")
|
||||||
set(CMAKE_C_LINK_PIE_SUPPORTED TRUE)
|
set(CMAKE_C_LINK_PIE_SUPPORTED TRUE)
|
||||||
set(CMAKE_C_LINK_NO_PIE_SUPPORTED TRUE)
|
set(CMAKE_C_LINK_NO_PIE_SUPPORTED TRUE)
|
||||||
SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
|
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_C_OUTPUT_EXTENSION .o)
|
||||||
set(CMAKE_CXX_OUTPUT_EXTENSION .o)
|
set(CMAKE_CXX_OUTPUT_EXTENSION .o)
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
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)
|
link_libraries(-lgcc)
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ endif ()
|
|||||||
|
|
||||||
find_program(LLDB lldb)
|
find_program(LLDB lldb)
|
||||||
find_program(GDB gdb)
|
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(patched_kernel ${CMAKE_CURRENT_BINARY_DIR}/kernel/${kernel_name}.elf32)
|
||||||
set(generic_flags -m 128M -cpu qemu64,+rdrand)
|
set(generic_flags -m 128M -cpu qemu64,+rdrand)
|
||||||
@@ -63,6 +66,23 @@ if (image_cdrom)
|
|||||||
DEPENDS ${image_cdrom})
|
DEPENDS ${image_cdrom})
|
||||||
endif ()
|
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)
|
if (LLDB)
|
||||||
message(STATUS "QEMU: Enable direct-kernel debug with LLDB")
|
message(STATUS "QEMU: Enable direct-kernel debug with LLDB")
|
||||||
add_custom_target(debug-kernel
|
add_custom_target(debug-kernel
|
||||||
@@ -71,6 +91,8 @@ if (LLDB)
|
|||||||
-kernel ${patched_kernel}
|
-kernel ${patched_kernel}
|
||||||
-initrd ${sys_dir}/${bsp_name}
|
-initrd ${sys_dir}/${bsp_name}
|
||||||
${generic_flags}
|
${generic_flags}
|
||||||
|
--append kernel.enable-debugger
|
||||||
|
-serial tcp::7720,server,nowait
|
||||||
-s -S &
|
-s -S &
|
||||||
${LLDB}
|
${LLDB}
|
||||||
-o "file ${CMAKE_BINARY_DIR}/kernel/${kernel_name}.debug"
|
-o "file ${CMAKE_BINARY_DIR}/kernel/${kernel_name}.debug"
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[seed]
|
||||||
|
name = 'cdrom'
|
||||||
|
|
||||||
|
[build]
|
||||||
|
build_system = 'cmake'
|
||||||
|
|
||||||
|
# vim: ft=toml
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[command]
|
||||||
|
name = 'debug'
|
||||||
|
description = 'Run the system under a debugger'
|
||||||
|
|
||||||
|
# vim: ft=toml
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
@@ -115,19 +115,43 @@ function(bsp_add_service)
|
|||||||
|
|
||||||
get_property(bsp_targets GLOBAL PROPERTY bsp_target_list)
|
get_property(bsp_targets GLOBAL PROPERTY bsp_target_list)
|
||||||
get_property(cfg_file TARGET ${arg_NAME} PROPERTY service_cfg_path)
|
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 bsp_targets nr_bsp_targets)
|
||||||
|
list(LENGTH file_list nr_service_files)
|
||||||
if (${nr_bsp_targets} GREATER 0)
|
if (${nr_bsp_targets} GREATER 0)
|
||||||
math(EXPR serialiser_index "${nr_bsp_targets}-1")
|
math(EXPR serialiser_index "${nr_bsp_targets}-1")
|
||||||
list(GET bsp_targets ${serialiser_index} serialiser)
|
list(GET bsp_targets ${serialiser_index} serialiser)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_custom_target(${bsp_target_name}
|
set(commands
|
||||||
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
|
|
||||||
add-binary ${bsp_manifest} ${target_name}
|
|
||||||
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>
|
|
||||||
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
|
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
|
||||||
add-binary ${bsp_manifest} ${target_name}-cfg
|
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}"
|
COMMENT "Preparing bsp component: ${target_name}"
|
||||||
DEPENDS ${target_name} ${serialiser})
|
DEPENDS ${target_name} ${serialiser})
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ function(add_interface)
|
|||||||
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})
|
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
add_dependencies(iflib-${arg_NAME} ifgen-${arg_NAME})
|
add_dependencies(iflib-${arg_NAME} ifgen-${arg_NAME})
|
||||||
add_library(interface::${arg_NAME} ALIAS iflib-${arg_NAME})
|
add_library(interface::${arg_NAME} ALIAS iflib-${arg_NAME})
|
||||||
|
install(FILES ${header_path} DESTINATION include/${arg_PARENT_DIR})
|
||||||
endfunction(add_interface)
|
endfunction(add_interface)
|
||||||
|
|
||||||
function(iface_get_header_path)
|
function(iface_get_header_path)
|
||||||
|
|||||||
@@ -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
@@ -170,19 +170,44 @@ function(sysroot_add_service)
|
|||||||
|
|
||||||
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)
|
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)
|
||||||
get_property(cfg_file TARGET ${arg_NAME} PROPERTY service_cfg_path)
|
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 sysroot_targets nr_sysroot_targets)
|
||||||
|
list(LENGTH file_list nr_service_files)
|
||||||
if (${nr_sysroot_targets} GREATER 0)
|
if (${nr_sysroot_targets} GREATER 0)
|
||||||
math(EXPR serialiser_index "${nr_sysroot_targets}-1")
|
math(EXPR serialiser_index "${nr_sysroot_targets}-1")
|
||||||
list(GET sysroot_targets ${serialiser_index} serialiser)
|
list(GET sysroot_targets ${serialiser_index} serialiser)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_custom_target(${sysroot_target_name}
|
set(commands
|
||||||
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
|
||||||
add-binary ${sysroot_manifest} ${target_name}
|
|
||||||
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>
|
|
||||||
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
||||||
add-binary ${sysroot_manifest} ${target_name}-cfg
|
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}"
|
COMMENT "Preparing sysroot component: ${target_name}"
|
||||||
DEPENDS ${target_name} ${serialiser})
|
DEPENDS ${target_name} ${serialiser})
|
||||||
|
|
||||||
|
|||||||
+6
-25
@@ -32,29 +32,6 @@ function(rosetta_add_executable)
|
|||||||
DESTINATION ${arg_SYSROOT_PATH})
|
DESTINATION ${arg_SYSROOT_PATH})
|
||||||
endfunction(rosetta_add_executable)
|
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)
|
function(rosetta_add_library)
|
||||||
set(options STATIC SHARED)
|
set(options STATIC SHARED)
|
||||||
set(one_value_args NAME)
|
set(one_value_args NAME)
|
||||||
@@ -156,7 +133,7 @@ endfunction(rosetta_add_object_library)
|
|||||||
|
|
||||||
function(rosetta_wrap_library)
|
function(rosetta_wrap_library)
|
||||||
set(options)
|
set(options)
|
||||||
set(one_value_args NAME)
|
set(one_value_args NAME SONAME PREFIX)
|
||||||
set(multi_value_args
|
set(multi_value_args
|
||||||
PUBLIC_INCLUDE_DIRS)
|
PUBLIC_INCLUDE_DIRS)
|
||||||
cmake_parse_arguments(PARSE_ARGV 0 arg
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||||
@@ -174,10 +151,14 @@ function(rosetta_wrap_library)
|
|||||||
PATH ${arg_PUBLIC_INCLUDE_DIRS})
|
PATH ${arg_PUBLIC_INCLUDE_DIRS})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (arg_SONAME)
|
||||||
|
target_link_options(${lib_name} PRIVATE -Wl,--soname,${arg_SONAME}.so)
|
||||||
|
endif ()
|
||||||
|
|
||||||
set_target_properties(${lib_name} PROPERTIES
|
set_target_properties(${lib_name} PROPERTIES
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include
|
src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
PREFIX "")
|
PREFIX "${arg_PREFIX}")
|
||||||
endfunction(rosetta_wrap_library)
|
endfunction(rosetta_wrap_library)
|
||||||
|
|
||||||
function(rosetta_add_object_library)
|
function(rosetta_add_object_library)
|
||||||
|
|||||||
Vendored
+12
@@ -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
|
||||||
Vendored
+22
@@ -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
|
||||||
Vendored
+15
@@ -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
|
||||||
Vendored
+18
@@ -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
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.31)
|
||||||
|
project(rosetta-interface)
|
||||||
|
|
||||||
|
include(Msg-Interface)
|
||||||
|
|
||||||
file(GLOB if_files *.xpc)
|
file(GLOB if_files *.xpc)
|
||||||
|
|
||||||
foreach (file ${if_files})
|
foreach (file ${if_files})
|
||||||
get_filename_component(name ${file} NAME_WLE)
|
get_filename_component(name ${file} NAME_WLE)
|
||||||
add_interface(NAME ${name} PATH ${file} PARENT_DIR rosetta)
|
add_interface(NAME ${name} PATH ${file} PARENT_DIR rosetta)
|
||||||
sysroot_add_interface(NAME ${name} DEST_DIR /usr/include)
|
|
||||||
endforeach (file)
|
endforeach (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 map[5](prot: int, flags: int) -> (err: int, vmo: handle);
|
||||||
|
|
||||||
func getdents[6]() -> (err: int, dents: buffer);
|
func getdents[6]() -> (err: int, dents: buffer);
|
||||||
|
func mount[7](path: string, nd: int, pid: int, chid: int) -> (err: int);
|
||||||
|
|||||||
@@ -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
@@ -31,9 +31,10 @@ endforeach (item)
|
|||||||
|
|
||||||
foreach (assembly ${fx_assemblies})
|
foreach (assembly ${fx_assemblies})
|
||||||
target_link_libraries(${assembly} libc libpthread)
|
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(
|
rosetta_wrap_library(
|
||||||
NAME ${assembly}
|
NAME ${assembly}
|
||||||
|
SONAME lib${assembly}
|
||||||
PUBLIC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/libfx/${module}/include)
|
PUBLIC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/libfx/${module}/include)
|
||||||
set_target_properties(${assembly} PROPERTIES
|
set_target_properties(${assembly} PROPERTIES
|
||||||
PREFIX "lib")
|
PREFIX "lib")
|
||||||
|
|||||||
Vendored
+15
@@ -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
|
||||||
Vendored
+16
@@ -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
@@ -1,10 +1,12 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.31)
|
||||||
|
project(libc C ASM)
|
||||||
|
|
||||||
set(source_dirs core malloc io exec)
|
set(source_dirs core malloc io exec)
|
||||||
|
|
||||||
|
set(LIBC_STANDALONE FALSE)
|
||||||
set(public_include_dirs
|
set(public_include_dirs
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
add_subdirectory(runtime)
|
|
||||||
|
|
||||||
foreach (dir ${source_dirs})
|
foreach (dir ${source_dirs})
|
||||||
add_subdirectory(${dir})
|
add_subdirectory(${dir})
|
||||||
set(sources ${sources} ${component_sources})
|
set(sources ${sources} ${component_sources})
|
||||||
@@ -12,22 +14,11 @@ foreach (dir ${source_dirs})
|
|||||||
set(public_include_dirs ${public_include_dirs} ${component_public_include_dirs})
|
set(public_include_dirs ${public_include_dirs} ${component_public_include_dirs})
|
||||||
endforeach (dir)
|
endforeach (dir)
|
||||||
|
|
||||||
rosetta_add_library(SHARED
|
add_library(libc SHARED ${sources} ${headers})
|
||||||
NAME libc
|
target_include_directories(libc PUBLIC ${public_include_dirs})
|
||||||
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
|
target_link_libraries(libc PRIVATE rosetta libxpc.a liblaunch.a libmagenta.a)
|
||||||
SOURCES ${sources}
|
target_compile_options(libc PRIVATE -ffreestanding -nostdlib)
|
||||||
HEADERS ${headers})
|
target_link_options(libc PRIVATE -ffreestanding -nostdlib)
|
||||||
|
target_compile_definitions(libc PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_SHARED=1)
|
||||||
sysroot_add_library(
|
set_target_properties(libc PROPERTIES PREFIX "")
|
||||||
NAME libc
|
install(TARGETS 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)
|
|
||||||
|
|||||||
@@ -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)
|
set(source_dirs assert stdio stdlib string errno ctype wctype unistd)
|
||||||
|
|
||||||
foreach (dir ${source_dirs})
|
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}/*.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/sys/${CMAKE_SYSTEM_PROCESSOR}/*.S)
|
${CMAKE_CURRENT_SOURCE_DIR}/sys/${CMAKE_SYSTEM_PROCESSOR}/*.S)
|
||||||
|
|
||||||
|
if (NOT LIBC_STANDALONE)
|
||||||
set(component_sources ${sources} ${sys_sources} PARENT_SCOPE)
|
set(component_sources ${sources} ${sys_sources} PARENT_SCOPE)
|
||||||
set(component_headers ${headers} PARENT_SCOPE)
|
set(component_headers ${headers} PARENT_SCOPE)
|
||||||
|
return ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
rosetta_add_library(STATIC
|
add_library(libc-core STATIC ${sources} ${sys_sources} ${headers})
|
||||||
NAME libc-core
|
target_include_directories(libc-core PUBLIC ${public_include_dirs})
|
||||||
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)
|
|
||||||
|
|
||||||
target_link_libraries(libc-core PRIVATE libmagenta librosetta)
|
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)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include <magenta/log.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern void __libc_assert_failed(
|
extern void __libc_assert_failed(
|
||||||
@@ -6,5 +8,6 @@ extern void __libc_assert_failed(
|
|||||||
const char *func,
|
const char *func,
|
||||||
const char *cond)
|
const char *cond)
|
||||||
{
|
{
|
||||||
|
kern_logf("ASSERT: %s failed (%s in %s:%d)", cond, func, file, line);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -28,14 +28,14 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <magenta/log.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
long long strtoll(
|
long long strtoll(const char *restrict ptr, char **restrict endptr, int base)
|
||||||
const char *restrict ptr,
|
|
||||||
char **restrict endptr,
|
|
||||||
register int base)
|
|
||||||
{
|
{
|
||||||
const char *s = ptr;
|
const char *s = ptr;
|
||||||
long long acc;
|
long long acc;
|
||||||
@@ -64,8 +64,31 @@ long long strtoll(
|
|||||||
base = c == '0' ? 8 : 10;
|
base = c == '0' ? 8 : 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
cutoff = (long long)LLONG_MAX / (long long)base;
|
/* XXX cannot just divide by base here. Doing so results in a #DE
|
||||||
cutlim = (long long)LLONG_MAX % (long long)base;
|
* 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++) {
|
for (acc = 0, any = 0;; c = *s++) {
|
||||||
if (isdigit(c)) {
|
if (isdigit(c)) {
|
||||||
c -= '0';
|
c -= '0';
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
|
#include <errno.h>
|
||||||
#include <magenta/log.h>
|
#include <magenta/log.h>
|
||||||
#include <rosetta/bootstrap.h>
|
#include <rosetta/bootstrap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <sys/remote.h>
|
||||||
|
|
||||||
extern int main(int, const char **, const char **);
|
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)
|
int __libc_init(const struct rosetta_bootstrap *bsinfo)
|
||||||
{
|
{
|
||||||
|
sys_remote_set(SYS_REMOTE_NSD, 0, 0);
|
||||||
(volatile void)pthread_self();
|
(volatile void)pthread_self();
|
||||||
__set_errno(SUCCESS);
|
__set_errno(SUCCESS);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
set(source_dirs unistd spawn)
|
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)
|
file(GLOB sources *.c *.h)
|
||||||
|
|
||||||
foreach (dir ${source_dirs})
|
foreach (dir ${source_dirs})
|
||||||
@@ -13,21 +18,17 @@ endforeach (dir)
|
|||||||
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
|
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
|
||||||
set(headers ${headers} ${sub_headers})
|
set(headers ${headers} ${sub_headers})
|
||||||
|
|
||||||
|
if (NOT LIBC_STANDALONE)
|
||||||
set(component_sources ${sources} PARENT_SCOPE)
|
set(component_sources ${sources} PARENT_SCOPE)
|
||||||
set(component_headers ${headers} PARENT_SCOPE)
|
set(component_headers ${headers} PARENT_SCOPE)
|
||||||
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
|
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
rosetta_add_library(STATIC
|
add_library(libc-exec STATIC ${sources} ${headers})
|
||||||
NAME libc-exec
|
target_include_directories(libc-exec PUBLIC
|
||||||
PUBLIC_INCLUDE_DIRS
|
|
||||||
${public_include_dirs}
|
${public_include_dirs}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
SOURCES ${sources}
|
|
||||||
HEADERS ${headers})
|
|
||||||
|
|
||||||
sysroot_add_library(
|
|
||||||
NAME libc-exec
|
|
||||||
HEADER_DIR /usr/include
|
|
||||||
LIB_DIR /usr/lib)
|
|
||||||
|
|
||||||
target_link_libraries(libc-exec libc-core libc-io libmagenta liblaunch-static)
|
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)
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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)
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef FCNTL_H_
|
#ifndef FCNTL_H_
|
||||||
#define FCNTL_H_
|
#define FCNTL_H_
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define O_RDONLY 0x0000 /* open for reading only */
|
#define O_RDONLY 0x0000 /* open for reading only */
|
||||||
#define O_WRONLY 0x0001 /* open for writing only */
|
#define O_WRONLY 0x0001 /* open for writing only */
|
||||||
#define O_RDWR 0x0002 /* open for reading and writing */
|
#define O_RDWR 0x0002 /* open for reading and writing */
|
||||||
@@ -50,4 +52,47 @@
|
|||||||
#define AT_SYMLINK_NOFOLLOW_ANY \
|
#define AT_SYMLINK_NOFOLLOW_ANY \
|
||||||
0x0800 /* Path should not contain any symlinks */
|
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
|
#endif
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -25,6 +25,8 @@ typedef struct __opaque_file FILE;
|
|||||||
extern int printf(const char *format, ...);
|
extern int printf(const char *format, ...);
|
||||||
extern int vprintf(const char *format, va_list arg);
|
extern int vprintf(const char *format, va_list arg);
|
||||||
extern int fprintf(FILE *stream, const char *format, ...);
|
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 snprintf(char *buffer, size_t count, const char *format, ...);
|
||||||
extern int vsnprintf(
|
extern int vsnprintf(
|
||||||
char *buffer,
|
char *buffer,
|
||||||
@@ -33,6 +35,8 @@ extern int vsnprintf(
|
|||||||
va_list va);
|
va_list va);
|
||||||
|
|
||||||
extern FILE *fopen(const char *path, const char *mode);
|
extern FILE *fopen(const char *path, const char *mode);
|
||||||
|
extern FILE *fdopen(int fildes, const char *mode);
|
||||||
|
|
||||||
extern int fclose(FILE *stream);
|
extern int fclose(FILE *stream);
|
||||||
|
|
||||||
extern int feof(FILE *stream);
|
extern int feof(FILE *stream);
|
||||||
@@ -52,12 +56,14 @@ static inline int putc(int c, FILE *stream)
|
|||||||
{
|
{
|
||||||
return fputc(c, stream);
|
return fputc(c, stream);
|
||||||
}
|
}
|
||||||
|
extern int putchar(int c);
|
||||||
|
|
||||||
extern char *fgets(char *restrict str, int count, FILE *restrict stream);
|
extern char *fgets(char *restrict str, int count, FILE *restrict stream);
|
||||||
extern int fputs(const char *restrict str, FILE *restrict stream);
|
extern int fputs(const char *restrict str, FILE *restrict stream);
|
||||||
|
|
||||||
extern long ftell(FILE *stream);
|
extern long ftell(FILE *stream);
|
||||||
extern int fseek(FILE *stream, long offset, int origin);
|
extern int fseek(FILE *stream, long offset, int origin);
|
||||||
|
extern int fflush(FILE *stream);
|
||||||
|
|
||||||
extern int sscanf(
|
extern int sscanf(
|
||||||
const char *restrict buffer,
|
const char *restrict buffer,
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ extern void abort(void);
|
|||||||
extern void exit(int result);
|
extern void exit(int result);
|
||||||
extern int atexit(void (*func)(void));
|
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 *malloc(size_t count);
|
||||||
extern void *calloc(size_t count, size_t size);
|
extern void *calloc(size_t count, size_t size);
|
||||||
extern void *realloc(void *p, size_t count);
|
extern void *realloc(void *p, size_t count);
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ extern size_t strlen(const char *s);
|
|||||||
|
|
||||||
extern size_t strcspn(const char *dest, const char *src);
|
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 *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 strcmp(const char *s1, const char *s2);
|
||||||
extern int strncmp(const char *s1, const char *s2, unsigned long n);
|
extern int strncmp(const char *s1, const char *s2, unsigned long n);
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#define SEEK_END 2
|
#define SEEK_END 2
|
||||||
|
|
||||||
typedef size_t ino_t;
|
typedef size_t ino_t;
|
||||||
typedef long pid_t;
|
typedef int pid_t;
|
||||||
typedef long mode_t;
|
typedef long mode_t;
|
||||||
|
|
||||||
struct dentry {
|
struct dentry {
|
||||||
|
|||||||
@@ -4,12 +4,14 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/types.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 close(int fd);
|
||||||
|
|
||||||
extern int read(int fd, void *buf, size_t count);
|
extern int read(int fd, void *buf, size_t count);
|
||||||
extern int write(int fd, const 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 off_t lseek(int fd, off_t offset, int whence);
|
||||||
|
|
||||||
extern long getdents(int fd, struct dentry *dirp, unsigned int count);
|
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 execlp(const char *file, const char *arg, ...);
|
||||||
extern int execle(const char *path, const char *arg, ...);
|
extern int execle(const char *path, const char *arg, ...);
|
||||||
extern int execv(const char *path, char *const argv[]);
|
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 execvp(const char *file, char *const argv[]);
|
||||||
extern int execvpe(const char *file, char *const argv[], char *const envp[]);
|
extern int execvpe(const char *file, char *const argv[], char *const envp[]);
|
||||||
|
|
||||||
|
extern pid_t getpid(void);
|
||||||
|
extern pid_t getppid(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+15
-13
@@ -1,5 +1,10 @@
|
|||||||
set(source_dirs unistd stdio)
|
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)
|
file(GLOB sources *.c *.h)
|
||||||
|
|
||||||
foreach (dir ${source_dirs})
|
foreach (dir ${source_dirs})
|
||||||
@@ -13,21 +18,18 @@ endforeach (dir)
|
|||||||
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
|
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
|
||||||
set(headers ${headers} ${sub_headers})
|
set(headers ${headers} ${sub_headers})
|
||||||
|
|
||||||
|
if (NOT LIBC_STANDALONE)
|
||||||
set(component_sources ${sources} PARENT_SCOPE)
|
set(component_sources ${sources} PARENT_SCOPE)
|
||||||
set(component_headers ${headers} PARENT_SCOPE)
|
set(component_headers ${headers} PARENT_SCOPE)
|
||||||
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
|
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
|
||||||
|
return ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
rosetta_add_library(STATIC
|
add_library(libc-io STATIC ${sources} ${headers})
|
||||||
NAME libc-io
|
target_include_directories(libc-io PUBLIC
|
||||||
PUBLIC_INCLUDE_DIRS
|
|
||||||
${public_include_dirs}
|
${public_include_dirs}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
SOURCES ${sources}
|
target_link_libraries(libc-io libc-core libxpc.a libmagenta)
|
||||||
HEADERS ${headers})
|
target_compile_definitions(libc-io PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_STATIC=1)
|
||||||
|
set_target_properties(libc-io PROPERTIES PREFIX "")
|
||||||
sysroot_add_library(
|
install(TARGETS libc-io)
|
||||||
NAME libc-io
|
|
||||||
HEADER_DIR /usr/include
|
|
||||||
LIB_DIR /usr/lib)
|
|
||||||
|
|
||||||
target_link_libraries(libc-io libc-core interface::fs libxpc-static libmagenta)
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -57,6 +57,7 @@ int __libc_dir_refill(struct __opaque_dir *d)
|
|||||||
|
|
||||||
int __libc_dir_move_next(struct __opaque_dir *d)
|
int __libc_dir_move_next(struct __opaque_dir *d)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (d->d_fd < 0) {
|
if (d->d_fd < 0) {
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int fprintf(struct __opaque_file *stream, const char *format, ...)
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ int printf(const char *format, ...)
|
|||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
va_start(arg, format);
|
va_start(arg, format);
|
||||||
int ret = vprintf(format, arg);
|
int ret = vfprintf(stdout, format, arg);
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int putchar(int c)
|
||||||
|
{
|
||||||
|
return fputc(c, stdout);
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -145,7 +145,7 @@ long __libc_ringbuf_read(struct ringbuf *buf, void *p, size_t count)
|
|||||||
|
|
||||||
memcpy(dest, src, to_copy);
|
memcpy(dest, src, to_copy);
|
||||||
|
|
||||||
nr_read += available;
|
nr_read += to_copy;
|
||||||
__libc_ringbuf_put_read_buffer(buf, &src, &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);
|
memcpy(dest, src, to_copy);
|
||||||
|
|
||||||
nr_written += available;
|
nr_written += to_copy;
|
||||||
__libc_ringbuf_put_write_buffer(buf, &dest, &to_copy);
|
__libc_ringbuf_put_write_buffer(buf, &dest, &to_copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
static struct __opaque_file __stderr = {
|
static struct __opaque_file __stderr = {
|
||||||
.f_fd = 2,
|
.f_fd = 2,
|
||||||
.f_flags = FILE_STATIC,
|
.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)
|
extern struct __opaque_file *__libc_file_stderr(void)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
extern int __libc_fctprintf(
|
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)
|
int vprintf(const char *format, va_list arg)
|
||||||
{
|
{
|
||||||
__libc_file_lock(stdout);
|
return vfprintf(stdout, format, arg);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
set(source_dirs stdlib string)
|
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)
|
file(GLOB sources *.c *.h)
|
||||||
|
|
||||||
foreach (dir ${source_dirs})
|
foreach (dir ${source_dirs})
|
||||||
@@ -13,22 +18,17 @@ endforeach (dir)
|
|||||||
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
|
file(GLOB_RECURSE sub_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
|
||||||
set(headers ${headers} ${sub_headers})
|
set(headers ${headers} ${sub_headers})
|
||||||
|
|
||||||
|
if (NOT LIBC_STANDALONE)
|
||||||
set(component_sources ${sources} PARENT_SCOPE)
|
set(component_sources ${sources} PARENT_SCOPE)
|
||||||
set(component_headers ${headers} PARENT_SCOPE)
|
set(component_headers ${headers} PARENT_SCOPE)
|
||||||
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
|
set(component_public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
rosetta_add_library(STATIC
|
add_library(libc-malloc STATIC ${sources} ${headers})
|
||||||
NAME libc-malloc
|
target_compile_definitions(libc-malloc PRIVATE LIBC_STATIC=1 ENABLE_GLOBAL_HEAP=1)
|
||||||
PUBLIC_INCLUDE_DIRS
|
target_include_directories(libc-malloc PUBLIC ${public_include_dirs} include)
|
||||||
${public_include_dirs}
|
target_compile_definitions(libc-malloc PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_STATIC=1)
|
||||||
${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)
|
|
||||||
target_link_libraries(libc-malloc libc-core libmagenta)
|
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)
|
||||||
|
|||||||
@@ -8,6 +8,12 @@
|
|||||||
#include <magenta/vm.h>
|
#include <magenta/vm.h>
|
||||||
#include <stdio.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_REGION_SIZE 0x40000000
|
||||||
#define HEAP_EXPAND_INCREMENT 0x100000
|
#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(
|
kern_status_t status = address_space_reserve(
|
||||||
address_space,
|
address_space,
|
||||||
MAP_ADDRESS_ANY,
|
HEAP_REGION_BASE,
|
||||||
HEAP_REGION_SIZE,
|
HEAP_REGION_SIZE,
|
||||||
&heap->heap_base);
|
&heap->heap_base);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
#include "liballoc.h"
|
#include "liballoc.h"
|
||||||
|
|
||||||
|
#include <magenta/config.h>
|
||||||
|
#include <magenta/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/** Durand's Amazing Super Duper Memory functions. */
|
/** Durand's Amazing Super Duper Memory functions. */
|
||||||
|
|
||||||
#define VERSION "1.1"
|
#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.
|
return NULL; // uh oh, we ran out of memory.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(maj, 0x0, sizeof *maj);
|
||||||
|
|
||||||
maj->prev = NULL;
|
maj->prev = NULL;
|
||||||
maj->next = NULL;
|
maj->next = NULL;
|
||||||
maj->pages = st;
|
maj->pages = st;
|
||||||
@@ -455,12 +462,10 @@ void *PREFIX(malloc)(heap_t *heap, size_t req_size)
|
|||||||
if (diff
|
if (diff
|
||||||
>= (size + sizeof(struct liballoc_minor))) {
|
>= (size + sizeof(struct liballoc_minor))) {
|
||||||
// yay....
|
// yay....
|
||||||
min->next
|
min->next = (struct liballoc_minor
|
||||||
= (struct liballoc_minor
|
|
||||||
*)((uintptr_t)min
|
*)((uintptr_t)min
|
||||||
+ sizeof(
|
+ sizeof(
|
||||||
struct
|
struct liballoc_minor)
|
||||||
liballoc_minor)
|
|
||||||
+ min->size);
|
+ min->size);
|
||||||
min->next->prev = min;
|
min->next->prev = min;
|
||||||
min = min->next;
|
min = min->next;
|
||||||
@@ -506,8 +511,7 @@ void *PREFIX(malloc)(heap_t *heap, size_t req_size)
|
|||||||
new_min = (struct liballoc_minor
|
new_min = (struct liballoc_minor
|
||||||
*)((uintptr_t)min
|
*)((uintptr_t)min
|
||||||
+ sizeof(
|
+ sizeof(
|
||||||
struct
|
struct liballoc_minor)
|
||||||
liballoc_minor)
|
|
||||||
+ min->size);
|
+ min->size);
|
||||||
|
|
||||||
new_min->magic = LIBALLOC_MAGIC;
|
new_min->magic = LIBALLOC_MAGIC;
|
||||||
@@ -822,9 +826,11 @@ int liballoc_unlock(heap_t *heap)
|
|||||||
return 0;
|
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)
|
int liballoc_free(heap_t *heap, void *p, size_t sz)
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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})
|
foreach (dir ${pthread_source_dirs})
|
||||||
file(GLOB dir_sources ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*.c)
|
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_headers ${pthread_headers} ${CMAKE_CURRENT_SOURCE_DIR}/include/pthread.h)
|
||||||
set(pthread_public_include_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
set(pthread_public_include_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
rosetta_add_library(STATIC
|
if (PTHREAD_STATIC)
|
||||||
NAME libc-pthread
|
add_library(libc-pthread STATIC ${pthread_sources} ${pthread_headers})
|
||||||
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})
|
|
||||||
|
|
||||||
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(libc-pthread PRIVATE libc-io libmagenta)
|
||||||
target_link_libraries(libpthread PRIVATE libmagenta)
|
target_include_directories(libc-pthread PUBLIC
|
||||||
target_link_libraries(libpthread PUBLIC libc)
|
${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 ()
|
||||||
|
|
||||||
|
install(FILES include/pthread.h DESTINATION include)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#define __PTHREAD_ATTR_SIZE__ 32
|
#define __PTHREAD_ATTR_SIZE__ 32
|
||||||
|
|
||||||
|
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) {.__v = 0})
|
||||||
|
|
||||||
typedef struct __pthread *pthread_t;
|
typedef struct __pthread *pthread_t;
|
||||||
|
|
||||||
typedef struct __pthread_attr {
|
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 int pthread_detach(pthread_t thread);
|
||||||
extern void pthread_exit(void *retval);
|
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
|
#endif
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -1,10 +1,16 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.31)
|
||||||
|
project(libc-runtime C ASM)
|
||||||
|
|
||||||
file(GLOB runtime_sources
|
file(GLOB runtime_sources
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/*.s)
|
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/*.s)
|
||||||
|
|
||||||
rosetta_add_object_library(
|
foreach (s ${runtime_sources})
|
||||||
NAME libc-runtime STATIC
|
get_filename_component(object_name ${s} NAME)
|
||||||
SOURCES ${runtime_sources})
|
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(
|
add_library(libc-runtime OBJECT ${runtime_sources})
|
||||||
NAME libc-runtime
|
|
||||||
LIB_DIR /usr/lib)
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -1,24 +1 @@
|
|||||||
.code64
|
.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
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.code64
|
||||||
|
|
||||||
|
.global _crtbeginS
|
||||||
|
.type _crtbeginS, @function
|
||||||
|
|
||||||
|
_crtbeginS:
|
||||||
|
ret
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.code64
|
||||||
|
|
||||||
|
.global _crtendS
|
||||||
|
.type _crtendS, @function
|
||||||
|
|
||||||
|
_crtendS:
|
||||||
|
ret
|
||||||
+16
-22
@@ -1,33 +1,27 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.31)
|
||||||
|
project(fs C ASM)
|
||||||
|
|
||||||
file(GLOB sources
|
file(GLOB sources
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/*.c
|
${CMAKE_CURRENT_SOURCE_DIR}/*.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/interface/*.c)
|
${CMAKE_CURRENT_SOURCE_DIR}/interface/*.c)
|
||||||
file(GLOB headers
|
file(GLOB headers
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h
|
${CMAKE_CURRENT_SOURCE_DIR}/*.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/fs/*.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/include/fs/*.h)
|
||||||
|
file(GLOB public_headers
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include/fs/*.h)
|
||||||
|
|
||||||
set(public_include_dirs
|
set(public_include_dirs
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
rosetta_add_library(
|
if (FS_STATIC)
|
||||||
NAME libfs SHARED STATIC
|
add_library(fs STATIC ${sources} ${headers})
|
||||||
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
|
target_link_libraries(fs magenta libc-core libxpc.a)
|
||||||
SOURCES ${sources}
|
set_target_properties(fs PROPERTIES POSITION_INDEPENDENT_CODE FALSE)
|
||||||
HEADERS ${headers})
|
else ()
|
||||||
|
add_library(fs SHARED ${sources} ${headers})
|
||||||
|
target_link_libraries(fs magenta c xpc)
|
||||||
|
endif ()
|
||||||
|
|
||||||
sysroot_add_library(
|
target_include_directories(fs PUBLIC include)
|
||||||
NAME libfs
|
install(TARGETS fs)
|
||||||
HEADER_DIR /usr/include
|
install(FILES ${public_headers} DESTINATION include/fs)
|
||||||
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)
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
[seed]
|
||||||
|
name = 'libfs'
|
||||||
|
|
||||||
|
[dependency]
|
||||||
|
seeds = [
|
||||||
|
'libxpc',
|
||||||
|
'librosetta-interface'
|
||||||
|
]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
build_system = 'cmake'
|
||||||
|
|
||||||
|
# vim: ft=toml
|
||||||
+1
-1
Submodule lib/libfx updated: 8c0a31e19b...9da33eec71
@@ -1,25 +1,25 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.31)
|
||||||
|
project(launch C ASM)
|
||||||
|
|
||||||
file(GLOB sources
|
file(GLOB sources
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
||||||
file(GLOB headers
|
file(GLOB headers
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/launch.h
|
${CMAKE_CURRENT_SOURCE_DIR}/include/launch.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
||||||
|
file(GLOB public_headers
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include/launch.h)
|
||||||
|
|
||||||
set(public_include_dirs
|
set(public_include_dirs
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
rosetta_add_library(
|
if (LAUNCH_STATIC)
|
||||||
NAME liblaunch SHARED STATIC
|
add_library(launch STATIC ${sources} ${headers})
|
||||||
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
|
target_link_libraries(launch PRIVATE librosetta libmagenta libc-core)
|
||||||
SOURCES ${sources}
|
else ()
|
||||||
HEADERS ${headers})
|
add_library(launch SHARED ${sources} ${headers})
|
||||||
|
target_link_libraries(launch PRIVATE rosetta magenta c)
|
||||||
|
endif ()
|
||||||
|
|
||||||
sysroot_add_library(
|
target_include_directories(launch PUBLIC include)
|
||||||
NAME liblaunch
|
install(TARGETS launch)
|
||||||
HEADER_DIR /usr/include
|
install(FILES ${public_headers} DESTINATION 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)
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[seed]
|
||||||
|
name = 'liblaunch'
|
||||||
|
|
||||||
|
[build]
|
||||||
|
build_system = 'cmake'
|
||||||
|
|
||||||
|
# vim: ft=toml
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.31)
|
||||||
|
project(librosetta C ASM)
|
||||||
|
|
||||||
file(GLOB sources *.c)
|
file(GLOB sources *.c)
|
||||||
file(GLOB headers include/rosetta/*.h)
|
file(GLOB headers include/rosetta/*.h)
|
||||||
|
|
||||||
rosetta_add_library(
|
add_library(rosetta STATIC ${sources} ${headers})
|
||||||
NAME librosetta STATIC
|
target_include_directories(rosetta PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
PUBLIC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
||||||
SOURCES ${sources}
|
|
||||||
HEADERS ${headers})
|
|
||||||
|
|
||||||
sysroot_add_library(
|
target_link_libraries(rosetta PRIVATE libmagenta)
|
||||||
NAME librosetta
|
|
||||||
HEADER_DIR /usr/include
|
|
||||||
LIB_DIR /usr/lib)
|
|
||||||
|
|
||||||
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 {
|
enum rosetta_bootstrap_channel_type {
|
||||||
RSBS_CHANNEL_NONE,
|
RSBS_CHANNEL_NONE,
|
||||||
RSBS_CHANNEL_SYSTEM,
|
RSBS_CHANNEL_SYSTEM,
|
||||||
|
RSBS_CHANNEL_NAMESPACE,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rosetta_bootstrap_handle {
|
struct rosetta_bootstrap_handle {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
[seed]
|
||||||
|
name = 'librosetta'
|
||||||
|
|
||||||
|
[dependency]
|
||||||
|
no_standard_dependencies = true
|
||||||
|
seeds = [
|
||||||
|
'libmagenta',
|
||||||
|
]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
build_system = 'cmake'
|
||||||
|
|
||||||
|
# vim: ft=toml
|
||||||
+16
-16
@@ -1,28 +1,28 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.31)
|
||||||
|
project(xpc C ASM)
|
||||||
|
|
||||||
file(GLOB sources
|
file(GLOB sources
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
||||||
file(GLOB headers
|
file(GLOB headers
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h
|
${CMAKE_CURRENT_SOURCE_DIR}/*.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/xpc/*.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/include/xpc/*.h)
|
||||||
|
|
||||||
|
file(GLOB public_headers
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include/xpc/*.h)
|
||||||
|
|
||||||
set(public_include_dirs
|
set(public_include_dirs
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
rosetta_add_library(
|
if (XPC_STATIC)
|
||||||
NAME libxpc SHARED STATIC
|
add_library(xpc STATIC ${sources} ${headesr})
|
||||||
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
|
target_link_libraries(xpc magenta libc-core)
|
||||||
SOURCES ${sources}
|
else ()
|
||||||
HEADERS ${headers})
|
add_library(xpc SHARED ${sources} ${headesr})
|
||||||
|
target_link_libraries(xpc magenta c)
|
||||||
|
endif ()
|
||||||
|
|
||||||
sysroot_add_library(
|
target_include_directories(xpc PUBLIC ${public_include_dirs})
|
||||||
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)
|
|
||||||
|
|
||||||
|
install(TARGETS xpc)
|
||||||
|
install(FILES ${public_headers} DESTINATION include/xpc)
|
||||||
#set_target_properties(libxpc-static PROPERTIES POSITION_INDEPENDENT_CODE FALSE)
|
#set_target_properties(libxpc-static PROPERTIES POSITION_INDEPENDENT_CODE FALSE)
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[seed]
|
||||||
|
name = 'libxpc'
|
||||||
|
|
||||||
|
[build]
|
||||||
|
build_system = 'cmake'
|
||||||
|
|
||||||
|
# vim: ft=toml
|
||||||
@@ -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 "$@"
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
file(GLOB items *)
|
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})
|
foreach(item ${items})
|
||||||
if (NOT IS_DIRECTORY ${item})
|
if (NOT IS_DIRECTORY ${item})
|
||||||
continue()
|
continue()
|
||||||
@@ -7,3 +12,40 @@ foreach(item ${items})
|
|||||||
|
|
||||||
add_subdirectory(${item})
|
add_subdirectory(${item})
|
||||||
endforeach (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)
|
||||||
|
|||||||
Submodule
+1
Submodule programs/bshell added at f189643cf4
Vendored
+18
@@ -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
|
||||||
@@ -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)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# vim ft=toml
|
|
||||||
[runlevel]
|
|
||||||
name = "single-user"
|
|
||||||
description = "Single-User"
|
|
||||||
requires = [
|
|
||||||
"nsd",
|
|
||||||
"devmd"
|
|
||||||
]
|
|
||||||
@@ -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)
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# vim ft=toml
|
||||||
|
[unit]
|
||||||
|
description = "BShell Test Script"
|
||||||
|
|
||||||
|
[service]
|
||||||
|
exec = [
|
||||||
|
"/usr/bin/bshell",
|
||||||
|
"/sbin/test.bshell"
|
||||||
|
]
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
$x = "Jonh"
|
||||||
|
echo "Hello, $x!"
|
||||||
@@ -1,15 +1,7 @@
|
|||||||
file(GLOB sources *.c)
|
cmake_minimum_required(VERSION 3.31)
|
||||||
rosetta_add_service(
|
project(devmd C)
|
||||||
NAME devmd
|
|
||||||
SOURCES ${sources}
|
|
||||||
CFG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/devmd.service)
|
|
||||||
target_link_libraries(devmd libc libc-runtime)
|
|
||||||
|
|
||||||
sysroot_add_service(
|
file(GLOB sources *.c)
|
||||||
NAME devmd
|
add_executable(devmd ${sources})
|
||||||
BIN_DIR /usr/bin
|
target_link_libraries(devmd c -l:crt0.o)
|
||||||
SVC_DIR /etc/herdd/services)
|
install(TARGETS devmd)
|
||||||
bsp_add_service(
|
|
||||||
NAME devmd
|
|
||||||
BIN_DIR /usr/bin
|
|
||||||
SVC_DIR /etc/herdd/services)
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user