source: rtems/testsuites/libtests/block02/init.c @ 4c86e3d

4.115
Last change on this file since 4c86e3d was 4c86e3d, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/12 at 17:20:47

libtmtests - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup test_bdbuf
5 *
6 * @brief Bdbuf test.
7 */
8
9/*
10 * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include "tmacros.h"
28
29#include <rtems.h>
30#include <rtems/ramdisk.h>
31#include <rtems/bdbuf.h>
32#include <rtems/diskdevs.h>
33
34/* forward declarations to avoid warnings */
35static rtems_task Init(rtems_task_argument argument);
36
37#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
38
39#define PRIORITY_INIT 10
40
41#define PRIORITY_SWAPOUT 50
42
43#define PRIORITY_HIGH 30
44
45#define PRIORITY_LOW 40
46
47#define BLOCK_SIZE_A 512
48
49#define BLOCK_COUNT_A 2
50
51#define BLOCK_SIZE_B 1024
52
53#define BLOCK_COUNT_B 1
54
55static const rtems_disk_device *dd_a;
56
57static const rtems_disk_device *dd_b;
58
59static volatile bool sync_done = false;
60
61static rtems_id task_id_low;
62
63static rtems_id task_id_high;
64
65static void task_low(rtems_task_argument arg)
66{
67  rtems_status_code sc = RTEMS_SUCCESSFUL;
68  rtems_bdbuf_buffer *bd = NULL;
69
70  rtems_test_assert(!sync_done);
71
72  printk("L: try access: A0\n");
73
74  sc = rtems_bdbuf_get(dd_a, 0, &bd);
75  ASSERT_SC(sc);
76
77  rtems_test_assert(sync_done);
78
79  printk("L: access: A0\n");
80
81  rtems_test_assert(bd->dd == dd_a);
82
83  printk("*** END OF TEST BLOCK 2 ***\n");
84
85  exit(0);
86}
87
88static void task_high(rtems_task_argument arg)
89{
90  rtems_status_code sc = RTEMS_SUCCESSFUL;
91  rtems_bdbuf_buffer *bd = NULL;
92
93  rtems_test_assert(!sync_done);
94
95  printk("H: try access: A0\n");
96
97  sc = rtems_bdbuf_get(dd_a, 0, &bd);
98  ASSERT_SC(sc);
99
100  rtems_test_assert(sync_done);
101
102  printk("H: access: A0\n");
103
104  printk("H: release: A0\n");
105
106  sc = rtems_bdbuf_release(bd);
107  ASSERT_SC(sc);
108
109  printk("H: release done: A0\n");
110
111  printk("H: try access: B0\n");
112
113  sc = rtems_bdbuf_get(dd_b, 0, &bd);
114  ASSERT_SC(sc);
115
116  printk("H: access: B0\n");
117
118  /* If we reach this code, we have likely a bug */
119
120  printk("H: release: B0\n");
121
122  sc = rtems_bdbuf_release(bd);
123  ASSERT_SC(sc);
124
125  printk("H: release done: B0\n");
126
127  rtems_task_delete(RTEMS_SELF);
128}
129
130static rtems_task Init(rtems_task_argument argument)
131{
132  rtems_status_code sc = RTEMS_SUCCESSFUL;
133  rtems_bdbuf_buffer *bd = NULL;
134  dev_t dev_a = 0;
135  dev_t dev_b = 0;
136
137  printk("\n\n*** TEST BLOCK 2 ***\n");
138
139  sc = rtems_disk_io_initialize();
140  ASSERT_SC(sc);
141
142  sc = ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT_A, false, "/dev/rda", &dev_a);
143  ASSERT_SC(sc);
144
145  sc = ramdisk_register(BLOCK_SIZE_B, BLOCK_COUNT_B, false, "/dev/rdb", &dev_b);
146  ASSERT_SC(sc);
147
148  dd_a = rtems_disk_obtain(dev_a);
149  rtems_test_assert(dd_a != NULL);
150
151  dd_b = rtems_disk_obtain(dev_b);
152  rtems_test_assert(dd_b != NULL);
153
154  sc = rtems_task_create(
155    rtems_build_name(' ', 'L', 'O', 'W'),
156    PRIORITY_LOW,
157    0,
158    RTEMS_DEFAULT_MODES,
159    RTEMS_DEFAULT_ATTRIBUTES,
160    &task_id_low
161  );
162  ASSERT_SC(sc);
163
164  sc = rtems_task_start(task_id_low, task_low, 0);
165  ASSERT_SC(sc);
166
167  sc = rtems_task_create(
168    rtems_build_name('H', 'I', 'G', 'H'),
169    PRIORITY_HIGH,
170    0,
171    RTEMS_DEFAULT_MODES,
172    RTEMS_DEFAULT_ATTRIBUTES,
173    &task_id_high
174  );
175  ASSERT_SC(sc);
176
177  sc = rtems_task_start(task_id_high, task_high, 0);
178  ASSERT_SC(sc);
179
180  sc = rtems_bdbuf_get(dd_a, 0, &bd);
181  ASSERT_SC(sc);
182
183  sc = rtems_bdbuf_sync(bd);
184  ASSERT_SC(sc);
185
186  printk("I: sync done: A0\n");
187
188  sync_done = true;
189
190  sc = rtems_task_suspend(RTEMS_SELF);
191  ASSERT_SC(sc);
192}
193
194#define CONFIGURE_INIT
195
196#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
197#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
198#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
199
200#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
201
202#define CONFIGURE_MAXIMUM_TASKS 5
203#define CONFIGURE_MAXIMUM_DRIVERS 3
204
205#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
206
207#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_INIT
208#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
209#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
210
211#define CONFIGURE_SWAPOUT_TASK_PRIORITY PRIORITY_SWAPOUT
212
213#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE BLOCK_SIZE_A
214#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE BLOCK_SIZE_B
215#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE BLOCK_SIZE_B
216
217#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.