utest: add syscall test

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-19 21:43:37 -04:00
commit 7cc7da0f54
3 changed files with 52 additions and 2 deletions

View file

@ -1,6 +1,34 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <stdint.h>
#include <stddef.h>
typedef uint64_t off_t;
int open(const char *path, int flags);
int close(int fd);
int read(int fd, void *buf, size_t nbyte);
int write(int fd, void *buf, size_t nbyte);
int pread(int fd, void *buf, size_t nbyte, off_t offset);
int pwrite(int fd, void *buf, size_t nbyte, off_t offset);
size_t strlen(const char *c)
{
const char *b = c;
while (*b)
b++;
return b - c;
}
void _start()
{
int fd = open("/dev/ttyS0", 0);
if (fd < 0)
goto loop;
char msg[] = "Hello, userspace!\n";
write(fd, msg, strlen(msg));
loop:
while (1)
(void)0;
continue;
}