Compare commits
25 Commits
30dd0e753d
...
4fbc6b9027
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fbc6b9027 | |||
| 4beab43728 | |||
| f290ebcd84 | |||
| 7aea4e0206 | |||
| a15ebef9c7 | |||
| 89c8f96829 | |||
| 809f19ebe7 | |||
| 6c80d375f2 | |||
| 109ee7b79c | |||
| b5b95c661e | |||
| 5dcc190f02 | |||
| 19683dbaa8 | |||
| f5c3d885ec | |||
| c64abb9bbc | |||
| a11188b6bf | |||
| 5b996585d4 | |||
| 466af317b2 | |||
| 0d97fe2340 | |||
| 902537ad52 | |||
| 07d5b4852c | |||
| b07acb3cdf | |||
| 0e3f010713 | |||
| 92aaa5439b | |||
| 648a7e2dfb | |||
| 4b6099584b |
+176
@@ -0,0 +1,176 @@
|
|||||||
|
BasedOnStyle: WebKit
|
||||||
|
IndentWidth: 8
|
||||||
|
---
|
||||||
|
Language: C
|
||||||
|
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: 999999999
|
||||||
|
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: 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"
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 4.0)
|
cmake_minimum_required(VERSION 3.31)
|
||||||
project(Rosetta C CXX ASM)
|
project(Rosetta C CXX ASM)
|
||||||
|
|
||||||
include(CheckPIESupported)
|
include(CheckPIESupported)
|
||||||
|
|||||||
+11
-10
@@ -78,16 +78,6 @@ if (LLDB)
|
|||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
DEPENDS ${patched_kernel} bsp)
|
DEPENDS ${patched_kernel} bsp)
|
||||||
|
|
||||||
add_custom_target(debug-kernel-monitor
|
|
||||||
COMMAND
|
|
||||||
${QEMU}
|
|
||||||
-kernel ${patched_kernel}
|
|
||||||
-initrd ${sys_dir}/${bsp_name}
|
|
||||||
${generic_flags}
|
|
||||||
-monitor stdio -s -S
|
|
||||||
USES_TERMINAL
|
|
||||||
DEPENDS ${patched_kernel} bsp)
|
|
||||||
|
|
||||||
if (image_cdrom)
|
if (image_cdrom)
|
||||||
message(STATUS "QEMU: Enable CD-ROM debug with LLDB")
|
message(STATUS "QEMU: Enable CD-ROM debug with LLDB")
|
||||||
add_custom_target(debug-cdrom
|
add_custom_target(debug-cdrom
|
||||||
@@ -132,3 +122,14 @@ elseif (GDB)
|
|||||||
DEPENDS ${image_cdrom})
|
DEPENDS ${image_cdrom})
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
add_custom_target(debug-kernel-monitor
|
||||||
|
COMMAND
|
||||||
|
${QEMU}
|
||||||
|
-kernel ${patched_kernel}
|
||||||
|
-initrd ${sys_dir}/${bsp_name}
|
||||||
|
${generic_flags}
|
||||||
|
-monitor stdio -s -S
|
||||||
|
USES_TERMINAL
|
||||||
|
DEPENDS ${patched_kernel} bsp)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
find_program(GRUB_MKRESCUE grub-mkrescue)
|
find_program(GRUB_MKRESCUE NAMES grub-mkrescue grub2-mkrescue)
|
||||||
|
|
||||||
if (GRUB_MKRESCUE)
|
if (GRUB_MKRESCUE)
|
||||||
message(STATUS "GRUB: Found grub-mkrescue. Bootable CD-ROM image creation is enabled")
|
message(STATUS "GRUB: Found grub-mkrescue. Bootable CD-ROM image creation is enabled")
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
# configuration file generated by Bochs
|
# configuration file generated by Bochs
|
||||||
plugin_ctrl: unmapped=true, biosdev=true, speaker=true, extfpuirq=true, parallel=true, serial=true, iodebug=true
|
plugin_ctrl: unmapped=true, biosdev=true, speaker=true, extfpuirq=true, parallel=true, serial=true
|
||||||
config_interface: textconfig
|
config_interface: textconfig
|
||||||
display_library: sdl2
|
display_library: sdl2
|
||||||
memory: guest=128, host=128, block_size=128
|
memory: guest=128, host=128, block_size=128
|
||||||
romimage: file="/usr/local/share/bochs/BIOS-bochs-latest", address=0x00000000, options=none, flash_data=none
|
|
||||||
vgaromimage: file="/usr/local/share/bochs/VGABIOS-lgpl-latest.bin"
|
|
||||||
boot: cdrom
|
boot: cdrom
|
||||||
floppy_bootsig_check: disabled=0
|
floppy_bootsig_check: disabled=0
|
||||||
floppya: type=1_44
|
floppya: type=1_44
|
||||||
@@ -31,7 +29,7 @@ cpu: count=1:1:1, ips=4000000, quantum=16, model=core2_penryn_t9600, reset_on_tr
|
|||||||
print_timestamps: enabled=0
|
print_timestamps: enabled=0
|
||||||
debugger_log: -
|
debugger_log: -
|
||||||
magic_break: enabled=1 0x0
|
magic_break: enabled=1 0x0
|
||||||
port_e9_hack: enabled=false, all_rings=false
|
port_e9_hack: enabled=true, all_rings=false
|
||||||
iodebug: all_rings=0
|
iodebug: all_rings=0
|
||||||
private_colormap: enabled=0
|
private_colormap: enabled=0
|
||||||
clock: sync=none, time0=local, rtc_sync=0
|
clock: sync=none, time0=local, rtc_sync=0
|
||||||
@@ -47,7 +45,7 @@ mouse: type=ps2, enabled=false, toggle=ctrl+mbutton
|
|||||||
speaker: enabled=true, mode=system
|
speaker: enabled=true, mode=system
|
||||||
parport1: enabled=true, file=none
|
parport1: enabled=true, file=none
|
||||||
parport2: enabled=false
|
parport2: enabled=false
|
||||||
com1: enabled=true, mode=null
|
com1: enabled=true, mode=file, dev=kernel.log
|
||||||
com2: enabled=false
|
com2: enabled=false
|
||||||
com3: enabled=false
|
com3: enabled=false
|
||||||
com4: enabled=false
|
com4: enabled=false
|
||||||
|
|||||||
@@ -24,13 +24,10 @@ def successful_boot(boot_log, out):
|
|||||||
log(out, "Kernel rebooted during test!")
|
log(out, "Kernel rebooted during test!")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
nr_finish = boot_log.count("ld finished")
|
nr_finish = boot_log.count("exiting (Inappropriate file type or format)")
|
||||||
if nr_finish == 0:
|
if nr_finish != 2:
|
||||||
log(out, "Didn't reach end of boot sequence!")
|
log(out, "Didn't reach end of boot sequence!")
|
||||||
return 1
|
return 1
|
||||||
if nr_finish > 1:
|
|
||||||
log(out, "Boot sequence performed multiple times!")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
@@ -34,15 +34,10 @@ initrd=$5
|
|||||||
while true; do
|
while true; do
|
||||||
log "Test $count"
|
log "Test $count"
|
||||||
result_file="$log_dir/$count.log"
|
result_file="$log_dir/$count.log"
|
||||||
$qemu \
|
ninja run-cdrom-bochs > $result_file &
|
||||||
-kernel $kernel \
|
|
||||||
-initrd $initrd \
|
|
||||||
-serial file:$result_file \
|
|
||||||
-cpu qemu64,+rdrand \
|
|
||||||
--append kernel.early-console=ttyS0 -s > /dev/null &
|
|
||||||
qemu_id=$!
|
qemu_id=$!
|
||||||
|
|
||||||
sleep 1.2
|
sleep 5
|
||||||
|
|
||||||
$python $validation_script successful-boot $result_file $logfile
|
$python $validation_script successful-boot $result_file $logfile
|
||||||
result=$?
|
result=$?
|
||||||
@@ -54,12 +49,9 @@ while true; do
|
|||||||
else
|
else
|
||||||
mv $result_file "$result_file.FAIL"
|
mv $result_file "$result_file.FAIL"
|
||||||
fail=$fail+1
|
fail=$fail+1
|
||||||
lldb \
|
|
||||||
-o "file kernel/mango_kernel.debug" \
|
|
||||||
-o "gdb-remote localhost:1234"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kill -INT $qemu_id
|
killall -9 bochs
|
||||||
|
|
||||||
log "---------------"
|
log "---------------"
|
||||||
log "Total tests: $count"
|
log "Total tests: $count"
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
menuentry "Rosetta" {
|
set timeout_style=menu
|
||||||
multiboot /boot/mango_kernel
|
set timeout=0
|
||||||
module /boot/rosetta-system.bsp
|
|
||||||
boot
|
|
||||||
}
|
|
||||||
|
|
||||||
menuentry "Rosetta (Serial Log)" {
|
menuentry "Rosetta (Serial Log)" {
|
||||||
multiboot /boot/mango_kernel kernel.early-console=ttyS0
|
multiboot /boot/mango_kernel kernel.early-console=ttyS0
|
||||||
|
|||||||
+1
-1
Submodule kernel updated: b92542c688...bc575aa1a1
@@ -1,7 +1,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <mango/status.h>
|
#include <mango/status.h>
|
||||||
|
|
||||||
static int __errno = 32;
|
static int __errno = SUCCESS;
|
||||||
|
|
||||||
int __attribute__((weak)) * __errno_location(void)
|
int __attribute__((weak)) * __errno_location(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// output function type
|
// output function type
|
||||||
typedef void (
|
typedef int (
|
||||||
*out_fct_type)(char character, void *buffer, size_t idx, size_t maxlen);
|
*out_fct_type)(char character, void *buffer, size_t idx, size_t maxlen);
|
||||||
|
|
||||||
// wrapper (used as buffer) for output function type
|
// wrapper (used as buffer) for output function type
|
||||||
@@ -128,7 +128,7 @@ typedef struct {
|
|||||||
} out_fct_wrap_type;
|
} out_fct_wrap_type;
|
||||||
|
|
||||||
// internal buffer output
|
// internal buffer output
|
||||||
static inline void _out_buffer(
|
static inline int _out_buffer(
|
||||||
char character,
|
char character,
|
||||||
void *buffer,
|
void *buffer,
|
||||||
size_t idx,
|
size_t idx,
|
||||||
@@ -137,10 +137,12 @@ static inline void _out_buffer(
|
|||||||
if (idx < maxlen) {
|
if (idx < maxlen) {
|
||||||
((char *)buffer)[idx] = character;
|
((char *)buffer)[idx] = character;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal null output
|
// internal null output
|
||||||
static inline void _out_null(
|
static inline int _out_null(
|
||||||
char character,
|
char character,
|
||||||
void *buffer,
|
void *buffer,
|
||||||
size_t idx,
|
size_t idx,
|
||||||
@@ -150,10 +152,11 @@ static inline void _out_null(
|
|||||||
(void)buffer;
|
(void)buffer;
|
||||||
(void)idx;
|
(void)idx;
|
||||||
(void)maxlen;
|
(void)maxlen;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal output function wrapper
|
// internal output function wrapper
|
||||||
static inline void _out_fct(
|
static inline int _out_fct(
|
||||||
char character,
|
char character,
|
||||||
void *buffer,
|
void *buffer,
|
||||||
size_t idx,
|
size_t idx,
|
||||||
@@ -166,6 +169,8 @@ static inline void _out_fct(
|
|||||||
((out_fct_wrap_type *)buffer)
|
((out_fct_wrap_type *)buffer)
|
||||||
->fct(character, ((out_fct_wrap_type *)buffer)->arg);
|
->fct(character, ((out_fct_wrap_type *)buffer)->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal secure strlen
|
// internal secure strlen
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <mango/log.h>
|
#include <mango/log.h>
|
||||||
#include <rosetta/bootstrap.h>
|
#include <rosetta/bootstrap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
extern int main(int, const char **, const char **);
|
extern int main(int, const char **, const char **);
|
||||||
|
|
||||||
@@ -13,5 +14,6 @@ void *__attribute__((weak)) pthread_self(void)
|
|||||||
int __libc_init(const struct rosetta_bootstrap *bsinfo)
|
int __libc_init(const struct rosetta_bootstrap *bsinfo)
|
||||||
{
|
{
|
||||||
(volatile void)pthread_self();
|
(volatile void)pthread_self();
|
||||||
|
__set_errno(SUCCESS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ int __fputc(int c, struct __opaque_file *stream)
|
|||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__set_errno(SUCCESS);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ static int ringbuf_init(struct ringbuf *buf)
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(buf->buf_ptr, 0x0, buf->buf_max);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
extern int __libc_fctprintf(
|
extern int __libc_fctprintf(
|
||||||
void (*out)(char character, void *arg),
|
int (*out)(char character, void *arg),
|
||||||
void *arg,
|
void *arg,
|
||||||
const char *format,
|
const char *format,
|
||||||
va_list va);
|
va_list va);
|
||||||
extern int __fputc(int c, struct __opaque_file *stream);
|
extern int __fputc(int c, struct __opaque_file *stream);
|
||||||
|
|
||||||
static inline void _out_file(char character, void *arg)
|
static inline int _out_file(char character, void *arg)
|
||||||
{
|
{
|
||||||
struct __opaque_file *fp = arg;
|
FILE *fp = arg;
|
||||||
__fputc(character, fp);
|
return __fputc(character, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vprintf(const char *format, va_list arg)
|
int vprintf(const char *format, va_list arg)
|
||||||
@@ -21,6 +22,13 @@ int vprintf(const char *format, va_list arg)
|
|||||||
__libc_file_lock(stdout);
|
__libc_file_lock(stdout);
|
||||||
|
|
||||||
int ret = __libc_fctprintf(_out_file, 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);
|
__libc_file_unlock(stdout);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ sysroot_add_library(
|
|||||||
HEADER_DIR /usr/include
|
HEADER_DIR /usr/include
|
||||||
LIB_DIR /usr/lib)
|
LIB_DIR /usr/lib)
|
||||||
|
|
||||||
|
bsp_add_library(
|
||||||
|
NAME libfs
|
||||||
|
LIB_DIR /usr/lib)
|
||||||
|
|
||||||
target_link_libraries(libfs libmango interface::fs libc libxpc)
|
target_link_libraries(libfs libmango interface::fs libc libxpc)
|
||||||
target_link_libraries(libfs-static libmango interface::fs libc-core libxpc-static)
|
target_link_libraries(libfs-static libmango interface::fs libc-core libxpc-static)
|
||||||
|
|
||||||
|
|||||||
+70
-16
@@ -197,9 +197,9 @@ static enum fs_status handle_msg(struct fs_context *ctx)
|
|||||||
return FS_SUCCESS;
|
return FS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum fs_status handle_page_request_detach(
|
static enum fs_status handle_vm_request_detach(
|
||||||
struct fs_context *ctx,
|
struct fs_context *ctx,
|
||||||
equeue_packet_page_request_t *packet,
|
equeue_packet_vm_request_t *packet,
|
||||||
struct file_mapping *mapping)
|
struct file_mapping *mapping)
|
||||||
{
|
{
|
||||||
if (!mapping) {
|
if (!mapping) {
|
||||||
@@ -210,7 +210,7 @@ static enum fs_status handle_page_request_detach(
|
|||||||
}
|
}
|
||||||
|
|
||||||
kern_tracef(
|
kern_tracef(
|
||||||
"received page request (detach) for file %s",
|
"received vm request (detach) for file %s",
|
||||||
mapping->m_file->f_dent->d_name);
|
mapping->m_file->f_dent->d_name);
|
||||||
|
|
||||||
struct fs_file *f = mapping->m_file;
|
struct fs_file *f = mapping->m_file;
|
||||||
@@ -229,16 +229,19 @@ static enum fs_status handle_page_request_detach(
|
|||||||
return FS_SUCCESS;
|
return FS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum fs_status handle_page_request_read(
|
static enum fs_status handle_vm_request_read(
|
||||||
struct fs_context *ctx,
|
struct fs_context *ctx,
|
||||||
equeue_packet_page_request_t *packet,
|
equeue_packet_vm_request_t *packet,
|
||||||
struct file_mapping *mapping)
|
struct file_mapping *mapping)
|
||||||
{
|
{
|
||||||
kern_tracef(
|
kern_tracef(
|
||||||
"received page request (read) [%zx-%zx] for file %s",
|
"received vm request (read) [%zx-%zx] for file %s",
|
||||||
packet->req_offset,
|
packet->req_offset,
|
||||||
packet->req_offset + packet->req_length,
|
packet->req_offset + packet->req_length,
|
||||||
mapping->m_file->f_dent->d_name);
|
mapping ? mapping->m_file->f_dent->d_name : "NULL");
|
||||||
|
if (!mapping) {
|
||||||
|
return FS_ERR_INTERNAL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
size_t length = packet->req_length;
|
size_t length = packet->req_length;
|
||||||
if (length > TEMP_OBJECT_SIZE) {
|
if (length > TEMP_OBJECT_SIZE) {
|
||||||
@@ -267,25 +270,76 @@ static enum fs_status handle_page_request_read(
|
|||||||
return FS_SUCCESS;
|
return FS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum fs_status handle_page_request(struct fs_context *ctx)
|
static enum fs_status handle_vm_request_attach(
|
||||||
|
struct fs_context *ctx,
|
||||||
|
equeue_packet_vm_request_t *packet)
|
||||||
{
|
{
|
||||||
equeue_packet_page_request_t packet;
|
struct file_mapping *src_mapping
|
||||||
|
= (struct file_mapping *)packet->req_src_vmo;
|
||||||
|
kern_logf(
|
||||||
|
"received attach request [%zx] for cow-duplicate of %s",
|
||||||
|
packet->req_id,
|
||||||
|
src_mapping->m_file->f_dent->d_name);
|
||||||
|
|
||||||
|
if (src_mapping->m_type == FILE_MAPPING_SHARED) {
|
||||||
|
kern_logf("cannot attach another shared mapping to file");
|
||||||
|
return FS_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
kern_handle_t new_vmo = KERN_HANDLE_INVALID;
|
||||||
|
kern_status_t status = vm_controller_prepare_attach(
|
||||||
|
ctx->ctx_vm_controller,
|
||||||
|
packet->req_id,
|
||||||
|
&new_vmo);
|
||||||
|
if (status != KERN_OK) {
|
||||||
|
kern_logf("vm_controller_prepare_attach failed (%d)", status);
|
||||||
|
return FS_ERR_INTERNAL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct file_mapping *new_mapping
|
||||||
|
= fs_context_alloc(ctx, sizeof *new_mapping);
|
||||||
|
if (!new_mapping) {
|
||||||
|
return FS_ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(new_mapping, 0x0, sizeof *new_mapping);
|
||||||
|
|
||||||
|
new_mapping->m_vmo = new_vmo;
|
||||||
|
new_mapping->m_type = src_mapping->m_type;
|
||||||
|
new_mapping->m_file = src_mapping->m_file;
|
||||||
|
queue_push_back(
|
||||||
|
&new_mapping->m_file->f_mappings,
|
||||||
|
&new_mapping->m_entry);
|
||||||
|
|
||||||
|
vm_controller_finish_attach(
|
||||||
|
ctx->ctx_vm_controller,
|
||||||
|
packet->req_id,
|
||||||
|
(equeue_key_t)new_mapping);
|
||||||
|
|
||||||
|
return FS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum fs_status handle_vm_request(struct fs_context *ctx)
|
||||||
|
{
|
||||||
|
equeue_packet_vm_request_t packet;
|
||||||
kern_status_t status
|
kern_status_t status
|
||||||
= vm_controller_recv(ctx->ctx_vm_controller, &packet);
|
= vm_controller_recv(ctx->ctx_vm_controller, &packet);
|
||||||
|
|
||||||
if (status != KERN_OK) {
|
if (status != KERN_OK) {
|
||||||
return KERN_BAD_STATE;
|
return FS_ERR_INTERNAL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct file_mapping *mapping = (struct file_mapping *)packet.req_vmo;
|
struct file_mapping *mapping = (struct file_mapping *)packet.req_vmo;
|
||||||
|
|
||||||
switch (packet.req_type) {
|
switch (packet.req_type) {
|
||||||
case PAGE_REQUEST_READ:
|
case VM_REQUEST_READ:
|
||||||
return handle_page_request_read(ctx, &packet, mapping);
|
return handle_vm_request_read(ctx, &packet, mapping);
|
||||||
case PAGE_REQUEST_DETACH:
|
case VM_REQUEST_DETACH:
|
||||||
return handle_page_request_detach(ctx, &packet, mapping);
|
return handle_vm_request_detach(ctx, &packet, mapping);
|
||||||
|
case VM_REQUEST_ATTACH:
|
||||||
|
return handle_vm_request_attach(ctx, &packet);
|
||||||
default:
|
default:
|
||||||
kern_logf("unknown page request type %zx", packet.req_type);
|
kern_logf("unknown vm request type %zx", packet.req_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FS_SUCCESS;
|
return FS_SUCCESS;
|
||||||
@@ -315,7 +369,7 @@ enum fs_status fs_context_handle_request(struct fs_context *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (waiters[1].w_observed & VM_CONTROLLER_SIGNAL_REQUEST_RECEIVED) {
|
if (waiters[1].w_observed & VM_CONTROLLER_SIGNAL_REQUEST_RECEIVED) {
|
||||||
return handle_page_request(ctx);
|
return handle_vm_request(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FS_SUCCESS;
|
return FS_SUCCESS;
|
||||||
|
|||||||
+1
-1
Submodule lib/libfx updated: 912c450e6e...cb39baa233
@@ -8,7 +8,7 @@ set(public_include_dirs
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
rosetta_add_library(
|
rosetta_add_library(
|
||||||
NAME liblaunch STATIC
|
NAME liblaunch SHARED STATIC
|
||||||
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
|
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
|
||||||
SOURCES ${sources}
|
SOURCES ${sources}
|
||||||
HEADERS ${headers})
|
HEADERS ${headers})
|
||||||
@@ -17,5 +17,9 @@ sysroot_add_library(
|
|||||||
NAME liblaunch
|
NAME liblaunch
|
||||||
HEADER_DIR /usr/include
|
HEADER_DIR /usr/include
|
||||||
LIB_DIR /usr/lib)
|
LIB_DIR /usr/lib)
|
||||||
|
bsp_add_library(
|
||||||
|
NAME liblaunch
|
||||||
|
LIB_DIR /usr/lib)
|
||||||
|
|
||||||
target_link_libraries(liblaunch PRIVATE librosetta libmango libc-core)
|
target_link_libraries(liblaunch-static PRIVATE librosetta libmango libc-core)
|
||||||
|
target_link_libraries(liblaunch PRIVATE librosetta libmango libc)
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ static int load_services(const char *dir, struct queue *out)
|
|||||||
printf("failed to load %s (%s)\n",
|
printf("failed to load %s (%s)\n",
|
||||||
filepath,
|
filepath,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
} else {
|
||||||
|
|
||||||
queue_push_back(out, &s->s_entry);
|
queue_push_back(out, &s->s_entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
closedir(d);
|
closedir(d);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
@@ -122,11 +122,14 @@ int main(int argc, const char *argv[], const char *envp[])
|
|||||||
|
|
||||||
if (new_task == KERN_HANDLE_INVALID) {
|
if (new_task == KERN_HANDLE_INVALID) {
|
||||||
kern_log("this is the child");
|
kern_log("this is the child");
|
||||||
|
long r = printf("hello\n");
|
||||||
|
kern_logf("printf returned %ld (%d)", r, (errno));
|
||||||
} else {
|
} else {
|
||||||
kern_log("this is the parent");
|
kern_log("this is the parent");
|
||||||
|
long r = printf("goodbye\n");
|
||||||
|
kern_logf("printf returned %ld (%d)", r, (errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("hello\n");
|
kern_logf("exiting (%s)", strerror(EFTYPE));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,8 +95,9 @@ int runlevel_load(const char *path, struct runlevel **out)
|
|||||||
fx_stream *in = fx_stream_open_fp(fp);
|
fx_stream *in = fx_stream_open_fp(fp);
|
||||||
fx_serial_ctx *ctx = fx_toml_serial_ctx_create();
|
fx_serial_ctx *ctx = fx_toml_serial_ctx_create();
|
||||||
fx_object *data;
|
fx_object *data;
|
||||||
fx_status status = fx_serial_ctx_deserialise(ctx, in, &data, 0);
|
fx_result result = fx_serial_ctx_deserialise(ctx, in, &data, 0);
|
||||||
if (!FX_OK(status)) {
|
if (fx_result_is_error(result)) {
|
||||||
|
fx_throw(result);
|
||||||
free(rl);
|
free(rl);
|
||||||
errno = EFTYPE;
|
errno = EFTYPE;
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ static int parse_service_data(fx_object *in, struct service *out)
|
|||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
fx_foreach_ptr(fx_string, role, it)
|
fx_foreach_ptr(fx_string, role, it)
|
||||||
{
|
{
|
||||||
const char *role_cstr = fx_string_ptr(role);
|
const char *role_cstr = fx_string_get_cstr(role);
|
||||||
if (!strcmp(role_cstr, "NamespaceProvider")) {
|
if (!strcmp(role_cstr, "NamespaceProvider")) {
|
||||||
out->s_roles |= SVC_ROLE_NAMESPACE_PROVIDER;
|
out->s_roles |= SVC_ROLE_NAMESPACE_PROVIDER;
|
||||||
}
|
}
|
||||||
@@ -107,8 +107,9 @@ int service_load(const char *path, struct service **out)
|
|||||||
fx_stream *in = fx_stream_open_fp(fp);
|
fx_stream *in = fx_stream_open_fp(fp);
|
||||||
fx_serial_ctx *ctx = fx_toml_serial_ctx_create();
|
fx_serial_ctx *ctx = fx_toml_serial_ctx_create();
|
||||||
fx_object *data;
|
fx_object *data;
|
||||||
fx_status status = fx_serial_ctx_deserialise(ctx, in, &data, 0);
|
fx_result result = fx_serial_ctx_deserialise(ctx, in, &data, 0);
|
||||||
if (!FX_OK(status)) {
|
if (fx_result_is_error(result)) {
|
||||||
|
fx_throw(result);
|
||||||
free(rl);
|
free(rl);
|
||||||
errno = EFTYPE;
|
errno = EFTYPE;
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ target_link_libraries(bootstrap
|
|||||||
libmango librosetta
|
libmango librosetta
|
||||||
libc-core libc-malloc libc-pthread
|
libc-core libc-malloc libc-pthread
|
||||||
libfs-static
|
libfs-static
|
||||||
liblaunch
|
liblaunch-static
|
||||||
libxpc-static
|
libxpc-static
|
||||||
interface::fs)
|
interface::fs)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -147,7 +147,7 @@ static int map_image(struct elf_image *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int fd = image->e_fd;
|
int fd = image->e_fd;
|
||||||
int flags = MAP_SHARED | MAP_EXECUTABLE | MAP_FIXED;
|
int flags = MAP_PRIVATE | MAP_EXECUTABLE | MAP_FIXED;
|
||||||
|
|
||||||
if (phdr.p_flags & PF_W) {
|
if (phdr.p_flags & PF_W) {
|
||||||
fd = -1;
|
fd = -1;
|
||||||
@@ -176,6 +176,7 @@ static int map_image(struct elf_image *image)
|
|||||||
if (phdr.p_flags & PF_W) {
|
if (phdr.p_flags & PF_W) {
|
||||||
lseek(image->e_fd, phdr.p_offset, SEEK_SET);
|
lseek(image->e_fd, phdr.p_offset, SEEK_SET);
|
||||||
void *dst = (void *)image->e_base + phdr.p_vaddr;
|
void *dst = (void *)image->e_base + phdr.p_vaddr;
|
||||||
|
memset(dst, 0x0, phdr.p_memsz);
|
||||||
r = read(image->e_fd, dst, phdr.p_filesz);
|
r = read(image->e_fd, dst, phdr.p_filesz);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
return -r;
|
return -r;
|
||||||
|
|||||||
@@ -184,6 +184,30 @@ static int link_images(const char *task_name, struct image_list *list)
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dump_loaded_images(struct image_list *list)
|
||||||
|
{
|
||||||
|
int status = SUCCESS;
|
||||||
|
struct image_list_iterator it;
|
||||||
|
image_list_iterator_begin(&it, list);
|
||||||
|
|
||||||
|
kern_log("------------");
|
||||||
|
kern_log("loaded images:");
|
||||||
|
while (it.it_leaf) {
|
||||||
|
struct elf_image *image
|
||||||
|
= QUEUE_CONTAINER(struct elf_image, e_leaf, it.it_leaf);
|
||||||
|
kern_logf(
|
||||||
|
"%s [%zx-%zx]",
|
||||||
|
it.it_leaf->l_name,
|
||||||
|
image->e_base,
|
||||||
|
image->e_base + image->e_length);
|
||||||
|
|
||||||
|
image_list_iterator_move_next(&it);
|
||||||
|
}
|
||||||
|
kern_logf("------------");
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int main(const struct rosetta_bootstrap *bs)
|
int main(const struct rosetta_bootstrap *bs)
|
||||||
{
|
{
|
||||||
kern_tracef("ld");
|
kern_tracef("ld");
|
||||||
@@ -241,6 +265,7 @@ int main(const struct rosetta_bootstrap *bs)
|
|||||||
image_list_iterator_move_next(&it);
|
image_list_iterator_move_next(&it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dump_loaded_images(&images);
|
||||||
kern_tracef("ld finished");
|
kern_tracef("ld finished");
|
||||||
struct rosetta_bootstrap exec_bsinfo;
|
struct rosetta_bootstrap exec_bsinfo;
|
||||||
memcpy(&exec_bsinfo, bs, sizeof exec_bsinfo);
|
memcpy(&exec_bsinfo, bs, sizeof exec_bsinfo);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
|||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||||
|
|
||||||
|
set(FX_STATIC 1)
|
||||||
find_package(FX REQUIRED COMPONENTS Core Ds Term Cmd Io)
|
find_package(FX REQUIRED COMPONENTS Core Ds Term Cmd Io)
|
||||||
|
|
||||||
add_subdirectory(
|
add_subdirectory(
|
||||||
|
|||||||
Reference in New Issue
Block a user