|
|||
Prex Home / Browse Source - Prex Version: 0.9.0 |
|||
root/include/sys/prex.h/* [<][>][^][v][top][bottom][index][help] */INCLUDED FROM1 /* 2 * Copyright (c) 2005-2007, Kohsuke Ohtani 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the author nor the names of any co-contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30 #ifndef _SYS_H 31 #define _SYS_H 32 #ifndef KERNEL 33 34 #include <conf/config.h> 35 #include <sys/cdefs.h> 36 #include <sys/types.h> 37 #include <sys/param.h> 38 #include <sys/sysinfo.h> 39 #include <sys/capability.h> 40 #include <sys/dbgctl.h> 41 42 /* 43 * vm_option for task_crate() 44 */ 45 #define VM_NEW 0 46 #define VM_SHARE 1 47 #define VM_COPY 2 48 49 /* 50 * protection flags for vm_attribute() 51 */ 52 #define PROT_READ 0x1 /* pages can be read */ 53 #define PROT_WRITE 0x2 /* pages can be written */ 54 #define PROT_EXEC 0x4 /* pages can be executed */ 55 56 /* 57 * Device open mode for device_open() 58 */ 59 #define DO_RDONLY 0x0 60 #define DO_WRONLY 0x1 61 #define DO_RDWR 0x2 62 #define DO_RWMASK 0x3 63 64 /* 65 * Scheduling policy 66 */ 67 #define SCHED_FIFO 0 /* First In First Out */ 68 #define SCHED_RR 1 /* Round Robin */ 69 #define SCHED_OTHER 2 /* Other */ 70 71 /* Default exception handler */ 72 #define EXC_DFL ((void (*)(int)) -1) 73 74 /* 75 * Synch initializer 76 */ 77 #define MUTEX_INITIALIZER (mutex_t)0x4d496e69 78 #define COND_INITIALIZER (cond_t)0x43496e69 79 80 81 __BEGIN_DECLS 82 void exception_return(void); 83 int exception_setup(void (*handler)(int)); 84 int exception_raise(task_t task, int excno); 85 int exception_wait(int *excno); 86 87 int task_create(task_t parent, int vm_option, task_t *childp); 88 int task_terminate(task_t task); 89 task_t task_self(void); 90 int task_suspend(task_t task); 91 int task_resume(task_t task); 92 int task_setname(task_t task, const char *name); 93 int task_setcap(task_t task, cap_t cap); 94 int task_chkcap(task_t task, cap_t cap); 95 96 int thread_create(task_t task, thread_t *tp); 97 int thread_terminate(thread_t t); 98 int thread_load(thread_t t, void (*entry)(void), void *stack); 99 thread_t thread_self(void); 100 void thread_yield(void); 101 int thread_suspend(thread_t t); 102 int thread_resume(thread_t t); 103 int thread_getpri(thread_t t, int *pri); 104 int thread_setpri(thread_t t, int pri); 105 int thread_getpolicy(thread_t t, int *policy); 106 int thread_setpolicy(thread_t t, int policy); 107 108 int vm_allocate(task_t task, void **addr, size_t size, int anywhere); 109 int vm_free(task_t task, void *addr); 110 int vm_attribute(task_t task, void *addr, int prot); 111 int vm_map(task_t target, void *addr, size_t size, void **alloc); 112 113 int object_create(const char *name, object_t *objp); 114 int object_destroy(object_t obj); 115 int object_lookup(const char *name, object_t *objp); 116 117 int msg_send(object_t obj, void *msg, size_t size); 118 int msg_receive(object_t obj, void *msg, size_t size); 119 int msg_reply(object_t obj, void *msg, size_t size); 120 121 int timer_sleep(u_long msec, u_long *remain); 122 int timer_alarm(u_long msec, u_long *remain); 123 int timer_periodic(thread_t t, u_long start, u_long period); 124 int timer_waitperiod(void); 125 126 int device_open(const char *name, int mode, device_t *dev); 127 int device_close(device_t dev); 128 int device_read(device_t dev, void *buf, size_t *nbyte, int blkno); 129 int device_write(device_t dev, void *buf, size_t *nbyte, int blkno); 130 int device_ioctl(device_t dev, u_long cmd, void *arg); 131 132 int mutex_init(mutex_t *mp); 133 int mutex_destroy(mutex_t *mp); 134 int mutex_trylock(mutex_t *mp); 135 int mutex_lock(mutex_t *mp); 136 int mutex_unlock(mutex_t *mp); 137 138 int cond_init(cond_t *cp); 139 int cond_destroy(cond_t *cp); 140 int cond_wait(cond_t *cp, mutex_t *mp); 141 int cond_signal(cond_t *cp); 142 int cond_broadcast(cond_t *cp); 143 144 int sem_init(sem_t *sp, u_int value); 145 int sem_destroy(sem_t *sp); 146 int sem_wait(sem_t *sp, u_long timeout); 147 int sem_trywait(sem_t *sp); 148 int sem_post(sem_t *sp); 149 int sem_getvalue(sem_t *sp, u_int *value); 150 151 int sys_log(const char *msg); 152 void sys_panic(const char *msg); 153 int sys_info(int type, void *buf); 154 int sys_time(u_long *ticks); 155 int sys_debug(int cmd, void *data); 156 157 void panic(const char *fmt, ...); 158 void dprintf(const char *fmt, ...); 159 160 __END_DECLS 161 162 #endif /* KERNEL */ 163 #endif /* !_SYS_H */ /* [<][>][^][v][top][bottom][index][help] */ | |||
Copyright© 2005-2009 Kohsuke Ohtani |