diff --git a/sys/include/sys/sysproto.h b/sys/include/sys/sysproto.h index 39d16c7..b0a8de2 100644 --- a/sys/include/sys/sysproto.h +++ b/sys/include/sys/sysproto.h @@ -29,12 +29,8 @@ #ifndef _SYS_SYSPROTO_H #define _SYS_SYSPROTO_H -#include #include -/* TEMP */ -#include - typedef int register_t; #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? 0 : sizeof(register_t) - sizeof(t)) @@ -48,9 +44,9 @@ #endif //Protos -struct sys_exit_args { +struct sys_mpiCreateMbox_args { char status_l_[PADL_(int)]; - int status; + char *name; char status_r_[PADR_(int)]; }; @@ -72,687 +68,8 @@ char nbyte_r_[PADR_(size_t)]; }; -struct sys_write_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - - char buf_l_[PADL_(const void *)]; - const void * buf; - char buf_r_[PADR_(const void *)]; - - char nbyte_l_[PADL_(size_t)]; - size_t nbyte; - char nbyte_r_[PADR_(size_t)]; -}; - -struct sys_open_args { - char path_l_[PADL_(char *)]; - char *path; - char path_r_[PADR_(char *)]; - - char flags_l_[PADL_(int)]; - int flags; - char flags_r_[PADR_(int)]; - - char mode_l_[PADL_(int)]; - int mode; - char mode_r_[PADR_(int)]; -}; - -struct sys_close_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; -}; - -struct sys_wait4_args { - char pid_l_[PADL_(int)]; - int pid; - char pid_r_[PADR_(int)]; - - char status_l_[PADL_(int *)]; - int *status; - char status_r_[PADR_(int *)]; - - char options_l_[PADL_(int)]; - int options; - char options_r_[PADR_(int)]; - - char rusage_l_[PADL_(void *)]; - void *rusage; - char rusage_r_[PADR_(void *)]; -}; - -struct sys_chdir_args { - char path_l_[PADL_(char *)]; - char *path; - char path_r_[PADR_(char *)]; -}; - -struct sys_getcwd_args { - char buf_l_[PADL_(const void *)]; - void *buf; - char buf_r_[PADR_(const void *)]; - - char size_l_[PADL_(uint32_t)]; - uint32_t size; - char size_r_[PADR_(uint32_t)]; -}; - -struct sys_setUID_args { - char uid_l_[PADL_(int)]; - int uid; - char uid_r_[PADR_(int)]; -}; - -struct sys_setGID_args { - char gid_l_[PADL_(int)]; - int gid; - char gid_r_[PADR_(int)]; -}; - -struct sys_execve_args { - char fname_l_[PADL_(char *)]; - char *fname; - char fname_r_[PADR_(char *)]; - char argv_l_[PADL_(char **)]; - char **argv; - char argv_r_[PADR_(char **)]; - char envp_l_[PADL_(char **)]; - char **envp; - char envp_r_[PADR_(char **)]; -}; - -struct sys_fopen_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char mode_l_[PADL_(char *)]; - char * mode; - char mode_r_[PADR_(char *)]; - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; -}; - -struct sys_fread_args { - char ptr_l_[PADL_(void *)]; - void *ptr; - char ptr_r_[PADR_(void *)]; - char size_l_[PADL_(long)]; - long size; - char size_r_[PADR_(long)]; - char nmemb_l_[PADL_(long)]; - long nmemb; - char nmemb_r_[PADR_(long)]; - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; -}; - -struct sys_fclose_args { - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; -}; - -struct sys_fgetc_args { - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; -}; - -struct sys_fseek_args { - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; - char offset_l_[PADL_(long)]; - long offset; - char offset_r_[PADR_(long)]; - char whence_l_[PADL_(int)]; - int whence; - char whence_r_[PADR_(int)]; -}; - -struct sys_sysctl_args { - char name_l_[PADL_(int *)]; - int *name; - char name_r_[PADR_(int *)]; - char namelen_l_[PADL_(u_int)]; - u_int namelen; - char namelen_r_[PADR_(u_int)]; - char oldp_l_[PADL_(void *)]; - void *oldp; - char oldp_r_[PADR_(void *)]; - char oldlenp_l_[PADL_(size_t *)]; - size_t *oldlenp; - char oldlenp_r_[PADR_(size_t *)]; - char newp_l_[PADL_(void *)]; - void *newp; - char newp_r_[PADR_(void *)]; - char newlenp_l_[PADL_(size_t)]; - size_t newlenp; - char newlenp_r_[PADR_(size_t)]; - -}; - -/* OLD */ - -struct setitimer_args { - char which_l_[PADL_(u_int)]; - u_int which; - char which_r_[PADR_(u_int)]; - char itv_l_[PADL_(struct itimerval *)]; - struct itimerval * itv; - char itv_r_[PADR_(struct itimerval *)]; - char oitv_l_[PADL_(struct itimerval *)]; - struct itimerval * oitv; - char oitv_r_[PADR_(struct itimerval *)]; -}; - -struct access_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char flags_l_[PADL_(int)]; - int flags; - char flags_r_[PADR_(int)]; -}; - -struct sys_fstatfs_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char buf_l_[PADL_(struct statfs *)]; - struct statfs * buf; - char buf_r_[PADR_(struct statfs *)]; -}; - -struct mprotect_args { - char addr_l_[PADL_(const void *)]; - const void * addr; - char addr_r_[PADR_(const void *)]; - char len_l_[PADL_(size_t)]; - size_t len; - char len_r_[PADR_(size_t)]; - char prot_l_[PADL_(int)]; - int prot; - char prot_r_[PADR_(int)]; -}; - -//Old - -struct sysctl_args { - char name_l_[PADL_(int *)]; - int * name; - char name_r_[PADR_(int *)]; - char namelen_l_[PADL_(u_int)]; - u_int namelen; - char namelen_r_[PADR_(u_int)]; - char old_l_[PADL_(void *)]; - void *oldp; - char old_r_[PADR_(void *)]; - char oldlenp_l_[PADL_(size_t *)]; - size_t * oldlenp; - char oldlenp_r_[PADR_(size_t *)]; - char new_l_[PADL_(void *)]; - void * newp; - char new_r_[PADR_(void *)]; - char newlen_l_[PADL_(size_t)]; - size_t newlen; - char newlen_r_[PADR_(size_t)]; -}; - -struct getpid_args { - register_t dummy; -}; -struct sys_issetugid_args { - register_t dummy; -}; -struct fcntl_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char cmd_l_[PADL_(int)]; - int cmd; - char cmd_r_[PADR_(int)]; - char arg_l_[PADL_(long)]; - long arg; - char arg_r_[PADR_(long)]; -}; - -struct pipe_args { - register_t dummy; -}; - -struct readlink_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char buf_l_[PADL_(char *)]; - char * buf; - char buf_r_[PADR_(char *)]; - char count_l_[PADL_(int)]; - int count; - char count_r_[PADR_(int)]; -}; - -struct getuid_args { - register_t dummy; -}; - -struct getgid_args { - register_t dummy; -}; -struct close_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; -}; - -struct sys_mmap_args { - char addr_l_[PADL_(caddr_t)]; - caddr_t addr; - char addr_r_[PADR_(caddr_t)]; - char len_l_[PADL_(size_t)]; - size_t len; - char len_r_[PADR_(size_t)]; - char prot_l_[PADL_(int)]; - int prot; - char prot_r_[PADR_(int)]; - char flags_l_[PADL_(int)]; - int flags; - char flags_r_[PADR_(int)]; - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char pos_l_[PADL_(off_t)]; - off_t pos; - char pos_r_[PADR_(off_t)]; -}; - -struct sys_stat_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char ub_l_[PADL_(struct stat *)]; - struct stat * ub; - char ub_r_[PADR_(struct stat *)]; -}; - -struct sys_lstat_args { - char path_l_[PADL_(char *)]; - char *path; - char path_r_[PADR_(char *)]; - char sb_l_[PADL_(struct stat *)]; - struct stat *sb; - char sb_r_[PADR_(struct stat *)]; -}; - -struct obreak_args { - char nsize_l_[PADL_(char *)]; - char * nsize; - char nsize_r_[PADR_(char *)]; -}; - -struct sigaction_args { - char sig_l_[PADL_(int)]; - int sig; - char sig_r_[PADR_(int)]; - char act_l_[PADL_(const struct sigaction *)]; - const struct sigaction * act; - char act_r_[PADR_(const struct sigaction *)]; - char oact_l_[PADL_(struct sigaction *)]; - struct sigaction * oact; - char oact_r_[PADR_(struct sigaction *)]; -}; - -struct getdtablesize_args { - register_t dummy; -}; - -struct sys_munmap_args { - char addr_l_[PADL_(void *)]; - void * addr; - char addr_r_[PADR_(void *)]; - char len_l_[PADL_(size_t)]; - size_t len; - char len_r_[PADR_(size_t)]; -}; - -struct sigprocmask_args { - char how_l_[PADL_(int)]; - int how; - char how_r_[PADR_(int)]; - char set_l_[PADL_(const sigset_t *)]; - const sigset_t * set; - char set_r_[PADR_(const sigset_t *)]; - char oset_l_[PADL_(sigset_t *)]; - sigset_t * oset; - char oset_r_[PADR_(sigset_t *)]; -}; -struct gettimeofday_args { - char tp_l_[PADL_(struct timeval *)]; - struct timeval * tp; - char tp_r_[PADR_(struct timeval *)]; - char tzp_l_[PADL_(struct timezone *)]; - struct timezone * tzp; - char tzp_r_[PADR_(struct timezone *)]; -}; -struct sys_fstat_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char sb_l_[PADL_(struct stat *)]; - struct stat * sb; - char sb_r_[PADR_(struct stat *)]; -}; -struct ioctl_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char com_l_[PADL_(u_long)]; - u_long com; - char com_r_[PADR_(u_long)]; - char data_l_[PADL_(caddr_t)]; - caddr_t data; - char data_r_[PADR_(caddr_t)]; -}; - -struct read_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char buf_l_[PADL_(void *)]; - void * buf; - char buf_r_[PADR_(void *)]; - char nbyte_l_[PADL_(size_t)]; - size_t nbyte; - char nbyte_r_[PADR_(size_t)]; -}; - -struct sys_openat_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char flag_l_[PADL_(int)]; - int flag; - char flag_r_[PADR_(int)]; - char mode_l_[PADL_(__mode_t)]; - __mode_t mode; - char mode_r_[PADR_(__mode_t)]; -}; - -struct sys_sysarch_args { - char op_l_[PADL_(int)]; - int op; - char op_r_[PADR_(int)]; - char parms_l_[PADL_(char *)]; - char * parms; - char parms_r_[PADR_(char *)]; -}; - -struct sys_getpid_args { - register_t dummy; -}; - -struct sys_ioctl_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char com_l_[PADL_(u_long)]; - u_long com; - char com_r_[PADR_(u_long)]; - char data_l_[PADL_(caddr_t)]; - caddr_t data; - char data_r_[PADR_(caddr_t)]; -}; - -struct sys_geteuid_args { - register_t dummy; -}; - -struct sys_getppid_args { - register_t dummy; -}; - -struct sys_getegid_args { - register_t dummy; -}; - -struct sys_sigprocmask_args { - char how_l_[PADL_(int)]; - int how; - char how_r_[PADR_(int)]; - char set_l_[PADL_(const sigset_t *)]; - const sigset_t * set; - char set_r_[PADR_(const sigset_t *)]; - char oset_l_[PADL_(sigset_t *)]; - sigset_t * oset; - char oset_r_[PADR_(sigset_t *)]; -}; - -struct sys_sigaction_args { - char sig_l_[PADL_(int)]; - int sig; - char sig_r_[PADR_(int)]; - char act_l_[PADL_(const struct sigaction *)]; - const struct sigaction * act; - char act_r_[PADR_(const struct sigaction *)]; - char oact_l_[PADL_(struct sigaction *)]; - struct sigaction * oact; - char oact_r_[PADR_(struct sigaction *)]; -}; - -struct sys_getpgrp_args { - register_t dummy; -}; -struct sys_setpgid_args { - char pid_l_[PADL_(int)]; - int pid; - char pid_r_[PADR_(int)]; - char pgid_l_[PADL_(int)]; - int pgid; - char pgid_r_[PADR_(int)]; -}; - -struct sys_access_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char amode_l_[PADL_(int)]; - int amode; - char amode_r_[PADR_(int)]; -}; - -struct sys_statfs_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char buf_l_[PADL_(struct statfs *)]; - struct statfs * buf; - char buf_r_[PADR_(struct statfs *)]; -}; - -struct sys_fstatat_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char buf_l_[PADL_(struct stat *)]; - struct stat * buf; - char buf_r_[PADR_(struct stat *)]; - char flag_l_[PADL_(int)]; - int flag; - char flag_r_[PADR_(int)]; -}; - -struct sys_fchdir_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; -}; - -struct sys_getdirentries_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char buf_l_[PADL_(char *)]; - char * buf; - char buf_r_[PADR_(char *)]; - char count_l_[PADL_(u_int)]; - u_int count; - char count_r_[PADR_(u_int)]; - char basep_l_[PADL_(long *)]; - long * basep; - char basep_r_[PADR_(long *)]; -}; - -struct sys_socket_args { - char domain_l_[PADL_(int)]; - int domain; - char domain_r_[PADR_(int)]; - char type_l_[PADL_(int)]; - int type; - char type_r_[PADR_(int)]; - char protocol_l_[PADL_(int)]; - int protocol; - char protocol_r_[PADR_(int)]; -}; - -struct sys_setsockopt_args { - char s_l_[PADL_(int)]; - int s; - char s_r_[PADR_(int)]; - char level_l_[PADL_(int)]; - int level; - char level_r_[PADR_(int)]; - char name_l_[PADL_(int)]; - int name; - char name_r_[PADR_(int)]; - char val_l_[PADL_(caddr_t)]; - caddr_t val; - char val_r_[PADR_(caddr_t)]; - char valsize_l_[PADL_(int)]; - int valsize; - char valsize_r_[PADR_(int)]; -}; - -struct sys_select_args { - char nd_l_[PADL_(int)]; - int nd; - char nd_r_[PADR_(int)]; - char in_l_[PADL_(fd_set *)]; - fd_set * in; - char in_r_[PADR_(fd_set *)]; - char ou_l_[PADL_(fd_set *)]; - fd_set * ou; - char ou_r_[PADR_(fd_set *)]; - char ex_l_[PADL_(fd_set *)]; - fd_set * ex; - char ex_r_[PADR_(fd_set *)]; - char tv_l_[PADL_(struct timeval *)]; - struct timeval * tv; - char tv_r_[PADR_(struct timeval *)]; -}; - -struct sys_gettimeofday_args { - char tp_l_[PADL_(struct timeval *)]; struct timeval * tp; char tp_r_[PADR_(struct timeval *)]; - char tzp_l_[PADL_(struct timezone *)]; struct timezone * tzp; char tzp_r_[PADR_(struct timezone *)]; -}; - - -struct sys_sendto_args { - char s_l_[PADL_(int)]; int s; char s_r_[PADR_(int)]; - char buf_l_[PADL_(caddr_t)]; caddr_t buf; char buf_r_[PADR_(caddr_t)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; - char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; - char to_l_[PADL_(caddr_t)]; caddr_t to; char to_r_[PADR_(caddr_t)]; - char tolen_l_[PADL_(int)]; int tolen; char tolen_r_[PADR_(int)]; -}; //Func Defs -int sys_invalid(struct thread *, void *); -int sys_exit(struct thread *, struct sys_exit_args *); -int sys_fork(struct thread *, struct sys_fork_args *); -int sys_read(struct thread *, struct sys_read_args *); -int sys_write(struct thread *td, struct sys_write_args *); -int sys_open(struct thread *td, struct sys_open_args *); -int sys_close(struct thread *td, struct sys_close_args *); -int sys_wait4(struct thread *td, struct sys_wait4_args *); -int sys_chdir(struct thread *td, struct sys_chdir_args *); +int sys_mpiCreateMbox(struct thread *, struct sys_mpiCreateMbox_args *); -int sys_setUID(struct thread *td, struct sys_setUID_args *); -int sys_getUID(struct thread *td, void *); -int sys_setGID(struct thread *td, struct sys_setGID_args *); -int sys_getGID(struct thread *td, void *); - -int sys_execve(struct thread *td, struct sys_execve_args *); - -int sys_fopen(struct thread *td, struct sys_fopen_args *); -int sys_fread(struct thread *td, struct sys_fread_args *); -int sys_fclose(struct thread *td, struct sys_fclose_args *); -int sys_fgetc(struct thread *td, struct sys_fgetc_args *); -int sys_fseek(struct thread *td, struct sys_fseek_args *); - -int sys_sched_yield(struct thread *td, void *); - -int sys_getcwd(struct thread *td, struct sys_getcwd_args *); - -int sys_mmap(struct thread *td, struct sys_mmap_args *); -int sys_munmap(struct thread *td, struct sys_munmap_args *); -int sys_sysctl(struct thread *td, struct sys_sysctl_args *); - -int sys_issetugid(struct thread *td, struct sys_issetugid_args *); - -int setitimer(struct thread *td, struct setitimer_args *uap); -int access(struct thread *td, struct access_args *uap); -int fstatfs(struct thread *td, struct sys_fstatfs_args *uap); -int mprotect(struct thread *td, struct mprotect_args *uap); - -int sys_statfs(struct thread *td, struct sys_statfs_args *args); -int sys_fstatfs(struct thread *td, struct sys_fstatfs_args *); -int sys_stat(struct thread *td, struct sys_stat_args *); -int sys_lstat(struct thread *td, struct sys_lstat_args *); -int sys_fstat(struct thread *td, struct sys_fstat_args *); -int sys_fstatat(struct thread *td, struct sys_fstatat_args *); -int sys_openat(struct thread *td, struct sys_openat_args *); - -int sys_sysarch(struct thread *td, struct sys_sysarch_args *); -int sys_getpid(struct thread *td, struct sys_getpid_args *); -int sys_ioctl(struct thread *td, struct sys_ioctl_args *); - -int sys_geteuid(struct thread *td, struct sys_geteuid_args *); - -int sys_getegid(struct thread *td, struct sys_getegid_args *); - -int sys_getppid(struct thread *td, struct sys_getppid_args *); - -int sys_getpgrp(struct thread *td, struct sys_getpgrp_args *); -int sys_setpgrp(struct thread *td, struct sys_setpgid_args *); - -int sys_sigprocmask(struct thread *td, struct sys_sigprocmask_args *); -int sys_sigaction(struct thread *td, struct sys_sigaction_args *); - -int sys_getpgrp(struct thread *td, struct sys_getpgrp_args *); -int sys_setpgid(struct thread *td, struct sys_setpgid_args *); - -int sys_access(struct thread *td, struct sys_access_args *); -int sys_fchdir(struct thread *td, struct sys_fchdir_args *); - -int sys_getdirentries(struct thread *td, struct sys_getdirentries_args *); - -int sys_socket(struct thread *td, struct sys_socket_args *); -int sys_setsockopt(struct thread *td, struct sys_setsockopt_args *); -int sys_select(struct thread *td, struct sys_select_args *); - - -int sys_gettimeofday(struct thread *td, struct sys_gettimeofday_args *); -int sys_sendto(struct thread *td, struct sys_sendto_args *); #endif diff --git a/sys/include/sys/sysproto_posix.h b/sys/include/sys/sysproto_posix.h new file mode 100644 index 0000000..7b10839 --- /dev/null +++ b/sys/include/sys/sysproto_posix.h @@ -0,0 +1,758 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * 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, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project 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 AUTHOR 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 OWNER 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 _SYS_SYSPROTO_POSIX_H +#define _SYS_SYSPROTO_POSIX_H + +#include +#include + +/* TEMP */ +#include + +typedef int register_t; + +#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? 0 : sizeof(register_t) - sizeof(t)) + +#if BYTE_ORDER == LITTLE_ENDIAN +#define PADL_(t) 0 +#define PADR_(t) PAD_(t) +#else +#define PADL_(t) PAD_(t) +#define PADR_(t) 0 +#endif + +//Protos +struct sys_exit_args { + char status_l_[PADL_(int)]; + int status; + char status_r_[PADR_(int)]; +}; + +struct sys_fork_args { + char status_l_[PADL_(int)]; + int status; + char status_r_[PADR_(int)]; +}; + +struct sys_read_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char buf_l_[PADL_(const void *)]; + const void * buf; + char buf_r_[PADR_(const void *)]; + char nbyte_l_[PADL_(size_t)]; + size_t nbyte; + char nbyte_r_[PADR_(size_t)]; +}; + +struct sys_write_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + + char buf_l_[PADL_(const void *)]; + const void * buf; + char buf_r_[PADR_(const void *)]; + + char nbyte_l_[PADL_(size_t)]; + size_t nbyte; + char nbyte_r_[PADR_(size_t)]; +}; + +struct sys_open_args { + char path_l_[PADL_(char *)]; + char *path; + char path_r_[PADR_(char *)]; + + char flags_l_[PADL_(int)]; + int flags; + char flags_r_[PADR_(int)]; + + char mode_l_[PADL_(int)]; + int mode; + char mode_r_[PADR_(int)]; +}; + +struct sys_close_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; +}; + +struct sys_wait4_args { + char pid_l_[PADL_(int)]; + int pid; + char pid_r_[PADR_(int)]; + + char status_l_[PADL_(int *)]; + int *status; + char status_r_[PADR_(int *)]; + + char options_l_[PADL_(int)]; + int options; + char options_r_[PADR_(int)]; + + char rusage_l_[PADL_(void *)]; + void *rusage; + char rusage_r_[PADR_(void *)]; +}; + +struct sys_chdir_args { + char path_l_[PADL_(char *)]; + char *path; + char path_r_[PADR_(char *)]; +}; + +struct sys_getcwd_args { + char buf_l_[PADL_(const void *)]; + void *buf; + char buf_r_[PADR_(const void *)]; + + char size_l_[PADL_(uint32_t)]; + uint32_t size; + char size_r_[PADR_(uint32_t)]; +}; + +struct sys_setUID_args { + char uid_l_[PADL_(int)]; + int uid; + char uid_r_[PADR_(int)]; +}; + +struct sys_setGID_args { + char gid_l_[PADL_(int)]; + int gid; + char gid_r_[PADR_(int)]; +}; + +struct sys_execve_args { + char fname_l_[PADL_(char *)]; + char *fname; + char fname_r_[PADR_(char *)]; + char argv_l_[PADL_(char **)]; + char **argv; + char argv_r_[PADR_(char **)]; + char envp_l_[PADL_(char **)]; + char **envp; + char envp_r_[PADR_(char **)]; +}; + +struct sys_fopen_args { + char path_l_[PADL_(char *)]; + char * path; + char path_r_[PADR_(char *)]; + char mode_l_[PADL_(char *)]; + char * mode; + char mode_r_[PADR_(char *)]; + char FILE_l_[PADL_(userFileDescriptor *)]; + userFileDescriptor *FILE; + char FILE_r_[PADR_(userFileDescriptor *)]; +}; + +struct sys_fread_args { + char ptr_l_[PADL_(void *)]; + void *ptr; + char ptr_r_[PADR_(void *)]; + char size_l_[PADL_(long)]; + long size; + char size_r_[PADR_(long)]; + char nmemb_l_[PADL_(long)]; + long nmemb; + char nmemb_r_[PADR_(long)]; + char FILE_l_[PADL_(userFileDescriptor *)]; + userFileDescriptor *FILE; + char FILE_r_[PADR_(userFileDescriptor *)]; +}; + +struct sys_fclose_args { + char FILE_l_[PADL_(userFileDescriptor *)]; + userFileDescriptor *FILE; + char FILE_r_[PADR_(userFileDescriptor *)]; +}; + +struct sys_fgetc_args { + char FILE_l_[PADL_(userFileDescriptor *)]; + userFileDescriptor *FILE; + char FILE_r_[PADR_(userFileDescriptor *)]; +}; + +struct sys_fseek_args { + char FILE_l_[PADL_(userFileDescriptor *)]; + userFileDescriptor *FILE; + char FILE_r_[PADR_(userFileDescriptor *)]; + char offset_l_[PADL_(long)]; + long offset; + char offset_r_[PADR_(long)]; + char whence_l_[PADL_(int)]; + int whence; + char whence_r_[PADR_(int)]; +}; + +struct sys_sysctl_args { + char name_l_[PADL_(int *)]; + int *name; + char name_r_[PADR_(int *)]; + char namelen_l_[PADL_(u_int)]; + u_int namelen; + char namelen_r_[PADR_(u_int)]; + char oldp_l_[PADL_(void *)]; + void *oldp; + char oldp_r_[PADR_(void *)]; + char oldlenp_l_[PADL_(size_t *)]; + size_t *oldlenp; + char oldlenp_r_[PADR_(size_t *)]; + char newp_l_[PADL_(void *)]; + void *newp; + char newp_r_[PADR_(void *)]; + char newlenp_l_[PADL_(size_t)]; + size_t newlenp; + char newlenp_r_[PADR_(size_t)]; + +}; + +/* OLD */ + +struct setitimer_args { + char which_l_[PADL_(u_int)]; + u_int which; + char which_r_[PADR_(u_int)]; + char itv_l_[PADL_(struct itimerval *)]; + struct itimerval * itv; + char itv_r_[PADR_(struct itimerval *)]; + char oitv_l_[PADL_(struct itimerval *)]; + struct itimerval * oitv; + char oitv_r_[PADR_(struct itimerval *)]; +}; + +struct access_args { + char path_l_[PADL_(char *)]; + char * path; + char path_r_[PADR_(char *)]; + char flags_l_[PADL_(int)]; + int flags; + char flags_r_[PADR_(int)]; +}; + +struct sys_fstatfs_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char buf_l_[PADL_(struct statfs *)]; + struct statfs * buf; + char buf_r_[PADR_(struct statfs *)]; +}; + +struct mprotect_args { + char addr_l_[PADL_(const void *)]; + const void * addr; + char addr_r_[PADR_(const void *)]; + char len_l_[PADL_(size_t)]; + size_t len; + char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(int)]; + int prot; + char prot_r_[PADR_(int)]; +}; + +//Old + +struct sysctl_args { + char name_l_[PADL_(int *)]; + int * name; + char name_r_[PADR_(int *)]; + char namelen_l_[PADL_(u_int)]; + u_int namelen; + char namelen_r_[PADR_(u_int)]; + char old_l_[PADL_(void *)]; + void *oldp; + char old_r_[PADR_(void *)]; + char oldlenp_l_[PADL_(size_t *)]; + size_t * oldlenp; + char oldlenp_r_[PADR_(size_t *)]; + char new_l_[PADL_(void *)]; + void * newp; + char new_r_[PADR_(void *)]; + char newlen_l_[PADL_(size_t)]; + size_t newlen; + char newlen_r_[PADR_(size_t)]; +}; + +struct getpid_args { + register_t dummy; +}; +struct sys_issetugid_args { + register_t dummy; +}; +struct fcntl_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char cmd_l_[PADL_(int)]; + int cmd; + char cmd_r_[PADR_(int)]; + char arg_l_[PADL_(long)]; + long arg; + char arg_r_[PADR_(long)]; +}; + +struct pipe_args { + register_t dummy; +}; + +struct readlink_args { + char path_l_[PADL_(char *)]; + char * path; + char path_r_[PADR_(char *)]; + char buf_l_[PADL_(char *)]; + char * buf; + char buf_r_[PADR_(char *)]; + char count_l_[PADL_(int)]; + int count; + char count_r_[PADR_(int)]; +}; + +struct getuid_args { + register_t dummy; +}; + +struct getgid_args { + register_t dummy; +}; +struct close_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; +}; + +struct sys_mmap_args { + char addr_l_[PADL_(caddr_t)]; + caddr_t addr; + char addr_r_[PADR_(caddr_t)]; + char len_l_[PADL_(size_t)]; + size_t len; + char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(int)]; + int prot; + char prot_r_[PADR_(int)]; + char flags_l_[PADL_(int)]; + int flags; + char flags_r_[PADR_(int)]; + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char pos_l_[PADL_(off_t)]; + off_t pos; + char pos_r_[PADR_(off_t)]; +}; + +struct sys_stat_args { + char path_l_[PADL_(char *)]; + char * path; + char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct stat *)]; + struct stat * ub; + char ub_r_[PADR_(struct stat *)]; +}; + +struct sys_lstat_args { + char path_l_[PADL_(char *)]; + char *path; + char path_r_[PADR_(char *)]; + char sb_l_[PADL_(struct stat *)]; + struct stat *sb; + char sb_r_[PADR_(struct stat *)]; +}; + +struct obreak_args { + char nsize_l_[PADL_(char *)]; + char * nsize; + char nsize_r_[PADR_(char *)]; +}; + +struct sigaction_args { + char sig_l_[PADL_(int)]; + int sig; + char sig_r_[PADR_(int)]; + char act_l_[PADL_(const struct sigaction *)]; + const struct sigaction * act; + char act_r_[PADR_(const struct sigaction *)]; + char oact_l_[PADL_(struct sigaction *)]; + struct sigaction * oact; + char oact_r_[PADR_(struct sigaction *)]; +}; + +struct getdtablesize_args { + register_t dummy; +}; + +struct sys_munmap_args { + char addr_l_[PADL_(void *)]; + void * addr; + char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; + size_t len; + char len_r_[PADR_(size_t)]; +}; + +struct sigprocmask_args { + char how_l_[PADL_(int)]; + int how; + char how_r_[PADR_(int)]; + char set_l_[PADL_(const sigset_t *)]; + const sigset_t * set; + char set_r_[PADR_(const sigset_t *)]; + char oset_l_[PADL_(sigset_t *)]; + sigset_t * oset; + char oset_r_[PADR_(sigset_t *)]; +}; +struct gettimeofday_args { + char tp_l_[PADL_(struct timeval *)]; + struct timeval * tp; + char tp_r_[PADR_(struct timeval *)]; + char tzp_l_[PADL_(struct timezone *)]; + struct timezone * tzp; + char tzp_r_[PADR_(struct timezone *)]; +}; +struct sys_fstat_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char sb_l_[PADL_(struct stat *)]; + struct stat * sb; + char sb_r_[PADR_(struct stat *)]; +}; +struct ioctl_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char com_l_[PADL_(u_long)]; + u_long com; + char com_r_[PADR_(u_long)]; + char data_l_[PADL_(caddr_t)]; + caddr_t data; + char data_r_[PADR_(caddr_t)]; +}; + +struct read_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char buf_l_[PADL_(void *)]; + void * buf; + char buf_r_[PADR_(void *)]; + char nbyte_l_[PADL_(size_t)]; + size_t nbyte; + char nbyte_r_[PADR_(size_t)]; +}; + +struct sys_openat_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char path_l_[PADL_(char *)]; + char * path; + char path_r_[PADR_(char *)]; + char flag_l_[PADL_(int)]; + int flag; + char flag_r_[PADR_(int)]; + char mode_l_[PADL_(__mode_t)]; + __mode_t mode; + char mode_r_[PADR_(__mode_t)]; +}; + +struct sys_sysarch_args { + char op_l_[PADL_(int)]; + int op; + char op_r_[PADR_(int)]; + char parms_l_[PADL_(char *)]; + char * parms; + char parms_r_[PADR_(char *)]; +}; + +struct sys_getpid_args { + register_t dummy; +}; + +struct sys_ioctl_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char com_l_[PADL_(u_long)]; + u_long com; + char com_r_[PADR_(u_long)]; + char data_l_[PADL_(caddr_t)]; + caddr_t data; + char data_r_[PADR_(caddr_t)]; +}; + +struct sys_geteuid_args { + register_t dummy; +}; + +struct sys_getppid_args { + register_t dummy; +}; + +struct sys_getegid_args { + register_t dummy; +}; + +struct sys_sigprocmask_args { + char how_l_[PADL_(int)]; + int how; + char how_r_[PADR_(int)]; + char set_l_[PADL_(const sigset_t *)]; + const sigset_t * set; + char set_r_[PADR_(const sigset_t *)]; + char oset_l_[PADL_(sigset_t *)]; + sigset_t * oset; + char oset_r_[PADR_(sigset_t *)]; +}; + +struct sys_sigaction_args { + char sig_l_[PADL_(int)]; + int sig; + char sig_r_[PADR_(int)]; + char act_l_[PADL_(const struct sigaction *)]; + const struct sigaction * act; + char act_r_[PADR_(const struct sigaction *)]; + char oact_l_[PADL_(struct sigaction *)]; + struct sigaction * oact; + char oact_r_[PADR_(struct sigaction *)]; +}; + +struct sys_getpgrp_args { + register_t dummy; +}; +struct sys_setpgid_args { + char pid_l_[PADL_(int)]; + int pid; + char pid_r_[PADR_(int)]; + char pgid_l_[PADL_(int)]; + int pgid; + char pgid_r_[PADR_(int)]; +}; + +struct sys_access_args { + char path_l_[PADL_(char *)]; + char * path; + char path_r_[PADR_(char *)]; + char amode_l_[PADL_(int)]; + int amode; + char amode_r_[PADR_(int)]; +}; + +struct sys_statfs_args { + char path_l_[PADL_(char *)]; + char * path; + char path_r_[PADR_(char *)]; + char buf_l_[PADL_(struct statfs *)]; + struct statfs * buf; + char buf_r_[PADR_(struct statfs *)]; +}; + +struct sys_fstatat_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char path_l_[PADL_(char *)]; + char * path; + char path_r_[PADR_(char *)]; + char buf_l_[PADL_(struct stat *)]; + struct stat * buf; + char buf_r_[PADR_(struct stat *)]; + char flag_l_[PADL_(int)]; + int flag; + char flag_r_[PADR_(int)]; +}; + +struct sys_fchdir_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; +}; + +struct sys_getdirentries_args { + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + char buf_l_[PADL_(char *)]; + char * buf; + char buf_r_[PADR_(char *)]; + char count_l_[PADL_(u_int)]; + u_int count; + char count_r_[PADR_(u_int)]; + char basep_l_[PADL_(long *)]; + long * basep; + char basep_r_[PADR_(long *)]; +}; + +struct sys_socket_args { + char domain_l_[PADL_(int)]; + int domain; + char domain_r_[PADR_(int)]; + char type_l_[PADL_(int)]; + int type; + char type_r_[PADR_(int)]; + char protocol_l_[PADL_(int)]; + int protocol; + char protocol_r_[PADR_(int)]; +}; + +struct sys_setsockopt_args { + char s_l_[PADL_(int)]; + int s; + char s_r_[PADR_(int)]; + char level_l_[PADL_(int)]; + int level; + char level_r_[PADR_(int)]; + char name_l_[PADL_(int)]; + int name; + char name_r_[PADR_(int)]; + char val_l_[PADL_(caddr_t)]; + caddr_t val; + char val_r_[PADR_(caddr_t)]; + char valsize_l_[PADL_(int)]; + int valsize; + char valsize_r_[PADR_(int)]; +}; + +struct sys_select_args { + char nd_l_[PADL_(int)]; + int nd; + char nd_r_[PADR_(int)]; + char in_l_[PADL_(fd_set *)]; + fd_set * in; + char in_r_[PADR_(fd_set *)]; + char ou_l_[PADL_(fd_set *)]; + fd_set * ou; + char ou_r_[PADR_(fd_set *)]; + char ex_l_[PADL_(fd_set *)]; + fd_set * ex; + char ex_r_[PADR_(fd_set *)]; + char tv_l_[PADL_(struct timeval *)]; + struct timeval * tv; + char tv_r_[PADR_(struct timeval *)]; +}; + +struct sys_gettimeofday_args { + char tp_l_[PADL_(struct timeval *)]; struct timeval * tp; char tp_r_[PADR_(struct timeval *)]; + char tzp_l_[PADL_(struct timezone *)]; struct timezone * tzp; char tzp_r_[PADR_(struct timezone *)]; +}; + + +struct sys_sendto_args { + char s_l_[PADL_(int)]; int s; char s_r_[PADR_(int)]; + char buf_l_[PADL_(caddr_t)]; caddr_t buf; char buf_r_[PADR_(caddr_t)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; + char to_l_[PADL_(caddr_t)]; caddr_t to; char to_r_[PADR_(caddr_t)]; + char tolen_l_[PADL_(int)]; int tolen; char tolen_r_[PADR_(int)]; +}; + +//Func Defs +int sys_invalid(struct thread *, void *); +int sys_exit(struct thread *, struct sys_exit_args *); +int sys_fork(struct thread *, struct sys_fork_args *); +int sys_read(struct thread *, struct sys_read_args *); +int sys_write(struct thread *td, struct sys_write_args *); +int sys_open(struct thread *td, struct sys_open_args *); +int sys_close(struct thread *td, struct sys_close_args *); +int sys_wait4(struct thread *td, struct sys_wait4_args *); +int sys_chdir(struct thread *td, struct sys_chdir_args *); + +int sys_setUID(struct thread *td, struct sys_setUID_args *); +int sys_getUID(struct thread *td, void *); +int sys_setGID(struct thread *td, struct sys_setGID_args *); +int sys_getGID(struct thread *td, void *); + +int sys_execve(struct thread *td, struct sys_execve_args *); + +int sys_fopen(struct thread *td, struct sys_fopen_args *); +int sys_fread(struct thread *td, struct sys_fread_args *); +int sys_fclose(struct thread *td, struct sys_fclose_args *); +int sys_fgetc(struct thread *td, struct sys_fgetc_args *); +int sys_fseek(struct thread *td, struct sys_fseek_args *); + +int sys_sched_yield(struct thread *td, void *); + +int sys_getcwd(struct thread *td, struct sys_getcwd_args *); + +int sys_mmap(struct thread *td, struct sys_mmap_args *); +int sys_munmap(struct thread *td, struct sys_munmap_args *); +int sys_sysctl(struct thread *td, struct sys_sysctl_args *); + +int sys_issetugid(struct thread *td, struct sys_issetugid_args *); + +int setitimer(struct thread *td, struct setitimer_args *uap); +int access(struct thread *td, struct access_args *uap); +int fstatfs(struct thread *td, struct sys_fstatfs_args *uap); +int mprotect(struct thread *td, struct mprotect_args *uap); + +int sys_statfs(struct thread *td, struct sys_statfs_args *args); +int sys_fstatfs(struct thread *td, struct sys_fstatfs_args *); +int sys_stat(struct thread *td, struct sys_stat_args *); +int sys_lstat(struct thread *td, struct sys_lstat_args *); +int sys_fstat(struct thread *td, struct sys_fstat_args *); +int sys_fstatat(struct thread *td, struct sys_fstatat_args *); +int sys_openat(struct thread *td, struct sys_openat_args *); + +int sys_sysarch(struct thread *td, struct sys_sysarch_args *); +int sys_getpid(struct thread *td, struct sys_getpid_args *); +int sys_ioctl(struct thread *td, struct sys_ioctl_args *); + +int sys_geteuid(struct thread *td, struct sys_geteuid_args *); + +int sys_getegid(struct thread *td, struct sys_getegid_args *); + +int sys_getppid(struct thread *td, struct sys_getppid_args *); + +int sys_getpgrp(struct thread *td, struct sys_getpgrp_args *); +int sys_setpgrp(struct thread *td, struct sys_setpgid_args *); + +int sys_sigprocmask(struct thread *td, struct sys_sigprocmask_args *); +int sys_sigaction(struct thread *td, struct sys_sigaction_args *); + +int sys_getpgrp(struct thread *td, struct sys_getpgrp_args *); +int sys_setpgid(struct thread *td, struct sys_setpgid_args *); + +int sys_access(struct thread *td, struct sys_access_args *); +int sys_fchdir(struct thread *td, struct sys_fchdir_args *); + +int sys_getdirentries(struct thread *td, struct sys_getdirentries_args *); + +int sys_socket(struct thread *td, struct sys_socket_args *); +int sys_setsockopt(struct thread *td, struct sys_setsockopt_args *); +int sys_select(struct thread *td, struct sys_select_args *); + + +int sys_gettimeofday(struct thread *td, struct sys_gettimeofday_args *); +int sys_sendto(struct thread *td, struct sys_sendto_args *); +#endif /* END _SYS_SYSPROTO_POSIX_H */ diff --git a/sys/include/ubixos/syscalls.h b/sys/include/ubixos/syscalls.h index 387d3d8..8eee923 100644 --- a/sys/include/ubixos/syscalls.h +++ b/sys/include/ubixos/syscalls.h @@ -33,7 +33,7 @@ #include #include -#define SYSCALLS_MAX 495 +#define SYSCALLS_MAX 1024 #define PSL_C 0x00000001 /* carry bit */ #define EJUSTRETURN (-2) /* don't modify regs, just return */ diff --git a/sys/kernel/Makefile b/sys/kernel/Makefile index 93b8aec..50d81ae 100644 --- a/sys/kernel/Makefile +++ b/sys/kernel/Makefile @@ -6,7 +6,7 @@ include ../Makefile.incl # Objects -OBJS = sem.o vfs_calls.o tty.o kern_sig.o pipe.o descrip.o kern_sysctl.o gen_calls.o endtask.o ld.o time.o elf.o ubthread.o vitals.o access.o syscall.o syscall_posix.o syscalls_posix.o execve.o +OBJS = sem.o vfs_calls.o tty.o kern_sig.o pipe.o descrip.o kern_sysctl.o gen_calls.o endtask.o ld.o time.o elf.o ubthread.o vitals.o access.o syscall.o syscall_posix.o syscalls.o syscalls_posix.o execve.o #OBJS += ../${_ARCH}/schedyield.o ../${_ARCH}/kpanic.o ../${_ARCH}/timer.o ../${_ARCH}/spinlock.o ../${_ARCH}/exec.o ../${_ARCH}/sys_call_new.o ../${_ARCH}/sys_call.o ../${_ARCH}/bioscall.o ../${_ARCH}/fork.o ../${_ARCH}/syscall.o ../${_ARCH}/systemtask.o ../${_ARCH}/sched.o ../${_ARCH}/cpu.o # ap-boot.o smp.o vitals.o(obsolete) diff --git a/sys/kernel/syscall.c b/sys/kernel/syscall.c index eeeb9b7..0f7f1fe 100644 --- a/sys/kernel/syscall.c +++ b/sys/kernel/syscall.c @@ -26,37 +26,90 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include -#include -#include #include -#include -#include +#include #include -#include -#include +#include #include #include -#include -#include +#include /* #include */ -#include #include void sys_call(struct trapframe *frame) { - asm("nop"); + uint32_t code = 0x0; + caddr_t params; + + struct thread *td = &_current->td; + + td->frame = frame; + + int error = 0x0; + + params = (caddr_t) frame->tf_esp + sizeof(int); + + code = frame->tf_eax; + + if (code > totalCalls) { + die_if_kernel("Invalid System Call", frame, frame->tf_eax); + kpanic("PID: %i", _current->id); + } + else if ((uint32_t) systemCalls[code].sc_status == SYSCALL_INVALID) { + kprintf("Invalid Call: [%i][0x%X]\n", code, (uint32_t) systemCalls[code].sc_name); + frame->tf_eax = -1; + frame->tf_edx = 0x0; + } + else { + td->td_retval[0] = 0; + td->td_retval[1] = frame->tf_edx; + + if (systemCalls[code].sc_status == SYSCALL_DUMMY) + kprintf("Syscall->abi: [%i], PID: [%i], Code: %i, Call: %s\n", td->abi, _current->id, frame->tf_eax, systemCalls[code].sc_name); + + if (td->abi == ELFOSABI_UBIXOS) + error = (int) systemCalls[code].sc_entry( frame->tf_ebx, frame->tf_ecx, frame->tf_edx ); + else if (td->abi == ELFOSABI_FREEBSD) + error = (int) systemCalls[code].sc_entry(td, params); + else + error = (int) systemCalls[code].sc_entry(td, params); + + if (systemCalls[code].sc_status == SYSCALL_DUMMY) { + kprintf("DUMMY CALL: (%i)\n", code); + return; + } + + switch (error) { + case 0: + frame->tf_eax = td->td_retval[0]; + frame->tf_edx = td->td_retval[1]; + frame->tf_eflags &= ~PSL_C; + break; + default: + frame->tf_eax = td->td_retval[0]; + frame->tf_edx = td->td_retval[1]; + frame->tf_eflags |= PSL_C; + break; + } + } } -//long fuword( const void *base ); +int invalidCall() { + int sys_call; -//void sdeTestThread(); + asm( + "nop" + : "=a" (sys_call) + : + ); -int InvalidSystemCall() { - kprintf("attempt was made to an invalid system call\n"); + kprintf("Invalid System Call #[%i], PID: %i\n", sys_call, _current->id); return (0); } + typedef struct _UbixUser UbixUser; struct _UbixUser { char *username; @@ -123,22 +176,12 @@ ************************************************************************/ int sysGetFreePage(struct thread *td, uint32_t *count) { - //MrOlsen 2017-12-15 kprintf("sysGetFreePage - Count: %i\n", *count); + td->td_retval[0] = vmm_getFreeVirtualPage(_current->id, *count, VM_THRD); return(0); //return(vmm_getFreeVirtualPage(_current->id, *count, VM_TASK)); } -int sysGetFreePage_OLD(long *ptr, int count, int type) { - if (ptr) { - if (type == 2) - *ptr = (long) vmm_getFreeVirtualPage(_current->id, count, VM_THRD); - else - *ptr = (long) vmm_getFreeVirtualPage(_current->id, count, VM_TASK); - } - return (0); -} - int sysGetDrives(uInt32 *ptr) { if (ptr) *ptr = 0x0; //(uInt32)devices; diff --git a/sys/kernel/syscall_posix.c b/sys/kernel/syscall_posix.c index c16adc6..762a407 100644 --- a/sys/kernel/syscall_posix.c +++ b/sys/kernel/syscall_posix.c @@ -64,11 +64,11 @@ params += sizeof(quad_t); } - if (code > totalCalls) { + if (code > totalCalls_posix) { die_if_kernel("Invalid System Call", frame, frame->tf_eax); kpanic("PID: %i", _current->id); } - else if ((uint32_t) systemCalls[code].sc_status == SYSCALL_INVALID) { + else if ((uint32_t) systemCalls_posix[code].sc_status == SYSCALL_INVALID) { kprintf("Invalid Call: [%i][0x%X]\n", code, (uint32_t) systemCalls[code].sc_name); frame->tf_eax = -1; frame->tf_edx = 0x0; @@ -77,7 +77,7 @@ td->td_retval[0] = 0; td->td_retval[1] = frame->tf_edx; - if (systemCalls[code].sc_status == SYSCALL_DUMMY) + if (systemCalls_posix[code].sc_status == SYSCALL_DUMMY) kprintf("Syscall->abi: [%i], PID: [%i], Code: %i, Call: %s\n", td->abi, _current->id, frame->tf_eax, systemCalls[code].sc_name); /* @@ -86,11 +86,11 @@ */ if (td->abi == ELFOSABI_FREEBSD) - error = (int) systemCalls[code].sc_entry(td, params); + error = (int) systemCalls_posix[code].sc_entry(td, params); else - error = (int) systemCalls[code].sc_entry(td, params); + error = (int) systemCalls_posix[code].sc_entry(td, params); - if (systemCalls[code].sc_status == SYSCALL_DUMMY) { + if (systemCalls_posix[code].sc_status == SYSCALL_DUMMY) { kprintf("RET(%i)1", code); return; } @@ -100,7 +100,7 @@ frame->tf_eax = td->td_retval[0]; frame->tf_edx = td->td_retval[1]; frame->tf_eflags &= ~PSL_C; - if (systemCalls[code].sc_status == SYSCALL_DUMMY) + if (systemCalls_posix[code].sc_status == SYSCALL_DUMMY) kprintf("RET3"); break; default: diff --git a/sys/kernel/syscalls.c b/sys/kernel/syscalls.c new file mode 100644 index 0000000..12077e4 --- /dev/null +++ b/sys/kernel/syscalls.c @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * 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, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project 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 AUTHOR 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 OWNER 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. + */ + +#include +#include + +/* System Calls List */ +struct syscall_entry systemCalls[] = { + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 0 - syscall + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 1 - + { ARG_COUNT(struct sys_mpiCreateMbox_args) +, "mpiCrateMbox", sys_mpiCreateMbox, SYSCALL_VALID}, // 50 - mpiCreateMbox + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 51 - mpiDestroyMbox + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 52 - mpiPostMessage + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 53 - mpiFetchMessage + { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 54 - mpiSpam + }; + +int totalCalls = sizeof(systemCalls) / sizeof(struct syscall_entry); diff --git a/sys/kernel/syscalls_posix.c b/sys/kernel/syscalls_posix.c index 6a4fb73..f2ee8b0 100644 --- a/sys/kernel/syscalls_posix.c +++ b/sys/kernel/syscalls_posix.c @@ -27,10 +27,10 @@ */ #include -#include +#include /* System Calls List */ -struct syscall_entry systemCalls[] = { +struct syscall_entry systemCalls_posix[] = { { 0, "No Call", sys_invalid, SYSCALL_VALID }, // 0 - syscall { ARG_COUNT(sys_exit_args), "exit", (sys_call_t *) sys_exit, SYSCALL_VALID }, // 1 - exit { ARG_COUNT(sys_fork_args), "fork", (sys_call_t *) sys_fork, SYSCALL_VALID }, // 2 - fork @@ -147,7 +147,7 @@ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 113 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 114 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 115 - Invalid */ - { ARG_COUNT(sys_gettimeofday_args), "gettimeofday", sys_gettimeofday, SYSCALL_VALID }, // 116 - gettimeofday + { ARG_COUNT(sys_gettimeofday_args), "gettimeofday", sys_gettimeofday, SYSCALL_VALID }, // 116 - gettimeofday { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 117 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 118 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 119 - Invalid */ @@ -543,4 +543,4 @@ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ }; -int totalCalls = sizeof(systemCalls) / sizeof(struct syscall_entry); +int totalCalls_posix = sizeof(systemCalls_posix) / sizeof(struct syscall_entry); diff --git a/sys/mpi/Makefile b/sys/mpi/Makefile index 23e7f72..4e5d85b 100644 --- a/sys/mpi/Makefile +++ b/sys/mpi/Makefile @@ -6,7 +6,7 @@ include ../Makefile.incl # Objects -OBJS = system.o message.o +OBJS = system.o message.o mpi_syscalls.o all: $(OBJS) diff --git a/sys/mpi/mpi_syscalls.c b/sys/mpi/mpi_syscalls.c new file mode 100644 index 0000000..ff14453 --- /dev/null +++ b/sys/mpi/mpi_syscalls.c @@ -0,0 +1,7 @@ +#include +#include + +int sys_mpiCreateMbox(struct thread *td, struct sys_mpiCreateMbox_args *args) { + td->td_retval[0] = mpi_createMbox(args->name); + return (0x0); +} diff --git a/sys/mpi/system.c b/sys/mpi/system.c index 1af8b3b..e11e0f7 100644 --- a/sys/mpi/system.c +++ b/sys/mpi/system.c @@ -30,6 +30,8 @@ #include #include #include +#include + static mpi_mbox_t *mboxList = 0x0; static struct spinLock mpiSpinLock = SPIN_LOCK_INITIALIZER; @@ -69,14 +71,14 @@ mpi_mbox_t *mbox = 0x0; spinLock(&mpiSpinLock); - if (mpi_findMbox(name) != 0x0) { +if (mpi_findMbox(name) != 0x0) { spinUnlock(&mpiSpinLock); return (-1); } mbox = (mpi_mbox_t *) kmalloc(sizeof(mpi_mbox_t)); - sprintf(mbox->name, name); +sprintf(mbox->name, name); mbox->pid = _current->id; if (mboxList == 0x0) { @@ -91,6 +93,7 @@ mboxList = mbox; } + spinUnlock(&mpiSpinLock); return (0x0); } diff --git a/sys/sys/idt.c b/sys/sys/idt.c index 10c89a6..98b8a2b 100644 --- a/sys/sys/idt.c +++ b/sys/sys/idt.c @@ -65,12 +65,6 @@ struct tssStruct *sfTSS = (struct tssStruct *) 0x6200; struct tssStruct *gpfTSS = (struct tssStruct *) 0x4200; - /* Set up default vector table for all possible 256 interrupts */ - /* - for (i = 0x0; i < 256; i++) { - setVector(intNull, i, dPresent + dTrap + dDpl3); - }*/ - /* Load the IDT into the system */ asm volatile( "cli \n" @@ -101,7 +95,6 @@ setVector(_vmm_pageFault, 14, dPresent + dInt + dDpl0); setVector(_sys_call_posix, 0x80, dPresent + dTrap + dDpl3); setVector(_sys_call, 0x81, dPresent + dTrap + dDpl3); - //setVector(_sysCallNew, 0x90, dPresent + dTrap + dDpl3); setVector(timerInt, 0x68, (dInt + dPresent + dDpl0)); gpfTSS->back_link = 0x0; diff --git a/sys/vmm/vmm_mmap.c b/sys/vmm/vmm_mmap.c index 28aa85b..5c09d34 100644 --- a/sys/vmm/vmm_mmap.c +++ b/sys/vmm/vmm_mmap.c @@ -35,7 +35,7 @@ #include /* MrOlsen (2016-01-15) TEMP: Put These somewhere else */ -typedef __uint32_t __vm_size_t; typedef __vm_size_t +typedef __uint32_t __vm_size_t; typedef __vm_size_t vm_size_t; #define EINVAL 22 /* Invalid argument */ #define MAP_ALIGNED(n) ((n) << MAP_ALIGNMENT_SHIFT) @@ -155,8 +155,9 @@ int sys_munmap(struct thread *td, struct sys_munmap_args *uap) { //TEMP td->td_retval[0] = 0; - return(0); -}; + return (0); +} +; int sys_mmap(struct thread *td, struct sys_mmap_args *uap) { vm_offset_t addr = 0x0; @@ -171,13 +172,13 @@ for (x = 0x0; x < round_page(uap->len); x += 0x1000) { vmm_unmapPage(((uint32_t) uap->addr & 0xFFFFF000) + x, VMM_FREE); /* Make readonly and read/write !!! */ - if (vmm_remapPage(vmm_findFreePage(_current->id), (((uint32_t)uap->addr & 0xFFFFF000) + x), PAGE_DEFAULT, _current->id, 0) == 0x0) + if (vmm_remapPage(vmm_findFreePage(_current->id), (((uint32_t) uap->addr & 0xFFFFF000) + x), PAGE_DEFAULT, _current->id, 0) == 0x0) K_PANIC("Remap Page Failed"); } tmp = uap->addr; bzero(tmp, uap->len); - td->td_retval[0] = (uint32_t)tmp; + td->td_retval[0] = (uint32_t) tmp; return (0x0); } @@ -186,32 +187,34 @@ return (0x0); //vmm_getFreeVirtualPage(_current->id, round_page( uap->len ) / 0x1000, VM_THRD)); } else { - //kprintf("uap->flags: [0x%X]\n", uap->flags); - //MrOlsenkprintf("uap->addr: [0x%X]", uap->addr); - //MrOlsenkprintf("uap->len: [0x%X]", uap->len); - //kprintf("uap->prot: [0x%X]", uap->prot); - //MrOlsenkprintf("uap->fd: [%i]\n", uap->fd); - //kprintf("uap->pad: [0x%X]", uap->pad); - //kprintf("uap->pos: [0x%X]", uap->pos); + getfd(td, &fd, uap->fd); + if (uap->addr == 0x0) - tmp = (char *) vmm_getFreeVirtualPage(_current->id, round_page(uap->len) / 0x1000, VM_TASK); + tmp = (char *) vmm_getFreeVirtualPage(_current->id, round_page(uap->len) / 0x1000, VM_TASK); else { + for (x = 0x0; x < round_page(uap->len); x += 0x1000) { - vmm_unmapPage(((uint32_t)uap->addr & 0xFFFFF000) + x, 1); + + vmm_unmapPage(((uint32_t) uap->addr & 0xFFFFF000) + x, 1); + /* Make readonly and read/write !!! */ - if (vmm_remapPage(vmm_findFreePage(_current->id), (((uint32_t)uap->addr & 0xFFFFF000) + x), PAGE_DEFAULT, _current->id, 0) == 0x0) + if (vmm_remapPage(vmm_findFreePage(_current->id), (((uint32_t) uap->addr & 0xFFFFF000) + x), PAGE_DEFAULT, _current->id, 0) == 0x0) K_PANIC("Remap Page Failed"); } + tmp = uap->addr; - } + } + fseek(fd->fd, uap->pos, 0x0); fread(tmp, uap->len, 0x1, fd->fd); + td->td_retval[0] = (uint32_t) tmp; - if (td->td_retval[0] == (caddr_t)-1) - kpanic("BALLS"); + + if (td->td_retval[0] == (caddr_t) -1) + kpanic("MMAP_FAILED"); } return (0x0); }