Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
00b3198
Add 'writev' syscall
jmi-reds Oct 7, 2025
cdaaf6d
writev - Fix error in error case
jmi-reds Oct 7, 2025
99a1429
Add 'readv' syscall
jmi-reds Oct 7, 2025
2919321
[syscall] Update readv & writev from comments in MR #207
jmi-reds Oct 8, 2025
580e00f
[syscall] readv & writev clean-up - MR #207
jmi-reds Oct 9, 2025
0c97a7f
Run format checking for branch 144-support-musl
jmi-reds Oct 9, 2025
d175143
Merge pull request #207 from smartobjectoriented/206-add-writev-syscall
jmi-reds Oct 9, 2025
361ac6e
[syscall] mmap: Add support for ANONYMOUS flag
jmi-reds Oct 9, 2025
4972c2b
[syscall] mmap: Define USER_ANONYMOUS_VADDR for 39bits case
jmi-reds Oct 9, 2025
2ec2066
[syscall] mmap: Define USER_ANONYMOUS_VADDR for arm32b
jmi-reds Oct 10, 2025
5088531
Merge pull request #210 from smartobjectoriented/209-mmap-anon
daniel-rossier Oct 10, 2025
09a9518
change syscall number to correct ones
clemdiep Aug 28, 2025
cc2016f
rename sbrk to brk
clemdiep Aug 28, 2025
0a74276
add dup3 simple implementation
clemdiep Aug 28, 2025
0759ba5
implement time32 version for clock_gettime and gettimeofday
clemdiep Sep 2, 2025
41b182a
wait4 and getdents
clemdiep Sep 2, 2025
81c4c7c
add mmap2 and openat
clemdiep Sep 2, 2025
fff4b8f
remove support for sysinfo
clemdiep Sep 25, 2025
d420d5b
add pipe2
clemdiep Sep 30, 2025
e0bcb8a
add rt_sig, fstatat and correct syscall table
clemdiep Sep 30, 2025
0890750
correction after rebase
clemdiep Oct 10, 2025
b91c366
remove unwanted comment in syscall_number
clemdiep Oct 10, 2025
c9ca020
correct syscall arguments and numbers
clemdiep Oct 10, 2025
a50e08c
cleanups
clemdiep Oct 13, 2025
9d8fd89
rename llseek to _llseek
clemdiep Oct 13, 2025
d0a7017
autogenerate syscall table
clemdiep Oct 13, 2025
bfed7e5
Merge pull request #212 from smartobjectoriented/211-align-existing-s…
clemdiep Oct 27, 2025
5c85496
Merge pull request #214 from smartobjectoriented/213-improve-syscall-…
clemdiep Oct 27, 2025
baaab35
fix sh to bash in script
clemdiep Oct 30, 2025
fb05db6
Add template for futex syscall
jmi-reds Nov 3, 2025
f991130
[futex] Initial implementation of FUTEX_WAIT cmd
jmi-reds Nov 4, 2025
756f5cf
[futex] Initial implementation of FUTEX_WAKE cmd
jmi-reds Nov 4, 2025
7a1e5c7
rework thread creation to match pthread
clemdiep Nov 3, 2025
539a7ed
[futex] Clean-up
jmi-reds Nov 7, 2025
d53c4e7
[futex] fix clang-format
jmi-reds Nov 7, 2025
5746fa6
Remove "mutex" syscalls
jmi-reds Nov 10, 2025
7bf1139
fix style and missing comments
clemdiep Nov 10, 2025
ab43bbc
[futex] clean-up based on code review
jmi-reds Nov 10, 2025
027d7b5
[futex] Fix typo introduced in previous commit
jmi-reds Nov 10, 2025
37a2f1a
Merge pull request #218 from smartobjectoriented/215-rework-thread
clemdiep Nov 11, 2025
8be034c
[futex] make clearer the search of key in lists
jmi-reds Nov 11, 2025
774b56e
Merge pull request #221 from smartobjectoriented/217-implementation-o…
jmi-reds Nov 17, 2025
4326e00
remove ptrace support
clemdiep Nov 10, 2025
e3ca710
implement child tid behavior
clemdiep Nov 5, 2025
d6d9fe3
Merge pull request #223 from smartobjectoriented/222-remove-ptrace-su…
clemdiep Nov 18, 2025
02c1b64
Merge pull request #224 from smartobjectoriented/219-set_tid_address
clemdiep Nov 18, 2025
dfb33b8
rework args/env setup to add aux values
clemdiep Nov 19, 2025
3d0c2a7
fix futex miss call
clemdiep Nov 19, 2025
6749de8
small improvement
clemdiep Nov 19, 2025
2fb1707
fix clang-format from copied files
clemdiep Nov 19, 2025
fb8d6d1
Merge pull request #228 from smartobjectoriented/220-add-aux-array
clemdiep Nov 20, 2025
26b9b8c
fix brk implementation
clemdiep Nov 19, 2025
f66696c
Merge pull request #229 from smartobjectoriented/225-fix-brk-syscall
clemdiep Nov 20, 2025
fa7e4a7
change default heap base address to be after the program
clemdiep Nov 19, 2025
d0bd3e6
Merge pull request #230 from smartobjectoriented/226-rework-elf-loading
clemdiep Dec 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
branches: ["main", "144-support-musl"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to remove this change before merging


jobs:
formatting-check:
Expand Down
3 changes: 3 additions & 0 deletions so3/arch/arm32/include/asm/syscall_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@
#define SYSCALL_SETSOCKOPT 110
#define SYSCALL_RECVFROM 111

#define SYSCALL_READV 145
#define SYSCALL_WRITEV 146

#endif /* ARCH_ARM32_SYSCALL_NUMBER_H */
3 changes: 3 additions & 0 deletions so3/arch/arm64/include/asm/syscall_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
#define SYSCALL_MUTEX_LOCK 60
#define SYSCALL_MUTEX_UNLOCK 61

#define SYSCALL_READV 65
#define SYSCALL_WRITEV 66

#define SYSCALL_NANOSLEEP 70

#define SYSCALL_SYSINFO 99
Expand Down
2 changes: 1 addition & 1 deletion so3/devices/serial/pl011.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static irq_return_t pl011_int(int irq, void *dummy)

#ifdef CONFIG_IPC_SIGNAL
if (current()->pcb != NULL)
do_kill(current()->pcb->pid, SIGINT);
sys_do_kill(current()->pcb->pid, SIGINT);
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions so3/fs/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ uint8_t *elf_load_buffer(const char *filename)
struct stat st;

/* open and read file */
fd = do_open(filename, O_RDONLY);
fd = sys_do_open(filename, O_RDONLY);

if (fd < 0)
return NULL;

if (do_stat(filename, &st))
if (sys_do_stat(filename, &st))
return NULL;

if (!st.st_size)
Expand All @@ -52,9 +52,9 @@ uint8_t *elf_load_buffer(const char *filename)
return NULL;
}

do_read(fd, buffer, st.st_size);
sys_do_read(fd, buffer, st.st_size);

do_close(fd);
sys_do_close(fd);

return buffer;
}
Expand Down
75 changes: 69 additions & 6 deletions so3/fs/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ int vfs_clone_fd(int *fd_src, int *fd_dst)

/**************************** Syscall implementation ****************************/

SYSCALL_DEFINE3(read, int, fd, void *, buffer, int, count)
/* Low Level read */
static int do_read(int fd, void *buffer, int count)
{
int gfd;
int ret;
Expand Down Expand Up @@ -421,10 +422,8 @@ SYSCALL_DEFINE3(read, int, fd, void *, buffer, int, count)
return ret;
}

/**
* @brief This function writes a REGULAR FILE/FOLDER. It only support regular file, dirs and pipes
*/
SYSCALL_DEFINE3(write, int, fd, const void *, buffer, int, count)
/* Low Level write */
static int do_write(int fd, const void *buffer, int count)
{
int gfd;
int ret;
Expand Down Expand Up @@ -464,6 +463,19 @@ SYSCALL_DEFINE3(write, int, fd, const void *, buffer, int, count)
return ret;
}

SYSCALL_DEFINE3(read, int, fd, void *, buffer, int, count)
{
return do_read(fd, buffer, count);
}

/**
* @brief This function writes a REGULAR FILE/FOLDER. It only support regular file, dirs and pipes
*/
SYSCALL_DEFINE3(write, int, fd, const void *, buffer, int, count)
{
return do_write(fd, buffer, count);
}

/**
* @brief This function opens a file. Not all file types are supported.
*/
Expand Down Expand Up @@ -655,7 +667,7 @@ SYSCALL_DEFINE2(dup2, int, oldfd, int, newfd)
}

if (vfs_get_gfd(oldfd) != vfs_get_gfd(newfd))
do_close(newfd);
sys_do_close(newfd);

vfs_link_fd(newfd, vfs_get_gfd(oldfd));

Expand Down Expand Up @@ -824,6 +836,57 @@ SYSCALL_DEFINE3(fcntl, int, fd, unsigned long, cmd, unsigned long, args)
return 0;
}

/*
* Implementation of the writev syscall
*/
SYSCALL_DEFINE3(writev, unsigned long, fd, const struct iovec *, vec, unsigned long, vlen)
{
int i;
int ret = 0;
int total = 0;

for (i = 0; i < vlen; i++) {
ret = do_write(fd, (const void *) vec[i].iov_base, vec[i].iov_len);
if (ret < 0) {
break;
} else if ((ret >= 0) && (ret < vec[i].iov_len)) {
total += ret;
break;
}

total += ret;
}

if (total == 0)
return ret;
else
return total;
}

SYSCALL_DEFINE3(readv, unsigned long, fd, const struct iovec *, vec, unsigned long, vlen)
{
int i;
int ret = 0;
int total = 0;

for (i = 0; i < vlen; i++) {
ret = do_read(fd, vec[i].iov_base, vec[i].iov_len);
if (ret < 0) {
break;
} else if ((ret >= 0) && (ret < vec[i].iov_len)) {
total += ret;
break;
}

total += ret;
}

if (total == 0)
return ret;
else
return total;
}

static void vfs_gfd_init(void)
{
memset(open_fds, 0, MAX_FDS * sizeof(struct fd *));
Expand Down
20 changes: 10 additions & 10 deletions so3/include/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,33 @@
* __sys_SYSCALL_NAME taking syscall_args_t as arguments allowing for
* a common interface between all syscall to put them in an array.
*
* do_SYSCALL_NAME actual function with the syscall implementation with
* sys_do_SYSCALL_NAME actual function with the syscall implementation with
* arguments define like a normal function. That function is automatically
* called by __sys_SYCALL_NAME with the correct argument number and cast.
*/
#define SYSCALL_DECLARE(name, ...) \
long __sys_##name(syscall_args_t *args); \
inline long do_##name(__VA_ARGS__);
inline long sys_do_##name(__VA_ARGS__);

#define SYSCALL_DEFINE0(name) \
long __sys_##name(syscall_args_t *unused) \
{ \
return do_##name(); \
return sys_do_##name(); \
} \
inline long do_##name(void)
inline long sys_do_##name(void)
#define SYSCALL_DEFINE1(...) __SYSCALL_DEFINEx(1, __VA_ARGS__)
#define SYSCALL_DEFINE2(...) __SYSCALL_DEFINEx(2, __VA_ARGS__)
#define SYSCALL_DEFINE3(...) __SYSCALL_DEFINEx(3, __VA_ARGS__)
#define SYSCALL_DEFINE4(...) __SYSCALL_DEFINEx(4, __VA_ARGS__)
#define SYSCALL_DEFINE5(...) __SYSCALL_DEFINEx(5, __VA_ARGS__)
#define SYSCALL_DEFINE6(...) __SYSCALL_DEFINEx(6, __VA_ARGS__)

#define __SYSCALL_DEFINEx(x, name, ...) \
long __sys_##name(syscall_args_t *args) \
{ \
return do_##name(__MAP_ARGS(x, args->args, __VA_ARGS__)); \
} \
inline long do_##name(__MAP(x, __M_DECL, __VA_ARGS__))
#define __SYSCALL_DEFINEx(x, name, ...) \
long __sys_##name(syscall_args_t *args) \
{ \
return sys_do_##name(__MAP_ARGS(x, args->args, __VA_ARGS__)); \
} \
inline long sys_do_##name(__MAP(x, __M_DECL, __VA_ARGS__))

typedef struct {
unsigned long args[6];
Expand Down
9 changes: 9 additions & 0 deletions so3/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@

#include <device/device.h>

struct iovec {
void *iov_base;
size_t iov_len;
};

#define iovec iovec

struct file_operations {
int (*open)(int fd, const char *path);
int (*close)(int fd);
Expand Down Expand Up @@ -162,6 +169,8 @@ SYSCALL_DECLARE(mmap, addr_t start, size_t length, int prot, int fd, off_t offse
SYSCALL_DECLARE(ioctl, int fd, unsigned long cmd, unsigned long args);
SYSCALL_DECLARE(fcntl, int fd, unsigned long cmd, unsigned long args);
SYSCALL_DECLARE(lseek, int fd, off_t off, int whence);
SYSCALL_DECLARE(writev, unsigned long fd, const struct iovec *vec, unsigned long vlen);
SYSCALL_DECLARE(readv, unsigned long fd, const struct iovec *vec, unsigned long vlen);

/* VFS common interface */

Expand Down
4 changes: 2 additions & 2 deletions so3/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ SYSCALL_DEFINE1(exit, int, exit_status)
* locking in the low layers. */

for (i = 0; i < FD_MAX; i++)
do_close(i);
sys_do_close(i);

local_irq_disable();

Expand All @@ -944,7 +944,7 @@ SYSCALL_DEFINE1(exit, int, exit_status)
#ifdef CONFIG_IPC_SIGNAL

/* Send the SIGCHLD signal to the parent */
do_kill(pcb->parent->pid, SIGCHLD);
sys_do_kill(pcb->parent->pid, SIGCHLD);

#endif /* CONFIG_IPC_SIGNAL */

Expand Down
2 changes: 2 additions & 0 deletions so3/kernel/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ static const syscall_fn_t syscall_table[NR_SYSCALLS] = {
[SYSCALL_IOCTL] = __sys_ioctl,
[SYSCALL_FCNTL] = __sys_fcntl,
[SYSCALL_LSEEK] = __sys_lseek,
[SYSCALL_READV] = __sys_readv,
[SYSCALL_WRITEV] = __sys_writev,
#ifdef CONFIG_IPC_PIPE
[SYSCALL_PIPE] = __sys_pipe,
#endif
Expand Down
2 changes: 1 addition & 1 deletion so3/kernel/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void thread_exit(int *exit_status)
remove_tcb_from_pcb(current());

#ifdef CONFIG_PROC_ENV
do_exit(0);
sys_do_exit(0);
#endif

} else {
Expand Down
4 changes: 2 additions & 2 deletions so3/net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ SYSCALL_DEFINE3(socket, int, domain, int, type, int, protocol)
lwip_fd = lwip_socket(domain, type, protocol);

if (lwip_fd < 0) {
do_close(fd);
sys_do_close(fd);
return lwip_return(lwip_fd);
}

Expand Down Expand Up @@ -505,7 +505,7 @@ SYSCALL_DEFINE3(accept, int, sockfd, struct sockaddr *, addr, socklen_t *, addrl
lwip_bind_fd = lwip_accept(lwip_fd, addr_ptr, addrlen);

if (lwip_bind_fd < 0) {
do_close(fd);
sys_do_close(fd);
return lwip_return(lwip_bind_fd);
}

Expand Down