annotate packages/kernel/current/tests/kmbox1.c @ 3403:8c8767bb9a62 default tip

devs/nand/micron_mt29: Remove defunct references (in comments) to mt29f2g08_oob_ecc.
author Ross Younger <wry@ecoscentric.com>
date Sun, 18 Jan 2015 17:59:01 +1300
parents 80f232caf539
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 /*==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
3 // kmbox1.cxx
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
5 // Kernel Mbox test 1
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
6 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
16 // version.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
21 // for more details.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
33 // General Public License v2.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2310
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
39 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
41 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42 // Author: dsm
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
43 // Contributors: dsm
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
44 // Date: 1998-06-02
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
45 // Description: Tests basic mbox functionality.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
46 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
47 */
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
48
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
49 #include <cyg/hal/hal_arch.h> // CYGNUM_HAL_STACK_SIZE_TYPICAL
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
50
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51 #include <cyg/kernel/kapi.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53 #include <cyg/infra/testcase.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
54
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55 #ifdef CYGFUN_KERNEL_API_C
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57 #include "testaux.h"
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59 #define NTHREADS 2
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
60 #define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
61
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
62 static cyg_handle_t thread[NTHREADS];
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64 static cyg_thread thread_obj[NTHREADS];
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65 static char stack[NTHREADS][STACKSIZE];
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67 static cyg_handle_t m0, m1, m2;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68 static cyg_mbox mbox0, mbox1, mbox2;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
70 static cyg_atomic q = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
71
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72 #ifndef CYGMTH_MBOX_PUT_CAN_WAIT
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73 #define cyg_mbox_PUT cyg_mbox_tryput
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
75
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
76 static void entry0( cyg_addrword_t data )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78 cyg_count8 u,i,j;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80 CYG_TEST_INFO("Testing put() and tryput() without wakeup");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81 CYG_TEST_CHECK(!cyg_mbox_waiting_to_get(m0), "mbox not initialized properly");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
82 CYG_TEST_CHECK(0==cyg_mbox_peek(m0), "mbox not initialized properly");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83 CYG_TEST_CHECK(NULL==cyg_mbox_peek_item(m0), "mbox not initialized properly");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
84 cyg_mbox_PUT(m0, (void *)55);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85 CYG_TEST_CHECK(1==cyg_mbox_peek(m0), "peek() wrong");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
86 CYG_TEST_CHECK(55==(cyg_count8)cyg_mbox_peek_item(m0), "peek_item() wrong");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
87 for(u=1; cyg_mbox_tryput(m0, (void*)u); u++) {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88 CYG_TEST_CHECK(55==(cyg_count8)cyg_mbox_peek_item(m0), "peek_item() wrong");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89 CYG_TEST_CHECK(u+1==cyg_mbox_peek(m0), "peek() wrong");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
91 CYG_TEST_CHECK(u == CYGNUM_KERNEL_SYNCH_MBOX_QUEUE_SIZE, "mbox not configured size");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
92
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
93 // m0 now contains ( 55 1 2 .. u-1 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
94 CYG_TEST_CHECK(u==cyg_mbox_peek(m0), "peek() wrong");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
95 CYG_TEST_CHECK(55==(cyg_count8)cyg_mbox_peek_item(m0), "peek_item() wrong");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
96
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
97 CYG_TEST_INFO("Testing get(), tryget()");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99 i = (cyg_count8)cyg_mbox_tryget(m0);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
100 CYG_TEST_CHECK( 55 == i, "Got wrong message" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101 for(j=1; j<u;j++) {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 CYG_TEST_CHECK( j == (cyg_count8)cyg_mbox_peek_item(m0), "peek_item()" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103 CYG_TEST_CHECK( cyg_mbox_peek(m0) == u - j, "peek() wrong" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
104 i = (cyg_count8)cyg_mbox_get(m0);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105 CYG_TEST_CHECK( j == i, "Got wrong message" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
106 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
107
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108 CYG_TEST_CHECK( NULL == cyg_mbox_peek_item(m0), "peek_item()" );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109 CYG_TEST_CHECK( 0 == cyg_mbox_peek(m0), "peek()");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111 // m0 now empty
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113 CYG_TEST_CHECK(!cyg_mbox_waiting_to_put(m0), "waiting_to_put()");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114 CYG_TEST_CHECK(!cyg_mbox_waiting_to_get(m0), "waiting_to_get()");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
116 CYG_TEST_INFO("Testing get(), blocking");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
117
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118 CYG_TEST_CHECK(0==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119 cyg_mbox_PUT(m1, (void*)99); // wakes t1
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120 i = (cyg_count8)cyg_mbox_get(m0); // sent by t1
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
121 CYG_TEST_CHECK(3==i, "Recieved wrong message");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122 CYG_TEST_CHECK(2==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
123
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124 #ifdef CYGFUN_KERNEL_THREADS_TIMER
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
125 CYG_TEST_CHECK(NULL==cyg_mbox_timed_get(m0, cyg_current_time()+10),
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
126 "unexpectedly found message");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
127 CYG_TEST_CHECK(3==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
128 // Allow t1 to run as this get times out
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
129 // t1 must not be waiting...
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130 CYG_TEST_CHECK(cyg_mbox_waiting_to_get(m0), "waiting_to_get()");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
131
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
132 cyg_mbox_PUT(m0, (void*)7); // wake t1 from timed get
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
133 #ifdef CYGMTH_MBOX_PUT_CAN_WAIT
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
134 q=10;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135 while(cyg_mbox_tryput(m0, (void*)6)) // fill m0's queue
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
136 ;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
137 // m0 now contains ( 6 ... 6 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
138 CYG_TEST_CHECK(10==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
139 cyg_mbox_put(m1, (void*)4); // wake t1
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
140 CYG_TEST_CHECK(!cyg_mbox_timed_put(m0, (void*)8, cyg_current_time()+10),
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
141 "timed put() unexpectedly worked");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142 CYG_TEST_CHECK(12==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
143 // m0 still contains ( 6 ... 6 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
144 cyg_mbox_put(m0, (void*)9);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 CYG_TEST_CHECK(13==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
146 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
147 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
148 i=(cyg_count8)cyg_mbox_get(m2);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
149 CYG_TEST_FAIL_FINISH("Not reached");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
151
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
152 static void entry1( cyg_addrword_t data )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
153 {
3209
80f232caf539 * tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents: 2729
diff changeset
154 #ifdef CYGMTH_MBOX_PUT_CAN_WAIT
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
155 cyg_count8 i;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
156 i = (cyg_count8)cyg_mbox_get(m1);
3209
80f232caf539 * tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents: 2729
diff changeset
157 #endif
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
158 CYG_TEST_CHECK(1==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
159 cyg_mbox_PUT(m0, (void *)3); // wake t0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
160
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
161 #if defined(CYGFUN_KERNEL_THREADS_TIMER)
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
162 CYG_TEST_INFO("Testing timed functions");
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
163 CYG_TEST_CHECK(7==(cyg_count8)cyg_mbox_timed_get(m0,cyg_current_time()+20),
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
164 "timed get()");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
165 CYG_TEST_CHECK(4==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
166 #ifdef CYGMTH_MBOX_PUT_CAN_WAIT
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
167 CYG_TEST_CHECK(4==(cyg_count8)cyg_mbox_get(m1));
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
168
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
169 CYG_TEST_CHECK(11==q++, "bad synchronization");
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
170 thread[0]->delay(20); // allow t0 to reach put on m1
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
171 CYG_TEST_CHECK(14==q++, "bad synchronization");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
172 CYG_TEST_CHECK(cyg_mbox_waiting_to_put(m0), "waiting_to_put()");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
173 do {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
174 // after first get m0 contains ( 6 .. 6 9 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
175 i=(cyg_count8)cyg_mbox_tryget(m0);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
176 } while(6==i);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
177 CYG_TEST_CHECK(9==i,"put gone awry");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
178 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
179 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
180 CYG_TEST_PASS_FINISH("Kernel C API Mbox 1 OK");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
181 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
182
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
183 void kmbox1_main( void )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
184 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
185 CYG_TEST_INIT();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
186
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
187 cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "kmbox1-0",
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
188 (void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
189 cyg_thread_resume(thread[0]);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
190
2310
4be03fe7814d * cdl/synch.cdl: Added CYGIMP_MBOX_USE_MBOXT_PLAIN option. This is
nickg
parents: 210
diff changeset
191 cyg_thread_create(5, entry1 , (cyg_addrword_t)1, "kmbox1-1",
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
192 (void *)stack[1], STACKSIZE, &thread[1], &thread_obj[1]);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
193 cyg_thread_resume(thread[1]);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
194
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
195 cyg_mbox_create( &m0, &mbox0 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
196 cyg_mbox_create( &m1, &mbox1 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
197 cyg_mbox_create( &m2, &mbox2 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
198
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
199 cyg_scheduler_start();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
200
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
201 CYG_TEST_FAIL_FINISH("Not reached");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
202 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
203
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
204 externC void
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
205 cyg_start( void )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
206 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
207 kmbox1_main();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
208 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
209 #else /* def CYGFUN_KERNEL_API_C */
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
210 externC void
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
211 cyg_start( void )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
212 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
213 CYG_TEST_INIT();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
214 CYG_TEST_NA("Kernel C API layer disabled");
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
215 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
216 #endif /* def CYGFUN_KERNEL_API_C */
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
217
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
218 /* EOF kmbox1.c */