From 7b86089f95815983187219a77f61f32afa2cb847 Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Sat, 18 Jan 2020 10:14:51 -0500 Subject: [PATCH] Add support for access, chdir and fchdir in knight-posix (needs testing) --- test/common_knight/functions/access.c | 24 +++++++++++++++++++++++ test/common_knight/functions/chdir.c | 28 +++++++++++++++++++++++++++ test/common_knight/knight_defs.M1 | 3 +++ 3 files changed, 55 insertions(+) create mode 100644 test/common_knight/functions/access.c create mode 100644 test/common_knight/functions/chdir.c diff --git a/test/common_knight/functions/access.c b/test/common_knight/functions/access.c new file mode 100644 index 0000000..c5dafbf --- /dev/null +++ b/test/common_knight/functions/access.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2020 Jeremiah Orians + * This file is part of M2-Planet. + * + * M2-Planet is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * M2-Planet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with M2-Planet. If not, see . + */ + + +int access(char* pathname, int mode) +{ + asm("LOAD R0 R14 0" + "LOAD R1 R14 4" + "ACCESS"); +} diff --git a/test/common_knight/functions/chdir.c b/test/common_knight/functions/chdir.c new file mode 100644 index 0000000..e6c6a2e --- /dev/null +++ b/test/common_knight/functions/chdir.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2020 Jeremiah Orians + * This file is part of M2-Planet. + * + * M2-Planet is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * M2-Planet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with M2-Planet. If not, see . + */ + +int chdir(char* path) +{ + asm("LOAD R0 R14 0" + "CHDIR"); +} + +int fchdir(int fd) +{ + asm("LOAD R0 R14 0" + "FCHDIR"); +} diff --git a/test/common_knight/knight_defs.M1 b/test/common_knight/knight_defs.M1 index 2eb9171..765b0e1 100644 --- a/test/common_knight/knight_defs.M1 +++ b/test/common_knight/knight_defs.M1 @@ -242,8 +242,11 @@ DEFINE JUMP 3C00 DEFINE FOPEN 42000002 DEFINE FCLOSE 42000003 DEFINE FSEEK 42000008 +DEFINE ACCESS 42000015 DEFINE EXIT 4200003C DEFINE UNAME 4200003F +DEFINE CHDIR 42000050 +DEFINE FCHDIR 42000051 DEFINE CHMOD 4200005A DEFINE FGETC 42100100 DEFINE FPUTC 42100200