diff options
Diffstat (limited to 'hurd/thread.h')
-rw-r--r-- | hurd/thread.h | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/hurd/thread.h b/hurd/thread.h index f65f17f..94c29e8 100644 --- a/hurd/thread.h +++ b/hurd/thread.h @@ -93,7 +93,6 @@ struct activation_frame #include <viengoos/addr-trans.h> #include <viengoos/cap.h> #include <viengoos/messenger.h> -#include <hurd/exceptions.h> #include <setjmp.h> /* The user thread control block. */ @@ -133,13 +132,90 @@ struct hurd_utcb uintptr_t canary0; uintptr_t canary1; }; + +/* Return the calling thread's UTCB. Threading libraries should set + this to their own implementation once they are up and running. */ +extern struct hurd_utcb *(*hurd_utcb) (void); +/* Initializes the activation handler to allow receiving IPCs (but + does not handle other faults). This must be called exactly once + before any IPCs are sent. */ +extern void hurd_activation_handler_init_early (void); + +/* Initialize the activation handler. This must be called after the + storage sub-system has been initialized. At this point, the + activation handler is able to handle exceptions. */ +extern void hurd_activation_handler_init (void); + + +/* Allocate a utcb buffer and associated data structures (including an + exception messenger) for the thread THEAD (which must already exist + but should not be running). Installs the UTCB and exception + messenger in the thread object. Returns the new UTCB in *UTCB. + Returns 0 on success, otherwise an error code. */ +extern error_t hurd_activation_state_alloc (vg_addr_t thread, + struct hurd_utcb **utcb); + +/* Release the state allocated by hurd_activation_state_alloc. May + not be called by a thread on its own UTCB! */ +extern void hurd_activation_state_free (struct hurd_utcb *utcb); + + +/* When a thread causes an activation, the kernel invokes the thread's + activation handler. This points to the low-level activation handler, + which invokes activation_handler_activated. (It is passed a pointer + to the utcb.) + + This function must determine how to continue. It may, but need + not, immediately handle the activation. The problem with handling + an activation immediately is that this function runs on the + activation handler's tiny stack and it runs in activated mode. The + latter means that it may not fault (which generally precludes + accessing any dynamically allocated storage) or even properly send + IPC (as it has no easy way to determine when the IPC has been + received and when a reply is available--this information is + delivered by activations!). + + To allow an easy transition to another function in normal-mode, if + the function returns an activation_frame, then the activation + handler will call hurd_activation_handler_normal passing it that + argument. This function runs in normal mode and on the normal + stack. When this function returns, the interrupted state is + restored. */ +extern struct activation_frame *hurd_activation_handler_activated + (struct hurd_utcb *utcb); + +extern void hurd_activation_handler_normal + (struct activation_frame *activation_frame, struct hurd_utcb *utcb); + + +/* The first instruction of activation handler dispatcher. */ +extern char hurd_activation_handler_entry; +/* The instruction immediately following the last instruction of the + activation handler dispatcher. */ +extern char hurd_activation_handler_end; + + +/* Register the current extant IPC. */ +extern void hurd_activation_message_register (struct hurd_message_buffer *mb); + +/* Unregister the current extant IPC. This is normally done + automatically when a reply is receive. However, if the IPC is + aborted, then this function must be called before the next IPC may + be sent. */ +extern void hurd_activation_message_unregister (struct hurd_message_buffer *mb); + + /* Cause the activation frame to assume the state of the long jump buffer BUF. If SET_RET is true, the normal function return value is set to RET. */ extern void hurd_activation_frame_longjmp (struct activation_frame *af, jmp_buf buf, bool set_ret, int ret); + + +/* Dump the activation stack to stdout. */ +extern void hurd_activation_stack_dump (void); struct hurd_fault_catcher { |