diff options
author | Alex Auvolat <alex@adnab.me> | 2016-07-16 15:59:46 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2016-07-16 15:59:46 +0200 |
commit | 3d6a857b9186ef6304ea6cf04627c2b787169f29 (patch) | |
tree | 756179ce1e1838f75c57e3efec2a570d72051594 /src/lib/include | |
parent | 59000174aa50ed6b2d24a71576d15e6a53c5be0c (diff) | |
download | kogata-3d6a857b9186ef6304ea6cf04627c2b787169f29.tar.gz kogata-3d6a857b9186ef6304ea6cf04627c2b787169f29.zip |
Make way for libc implementation
Diffstat (limited to 'src/lib/include')
-rw-r--r-- | src/lib/include/assert.h | 3 | ||||
-rw-r--r-- | src/lib/include/kogata/syscall.h | 92 | ||||
-rw-r--r-- | src/lib/include/readline/history.h | 5 | ||||
-rw-r--r-- | src/lib/include/readline/readline.h | 6 | ||||
-rw-r--r-- | src/lib/include/setjmp.h | 2 | ||||
-rw-r--r-- | src/lib/include/stdio.h | 11 | ||||
-rw-r--r-- | src/lib/include/stdlib.h | 7 |
7 files changed, 68 insertions, 58 deletions
diff --git a/src/lib/include/assert.h b/src/lib/include/assert.h index af02bb5..655d6f6 100644 --- a/src/lib/include/assert.h +++ b/src/lib/include/assert.h @@ -1,6 +1,5 @@ #pragma once -// TODO - +#include <kogata/debug.h> /* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/kogata/syscall.h b/src/lib/include/kogata/syscall.h index 378dda2..8ae5325 100644 --- a/src/lib/include/kogata/syscall.h +++ b/src/lib/include/kogata/syscall.h @@ -13,51 +13,51 @@ typedef void (*entry_t)(void*); -void dbg_print(const char* str); -void yield(); -void exit(int code); -void usleep(int usecs); -bool sys_new_thread(void* eip, void* esp); -void exit_thread(); - -bool mmap(void* addr, size_t size, int mode); -bool mmap_file(fd_t file, size_t offset, void* addr, size_t size, int mode); -bool mchmap(void* addr, int mode); -bool munmap(void* addr); - -bool create(const char* name, int type); -bool delete(const char* name); -bool move(const char* oldname, const char* newname); -bool stat(const char* name, stat_t *s); - -fd_t open(const char* name, int mode); -void close(fd_t file); -size_t read(fd_t file, size_t offset, size_t len, char *buf); -size_t write(fd_t file, size_t offset, size_t len, const char* buf); -bool readdir(fd_t file, size_t ent_no, dirent_t *d); -bool stat_open(fd_t file, stat_t *s); -int ioctl(fd_t file, int command, void* data); -int fctl(fd_t file, int command, void* data); -bool select(sel_fd_t* fds, size_t nfds, int timeout); - -fd_pair_t make_channel(bool blocking); -fd_t make_shm(size_t size); -bool gen_token(fd_t file, token_t *tok); -fd_t use_token(token_t *tok); - -bool make_fs(const char* name, const char* driver, fd_t source, const char* options); -bool fs_add_source(const char* fs, fd_t source, const char* options); -bool fs_subfs(const char* name, const char* orig_fs, const char* root, int ok_modes); -void fs_remove(const char* name); - -pid_t new_proc(); -bool bind_fs(pid_t pid, const char* new_name, const char* fs); -bool bind_subfs(pid_t pid, const char* new_name, const char* fs, const char* root, int ok_modes); -bool bind_make_fs(pid_t pid, const char* name, const char* driver, fd_t source, const char* options); -bool bind_fd(pid_t pid, fd_t new_fd, fd_t fd); -bool proc_exec(pid_t pid, const char* file); -bool proc_status(pid_t pid, proc_status_t *s); -bool proc_kill(pid_t pid, proc_status_t *s); -void proc_wait(pid_t pid, bool wait, proc_status_t *s); +void sc_dbg_print(const char* str); +void sc_yield(); +void sc_exit(int code); +void sc_usleep(int usecs); +bool sc_sys_new_thread(void* eip, void* esp); +void sc_exit_thread(); + +bool sc_mmap(void* addr, size_t size, int mode); +bool sc_mmap_file(fd_t file, size_t offset, void* addr, size_t size, int mode); +bool sc_mchmap(void* addr, int mode); +bool sc_munmap(void* addr); + +bool sc_create(const char* name, int type); +bool sc_delete(const char* name); +bool sc_move(const char* oldname, const char* newname); +bool sc_stat(const char* name, stat_t *s); + +fd_t sc_open(const char* name, int mode); +void sc_close(fd_t file); +size_t sc_read(fd_t file, size_t offset, size_t len, char *buf); +size_t sc_write(fd_t file, size_t offset, size_t len, const char* buf); +bool sc_readdir(fd_t file, size_t ent_no, dirent_t *d); +bool sc_stat_open(fd_t file, stat_t *s); +int sc_ioctl(fd_t file, int command, void* data); +int sc_fctl(fd_t file, int command, void* data); +bool sc_select(sel_fd_t* fds, size_t nfds, int timeout); + +fd_pair_t sc_make_channel(bool blocking); +fd_t sc_make_shm(size_t size); +bool sc_gen_token(fd_t file, token_t *tok); +fd_t sc_use_token(token_t *tok); + +bool sc_make_fs(const char* name, const char* driver, fd_t source, const char* options); +bool sc_fs_add_source(const char* fs, fd_t source, const char* options); +bool sc_fs_subfs(const char* name, const char* orig_fs, const char* root, int ok_modes); +void sc_fs_remove(const char* name); + +pid_t sc_new_proc(); +bool sc_bind_fs(pid_t pid, const char* new_name, const char* fs); +bool sc_bind_subfs(pid_t pid, const char* new_name, const char* fs, const char* root, int ok_modes); +bool sc_bind_make_fs(pid_t pid, const char* name, const char* driver, fd_t source, const char* options); +bool sc_bind_fd(pid_t pid, fd_t new_fd, fd_t fd); +bool sc_proc_exec(pid_t pid, const char* file); +bool sc_proc_status(pid_t pid, proc_status_t *s); +bool sc_proc_kill(pid_t pid, proc_status_t *s); +void sc_proc_wait(pid_t pid, bool wait, proc_status_t *s); /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/readline/history.h b/src/lib/include/readline/history.h new file mode 100644 index 0000000..3b98ca2 --- /dev/null +++ b/src/lib/include/readline/history.h @@ -0,0 +1,5 @@ +#pragma once + +#include "readline.h" + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/readline/readline.h b/src/lib/include/readline/readline.h new file mode 100644 index 0000000..ae3e05c --- /dev/null +++ b/src/lib/include/readline/readline.h @@ -0,0 +1,6 @@ +#pragma once + +char* readline(const char* prompt); +void add_history(const char* line); + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/setjmp.h b/src/lib/include/setjmp.h index 42df49e..46c3b5d 100644 --- a/src/lib/include/setjmp.h +++ b/src/lib/include/setjmp.h @@ -1,6 +1,6 @@ #pragma once -// TODO +#include <stdint.h> struct _jmp_buf { uint32_t stuff[10]; // 40 bytes diff --git a/src/lib/include/stdio.h b/src/lib/include/stdio.h index 3914a89..c6b636d 100644 --- a/src/lib/include/stdio.h +++ b/src/lib/include/stdio.h @@ -2,17 +2,16 @@ #include <stdarg.h> -#include <kogata/syscall.h> +#include <kogata/printf.h> -extern fd_t stdio; +#include <kogata/syscall.h> -// CUSTOM! -void getline(char* buf, size_t l); +void setup_libc_stdio(); //TODO below struct file_t { - fd_t fd; + // TODO }; typedef struct file_t FILE; @@ -78,12 +77,10 @@ int rename(const char *old, const char *new); int remove(const char *pathname); - int printf(const char *format, ...); int fprintf(FILE *stream, const char *format, ...); int dprintf(int fd, const char *format, ...); int sprintf(char *str, const char *format, ...); -int snprintf(char *str, size_t size, const char *format, ...); /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/include/stdlib.h b/src/lib/include/stdlib.h index 53aef80..e451c52 100644 --- a/src/lib/include/stdlib.h +++ b/src/lib/include/stdlib.h @@ -1,10 +1,13 @@ #pragma once #include <kogata/malloc.h> +#include <kogata/syscall.h> #define EXIT_SUCCESS 0 #define EXIT_FAILURE 255 +#define exit sc_exit + int rand(void); //int rand_r(unsigned int *seedp); void srand(unsigned int seed); @@ -14,8 +17,8 @@ void srand(unsigned int seed); void abort() __attribute__((__noreturn__)); -double strtod(const char *nptr, const char **endptr); -float strtof(const char *nptr, const char **endptr); +double strtod(const char *nptr, char **endptr); +float strtof(const char *nptr, char **endptr); char *getenv(const char *name); |