syscall.h (3563B)
1 /* Copyright 1998-2000 Brian J. Swetland. All rights reserved. 2 ** Distributed under the terms of the OpenBLT License. 3 */ 4 5 #ifndef _SYSCALL_H_ 6 #define _SYSCALL_H_ 7 8 #include <blt/types.h> 9 #include <blt/os.h> 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 void os_terminate(int status); 16 void os_console(char *string); 17 int os_brk(int addr); 18 void os_handle_irq(int irq); 19 void os_sleep_irq(void); 20 void os_debug(void); 21 void os_sleep(int ticks); 22 int os_identify(int rsrc); /* returns the team_id of the owner of a resource */ 23 24 sem_id sem_create(int value, const char *name); 25 int sem_destroy(sem_id sem); 26 int sem_acquire(sem_id sem); 27 int sem_release(sem_id sem); 28 29 port_id port_create(int restrict, const char *name); 30 int port_destroy(port_id port); 31 int port_option(port_id port, uint32 opt, uint32 arg); 32 ssize_t port_send(port_id src, port_id dst, const void *data, size_t len, uint32 code); 33 ssize_t port_recv(port_id dst, port_id *src, void *data, size_t max, uint32 *code); 34 ssize_t port_peek(port_id *src, port_id *dst, int *code); 35 36 #define port_set_restrict(port, restrict) port_option(port,PORT_OPT_SETRESTRICT,restrict); 37 #define port_slave(master, slave) port_option(slave,PORT_OPT_SLAVE,master) 38 #define port_set_nonblocking(port) port_option(port, PORT_OPT_NOWAIT, 1); 39 #define port_set_blocking(port) port_option(port, PORT_OPT_NOWAIT, 0); 40 #define port_set_timeout(port, useconds) 41 42 thread_id thr_create(void *addr, void *data, const char *name); 43 int thr_resume(thread_id thr_id); 44 int thr_suspend(thread_id thr_id); 45 int thr_kill(thread_id thr_id); 46 int thr_detach(thread_id (*addr)(void)); 47 int thr_wait(thread_id thr_id); 48 49 thread_id thr_spawn(uint32 eip, uint32 esp, 50 area_id area0, uint32 vaddr0, 51 area_id area1, uint32 vaddr1, 52 const char *name); 53 54 area_id area_create(off_t size, off_t virt, void **addr, uint32 flags); 55 area_id area_clone(area_id aid, off_t virt, void **addr, uint32 flags); 56 int area_destroy(area_id aid); 57 int area_resize(area_id aid, off_t size); 58 59 int right_create(int rsrc_id, uint32 flags); 60 int right_destroy(int right_id); 61 int right_revoke(int right_id, int thread_id); 62 int right_grant(int right_id, int thread_id); 63 64 /* look up a resource by name or id number and fill in information about it */ 65 int rsrc_find_id (rsrc_info *info, int rsrc_id, int rsrc_type); 66 int rsrc_find_name (rsrc_info *info, const char *name, int rsrc_type); 67 68 /* 69 * the metacall is for random things that are not compiled into the kernel 70 * by default, but might be useful for debugging, etc. if you think you 71 * need to add a syscall temporarily in order to debug something, using 72 * this will save you some time, since you only have to edit two files 73 * instead of four. 74 * 75 * the request parameter is used to multiplex the call among many different 76 * purposes. the range META_MIN_RESERVED to META_MAX_RESERVED is for 77 * temporary purposes that are not submitted to the repository. request 78 * defines are in include/blt/os.h. 79 */ 80 81 int os_meta(unsigned int request, ...); 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 /* compatability defines */ 88 #define os_thread(addr) thr_create(addr,NULL,NULL); 89 #define thr_join(thr_id,opt) thr_wait(thr_id); 90 #define thr_detach(addr) (0) 91 92 /* deprecated messaging system */ 93 typedef struct { 94 int flags; 95 int src; 96 int dst; 97 int size; 98 void *data; 99 } msg_hdr_t; 100 101 #define old_port_send(mh) port_send((mh)->src, (mh)->dst, (mh)->data, (mh)->size, 0) 102 #define old_port_recv(mh) port_recv((mh)->dst, &((mh)->src), (mh)->data, (mh)->size, 0) 103 104 #endif