/* Prototypes for rtmk kernel interface. Copyright 1999-2002 Johan Rydberg, jrydberg@rtmk.org. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _RTMK_H #define _RTMK_H 1 /* ??? this should not be included from the kernel. */ #ifdef _KERN_SOURCE # error "rtmk.h should not be included from the kernel" #endif #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif #ifndef __P # ifdef __STDC__ # define __P(X) X # else /* not __STDC__ */ # define __P(X) () # endif /* not __STDC__ */ #endif /* __P */ /* Tasks. */ /* Return send right name to current task. */ extern rtmk_port_t task_self __P ((void)); /* Create a child task to PARENT task. Send right to new task is returned in TASKP. If INHERIT_MEMORY_P is true, new task inherits parent's memory. */ extern kern_return_t task_create __P ((rtmk_port_t parent, bool inherit_memory_p, rtmk_port_t *taskp)); /* Terminate TASK. All resources held by TASK is destroyed. */ extern kern_return_t task_terminate __P ((rtmk_port_t task)); /* Threads. */ /* Return send right name to current executing @param thread. */ extern rtmk_port_t thread_self __P ((void)); /* Return receive right to newly allocated reply port. */ extern rtmk_port_t thread_reply_port __P ((void)); /* Create new thread in TASK's address and IPC space. On return, *THREADP will hold send right to thread. */ extern kern_return_t thread_create __P ((rtmk_port_t task, rtmk_port_t *threadp)); /* Terminate THREAD. */ extern kern_return_t thread_terminate __P ((rtmk_port_t thread)); /* Suspend execution of THREAD, prevent it from running. When this is called, the thread is no longer running (if it was). */ extern kern_return_t thread_suspend __P ((rtmk_port_t thread)); /* Resume execution of THREAD, if its suspend count drops to zero. */ extern kern_return_t thread_resume __P ((rtmk_port_t thread)); /* IPC. */ /* Deallocate right to PORT_NAME. */ extern kern_return_t port_deallocate __P ((rtmk_port_t port_name)); /* Destroy PORT_NAME. Will make the port a zombie port, until all user references are droped, and the port is deallocated. */ extern kern_return_t port_destroy __P ((rtmk_port_t port_name)); /* Allocate a new port in TASK's IPC space. If the caller is not a thread within TASK, it will not own any rights to the port. Port name is returned in PORTP. */ extern kern_return_t port_allocate __P ((rtmk_port_t task, rtmk_port_t *portp)); /* Rename OLD_NAME right name to NEW_NAME in TASK's IPC space. */ extern kern_return_t port_rename __P ((rtmk_port_t task, rtmk_port_name_t old_name, rtmk_port_name_t new_name)); /* Send message in HDR to send_name if OPTIONS has RTMK_MSG_OPTION_SEND set. Receive message from RECV_NAME if OPTIONS has RTMK_MSG_OPTION_RECEIVE set. If OPTIONS have RTMK_MSG_OPTION_TIMEOUT set, timeout after TIMEOUT milisecs. ??? should this be visible to the user? */ extern kern_return_t rtmk_msg_trap __P ((struct rtmk_msg_header *hdr, rtmk_msg_option_t options, rtmk_msg_size_t send_size, rtmk_port_t send_name, rtmk_msg_size_t recv_size, rtmk_port_t recv_name, rtmk_msg_timeout_t timeout)); /* Send message HDR to remote port specified in message header. If TIMEOUT is zero, we can block forever. */ extern kern_return_t msg_send __P ((struct rtmk_msg_header *hdr, rtmk_msg_timeout_t timeout)); /* Receive message from local port specified in message header in HDR. If TIMEOUT is zero, we can block forever. */ extern kern_return_t msg_receive __P ((struct rtmk_msg_header *hdr, rtmk_msg_timeout_t timeout)); /* Perform a full RPC from information in HDR. RECV_SIZE is length of receive buffer. If TIMEOUT is zero, we can block forever. */ extern kern_return_t msg_rpc __P ((struct rtmk_msg_header *hdr, rtmk_msg_size_t recv_size, rtmk_msg_timeout_t timeout)); /* Perform a full RPC with thread migration (the fast path). RECV_SIZE is length of receive buffer. */ extern kern_return_t msg_migrate __P ((struct rtmk_msg_header *hdr, rtmk_msg_size_t recv_size)); /* VM. */ /* Allocate memory in TASK's address space. SIZE should be rouned up to whole pages. If ANYWHERE_P is false, try fixed offset specified by *OFFSETP, otherwise choose available memory location. */ extern kern_return_t vm_allocate __P ((rtmk_port_t task, vm_size_t size, vm_offset_t *offsetp, int anywhere_p)); /* Deallocate memory object at OFFSET within TASK's address space. */ extern kern_return_t vm_deallocte __P ((rtmk_port_t task, vm_offset_t offset)); #ifdef __cplusplus }; #endif #endif /* rtmk.h */