sysdeps/qword: Add sysdeps for qword

This commit is contained in:
Alexander van der Grinten 2018-11-17 16:05:57 +01:00
parent 814834f000
commit e1dbe62621
4 changed files with 142 additions and 1 deletions

View file

@ -11,7 +11,14 @@ libc_sources = [ ]
disable_posix_option = false
disable_linux_option = false
subdir('sysdeps/managarm')
# Process sysdeps first, as sysdeps might want to disable unsupported options.
if host_machine.system() == 'managarm'
subdir('sysdeps/managarm')
elif host_machine.system() == 'qword'
subdir('sysdeps/qword')
else
error('No sysdeps defined for OS: ' + host_machine.system())
endif
internal_incl = include_directories('options/internal/include')
internal_sources = [

View file

@ -0,0 +1,98 @@
#include <bits/ensure.h>
#include <mlibc/debug.hpp>
#include <mlibc/sysdeps.hpp>
namespace mlibc {
void sys_libc_log(const char *message) {
unsigned long res;
asm volatile ("syscall" : "=a"(res)
: "a"(0), "D"(0), "S"(message)
: "rcx", "r11");
}
void sys_libc_panic() {
__builtin_trap();
}
int sys_tcb_set(void *pointer) {
return -1;
}
int sys_anon_allocate(size_t size, void **pointer) {
// The qword kernel wants us to allocate whole pages.
__ensure(!(size & 0xFFF));
void *res;
asm volatile ("syscall" : "=a"(res)
: "a"(6), "D"(0), "S"(size >> 12)
: "rcx", "r11");
if(!res)
return -1;
*pointer = res;
return 0;
}
int sys_anon_free(void *pointer, size_t size) {
return -1;
}
#ifndef MLIBC_BUILDING_RTDL
void sys_exit(int status) {
__builtin_trap();
}
#endif
#ifndef MLIBC_BUILDING_RTDL
int sys_clock_get(int clock, time_t *secs, long *nanos) {
return -1;
}
#endif
int sys_open(const char *path, int flags, int *fd) {
return -1;
}
int sys_close(int fd) {
return -1;
}
int sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read) {
return -1;
}
#ifndef MLIBC_BUILDING_RTDL
int sys_write(int fd, const void *buf, size_t count, ssize_t *bytes_written) {
return -1;
}
#endif
int sys_seek(int fd, off_t offset, int whence, off_t *new_offset) {
return -1;
}
int sys_vm_map(void *hint, size_t size, int prot, int flags, int fd, off_t offset, void **window) {
return -1;
}
#ifndef MLIBC_BUILDING_RTDL
int sys_fstat(int fd, struct stat *statbuf) {
return -1;
}
#endif
#ifndef MLIBC_BUILDING_RTDL
int sys_rename(const char *path, const char *new_path) {
return -1;
}
#endif
#ifndef MLIBC_BUILDING_RTDL
int sys_sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict) {
return -1;
}
#endif
} // namespace mlibc

View file

@ -0,0 +1,23 @@
// reserve 3 bits for the access mode
#define __MLIBC_O_ACCMODE 0x0007
#define __MLIBC_O_EXEC 1
#define __MLIBC_O_RDONLY 2
#define __MLIBC_O_RDWR 3
#define __MLIBC_O_SEARCH 4
#define __MLIBC_O_WRONLY 5
// all remaining flags get their own bit
#define __MLIBC_O_APPEND 0x0008
#define __MLIBC_O_CREAT 0x0010
#define __MLIBC_O_DIRECTORY 0x0020
#define __MLIBC_O_EXCL 0x0040
#define __MLIBC_O_NOCTTY 0x0080
#define __MLIBC_O_NOFOLLOW 0x0100
#define __MLIBC_O_TRUNC 0x0200
#define __MLIBC_O_NONBLOCK 0x0400
#define __MLIBC_O_DSYNC 0x0800
#define __MLIBC_O_RSYNC 0x1000
#define __MLIBC_O_SYNC 0x2000
#define __MLIBC_O_CLOEXEC 0x4000

13
sysdeps/qword/meson.build Normal file
View file

@ -0,0 +1,13 @@
disable_posix_option = true
disable_linux_option = true
rtdl_sources += files(
'generic/file.cpp'
)
libc_include_dirs += include_directories('include')
libc_sources += files(
'generic/file.cpp'
)