Annotation of prex/include/prex/prex.h, Revision 1.1
1.1 ! nbrk 1: /*
! 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 _PREX_H
! 31: #define _PREX_H
! 32: #ifndef KERNEL
! 33:
! 34: #include <conf/config.h>
! 35:
! 36: #include <sys/cdefs.h>
! 37: #include <sys/types.h>
! 38: #include <sys/param.h>
! 39: #include <prex/sysinfo.h>
! 40: #include <prex/capability.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: * attr flags for vm_attribute()
! 51: */
! 52: #define VMA_READ 0x01
! 53: #define VMA_WRITE 0x02
! 54: #define VMA_EXEC 0x04
! 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: /*
! 72: * Synch initializer
! 73: */
! 74: #define MUTEX_INITIALIZER (mutex_t)0x4d496e69
! 75: #define COND_INITIALIZER (cond_t)0x43496e69
! 76:
! 77: /*
! 78: * System debug service
! 79: */
! 80: #define DCMD_DUMP 0 /* kernel dump */
! 81: #define DCMD_LOGSIZE 1 /* return log size */
! 82: #define DCMD_GETLOG 2 /* return message log */
! 83:
! 84: /*
! 85: * Parameter for DCMD_DUMP
! 86: */
! 87: #define DUMP_THREAD 1
! 88: #define DUMP_TASK 2
! 89: #define DUMP_VM 3
! 90:
! 91: __BEGIN_DECLS
! 92: int object_create(const char *name, object_t *obj);
! 93: int object_destroy(object_t obj);
! 94: int object_lookup(const char *name, object_t *obj);
! 95:
! 96: int msg_send(object_t obj, void *msg, size_t size);
! 97: int msg_receive(object_t obj, void *msg, size_t size);
! 98: int msg_reply(object_t obj, void *msg, size_t size);
! 99:
! 100: int vm_allocate(task_t task, void **addr, size_t size, int anywhere);
! 101: int vm_free(task_t task, void *addr);
! 102: int vm_attribute(task_t task, void *addr, int attr);
! 103: int vm_map(task_t target, void *addr, size_t size, void **alloc);
! 104:
! 105: int task_create(task_t parent, int vm_option, task_t *child);
! 106: int task_terminate(task_t task);
! 107: task_t task_self(void);
! 108: int task_suspend(task_t task);
! 109: int task_resume(task_t task);
! 110: int task_name(task_t task, const char *name);
! 111: int task_getcap(task_t task, cap_t *cap);
! 112: int task_setcap(task_t task, cap_t *cap);
! 113:
! 114: int thread_create(task_t task, thread_t *th);
! 115: int thread_terminate(thread_t th);
! 116: int thread_load(thread_t th, void (*entry)(void), void *stack);
! 117: thread_t thread_self(void);
! 118: void thread_yield(void);
! 119: int thread_suspend(thread_t th);
! 120: int thread_resume(thread_t th);
! 121: int thread_getprio(thread_t th, int *prio);
! 122: int thread_setprio(thread_t th, int prio);
! 123: int thread_getpolicy(thread_t th, int *policy);
! 124: int thread_setpolicy(thread_t th, int policy);
! 125:
! 126: int timer_sleep(u_long msec, u_long *remain);
! 127: int timer_alarm(u_long msec, u_long *remain);
! 128: int timer_periodic(thread_t th, u_long start, u_long period);
! 129: int timer_waitperiod(void);
! 130:
! 131: int exception_setup(void (*handler)(int));
! 132: int exception_return(void);
! 133: int exception_raise(task_t task, int excpt);
! 134: int exception_wait(int *excpt);
! 135:
! 136: int device_open(const char *name, int mode, device_t *dev);
! 137: int device_close(device_t dev);
! 138: int device_read(device_t dev, void *buf, size_t *nbyte, int blkno);
! 139: int device_write(device_t dev, void *buf, size_t *nbyte, int blkno);
! 140: int device_ioctl(device_t dev, u_long cmd, void *arg);
! 141:
! 142: int mutex_init(mutex_t *mu);
! 143: int mutex_destroy(mutex_t *mu);
! 144: int mutex_trylock(mutex_t *mu);
! 145: int mutex_lock(mutex_t *mu);
! 146: int mutex_unlock(mutex_t *mu);
! 147:
! 148: int cond_init(cond_t *cond);
! 149: int cond_destroy(cond_t *cond);
! 150: int cond_wait(cond_t *cond, mutex_t *mu);
! 151: int cond_signal(cond_t *cond);
! 152: int cond_broadcast(cond_t *cond);
! 153:
! 154: int sem_init(sem_t *sem, u_int value);
! 155: int sem_destroy(sem_t *sem);
! 156: int sem_wait(sem_t *sem, u_long timeout);
! 157: int sem_trywait(sem_t *sem);
! 158: int sem_post(sem_t *sem);
! 159: int sem_getvalue(sem_t *sem, u_int *value);
! 160:
! 161: int sys_info(int type, void *buf);
! 162: int sys_log(const char *msg);
! 163: void sys_panic(const char *msg);
! 164: int sys_time(u_long *ticks);
! 165: int sys_debug(int cmd, void *data);
! 166: void sys_panic(const char *msg);
! 167:
! 168: void panic(const char *fmt, ...);
! 169: void dprintf(const char *fmt, ...);
! 170: __END_DECLS
! 171:
! 172: #endif /* KERNEL */
! 173: #endif /* !_PREX_H */
CVSweb