--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Alexander Jung <a.jung@lancs.ac.uk>
+ *
+ * Copyright (c) 2021, Lancaster University. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __LINUXU_MODE_H__
+#define __LINUXU_MODE_H__
+
+typedef unsigned int k_mode_t;
+
+#define K_O_RDONLY 0x0000
+
+#endif /* __LINUXU_MODE_H__ */
#include <sys/types.h>
+struct liblinuxuplat_memregion {
+ void *base;
+ size_t len;
+};
+
struct liblinuxuplat_opts {
+ struct liblinuxuplat_memregion heap;
+ struct liblinuxuplat_memregion initrd;
struct {
void *base;
size_t len;
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Alexander Jung <a.jung@lancs.ac.uk>
+ *
+ * Copyright (c) 2021, Lancaster University. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __LINUXU_STAT_H__
+#define __LINUXU_STAT_H__
+
+#include <linuxu/time.h>
+#include <linuxu/mode.h>
+
+typedef __u64 k_dev_t;
+typedef __u64 k_ino_t;
+typedef __u32 k_nlink_t;
+typedef unsigned int k_uid_t;
+typedef unsigned int k_gid_t;
+typedef unsigned int k_id_t;
+typedef __off k_off_t;
+typedef long k_blksize_t;
+typedef __s64 k_blkcnt_t;
+
+
+struct k_stat {
+ k_dev_t st_dev;
+ k_ino_t st_ino;
+ k_nlink_t st_nlink;
+ k_mode_t st_mode;
+ k_uid_t st_uit;
+ k_gid_t st_gid;
+
+ unsigned int __pad0;
+
+ k_dev_t st_rdev;
+ k_off_t st_size;
+ k_blksize_t st_blksize;
+ k_blkcnt_t st_blocks;
+
+ struct k_timespec st_atim;
+ struct k_timespec st_mtim;
+ struct k_timespec st_ctim;
+};
+
+#endif /* __LINUXU_STAT_H__ */
#define __SC_MUNMAP 91
#define __SC_EXIT 1
#define __SC_IOCTL 54
+#define __SC_FSTAT 108
#define __SC_RT_SIGPROCMASK 126
#define __SC_ARCH_PRCTL 172
#define __SC_RT_SIGACTION 174
#define __SC_WRITE 1
#define __SC_OPEN 2
#define __SC_CLOSE 3
+#define __SC_FSTAT 5
#define __SC_MMAP 9
#define __SC_MUNMAP 11
#define __SC_RT_SIGACTION 13
#define __SYSCALL_H__
#include <linuxu/time.h>
+#include <linuxu/stat.h>
+#include <linuxu/mode.h>
#include <sys/types.h>
#include <linuxu/signal.h>
#error "Unsupported architecture"
#endif
+static inline int sys_open(const char *pathname, int flags, k_mode_t mode)
+{
+ return (int)syscall3(__SC_OPEN,
+ (long) (pathname),
+ (long) (flags),
+ (long) (mode));
+}
+
+static inline int sys_close(int fd)
+{
+ return (int)syscall1(__SC_CLOSE,
+ (long) (fd));
+}
+
static inline ssize_t sys_read(int fd, const char *buf, size_t len)
{
return (ssize_t) syscall3(__SC_READ,
(long) (len));
}
+struct stat;
+static inline int sys_fstat(int fd, struct k_stat *statbuf)
+{
+ return (int)syscall2(__SC_FSTAT,
+ (long)(fd),
+ (long)(statbuf));
+}
+
static inline int sys_exit(int status)
{
return (int) syscall1(__SC_EXIT,
* Please note that on failure sys_mmap() is returning -errno
*/
#define MAP_SHARED (0x01)
+#define MAP_PRIVATE (0x02)
#define MAP_ANONYMOUS (0x20)
#define PROT_NONE (0x0)
#define PROT_READ (0x1)