FreeCalypso > hg > ffs-editor
annotate src/nucleus/pis.c @ 11:d65489886c6e
src/nucleus/gcc/tct.S: no small sleep in FFS editor
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 15 May 2020 03:56:21 +0000 |
parents | 92470e5d0b9e |
children |
rev | line source |
---|---|
0
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 /* Copyright Mentor Graphics Corporation 2002 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 /* All Rights Reserved. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 /* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 /* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 /* SUBJECT TO LICENSE TERMS. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 /* FILE NAME VERSION */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* pis.c Nucleus PLUS 1.14 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 /* COMPONENT */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 /* PI - Pipe Management */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 /* DESCRIPTION */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* This file contains the supplemental routines for the pipe */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 /* management component. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 /* DATA STRUCTURES */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 /* None */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 /* FUNCTIONS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 /* PIS_Reset_Pipe Reset a pipe */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /* PIS_Send_To_Front_Of_Pipe Send message to pipe's front */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /* PIS_Broadcast_To_Pipe Broadcast a message to pipe */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 /* DEPENDENCIES */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 /* cs_extr.h Common Service functions */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /* tc_extr.h Thread Control functions */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 /* pi_extr.h Pipe functions */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 /* hi_extr.h History functions */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 /* HISTORY */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 /* DATE REMARKS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 /* 03-01-1994 Created initial version 1.1 from */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 /* routines originally in core */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 /* 03-18-1994 Verified version 1.1 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 /* 04-17-1996 updated to version 1.2 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 /* 02-04-1998 Corrected SPR434 resulting in */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 /* version 1.2a. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 /* 03-24-1998 Released version 1.3 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 /* 03-26-1999 Released 1.11m (new release */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 /* numbering scheme) */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 /* 04-17-2002 Released version 1.13m */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 /* 11-07-2002 Released version 1.14 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 #define NU_SOURCE_FILE |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 #include "cs_extr.h" /* Common service functions */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 #include "tc_extr.h" /* Thread control functions */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 #include "pi_extr.h" /* Pipe functions */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 #include "hi_extr.h" /* History functions */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 #include "profiler.h" /* ProView interface */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 /* Define external inner-component global data references. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 extern CS_NODE *PID_Created_Pipes_List; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 extern UNSIGNED PID_Total_Pipes; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 extern TC_PROTECT PID_List_Protect; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 /* Define internal component function prototypes. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 VOID PIC_Cleanup(VOID *information); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 /* FUNCTION */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 /* PIS_Reset_Pipe */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 /* DESCRIPTION */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 /* This function resets the specified pipe back to the original */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 /* state. Any messages in the pipe are discarded. Also, any */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 /* tasks currently suspended on the pipe are resumed with the */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 /* reset status. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 /* CALLED BY */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 /* Application */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 /* PISE_Reset_Pipe Error checking shell */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 /* CALLS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 /* [HIC_Make_History_Entry] Make entry in history log */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 /* TCC_Resume_Task Resume a suspended task */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 /* [TCT_Check_Stack] Stack checking function */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 /* TCT_Control_To_System Transfer control to system */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 /* TCT_System_Protect Protect against system access*/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 /* TCT_Unprotect Release protection */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 /* INPUTS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 /* pipe_ptr Pipe control block pointer */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 /* OUTPUTS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 /* NU_SUCCESS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 /* HISTORY */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 /* NAME DATE REMARKS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 /* 03-01-1993 Created initial version 1.0 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 /* 04-19-1993 Verified version 1.0 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 /* 03-01-1994 Changed function interfaces to */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 /* match those in prototype, */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 /* added register options, changed */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 /* protection logic to reduce */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 /* overhead, fixed read and write */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 /* pointers to both point at the */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 /* start, resulting in version 1.1 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 /* 03-18-1994 Verified version 1.1 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 /* 02-04-1998 Corrected SPR434. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 STATUS PIS_Reset_Pipe(NU_PIPE *pipe_ptr) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 R1 PI_PCB *pipe; /* Pipe control block ptr */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 PI_SUSPEND *suspend_ptr; /* Suspend block pointer */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 PI_SUSPEND *next_ptr; /* Next suspend block pointer*/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 STATUS preempt; /* Status for resume call */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 NU_SUPERV_USER_VARIABLES |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 /* Switch to supervisor mode */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 NU_SUPERVISOR_MODE(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 /* Move input pipe pointer into internal pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 pipe = (PI_PCB *) pipe_ptr; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 #ifdef NU_ENABLE_STACK_CHECK |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 /* Call stack checking function to check for an overflow condition. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 TCT_Check_Stack(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 #endif |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 #ifdef NU_ENABLE_HISTORY |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 /* Make an entry that corresponds to this function in the system history |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 log. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 HIC_Make_History_Entry(NU_RESET_PIPE_ID, (UNSIGNED) pipe, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 (UNSIGNED) 0, (UNSIGNED) 0); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 #endif |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 /* Protect against access to the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 TCT_System_Protect(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 /* Pickup the suspended task suspension list. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 suspend_ptr = pipe -> pi_suspension_list; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 /* Walk the chain task(s) currently suspended on the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 preempt = 0; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 while (suspend_ptr) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 /* Resume the suspended task. Insure that the status returned is |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 NU_PIPE_RESET. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 suspend_ptr -> pi_return_status = NU_PIPE_RESET; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 /* Point to the next suspend structure in the link. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 next_ptr = (PI_SUSPEND *) (suspend_ptr -> pi_suspend_link.cs_next); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 /* Resume the specified task. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 preempt = preempt | |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 TCC_Resume_Task((NU_TASK *) suspend_ptr -> pi_suspended_task, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 NU_PIPE_SUSPEND); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 /* Determine if the next is the same as the head pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 if (next_ptr == pipe -> pi_suspension_list) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 /* Clear the suspension pointer to signal the end of the list |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 traversal. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 suspend_ptr = NU_NULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 /* Position the suspend pointer to the next block. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 suspend_ptr = next_ptr; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 /* Pickup the urgent message suspension list. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 suspend_ptr = pipe -> pi_urgent_list; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 /* Walk the chain task(s) currently suspended on the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 while (suspend_ptr) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 /* Resume the suspended task. Insure that the status returned is |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 NU_PIPE_RESET. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 suspend_ptr -> pi_return_status = NU_PIPE_RESET; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 /* Point to the next suspend structure in the link. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 next_ptr = (PI_SUSPEND *) (suspend_ptr -> pi_suspend_link.cs_next); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 /* Resume the specified task. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 preempt = preempt | |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 TCC_Resume_Task((NU_TASK *) suspend_ptr -> pi_suspended_task, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 NU_PIPE_SUSPEND); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 /* Determine if the next is the same as the head pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 if (next_ptr == pipe -> pi_urgent_list) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 /* Clear the suspension pointer to signal the end of the list |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 traversal. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 suspend_ptr = NU_NULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 /* Position the suspend pointer to the next active block. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 suspend_ptr = next_ptr; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 /* Initialize various elements of the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 pipe -> pi_available = pipe -> pi_end - pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 pipe -> pi_messages = 0; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 pipe -> pi_read = pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 pipe -> pi_write = pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 pipe -> pi_tasks_waiting = 0; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 pipe -> pi_suspension_list = NU_NULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 pipe -> pi_urgent_list = NU_NULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 #ifdef INCLUDE_PROVIEW |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 _RTProf_DumpPipe(RT_PROF_RESET_PIPE,pipe,RT_PROF_OK); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 #endif /* INCLUDE_PROVIEW */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 /* Determine if preemption needs to occur. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 if (preempt) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 /* Transfer control to system to facilitate preemption. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 TCT_Control_To_System(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 /* Release protection against access to the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 TCT_Unprotect(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 /* Return to user mode */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 NU_USER_MODE(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 /* Return a successful completion. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 return(NU_SUCCESS); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 /* FUNCTION */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 /* PIS_Send_To_Front_Of_Pipe */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 /* DESCRIPTION */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 /* This function sends a message to the front of the specified */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 /* message pipe. The message length is determined by the caller. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 /* If there are any tasks suspended on the pipe for a message, the */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 /* message is copied into the message area of the first waiting */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 /* task and that task is resumed. If there is enough room in the */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 /* pipe, the message is copied in front of all other messages. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 /* If there is not enough room in the pipe, suspension of the */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 /* caller is possible. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 /* CALLED BY */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 /* Application */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 /* PISE_Send_To_Front_Of_Pipe Error checking shell */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 /* CALLS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 /* CSC_Place_On_List Place on suspend list */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 /* CSC_Remove_From_List Remove from suspend list */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 /* [HIC_Make_History_Entry] Make entry in history log */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 /* TCC_Resume_Task Resume a suspended task */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 /* TCC_Suspend_Task Suspend calling task */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 /* [TCT_Check_Stack] Stack checking function */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 /* TCT_Control_To_System Transfer control to system */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 /* TCT_Current_Thread Pickup current thread pointer*/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 /* TCT_System_Protect Protect pipe */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 /* TCT_Unprotect Release protection */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 /* INPUTS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 /* pipe_ptr Pipe control block pointer */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 /* message Pointer to message to send */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 /* size Size of message to send */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 /* suspend Suspension option if full */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 /* OUTPUTS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 /* NU_SUCCESS If service is successful */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 /* NU_PIPE_FULL If pipe is currently full */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 /* NU_TIMEOUT If timeout on service expires*/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 /* NU_PIPE_DELETED If pipe was deleted during */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 /* suspension */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 /* NU_PIPE_RESET If pipe was reset during */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 /* suspension */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 /* HISTORY */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 /* DATE REMARKS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 /* 03-01-1993 Created initial version 1.0 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 /* 04-19-1993 Verified version 1.0 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 /* 03-01-1994 Changed function interfaces to */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 /* match those in prototype, */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 /* added register options, changed */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 /* protection logic to reduce */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 /* overhead, optimized copy loop, */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 /* resulting in version 1.1 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 /* 03-18-1994 Verified version 1.1 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 STATUS PIS_Send_To_Front_Of_Pipe(NU_PIPE *pipe_ptr, VOID *message, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 UNSIGNED size, UNSIGNED suspend) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 R1 PI_PCB *pipe; /* Pipe control block ptr */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 PI_SUSPEND suspend_block; /* Allocate suspension block */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 PI_SUSPEND *suspend_ptr; /* Pointer to suspend block */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 R2 BYTE_PTR source; /* Pointer to source */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 R3 BYTE_PTR destination; /* Pointer to destination */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 UNSIGNED copy_size; /* Partial copy size */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 R4 INT i; /* Working counter */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 UNSIGNED pad = 0; /* Number of pad bytes */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 TC_TCB *task; /* Task pointer */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 STATUS preempt; /* Preempt flag */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 STATUS status; /* Completion status */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 NU_SUPERV_USER_VARIABLES |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 /* Switch to supervisor mode */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 NU_SUPERVISOR_MODE(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 /* Move input pipe pointer into internal pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 pipe = (PI_PCB *) pipe_ptr; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 #ifdef NU_ENABLE_STACK_CHECK |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 /* Call stack checking function to check for an overflow condition. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 TCT_Check_Stack(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 #endif |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 #ifdef NU_ENABLE_HISTORY |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 /* Make an entry that corresponds to this function in the system history |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 log. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 HIC_Make_History_Entry(NU_SEND_TO_FRONT_OF_PIPE_ID, (UNSIGNED) pipe, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 (UNSIGNED) message, (UNSIGNED) size); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 #endif |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 /* Initialize the status as successful. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 status = NU_SUCCESS; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 /* Protect against simultaneous access to the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 TCT_System_Protect(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 /* Determine if an extra word of overhead needs to be added to the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 calculation. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 if (pipe -> pi_fixed_size) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 /* No overhead. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 i = 0; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 /* Variable messages have one additional word of overhead. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 i = sizeof(UNSIGNED); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 /* Calculate the number of pad bytes necessary to keep the pipe |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 write pointer on an UNSIGNED data element alignment. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 pad = (((size + sizeof(UNSIGNED) - 1)/sizeof(UNSIGNED)) * |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 sizeof(UNSIGNED)) - size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 /* Insure that padding is included in the overhead. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 i = i + ((INT) pad); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 /* Make special check to see if a suspension needs to be |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 forced for a variable length message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 if ((pipe -> pi_suspension_list) && (pipe -> pi_messages)) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 /* Pickup task control block pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 task = (TC_TCB *) TCT_Current_Thread(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 /* Now we know that there are other task(s) are suspended trying |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 to send a variable length message. Determine whether or not |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 a suspension should be forced. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 if ((pipe -> pi_fifo_suspend) || |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 (suspend == NU_NO_SUSPEND) || |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 ((pipe -> pi_suspension_list) -> pi_suspend_link.cs_priority <= |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 TCC_Task_Priority(task))) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 /* Bump the computed size to avoid placing the new variable |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 length message ahead of the suspended tasks. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 i = (INT) pipe -> pi_available; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 /* Determine if there is enough room in the pipe for the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 if (pipe -> pi_available < (size + i)) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 /* pipe does not have room for the message. Determine if |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 suspension is required. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 if (suspend) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 /* Suspension is requested. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 /* Increment the number of tasks waiting. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 pipe -> pi_tasks_waiting++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 #ifdef INCLUDE_PROVIEW |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 _RTProf_DumpPipe(RT_PROF_SEND_TO_FRONT_OF_PIPE,pipe,RT_PROF_WAIT); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 #endif /* INCLUDE_PROVIEW */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 /* Setup the suspend block and suspend the calling task. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 suspend_ptr = &suspend_block; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 suspend_ptr -> pi_pipe = pipe; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 suspend_ptr -> pi_suspend_link.cs_next = NU_NULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 suspend_ptr -> pi_suspend_link.cs_previous = NU_NULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 suspend_ptr -> pi_message_area = (BYTE_PTR) message; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 suspend_ptr -> pi_message_size = size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 task = (TC_TCB *) TCT_Current_Thread(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 suspend_ptr -> pi_suspended_task = task; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 /* Place the task on the urgent message suspension list. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 CSC_Place_On_List((CS_NODE **) &(pipe -> pi_urgent_list), |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 &(suspend_ptr -> pi_suspend_link)); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 /* Move the head pointer of the list to make this suspension the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 first in the list. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 pipe -> pi_urgent_list = (PI_SUSPEND *) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 (pipe -> pi_urgent_list) -> pi_suspend_link.cs_previous; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 /* Finally, suspend the calling task. Note that the suspension call |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 automatically clears the protection on the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 TCC_Suspend_Task((NU_TASK *) task, NU_PIPE_SUSPEND, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 PIC_Cleanup, suspend_ptr, suspend); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 /* Pickup the return status. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 status = suspend_ptr -> pi_return_status; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 /* Return a status of NU_PIPE_FULL because there is no |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 room in the pipe for the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 status = NU_PIPE_FULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 #ifdef INCLUDE_PROVIEW |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 _RTProf_DumpPipe(RT_PROF_SEND_TO_FRONT_OF_PIPE,pipe,RT_PROF_FAIL); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 #endif /* INCLUDE_PROVIEW */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 /* Determine if a task is waiting on an empty pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 if ((pipe -> pi_suspension_list) && (pipe -> pi_messages == 0)) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 /* Task is waiting on pipe for a message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 /* Decrement the number of tasks waiting on pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 pipe -> pi_tasks_waiting--; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 #ifdef INCLUDE_PROVIEW |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 _RTProf_DumpPipe(RT_PROF_SEND_TO_FRONT_OF_PIPE,pipe,RT_PROF_OK); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 #endif /* INCLUDE_PROVIEW */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 /* Remove the first suspended block from the list. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 suspend_ptr = pipe -> pi_suspension_list; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 CSC_Remove_From_List((CS_NODE **) &(pipe -> pi_suspension_list), |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 &(suspend_ptr -> pi_suspend_link)); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 /* Setup the source and destination pointers. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 source = (BYTE_PTR) message; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 destination = suspend_ptr -> pi_message_area; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 /* Initialize the return status. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 suspend_ptr -> pi_return_status = NU_SUCCESS; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 /* Loop to actually copy the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 i = (INT) size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 *(destination++) = *(source); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 source++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 /* Return the size of the message copied. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 suspend_ptr -> pi_actual_size = size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 /* Wakeup the waiting task and check for preemption. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 preempt = |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 TCC_Resume_Task((NU_TASK *) suspend_ptr -> pi_suspended_task, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 NU_PIPE_SUSPEND); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 /* Determine if preemption needs to take place. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 if (preempt) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 /* Transfer control to the system if the resumed task function |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 detects a preemption condition. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 TCT_Control_To_System(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 /* There is enough room in the pipe and no task is waiting. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 /* Setup the source pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 source = (BYTE_PTR) message; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 destination = pipe -> pi_read; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 /* Process according to the type of message supported. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 if (pipe -> pi_fixed_size) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 /* Fixed-size message pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 /* Determine if the read pointer is at the top of the pipe |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 if (destination == pipe -> pi_start) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 /* Prepare to place the message in the lower part of the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 pipe area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 destination = pipe -> pi_end - size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 /* Backup the length of the message from the current |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 read pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 destination = destination - size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 /* Adjust the actual read pointer before the copy is done. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 pipe -> pi_read = destination; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 /* Copy the message into the pipe area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 i = (INT) size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 *(destination++) = *(source); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 source++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 /* Variable-length message pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 /* Calculate the number of bytes remaining from the write |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 pointer to the bottom of the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 copy_size = destination - pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 /* Determine if part of the message needs to be placed at the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 bottom of the pipe area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 if (copy_size < (size + i)) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 /* Compute the starting location for the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 destination = pipe -> pi_end - ((size + i) - copy_size); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 /* Compute the starting location for the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 destination = destination - (size + i); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 /* Adjust the actual pipe read pointer also. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 pipe -> pi_read = destination; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 /* Place message size in first location. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 *((UNSIGNED *) destination) = size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 destination = destination + sizeof(UNSIGNED); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 /* Check for a wrap-around condition on the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 if (destination >= pipe -> pi_end) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 /* Wrap the write pointer back to the top of the pipe |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 destination = pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 /* Decrement the number of bytes remaining for this |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 extra word of overhead. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 pipe -> pi_available = pipe -> pi_available - |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 sizeof(UNSIGNED); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 /* Calculate the number of bytes remaining from the write |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 pointer to the bottom of the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 copy_size = pipe -> pi_end - destination; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 /* Determine if the message needs to be wrapped around the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 edge of the pipe area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 if (copy_size >= (size + pad)) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 /* Copy the whole message at once. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 i = (INT) size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 *(destination++) = *(source); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 source++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 /* Copy the first half of the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 i = (INT) copy_size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 *(destination) = *(source++); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 destination++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 /* Copy the second half of the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 destination = pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 /* Determine if there is anything left to copy. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 if (size > copy_size) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 /* Yes, there is something to copy. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 i = (INT) (size - copy_size); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 *(destination++) = *(source); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 source++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
657 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
658 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
659 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
660 /* Decrement the number of available bytes. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
661 pipe -> pi_available = pipe -> pi_available - pad; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
662 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
663 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
664 /* Decrement the number of available bytes. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
665 pipe -> pi_available = pipe -> pi_available - size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
666 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
667 /* Increment the number of messages in the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
668 pipe -> pi_messages++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
669 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
670 #ifdef INCLUDE_PROVIEW |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
671 _RTProf_DumpPipe(RT_PROF_SEND_TO_FRONT_OF_PIPE,pipe,RT_PROF_OK); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
672 #endif /* INCLUDE_PROVIEW */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
673 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
674 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
675 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
676 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
677 /* Release protection against access to the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
678 TCT_Unprotect(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
679 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
680 /* Return to user mode */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
681 NU_USER_MODE(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
682 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
683 /* Return the completion status. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
684 return(status); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
685 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
686 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
687 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
688 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
689 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
690 /* FUNCTION */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
691 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
692 /* PIS_Broadcast_To_Pipe */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
693 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
694 /* DESCRIPTION */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
695 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
696 /* This function sends a message to all tasks waiting for a message */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
697 /* from the specified pipe. If there are no tasks waiting for a */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
698 /* message the service performs like a standard send request. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
699 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
700 /* CALLED BY */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
701 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
702 /* Application */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
703 /* PISE_Broadcast_To_Pipe Error checking shell */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
704 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
705 /* CALLS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
706 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
707 /* CSC_Place_On_List Place on suspend list */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
708 /* CSC_Priority_Place_On_List Place on priority list */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
709 /* CSC_Remove_From_List Remove from suspend list */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
710 /* [HIC_Make_History_Entry] Make entry in history log */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
711 /* TCC_Resume_Task Resume a suspended task */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
712 /* TCC_Suspend_Task Suspend calling task */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
713 /* TCC_Task_Priority Pickup task's priority */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
714 /* [TCT_Check_Stack] Stack checking function */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
715 /* TCT_Control_To_System Transfer control to system */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
716 /* TCT_Current_Thread Pickup current thread pointer*/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
717 /* TCT_System_Protect Protect pipe */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
718 /* TCT_Unprotect Release protection */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
719 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
720 /* INPUTS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
721 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
722 /* pipe_ptr Pipe control block pointer */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
723 /* message Pointer to message to send */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
724 /* size Size of message to send */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
725 /* suspend Suspension option if full */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
726 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
727 /* OUTPUTS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
728 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
729 /* NU_SUCCESS If service is successful */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
730 /* NU_PIPE_FULL If pipe is currently full */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
731 /* NU_TIMEOUT If timeout on service expires*/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
732 /* NU_PIPE_DELETED If pipe was deleted during */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
733 /* suspension */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
734 /* NU_PIPE_RESET If pipe was reset during */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
735 /* suspension */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
736 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
737 /* HISTORY */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
738 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
739 /* DATE REMARKS */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
740 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
741 /* 03-01-1993 Created initial version 1.0 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
742 /* 04-19-1993 Verified version 1.0 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
743 /* 03-01-1994 Changed function interfaces to */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
744 /* match those in prototype, */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
745 /* added register options, changed */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
746 /* protection logic to reduce */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
747 /* overhead, optimized copy loop, */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
748 /* resulting in version 1.1 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
749 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
750 /* 03-18-1994 Verified version 1.1 */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
751 /* */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
752 /*************************************************************************/ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
753 STATUS PIS_Broadcast_To_Pipe(NU_PIPE *pipe_ptr, VOID *message, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
754 UNSIGNED size, UNSIGNED suspend) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
755 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
756 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
757 R1 PI_PCB *pipe; /* Pipe control block ptr */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
758 PI_SUSPEND suspend_block; /* Allocate suspension block */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
759 PI_SUSPEND *suspend_ptr; /* Pointer to suspend block */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
760 R2 BYTE_PTR source; /* Pointer to source */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
761 R3 BYTE_PTR destination; /* Pointer to destination */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
762 UNSIGNED copy_size; /* Partial copy size */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
763 UNSIGNED pad = 0; /* Number of pad bytes */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
764 R4 INT i; /* Working counter */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
765 TC_TCB *task; /* Task pointer */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
766 STATUS preempt; /* Preempt flag */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
767 STATUS status; /* Completion status */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
768 NU_SUPERV_USER_VARIABLES |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
769 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
770 /* Switch to supervisor mode */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
771 NU_SUPERVISOR_MODE(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
772 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
773 /* Move input pipe pointer into internal pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
774 pipe = (PI_PCB *) pipe_ptr; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
775 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
776 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
777 #ifdef NU_ENABLE_STACK_CHECK |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
778 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
779 /* Call stack checking function to check for an overflow condition. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
780 TCT_Check_Stack(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
781 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
782 #endif |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
783 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
784 #ifdef NU_ENABLE_HISTORY |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
785 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
786 /* Make an entry that corresponds to this function in the system history |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
787 log. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
788 HIC_Make_History_Entry(NU_BROADCAST_TO_PIPE_ID, (UNSIGNED) pipe, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
789 (UNSIGNED) message, (UNSIGNED) size); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
790 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
791 #endif |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
792 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
793 /* Initialize the status as successful. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
794 status = NU_SUCCESS; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
795 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
796 /* Protect against simultaneous access to the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
797 TCT_System_Protect(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
798 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
799 /* Determine if an extra word of overhead needs to be added to the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
800 calculation. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
801 if (pipe -> pi_fixed_size) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
802 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
803 /* No overhead. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
804 i = 0; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
805 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
806 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
807 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
808 /* Variable messages have one additional word of overhead. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
809 i = sizeof(UNSIGNED); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
810 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
811 /* Calculate the number of pad bytes necessary to keep the pipe |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
812 write pointer on an UNSIGNED data element alignment. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
813 pad = (((size + sizeof(UNSIGNED) - 1)/sizeof(UNSIGNED)) * |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
814 sizeof(UNSIGNED)) - size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
815 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
816 /* Insure that padding is included in the overhead. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
817 i = i + ((INT) pad); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
818 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
819 /* Make special check to see if a suspension needs to be |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
820 forced for a variable length message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
821 if ((pipe -> pi_suspension_list) && (pipe -> pi_messages)) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
822 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
823 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
824 /* Pickup task control block pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
825 task = (TC_TCB *) TCT_Current_Thread(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
826 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
827 /* Now we know that there are other task(s) are suspended trying |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
828 to send a variable length message. Determine whether or not |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
829 a suspension should be forced. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
830 if ((pipe -> pi_fifo_suspend) || |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
831 (suspend == NU_NO_SUSPEND) || |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
832 ((pipe -> pi_suspension_list) -> pi_suspend_link.cs_priority <= |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
833 TCC_Task_Priority(task))) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
834 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
835 /* Bump the computed size to avoid placing the new variable |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
836 length message ahead of the suspended tasks. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
837 i = (INT) pipe -> pi_available; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
838 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
839 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
840 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
841 /* Determine if there is enough room in the pipe for the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
842 if (pipe -> pi_available < (size + i)) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
843 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
844 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
845 /* pipe does not have room for the message. Determine if |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
846 suspension is required. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
847 if (suspend) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
848 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
849 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
850 /* Suspension is requested. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
851 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
852 /* Increment the number of tasks waiting. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
853 pipe -> pi_tasks_waiting++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
854 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
855 #ifdef INCLUDE_PROVIEW |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
856 _RTProf_DumpPipe(RT_PROF_BROADCAST_TO_PIPE,pipe,RT_PROF_WAIT); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
857 #endif /* INCLUDE_PROVIEW */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
858 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
859 /* Setup the suspend block and suspend the calling task. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
860 suspend_ptr = &suspend_block; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
861 suspend_ptr -> pi_pipe = pipe; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
862 suspend_ptr -> pi_suspend_link.cs_next = NU_NULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
863 suspend_ptr -> pi_suspend_link.cs_previous = NU_NULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
864 suspend_ptr -> pi_message_area = (BYTE_PTR) message; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
865 suspend_ptr -> pi_message_size = size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
866 task = (TC_TCB *) TCT_Current_Thread(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
867 suspend_ptr -> pi_suspended_task = task; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
868 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
869 /* Determine if priority or FIFO suspension is associated with the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
870 pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
871 if (pipe -> pi_fifo_suspend) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
872 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
873 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
874 /* FIFO suspension is required. Link the suspend block into |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
875 the list of suspended tasks on this pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
876 CSC_Place_On_List((CS_NODE **) &(pipe -> pi_suspension_list), |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
877 &(suspend_ptr -> pi_suspend_link)); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
878 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
879 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
880 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
881 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
882 /* Get the priority of the current thread so the suspend block |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
883 can be placed in the appropriate place. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
884 suspend_ptr -> pi_suspend_link.cs_priority = |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
885 TCC_Task_Priority(task); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
886 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
887 CSC_Priority_Place_On_List((CS_NODE **) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
888 &(pipe -> pi_suspension_list), |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
889 &(suspend_ptr -> pi_suspend_link)); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
890 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
891 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
892 /* Finally, suspend the calling task. Note that the suspension call |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
893 automatically clears the protection on the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
894 TCC_Suspend_Task((NU_TASK *) task, NU_PIPE_SUSPEND, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
895 PIC_Cleanup, suspend_ptr, suspend); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
896 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
897 /* Pickup the return status. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
898 status = suspend_ptr -> pi_return_status; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
899 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
900 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
901 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
902 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
903 /* Return a status of NU_PIPE_FULL because there is no |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
904 room in the pipe for the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
905 status = NU_PIPE_FULL; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
906 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
907 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
908 #ifdef INCLUDE_PROVIEW |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
909 _RTProf_DumpPipe(RT_PROF_BROADCAST_TO_PIPE,pipe,RT_PROF_FAIL); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
910 #endif /* INCLUDE_PROVIEW */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
911 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
912 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
913 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
914 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
915 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
916 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
917 #ifdef INCLUDE_PROVIEW |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
918 _RTProf_DumpPipe(RT_PROF_BROADCAST_TO_PIPE,pipe,RT_PROF_OK); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
919 #endif /* INCLUDE_PROVIEW */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
920 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
921 /* Determine if a task is waiting on an empty pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
922 if ((pipe -> pi_suspension_list) && (pipe -> pi_messages == 0)) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
923 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
924 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
925 /* Yes, one or more tasks are waiting for a message from this |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
926 pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
927 preempt = 0; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
928 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
929 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
930 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
931 /* Decrement the number of tasks waiting on pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
932 pipe -> pi_tasks_waiting--; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
933 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
934 /* Remove the first suspended block from the list. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
935 suspend_ptr = pipe -> pi_suspension_list; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
936 CSC_Remove_From_List((CS_NODE **) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
937 &(pipe -> pi_suspension_list), |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
938 &(suspend_ptr -> pi_suspend_link)); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
939 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
940 /* Setup the source and destination pointers. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
941 source = (BYTE_PTR) message; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
942 destination = suspend_ptr -> pi_message_area; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
943 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
944 /* Initialize the return status. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
945 suspend_ptr -> pi_return_status = NU_SUCCESS; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
946 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
947 /* Loop to actually copy the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
948 i = (INT) size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
949 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
950 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
951 *(destination++) = *(source); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
952 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
953 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
954 source++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
955 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
956 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
957 /* Return the size of the message copied. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
958 suspend_ptr -> pi_actual_size = size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
959 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
960 /* Wakeup the waiting task and check for preemption. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
961 preempt = preempt | |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
962 TCC_Resume_Task((NU_TASK *) suspend_ptr -> pi_suspended_task, |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
963 NU_PIPE_SUSPEND); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
964 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
965 /* Move the suspend pointer to the next node, which is now |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
966 at the head of the list. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
967 suspend_ptr = pipe -> pi_suspension_list; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
968 } while (suspend_ptr); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
969 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
970 /* Determine if preemption needs to take place. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
971 if (preempt) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
972 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
973 /* Transfer control to the system if the resumed task function |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
974 detects a preemption condition. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
975 TCT_Control_To_System(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
976 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
977 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
978 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
979 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
980 /* There is enough room in the pipe and no task is waiting. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
981 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
982 /* Setup the source pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
983 source = (BYTE_PTR) message; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
984 destination = pipe -> pi_write; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
985 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
986 /* Process according to the type of message supported. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
987 if (pipe -> pi_fixed_size) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
988 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
989 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
990 /* Fixed-size messages are supported by this pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
991 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
992 /* Loop to copy the message into the pipe area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
993 i = (INT) size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
994 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
995 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
996 *(destination++) = *(source); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
997 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
998 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
999 source++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1000 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1001 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1002 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1003 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1004 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1005 /* Variable-size messages are supported. Processing must |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1006 check for pipe wrap-around conditions. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1007 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1008 /* Place message size in first location. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1009 *((UNSIGNED *) destination) = size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1010 destination = destination + sizeof(UNSIGNED); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1011 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1012 /* Check for a wrap-around condition on the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1013 if (destination >= pipe -> pi_end) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1014 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1015 /* Wrap the write pointer back to the top of the pipe |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1016 area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1017 destination = pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1018 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1019 /* Decrement the number of bytes remaining for this |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1020 extra word of overhead. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1021 pipe -> pi_available = pipe -> pi_available - |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1022 sizeof(UNSIGNED); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1023 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1024 /* Calculate the number of bytes remaining from the write |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1025 pointer to the bottom of the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1026 copy_size = pipe -> pi_end - destination; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1027 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1028 /* Determine if the message needs to be wrapped around the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1029 edge of the pipe area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1030 if (copy_size >= size) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1031 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1032 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1033 /* Copy the whole message at once. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1034 i = (INT) size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1035 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1036 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1037 *(destination++) = *(source); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1038 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1039 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1040 source++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1041 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1042 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1043 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1044 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1045 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1046 /* Copy the first half of the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1047 i = (INT) copy_size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1048 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1049 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1050 *(destination) = *(source++); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1051 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1052 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1053 destination++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1054 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1055 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1056 /* Copy the second half of the message. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1057 destination = pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1058 i = (INT) (size - copy_size); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1059 do |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1060 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1061 *(destination++) = *(source); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1062 if ((--i) == 0) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1063 break; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1064 source++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1065 } while (1); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1066 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1067 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1068 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1069 /* Check again for wrap-around condition on the write pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1070 if (destination >= pipe -> pi_end) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1071 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1072 /* Move the write pointer to the top of the pipe area. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1073 destination = pipe -> pi_start; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1074 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1075 /* Determine if the pipe supports variable-length messages. If |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1076 so, pad bytes are needed to keep UNSIGNED alignment. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1077 if (pad) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1078 { |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1079 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1080 /* Variable-size message. Add pad bytes to the write |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1081 pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1082 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1083 /* Calculate the number of bytes remaining from the write |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1084 pointer to the bottom of the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1085 copy_size = pipe -> pi_end - destination; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1086 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1087 /* If there is not enough room at the bottom of the pipe, the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1088 pad bytes must be wrapped around to the top. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1089 if (copy_size <= pad) |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1090 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1091 /* Move write pointer to the top of the pipe and make the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1092 necessary adjustment. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1093 destination = pipe -> pi_start + (pad - copy_size); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1094 else |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1095 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1096 /* There is enough room in the pipe to simply add the |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1097 the pad bytes to the write pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1098 destination = destination + pad; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1099 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1100 /* Decrement the number of available bytes. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1101 pipe -> pi_available = pipe -> pi_available - pad; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1102 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1103 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1104 /* Update the actual write pointer. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1105 pipe -> pi_write = destination; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1106 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1107 /* Decrement the number of available bytes. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1108 pipe -> pi_available = pipe -> pi_available - size; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1109 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1110 /* Increment the number of messages in the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1111 pipe -> pi_messages++; |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1112 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1113 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1114 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1115 /* Release protection against access to the pipe. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1116 TCT_Unprotect(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1117 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1118 /* Return to user mode */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1119 NU_USER_MODE(); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1120 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1121 /* Return the completion status. */ |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1122 return(status); |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1123 } |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1124 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1125 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1126 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1127 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1128 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1129 |
92470e5d0b9e
src: partial import from FC Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1130 |