aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2021-11-18 16:40:51 -0800
committerNicholas Noll <nbnoll@eml.cc>2021-11-18 16:40:51 -0800
commit5bcc08d92ae9345d6863f555a3dd9ec960e0860f (patch)
treec0fc5dba61ee770d5757ffb9702d61d277d122a1 /include
parent4bf477d5ed372fd44697d2f0df245b61b4f3f7b3 (diff)
feat: filling out system layer's interface
Diffstat (limited to 'include')
-rw-r--r--include/base.h80
-rw-r--r--include/sys.h30
-rw-r--r--include/u.h7
3 files changed, 75 insertions, 42 deletions
diff --git a/include/base.h b/include/base.h
index 7077731..df580c3 100644
--- a/include/base.h
+++ b/include/base.h
@@ -3,8 +3,10 @@
// ------------------------------------------------------------------------
// standard library
-//#include <arch/types.h>
-//
+#include <sys.h>
+#include <arch/types.h>
+
+// TODO: remove dependency system headers
#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@ -125,9 +127,6 @@ char *str·copyn(char *dst, char *src, int n);
// -----------------------------------------------------------------------------
// i/o
-typedef FILE io·Stream;
-typedef struct stat io·Stat;
-
enum SeekPos
{
seek·cur = SEEK_CUR,
@@ -135,37 +134,6 @@ enum SeekPos
seek·end = SEEK_END
};
-/* XXX: change casing */
-enum
-{
- ReadOK = R_OK,
- WriteOK = W_OK,
- ExecOK = X_OK,
-};
-
-/* file handling */
-io·Stream *io·open(byte *name, byte *mode);
-int io·fd(io·Stream *s);
-int io·stat(io·Stream *s, io·Stat *buf);
-int io·close(io·Stream *s);
-byte io·getbyte(io·Stream *s);
-int io·ungetbyte(io·Stream *s, byte c);
-int io·read(io·Stream *s, int sz, int n, void *buf);
-int io·readln(io·Stream *s, int n, byte *buf);
-int io·putbyte(io·Stream *s, byte c);
-int io·putstring(io·Stream *s, string str);
-int io·write(io·Stream *s, int sz, int n, void *buf);
-int io·flush(io·Stream *s);
-int io·seek(io·Stream *s, long off, enum SeekPos whence);
-long io·tell(io·Stream *s);
-
-/* basic os helpers */
-int os·exists(byte *path, int flag);
-byte *os·dirname(byte *path);
-byte *os·basename(byte *path);
-int os·sep(void);
-
-/* io interfaces */
typedef struct io·Reader
{
int (*read)(void*, int sz, int n, void *buf);
@@ -227,6 +195,42 @@ typedef struct io·ReadWriter
} io·ReadWriter;
extern io·ReadWriter sys·ReadWriter;
+/* XXX: change casing */
+enum
+{
+ ReadOK = R_OK,
+ WriteOK = W_OK,
+ ExecOK = X_OK,
+};
+
+/* XXX(deprecated): file handling */
+
+typedef FILE io·Stream;
+typedef struct stat io·Stat;
+
+io·Stream *io·open(byte *name, byte *mode);
+int io·fd(io·Stream *s);
+int io·stat(io·Stream *s, io·Stat *buf);
+int io·close(io·Stream *s);
+byte io·getbyte(io·Stream *s);
+int io·ungetbyte(io·Stream *s, byte c);
+int io·read(io·Stream *s, int sz, int n, void *buf);
+int io·readln(io·Stream *s, int n, byte *buf);
+int io·putbyte(io·Stream *s, byte c);
+int io·putstring(io·Stream *s, string str);
+int io·write(io·Stream *s, int sz, int n, void *buf);
+int io·flush(io·Stream *s);
+int io·seek(io·Stream *s, long off, enum SeekPos whence);
+long io·tell(io·Stream *s);
+
+/* basic os helpers */
+
+int os·exists(byte *path, int flag);
+byte *os·dirname(byte *path);
+byte *os·basename(byte *path);
+int os·sep(void);
+
+/* io interfaces */
/* buffered i/o */
typedef struct io·Buffer io·Buffer;
@@ -364,9 +368,9 @@ long gz·tell(gz·Stream *s);
void exits(char *s);
void errorf(byte* fmt, ...);
-void verrorf(byte* fmt, va_list args);
+void verrorf(byte* fmt, va_list args);
void panicf(byte *fmt, ...);
-void vpanicf(byte *fmt, va_list args);
+void vpanicf(byte *fmt, va_list args);
// -----------------------------------------------------------------------------
// sorting
diff --git a/include/sys.h b/include/sys.h
index e7573bf..a838fe8 100644
--- a/include/sys.h
+++ b/include/sys.h
@@ -1,7 +1,11 @@
#pragma once
-#include <arch/constants.h>
-#include <arch/errno.h>
+/* types declarations */
+#include <arch/types.h>
+
+#include <os/types.h>
+#include <os/constants.h>
+#include <os/errno.h>
// -----------------------------------------------------------------------
// global constants
@@ -16,9 +20,15 @@
#define sys·SeekCur 1u
#define sys·SeekEnd 2u
+/* special file descriptors */
+#define sys·Stdin 0
+#define sys·Stdout 1
+#define sys·Stderr 2
+
// -----------------------------------------------------------------------
// functions
+/* errors */
char *sys·errormsg(int num);
/* file operations */
@@ -27,20 +37,32 @@ int sys·close(int fd);
int sys·write(int fd, uintptr len, void *buf, intptr *nw);
int sys·read(int fd, uintptr len, void *buf, intptr *nr);
int sys·seek(int fd, intptr offset, int from, intptr *pos);
+
+int sys·info(char *path, sys·Info *ret);
+int sys·infofd(int fd, sys·Info *ret);
+int sys·infoat(int dirfd, char *path, int flag, uint mask, sys·Info *ret);
+
int sys·dup(int from, int to);
/* directory operations */
-int sys·chdirfd(int fd);
int sys·chdir(char *path);
+int sys·chdirfd(int fd);
+int sys·mkdir(char *path, uint mode);
+int sys·mkdirat(int fd, char *path, uint mode);
+
int sys·direntry(int fd, int len, void *buffer, uintptr *size);
+/* file node */
+int sys·mknode(char *path, uint mode, uint64 dev);
+int sys·mknodeat(int dirfd, char *path, uint mode, uint64 device);
+
/* process operations */
int sys·fork(void);
int sys·exec(char *program, char *argv[], char *env[]);
/* memory operations */
int sys·brk(void *addr);
-int sys·sbrk(intptr delta, void **ret);
+//int sys·sbrk(intptr delta, void **ret);
int sys·mmap(void *addr, uintptr len, int prot, int flags, int fd, intptr off, void **ret);
int sys·mremap(void *old, uintptr from, uintptr to, int flags, void **new);
diff --git a/include/u.h b/include/u.h
index 87d5080..333d6b2 100644
--- a/include/u.h
+++ b/include/u.h
@@ -41,12 +41,19 @@ typedef uint32 rune;
/* pointer address */
typedef ADDR intptr;
typedef unsigned ADDR uintptr;
+typedef ADDR address_t;
+typedef REG register_t;
+typedef unsigned REG uregister_t;
+
+/* variable length list */
+typedef __builtin_va_list va_list;
#undef INT8
#undef INT16
#undef INT32
#undef INT64
#undef ADDR
+#undef REG
// ------------------------------------------------------------------
// global constants