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)
|
||||
|
||||
include(CheckPIESupported)
|
||||
|
||||
+11
-10
@@ -78,16 +78,6 @@ if (LLDB)
|
||||
USES_TERMINAL
|
||||
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)
|
||||
message(STATUS "QEMU: Enable CD-ROM debug with LLDB")
|
||||
add_custom_target(debug-cdrom
|
||||
@@ -132,3 +122,14 @@ elseif (GDB)
|
||||
DEPENDS ${image_cdrom})
|
||||
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)
|
||||
message(STATUS "GRUB: Found grub-mkrescue. Bootable CD-ROM image creation is enabled")
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
# 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
|
||||
display_library: sdl2
|
||||
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
|
||||
floppy_bootsig_check: disabled=0
|
||||
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
|
||||
debugger_log: -
|
||||
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
|
||||
private_colormap: enabled=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
|
||||
parport1: enabled=true, file=none
|
||||
parport2: enabled=false
|
||||
com1: enabled=true, mode=null
|
||||
com1: enabled=true, mode=file, dev=kernel.log
|
||||
com2: enabled=false
|
||||
com3: enabled=false
|
||||
com4: enabled=false
|
||||
|
||||
@@ -24,13 +24,10 @@ def successful_boot(boot_log, out):
|
||||
log(out, "Kernel rebooted during test!")
|
||||
return 1
|
||||
|
||||
nr_finish = boot_log.count("ld finished")
|
||||
if nr_finish == 0:
|
||||
nr_finish = boot_log.count("exiting (Inappropriate file type or format)")
|
||||
if nr_finish != 2:
|
||||
log(out, "Didn't reach end of boot sequence!")
|
||||
return 1
|
||||
if nr_finish > 1:
|
||||
log(out, "Boot sequence performed multiple times!")
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -34,15 +34,10 @@ initrd=$5
|
||||
while true; do
|
||||
log "Test $count"
|
||||
result_file="$log_dir/$count.log"
|
||||
$qemu \
|
||||
-kernel $kernel \
|
||||
-initrd $initrd \
|
||||
-serial file:$result_file \
|
||||
-cpu qemu64,+rdrand \
|
||||
--append kernel.early-console=ttyS0 -s > /dev/null &
|
||||
ninja run-cdrom-bochs > $result_file &
|
||||
qemu_id=$!
|
||||
|
||||
sleep 1.2
|
||||
sleep 5
|
||||
|
||||
$python $validation_script successful-boot $result_file $logfile
|
||||
result=$?
|
||||
@@ -54,12 +49,9 @@ while true; do
|
||||
else
|
||||
mv $result_file "$result_file.FAIL"
|
||||
fail=$fail+1
|
||||
lldb \
|
||||
-o "file kernel/mango_kernel.debug" \
|
||||
-o "gdb-remote localhost:1234"
|
||||
fi
|
||||
|
||||
kill -INT $qemu_id
|
||||
killall -9 bochs
|
||||
|
||||
log "---------------"
|
||||
log "Total tests: $count"
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
menuentry "Rosetta" {
|
||||
multiboot /boot/mango_kernel
|
||||
module /boot/rosetta-system.bsp
|
||||
boot
|
||||
}
|
||||
set timeout_style=menu
|
||||
set timeout=0
|
||||
|
||||
menuentry "Rosetta (Serial Log)" {
|
||||
multiboot /boot/mango_kernel kernel.early-console=ttyS0
|
||||
|
||||
+1
-1
Submodule kernel updated: b92542c688...bc575aa1a1
@@ -1,7 +1,7 @@
|
||||
#include <errno.h>
|
||||
#include <mango/status.h>
|
||||
|
||||
static int __errno = 32;
|
||||
static int __errno = SUCCESS;
|
||||
|
||||
int __attribute__((weak)) * __errno_location(void)
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
#endif
|
||||
|
||||
// output function type
|
||||
typedef void (
|
||||
typedef int (
|
||||
*out_fct_type)(char character, void *buffer, size_t idx, size_t maxlen);
|
||||
|
||||
// wrapper (used as buffer) for output function type
|
||||
@@ -128,7 +128,7 @@ typedef struct {
|
||||
} out_fct_wrap_type;
|
||||
|
||||
// internal buffer output
|
||||
static inline void _out_buffer(
|
||||
static inline int _out_buffer(
|
||||
char character,
|
||||
void *buffer,
|
||||
size_t idx,
|
||||
@@ -137,10 +137,12 @@ static inline void _out_buffer(
|
||||
if (idx < maxlen) {
|
||||
((char *)buffer)[idx] = character;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// internal null output
|
||||
static inline void _out_null(
|
||||
static inline int _out_null(
|
||||
char character,
|
||||
void *buffer,
|
||||
size_t idx,
|
||||
@@ -150,10 +152,11 @@ static inline void _out_null(
|
||||
(void)buffer;
|
||||
(void)idx;
|
||||
(void)maxlen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// internal output function wrapper
|
||||
static inline void _out_fct(
|
||||
static inline int _out_fct(
|
||||
char character,
|
||||
void *buffer,
|
||||
size_t idx,
|
||||
@@ -166,6 +169,8 @@ static inline void _out_fct(
|
||||
((out_fct_wrap_type *)buffer)
|
||||
->fct(character, ((out_fct_wrap_type *)buffer)->arg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// internal secure strlen
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <mango/log.h>
|
||||
#include <rosetta/bootstrap.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
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)
|
||||
{
|
||||
(volatile void)pthread_self();
|
||||
__set_errno(SUCCESS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ int __fputc(int c, struct __opaque_file *stream)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
__set_errno(SUCCESS);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ static int ringbuf_init(struct ringbuf *buf)
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
memset(buf->buf_ptr, 0x0, buf->buf_max);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
#include "file.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int __libc_fctprintf(
|
||||
void (*out)(char character, void *arg),
|
||||
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 void _out_file(char character, void *arg)
|
||||
static inline int _out_file(char character, void *arg)
|
||||
{
|
||||
struct __opaque_file *fp = arg;
|
||||
__fputc(character, fp);
|
||||
FILE *fp = arg;
|
||||
return __fputc(character, fp);
|
||||
}
|
||||
|
||||
int vprintf(const char *format, va_list arg)
|
||||
@@ -21,6 +22,13 @@ int vprintf(const char *format, va_list arg)
|
||||
__libc_file_lock(stdout);
|
||||
|
||||
int ret = __libc_fctprintf(_out_file, stdout, format, arg);
|
||||
if (errno != SUCCESS) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (ferror(stdout)) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
__libc_file_unlock(stdout);
|
||||
return ret;
|
||||
|
||||
@@ -23,6 +23,10 @@ sysroot_add_library(
|
||||
HEADER_DIR /usr/include
|
||||
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-static libmango interface::fs libc-core libxpc-static)
|
||||
|
||||
|
||||
+71
-17
@@ -197,20 +197,20 @@ static enum fs_status handle_msg(struct fs_context *ctx)
|
||||
return FS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum fs_status handle_page_request_detach(
|
||||
static enum fs_status handle_vm_request_detach(
|
||||
struct fs_context *ctx,
|
||||
equeue_packet_page_request_t *packet,
|
||||
equeue_packet_vm_request_t *packet,
|
||||
struct file_mapping *mapping)
|
||||
{
|
||||
if (!mapping) {
|
||||
kern_logf(
|
||||
"received DETACH request from VMO with no associated "
|
||||
"mapping");
|
||||
"mapping");
|
||||
return FS_ERR_INTERNAL_FAILURE;
|
||||
}
|
||||
|
||||
kern_tracef(
|
||||
"received page request (detach) for file %s",
|
||||
"received vm request (detach) for file %s",
|
||||
mapping->m_file->f_dent->d_name);
|
||||
|
||||
struct fs_file *f = mapping->m_file;
|
||||
@@ -229,16 +229,19 @@ static enum fs_status handle_page_request_detach(
|
||||
return FS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum fs_status handle_page_request_read(
|
||||
static enum fs_status handle_vm_request_read(
|
||||
struct fs_context *ctx,
|
||||
equeue_packet_page_request_t *packet,
|
||||
equeue_packet_vm_request_t *packet,
|
||||
struct file_mapping *mapping)
|
||||
{
|
||||
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_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;
|
||||
if (length > TEMP_OBJECT_SIZE) {
|
||||
@@ -267,25 +270,76 @@ static enum fs_status handle_page_request_read(
|
||||
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
|
||||
= vm_controller_recv(ctx->ctx_vm_controller, &packet);
|
||||
|
||||
if (status != KERN_OK) {
|
||||
return KERN_BAD_STATE;
|
||||
return FS_ERR_INTERNAL_FAILURE;
|
||||
}
|
||||
|
||||
struct file_mapping *mapping = (struct file_mapping *)packet.req_vmo;
|
||||
|
||||
switch (packet.req_type) {
|
||||
case PAGE_REQUEST_READ:
|
||||
return handle_page_request_read(ctx, &packet, mapping);
|
||||
case PAGE_REQUEST_DETACH:
|
||||
return handle_page_request_detach(ctx, &packet, mapping);
|
||||
case VM_REQUEST_READ:
|
||||
return handle_vm_request_read(ctx, &packet, mapping);
|
||||
case VM_REQUEST_DETACH:
|
||||
return handle_vm_request_detach(ctx, &packet, mapping);
|
||||
case VM_REQUEST_ATTACH:
|
||||
return handle_vm_request_attach(ctx, &packet);
|
||||
default:
|
||||
kern_logf("unknown page request type %zx", packet.req_type);
|
||||
kern_logf("unknown vm request type %zx", packet.req_type);
|
||||
break;
|
||||
}
|
||||
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) {
|
||||
return handle_page_request(ctx);
|
||||
return handle_vm_request(ctx);
|
||||
}
|
||||
|
||||
return FS_SUCCESS;
|
||||
|
||||
+1
-1
Submodule lib/libfx updated: 912c450e6e...cb39baa233
@@ -8,7 +8,7 @@ set(public_include_dirs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
rosetta_add_library(
|
||||
NAME liblaunch STATIC
|
||||
NAME liblaunch SHARED STATIC
|
||||
PUBLIC_INCLUDE_DIRS ${public_include_dirs}
|
||||
SOURCES ${sources}
|
||||
HEADERS ${headers})
|
||||
@@ -17,5 +17,9 @@ sysroot_add_library(
|
||||
NAME liblaunch
|
||||
HEADER_DIR /usr/include
|
||||
LIB_DIR /usr/lib)
|
||||
bsp_add_library(
|
||||
NAME liblaunch
|
||||
LIB_DIR /usr/lib)
|
||||
|
||||
target_link_libraries(liblaunch PRIVATE librosetta libmango libc-core)
|
||||
target_link_libraries(liblaunch-static PRIVATE librosetta libmango libc-core)
|
||||
target_link_libraries(liblaunch PRIVATE librosetta libmango libc)
|
||||
|
||||
@@ -50,9 +50,9 @@ static int load_services(const char *dir, struct queue *out)
|
||||
printf("failed to load %s (%s)\n",
|
||||
filepath,
|
||||
strerror(errno));
|
||||
} else {
|
||||
queue_push_back(out, &s->s_entry);
|
||||
}
|
||||
|
||||
queue_push_back(out, &s->s_entry);
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
@@ -122,11 +122,14 @@ int main(int argc, const char *argv[], const char *envp[])
|
||||
|
||||
if (new_task == KERN_HANDLE_INVALID) {
|
||||
kern_log("this is the child");
|
||||
long r = printf("hello\n");
|
||||
kern_logf("printf returned %ld (%d)", r, (errno));
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -95,8 +95,9 @@ int runlevel_load(const char *path, struct runlevel **out)
|
||||
fx_stream *in = fx_stream_open_fp(fp);
|
||||
fx_serial_ctx *ctx = fx_toml_serial_ctx_create();
|
||||
fx_object *data;
|
||||
fx_status status = fx_serial_ctx_deserialise(ctx, in, &data, 0);
|
||||
if (!FX_OK(status)) {
|
||||
fx_result result = fx_serial_ctx_deserialise(ctx, in, &data, 0);
|
||||
if (fx_result_is_error(result)) {
|
||||
fx_throw(result);
|
||||
free(rl);
|
||||
errno = EFTYPE;
|
||||
return -1;
|
||||
|
||||
@@ -76,7 +76,7 @@ static int parse_service_data(fx_object *in, struct service *out)
|
||||
size_t i = 0;
|
||||
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")) {
|
||||
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_serial_ctx *ctx = fx_toml_serial_ctx_create();
|
||||
fx_object *data;
|
||||
fx_status status = fx_serial_ctx_deserialise(ctx, in, &data, 0);
|
||||
if (!FX_OK(status)) {
|
||||
fx_result result = fx_serial_ctx_deserialise(ctx, in, &data, 0);
|
||||
if (fx_result_is_error(result)) {
|
||||
fx_throw(result);
|
||||
free(rl);
|
||||
errno = EFTYPE;
|
||||
return -1;
|
||||
|
||||
@@ -7,7 +7,7 @@ target_link_libraries(bootstrap
|
||||
libmango librosetta
|
||||
libc-core libc-malloc libc-pthread
|
||||
libfs-static
|
||||
liblaunch
|
||||
liblaunch-static
|
||||
libxpc-static
|
||||
interface::fs)
|
||||
|
||||
|
||||
+5
-4
@@ -126,9 +126,9 @@ static int map_image(struct elf_image *image)
|
||||
int prot = 0;
|
||||
size_t offset = phdr.p_offset & ~PAGE_MASK;
|
||||
|
||||
phdr.p_flags &PF_R && (prot |= PROT_READ);
|
||||
phdr.p_flags &PF_W && (prot |= PROT_WRITE);
|
||||
phdr.p_flags &PF_X && (prot |= PROT_EXEC);
|
||||
phdr.p_flags & PF_R && (prot |= PROT_READ);
|
||||
phdr.p_flags & PF_W && (prot |= PROT_WRITE);
|
||||
phdr.p_flags & PF_X && (prot |= PROT_EXEC);
|
||||
|
||||
virt_addr_t vaddr = phdr.p_vaddr;
|
||||
virt_addr_t vlimit = phdr.p_vaddr + phdr.p_memsz;
|
||||
@@ -147,7 +147,7 @@ static int map_image(struct elf_image *image)
|
||||
}
|
||||
|
||||
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) {
|
||||
fd = -1;
|
||||
@@ -176,6 +176,7 @@ static int map_image(struct elf_image *image)
|
||||
if (phdr.p_flags & PF_W) {
|
||||
lseek(image->e_fd, phdr.p_offset, SEEK_SET);
|
||||
void *dst = (void *)image->e_base + phdr.p_vaddr;
|
||||
memset(dst, 0x0, phdr.p_memsz);
|
||||
r = read(image->e_fd, dst, phdr.p_filesz);
|
||||
if (r < 0) {
|
||||
return -r;
|
||||
|
||||
@@ -184,6 +184,30 @@ static int link_images(const char *task_name, struct image_list *list)
|
||||
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)
|
||||
{
|
||||
kern_tracef("ld");
|
||||
@@ -241,6 +265,7 @@ int main(const struct rosetta_bootstrap *bs)
|
||||
image_list_iterator_move_next(&it);
|
||||
}
|
||||
|
||||
dump_loaded_images(&images);
|
||||
kern_tracef("ld finished");
|
||||
struct rosetta_bootstrap 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_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||
|
||||
set(FX_STATIC 1)
|
||||
find_package(FX REQUIRED COMPONENTS Core Ds Term Cmd Io)
|
||||
|
||||
add_subdirectory(
|
||||
|
||||
Reference in New Issue
Block a user