passwd_myos* myos_user_getID(int id){ int ret=syscall2(69,id,(uint32_t)&myos_pass); if (ret!=0) return &myos_pass; else return NULL; }
int register_named_ipc_port( const char* name, ipc_port_id port_id ) { return syscall2( SYS_register_named_ipc_port, ( int )name, port_id ); }
errval_t sys_debug_hardware_timer_read(uintptr_t* v) { struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_TIMER_READ); *v = sr.value; return sr.error; }
passwd_myos* myos_user_getN(const char* name){ int ret=syscall2(68,(uint32_t)name,(uint32_t)&myos_pass); if (ret!=0) return &myos_pass; else return NULL; }
static int PCILx_Init(LIBBASETYPEPTR LIBBASE) { APTR KernelBase; STRPTR arch; int ret; D(bug("LinuxPCI: Initializing\n")); KernelBase = OpenResource("kernel.resource"); if (!KernelBase) return FALSE; /* Make sure we are running on Linux. Otherwise we will just crash at first syscall. */ arch = (STRPTR)KrnGetSystemAttr(KATTR_Architecture); if (strncmp(arch, "linux", 5)) { D(bug("LinuxPCI: Running on %s, not on Linux\n", arch)); return FALSE; } ret = syscall1(__NR_iopl, 3); D(bug("LinuxPCI: iopl(3)=%d\n", ret)); LIBBASE->psd.fd = syscall2(__NR_open, (IPTR)"/dev/mem", 2); D(bug("LinuxPCI: /dev/mem fd=%d\n", LIBBASE->psd.fd)); if (ret==0) return TRUE; D(bug("LinuxPCI: has to be root in order to use this hidd\n")); return FALSE; }
int get_named_ipc_port( const char* name, ipc_port_id* port_id ) { return syscall2( SYS_get_named_ipc_port, ( int )name, ( int )port_id ); }
unsigned int sleep( unsigned int seconds ) { uint64_t time; time = seconds * 1000000; syscall2( SYS_sleep_thread, ( int )&time, ( int )NULL ); return 0; }
errval_t sys_debug_hardware_global_timer_read(uint64_t *ret) { struct sysret sr; uint32_t l, h; do { h = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_GLOBAL_TIMER_HIGH).value; l = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_GLOBAL_TIMER_LOW).value; // read high again, in case it changed sr = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_GLOBAL_TIMER_HIGH); } while(h != sr.value && err_is_ok(sr.error)); if(err_is_ok(sr.error) && ret) { *ret = (((uint64_t) h) << 32) | ((uint32_t) l); } return sr.error; }
static uint32_t sys_getcwd(uint32_t arg[]) { char *buf = (char *)arg[0]; size_t len = (size_t) arg[1]; /* See the comment of 'host_map_user' in arch/um/kernel/host_syscall.c for details. */ if (host_map_user(current, (uintptr_t) buf, len, 1) < 0) return -1; int ret = sysfile_getcwd(buf, len); syscall2(__NR_munmap, (uintptr_t) buf, len); return ret; }
int fstat( int fd, struct stat* stat ) { int error; error = syscall2( SYS_fstat, fd, ( int )stat ); if ( error < 0 ) { errno = -error; return -1; } return 0; }
int dup2( int old_fd, int new_fd ) { int error; error = syscall2( SYS_dup2, old_fd, new_fd ); if ( error < 0 ) { errno = -error; return -1; } return error; }
int access( const char* pathname, int mode ) { int error; error = syscall2( SYS_access, ( int )pathname, mode ); if ( error < 0 ) { errno = -error; return -1; } return 0; }
mapid_t mmap (int fd, void *addr) { return syscall2 (SYS_MMAP, fd, addr); }
int munmap(void *addr, size_t len) { return (int)syscall2(__NR_munmap, (unsigned long)addr, (unsigned long)len); }
void seek (int fd, unsigned position) { syscall2 (SYS_SEEK, fd, position); }
errval_t sys_debug_get_apic_ticks_per_sec(uint32_t *ret) { struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_TICKS_PER_SEC); *ret = sr.value; return sr.error; }
errval_t sys_debug_flush_cache(void) { return syscall2(SYSCALL_DEBUG, DEBUG_FLUSH_CACHE).error; }
errval_t sys_debug_get_apic_id(uint8_t *ret) { struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_ID); *ret = sr.value; return sr.error; }
errval_t sys_debug_get_apic_timer(uint32_t *ret) { struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_TIMER); *ret = sr.value; return sr.error; }
errval_t sys_debug_timeslice_counter_read(uint64_t *ret) { struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_TIMESLICE_COUNTER_READ); *ret = sr.value; return sr.error; }
errval_t sys_debug_get_tsc_per_ms(uint64_t *ret) { struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_TSC_PER_MS); *ret = sr.value; return sr.error; }
errval_t sys_debug_context_counter_reset(void) { return syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_RESET).error; }
errval_t sys_debug_context_counter_read(uint64_t *ret) { struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_READ); *ret = sr.value; return sr.error; }
int getatt(int req, char *buf) { syscall2(13, req, buf); }
int open(char* name, char* buf) { syscall2(SYS_OPEN, name, buf); }
bool readdir (int fd, char name[READDIR_MAX_LEN + 1]) { return syscall2 (SYS_READDIR, fd, name); }
int uthread_join(int th_id, int* th_status) { return syscall2 (SYS_UTHREAD_JOIN, th_id, th_status); }
/* * Added by Adrian Colesa - multithreading */ int uthread_create(THREAD_FUNC th_fc, int* fc_arg) { return syscall2 (SYS_UTHREAD_CREATE, th_fc, fc_arg); }
bool create (const char *file, unsigned initial_size) { return syscall2 (SYS_CREATE, file, initial_size); }
/** * Remap the specified address to a new page with new permission. * @param pgdir page directory * @param la linear address */ void tlb_update (pde_t *pgdir, uintptr_t la) { la = ROUNDDOWN (la, PGSIZE); pte_t* pte = get_pte (pgdir, la, 0); if (pte == 0 || (*pte & PTE_P) == 0) panic ("invalid tlb flushing\n"); uint32_t pa = PDE_ADDR(*pte); /* A tricky method to make the page table right under most circumstances. * Please consult the internal documentation for details. */ int r = 1, w = 1, x = 1; if (Get_PTE_A(pte) == 0) r = x = w = 0; else if (Get_PTE_W(pte) == 0 || Get_PTE_D(pte) == 0) w = 0; /* Make sure that the page is invalid before mapping * It is better to use 'mprotect' here actually. */ tlb_invalidate (pgdir, la); struct proc_struct *proc = find_proc_by_pgdir (pgdir); if (current != NULL && proc != NULL) { /* Map the page to the container process found using the stub code */ if (host_mmap (proc, (void*)la, PGSIZE, (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | (x ? PROT_EXEC : 0), MAP_SHARED | MAP_FIXED, ginfo->mem_fd, pa) == MAP_FAILED) panic ("map in child failed.\n"); } else { /* Map the page to the host process */ struct mmap_arg_struct args = { .addr = la, .len = PGSIZE, .prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | (x ? PROT_EXEC : 0), .flags = MAP_SHARED | MAP_FIXED, .fd = ginfo->mem_fd, .offset = pa, }; syscall1 (__NR_mmap, (long)&args); } } /** * unmap the page specified by @la in the container process corresponding to @pgdir * @param pgdir page directory * @param la the logical address of the page to be flushed */ void tlb_invalidate (pde_t *pgdir, uintptr_t la) { struct proc_struct *proc = find_proc_by_pgdir (pgdir); if (current != NULL && proc != NULL) { if (host_munmap (proc, (void*)la, PGSIZE) < 0) panic ("unmap in child failed\n"); } else { syscall2 (__NR_munmap, la, PGSIZE); } } /** * invalidate [USERBASE, USERTOP). * used by tests or do_execve if a 'clean' space is needed (though not neccesary). */ void tlb_invalidate_user (void) { syscall2 (__NR_munmap, USERBASE, USERTOP - USERBASE); }