annotate src/nucleus/mbs.c @ 111:97297555c71a

FFS dev.c flash device table reworked as described in TCS211-fw-arch
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Oct 2018 16:32:07 +0000
parents 0f80e1e4dce4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 /* Copyright Mentor Graphics Corporation 2002 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 /* All Rights Reserved. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 /* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 /* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 /* SUBJECT TO LICENSE TERMS. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 /* FILE NAME VERSION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /* mbs.c Nucleus PLUS 1.14 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 /* COMPONENT */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 /* MB - Mailbox Management */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 /* DESCRIPTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /* This file contains the core routines for the Mailbox management */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /* component. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 /* DATA STRUCTURES */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /* None */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 /* FUNCTIONS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 /* MBS_Reset_Mailbox Reset a mailbox */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 /* MBS_Broadcast_To_Mailbox Broadcast a mailbox message */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 /* DEPENDENCIES */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 /* cs_extr.h Common Service functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 /* tc_extr.h Thread Control functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /* mb_extr.h Mailbox functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /* hi_extr.h History functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 /* HISTORY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /* DATE REMARKS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 /* 03-01-1994 Initial version of supplemental */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 /* mailbox service file, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 /* version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 /* 03-18-1994 Verified version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 /* 04-17-1996 updated to version 1.2 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 /* 03-24-1998 Released version 1.3 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 /* 03-26-1999 Released 1.11m (new release */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* numbering scheme) */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 /* 04-23-2001 Fixed problem with resuming task in */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 /* MBS_Broadcast_To_Mailbox */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 /* 04-17-2002 Released version 1.13m */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 /* 11-07-2002 Released version 1.14 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 #define NU_SOURCE_FILE
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 #include "cs_extr.h" /* Common service functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 #include "tc_extr.h" /* Thread control functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 #include "mb_extr.h" /* Mailbox functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 #include "hi_extr.h" /* History functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 #include "profiler.h" /* ProView interface */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 /* Define internal component function prototypes. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 VOID MBC_Cleanup(VOID *information);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 /* FUNCTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 /* MBS_Reset_Mailbox */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 /* DESCRIPTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 /* This function resets a mailbox back to the initial state. Any */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 /* message in the mailbox is discarded. Also, all tasks suspended */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 /* on the mailbox are resumed with the reset completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 /* CALLED BY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 /* Application */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 /* MBSE_Reset_Mailbox Error checking shell */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 /* CALLS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 /* [HIC_Make_History_Entry] Make entry in history log */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 /* TCC_Resume_Task Resume a suspended task */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 /* [TCT_Check_Stack] Stack checking function */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 /* TCT_Control_To_System Transfer control to system */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 /* TCT_System_Protect Protect mailbox */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 /* TCT_Unprotect Release protection */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 /* INPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 /* mailbox_ptr Mailbox control block pointer*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 /* OUTPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 /* NU_SUCCESS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 /* HISTORY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 /* NAME DATE REMARKS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 /* 03-01-1993 Created initial version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 /* 04-19-1993 Verified version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 /* 03-01-1994 Changed function interface to */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 /* match the prototype, added */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 /* register variable logic, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 /* optimized protection logic, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 /* resulting in version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 /* 03-18-1994 Verified version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 STATUS MBS_Reset_Mailbox(NU_MAILBOX *mailbox_ptr)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 R1 MB_MCB *mailbox; /* Mailbox control block ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 R2 MB_SUSPEND *suspend_ptr; /* Suspend block pointer */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 MB_SUSPEND *next_ptr; /* Next suspend block pointer*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 STATUS preempt; /* Status for resume call */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 NU_SUPERV_USER_VARIABLES
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 /* Switch to supervisor mode */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 NU_SUPERVISOR_MODE();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 /* Move input mailbox pointer into internal pointer. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 mailbox = (MB_MCB *) mailbox_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 #ifdef NU_ENABLE_STACK_CHECK
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 /* Call stack checking function to check for an overflow condition. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 TCT_Check_Stack();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 #endif
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 #ifdef NU_ENABLE_HISTORY
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 /* Make an entry that corresponds to this function in the system history
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 log. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 HIC_Make_History_Entry(NU_RESET_MAILBOX_ID, (UNSIGNED) mailbox,
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 (UNSIGNED) 0, (UNSIGNED) 0);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 #endif
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 /* Protect against access to the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 TCT_System_Protect();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 /* Pickup the suspended task pointer list. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 suspend_ptr = mailbox -> mb_suspension_list;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 /* Walk the chain task(s) currently suspended on the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 preempt = 0;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 while (suspend_ptr)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 /* Resume the suspended task. Insure that the status returned is
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 NU_MAILBOX_RESET. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 suspend_ptr -> mb_return_status = NU_MAILBOX_RESET;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 /* Point to the next suspend structure in the link. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 next_ptr = (MB_SUSPEND *) (suspend_ptr -> mb_suspend_link.cs_next);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 /* Resume the specified task. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 preempt = preempt |
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 TCC_Resume_Task((NU_TASK *) suspend_ptr -> mb_suspended_task,
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 NU_MAILBOX_SUSPEND);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 /* Determine if the next is the same as the head pointer. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 if (next_ptr == mailbox -> mb_suspension_list)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 /* Clear the suspension pointer to signal the end of the list
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 traversal. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 suspend_ptr = NU_NULL;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 /* Position the suspend pointer to the next suspend block. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 suspend_ptr = next_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 /* Initialize the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 mailbox -> mb_message_present = NU_FALSE;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 mailbox -> mb_tasks_waiting = 0;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 mailbox -> mb_suspension_list = NU_NULL;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 #ifdef INCLUDE_PROVIEW
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 _RTProf_DumpMailBox(RT_PROF_RESET_MAILBOX,mailbox,RT_PROF_OK);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 #endif /* INCLUDE_PROVIEW */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 /* Determine if preemption needs to occur. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 if (preempt)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 /* Transfer control to system to facilitate preemption. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 TCT_Control_To_System();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 /* Release protection. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 TCT_Unprotect();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 /* Return to user mode */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 NU_USER_MODE();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 /* Return a successful completion. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 return(NU_SUCCESS);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 /* FUNCTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 /* MBS_Broadcast_To_Mailbox */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 /* DESCRIPTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 /* This function sends a message to all tasks currently waiting for */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 /* a message from the mailbox. If no tasks are waiting, this */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 /* service behaves like a normal send message. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 /* CALLED BY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 /* Application */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 /* MBSE_Broadcast_To_Mailbox Broadcast to a mailbox */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 /* CALLS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 /* CSC_Place_On_List Place on suspend list */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 /* CSC_Priority_Place_On_List Place on priority list */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 /* CSC_Remove_From_List Remove from suspend list */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 /* [HIC_Make_History_Entry] Make entry in history log */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 /* TCC_Resume_Task Resume a suspended task */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 /* TCC_Suspend_Task Suspend calling task */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 /* TCC_Task_Priority Priority of specified task */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 /* [TCT_Check_Stack] Stack checking function */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 /* TCT_Control_To_System Transfer control to system */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 /* TCT_Current_Thread Pickup current thread pointer*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 /* TCT_System_Protect Protect mailbox */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 /* TCT_Unprotect Release protection */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 /* INPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 /* mailbox_ptr Mailbox control block pointer*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 /* message Pointer to message to send */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 /* suspend Suspension option if full */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 /* OUTPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 /* NU_SUCCESS If service is successful */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 /* NU_MAILBOX_FULL If mailbox is currently full */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 /* NU_TIMEOUT If timeout on service expires*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 /* NU_MAILBOX_DELETED If mailbox is deleted during */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 /* suspension */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 /* NU_MAILBOX_RESET If mailbox is deleted during */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 /* suspension */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 /* HISTORY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 /* DATE REMARKS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 /* 03-01-1993 Created initial version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 /* 04-19-1993 Verified version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 /* 03-01-1994 Changed function interface to */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 /* match the prototype, added */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 /* register variable logic, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 /* optimized protection logic, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 /* resulting in version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 /* 03-18-1994 Verified version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 STATUS MBS_Broadcast_To_Mailbox(NU_MAILBOX *mailbox_ptr, VOID *message,
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 UNSIGNED suspend)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 R1 MB_MCB *mailbox; /* Mailbox control block ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 MB_SUSPEND suspend_block; /* Allocate suspension block */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 R2 MB_SUSPEND *suspend_ptr; /* Pointer to suspend block */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 MB_SUSPEND *suspend_head; /* Pointer to suspend head */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 MB_SUSPEND *next_suspend_ptr; /* Get before restarting task*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 STATUS preempt; /* Preemption flag */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 R3 UNSIGNED *source_ptr; /* Pointer to source */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 R4 UNSIGNED *destination_ptr; /* Pointer to destination */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 TC_TCB *task; /* Task pointer */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 STATUS status; /* Completion status */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 NU_SUPERV_USER_VARIABLES
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 /* Switch to supervisor mode */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 NU_SUPERVISOR_MODE();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 /* Move input mailbox pointer into internal pointer. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 mailbox = (MB_MCB *) mailbox_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 #ifdef NU_ENABLE_STACK_CHECK
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 /* Call stack checking function to check for an overflow condition. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 TCT_Check_Stack();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 #endif
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 #ifdef NU_ENABLE_HISTORY
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 /* Make an entry that corresponds to this function in the system history
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 log. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 HIC_Make_History_Entry(NU_BROADCAST_TO_MAILBOX_ID, (UNSIGNED) mailbox,
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 (UNSIGNED) message, (UNSIGNED) suspend);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 #endif
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 /* Initialize the status as successful. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 status = NU_SUCCESS;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 /* Protect against simultaneous access to the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 TCT_System_Protect();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 /* Determine if the mailbox is empty or full. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 if (mailbox -> mb_message_present)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 /* Mailbox already has a message. Determine if suspension is
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 required. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 if (suspend)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 /* Suspension is requested. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 /* Increment the number of tasks suspended on the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 mailbox -> mb_tasks_waiting++;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 #ifdef INCLUDE_PROVIEW
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 _RTProf_DumpMailBox(RT_PROF_BROADCAST_TO_MAILBOX,mailbox,RT_PROF_WAIT);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 #endif /* INCLUDE_PROVIEW */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 /* Setup the suspend block and suspend the calling task. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 suspend_ptr = &suspend_block;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 suspend_ptr -> mb_mailbox = mailbox;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 suspend_ptr -> mb_suspend_link.cs_next = NU_NULL;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 suspend_ptr -> mb_suspend_link.cs_previous = NU_NULL;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 suspend_ptr -> mb_message_area = (UNSIGNED *) message;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 task = (TC_TCB *) TCT_Current_Thread();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 suspend_ptr -> mb_suspended_task = task;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 /* Determine if priority or FIFO suspension is associated with the
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 if (mailbox -> mb_fifo_suspend)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 /* FIFO suspension is required. Link the suspend block into
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 the list of suspended tasks on this mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 CSC_Place_On_List((CS_NODE **) &(mailbox ->mb_suspension_list),
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 &(suspend_ptr -> mb_suspend_link));
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 /* Get the priority of the current thread so the suspend block
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 can be placed in the appropriate place. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368 suspend_ptr -> mb_suspend_link.cs_priority =
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 TCC_Task_Priority(task);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 CSC_Priority_Place_On_List((CS_NODE **)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 &(mailbox -> mb_suspension_list),
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 &(suspend_ptr -> mb_suspend_link));
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 /* Finally, suspend the calling task. Note that the suspension call
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 automatically clears the protection on the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 TCC_Suspend_Task((NU_TASK *) task, NU_MAILBOX_SUSPEND,
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 MBC_Cleanup, suspend_ptr, suspend);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381 /* Pickup the return status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 status = suspend_ptr -> mb_return_status;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 /* Return a status of NU_MAILBOX_FULL because there is no
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 room in the mailbox for the message. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
389 status = NU_MAILBOX_FULL;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
390
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
391 #ifdef INCLUDE_PROVIEW
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
392 _RTProf_DumpMailBox(RT_PROF_BROADCAST_TO_MAILBOX,mailbox,RT_PROF_FAIL);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
393 #endif /* INCLUDE_PROVIEW */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
394
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
395 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
396 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
397 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
398 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
399
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
400 /* Determine if a task is waiting on the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
401 if (mailbox -> mb_suspension_list)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
402 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
403
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
404 #ifdef INCLUDE_PROVIEW
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
405 _RTProf_DumpMailBox(RT_PROF_BROADCAST_TO_MAILBOX,mailbox,RT_PROF_OK);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
406 #endif /* INCLUDE_PROVIEW */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
407
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
408 /* At least one task is waiting on mailbox for a message. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
409
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
410 /* Save off the suspension list and and then clear out the
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
411 mailbox suspension. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
412 suspend_head = mailbox -> mb_suspension_list;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
413 mailbox -> mb_suspension_list = NU_NULL;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
414
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
415 /* Loop to wakeup all of the tasks waiting on the mailbox for
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
416 a message. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
417 suspend_ptr = suspend_head;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
418 preempt = 0;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
419 do
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
420 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
421
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
422 /* Setup the source and destination pointers. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
423 source_ptr = (UNSIGNED *) message;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
424 destination_ptr = suspend_ptr -> mb_message_area;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
425
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
426 /* Copy the message directly into the waiting task's
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
427 destination. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
428 *destination_ptr = *source_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
429 *(destination_ptr + 1) = *(source_ptr + 1);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
430 *(destination_ptr + 2) = *(source_ptr + 2);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
431 *(destination_ptr + 3) = *(source_ptr + 3);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
432
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
433 /* Setup the appropriate return value. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
434 suspend_ptr -> mb_return_status = NU_SUCCESS;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
435
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
436 /* Move the suspend pointer along to the next block. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
437 next_suspend_ptr = (MB_SUSPEND *)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
438 suspend_ptr -> mb_suspend_link.cs_next;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
439
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
440 /* Wakeup each task waiting. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
441 preempt = preempt |
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
442 TCC_Resume_Task((NU_TASK *) suspend_ptr -> mb_suspended_task,
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
443 NU_MAILBOX_SUSPEND);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
444 suspend_ptr = next_suspend_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
445
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
446 } while (suspend_ptr != suspend_head);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
447
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
448 /* Clear the number of tasks waiting counter of the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
449 mailbox -> mb_tasks_waiting = 0;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
450
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
451 /* Determine if a preempt condition is present. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
452 if (preempt)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
453
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
454 /* Transfer control to the system if the resumed task function
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
455 detects a preemption condition. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
456 TCT_Control_To_System();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
457 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
458 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
459 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
460
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
461 /* Mailbox is empty and no task is waiting. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
462
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
463 /* Setup the source and destination pointers. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
464 source_ptr = (UNSIGNED *) message;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
465 destination_ptr = &(mailbox -> mb_message_area[0]);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
466
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
467 /* Place the message in the mailbox. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
468 *destination_ptr = *source_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
469 *(destination_ptr + 1) = *(source_ptr + 1);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
470 *(destination_ptr + 2) = *(source_ptr + 2);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
471 *(destination_ptr + 3) = *(source_ptr + 3);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
472
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
473 /* Indicate that the mailbox has a message. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
474 mailbox -> mb_message_present = NU_TRUE;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
475
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
476 #ifdef INCLUDE_PROVIEW
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
477 _RTProf_DumpMailBox(RT_PROF_BROADCAST_TO_MAILBOX,mailbox,RT_PROF_OK);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
478 #endif /* INCLUDE_PROVIEW */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
479 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
480 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
481
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
482 /* Release protection. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
483 TCT_Unprotect();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
484
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
485 /* Return to user mode */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
486 NU_USER_MODE();
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
487
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
488 /* Return the completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
489 return(status);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
490 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
491
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
492
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
493
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
494
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
495
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
496