1 |
27 |
unneback |
//=============================================================================
|
2 |
|
|
//
|
3 |
|
|
// test_menu.h - Cyclone Diagnostics
|
4 |
|
|
//
|
5 |
|
|
//=============================================================================
|
6 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
7 |
|
|
// -------------------------------------------
|
8 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
9 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
10 |
|
|
//
|
11 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
12 |
|
|
// the terms of the GNU General Public License as published by the Free
|
13 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
14 |
|
|
//
|
15 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
16 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
17 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
18 |
|
|
// for more details.
|
19 |
|
|
//
|
20 |
|
|
// You should have received a copy of the GNU General Public License along
|
21 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
22 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
23 |
|
|
//
|
24 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
25 |
|
|
// or inline functions from this file, or you compile this file and link it
|
26 |
|
|
// with other works to produce a work based on this file, this file does not
|
27 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
28 |
|
|
// License. However the source code for this file must still be made available
|
29 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
30 |
|
|
//
|
31 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
32 |
|
|
// this file might be covered by the GNU General Public License.
|
33 |
|
|
//
|
34 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
35 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
36 |
|
|
// -------------------------------------------
|
37 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
38 |
|
|
//=============================================================================
|
39 |
|
|
//#####DESCRIPTIONBEGIN####
|
40 |
|
|
//
|
41 |
|
|
// Author(s): Scott Coulter, Jeff Frazier, Eric Breeden
|
42 |
|
|
// Contributors:
|
43 |
|
|
// Date: 2001-01-25
|
44 |
|
|
// Purpose:
|
45 |
|
|
// Description:
|
46 |
|
|
//
|
47 |
|
|
//####DESCRIPTIONEND####
|
48 |
|
|
//
|
49 |
|
|
//===========================================================================*/
|
50 |
|
|
|
51 |
|
|
/*****************************************************************************
|
52 |
|
|
* test_menu.h - Menu dispatching header
|
53 |
|
|
*
|
54 |
|
|
* modification history
|
55 |
|
|
* --------------------
|
56 |
|
|
* 30aug00 ejb Ported from MPC8240 Breeze to StrongARM2 Cygmon
|
57 |
|
|
*/
|
58 |
|
|
/*
|
59 |
|
|
DESCRIPTION
|
60 |
|
|
|
61 |
|
|
Include file for the table-driven menu module menu.c. This module displays
|
62 |
|
|
a menu of numbered items, prompts the user for a choice, then calls an action
|
63 |
|
|
routine associated with the choice. It then redisplays the menu and prompts
|
64 |
|
|
for another choice. A choice of zero (0) exits the menu routine.
|
65 |
|
|
|
66 |
|
|
To use this menu module, construct a table of type MENU_ITEM, with one entry
|
67 |
|
|
for each menu item. An entry consists of a string to print out with the
|
68 |
|
|
menu, an action routine, and an argument for the action routine. There is
|
69 |
|
|
no need to have an "exit" or "quit" item, since the menu routine handles
|
70 |
|
|
that by assigning at the zero (0) item number. For example, a simple menu
|
71 |
|
|
of tests would be constructed this way:
|
72 |
|
|
|
73 |
|
|
IMPORT VOID doTestA ();
|
74 |
|
|
IMPORT VOID doTestB ();
|
75 |
|
|
|
76 |
|
|
#define TESTA_ARG 0
|
77 |
|
|
#define TESTB_ARG 1
|
78 |
|
|
|
79 |
|
|
LOCAL MENU_ITEM testMenu[] =
|
80 |
|
|
{
|
81 |
|
|
{"Test A", doTestA, (MENU_ARG)TESTA_ARG},
|
82 |
|
|
{"Test B", doTestB, (MENU_ARG)TESTB_ARG},
|
83 |
|
|
};
|
84 |
|
|
|
85 |
|
|
#define NUM_ITEMS NELEMENTS(testMenu)
|
86 |
|
|
#define MENU_TITLE "Test Menu"
|
87 |
|
|
|
88 |
|
|
Then, in the test top level routine, call the routine menu(), declared as:
|
89 |
|
|
|
90 |
|
|
STATUS menu (menuTable, numMenuItems, title, options)
|
91 |
|
|
MENU_ITEM menuTable[];
|
92 |
|
|
int numMenuItems;
|
93 |
|
|
char *title;
|
94 |
|
|
ULONG options;
|
95 |
|
|
|
96 |
|
|
For example:
|
97 |
|
|
|
98 |
|
|
status = menu (testMenu, NUM_ITEMS, MENU_TITLE, MENU_OPT_NONE);
|
99 |
|
|
|
100 |
|
|
*/
|
101 |
|
|
|
102 |
|
|
/*
|
103 |
|
|
* The following types define an entry in the menu table. Each entry describes
|
104 |
|
|
* one menu item, including a string to describe that item, an action
|
105 |
|
|
* routine to call when that item is chosen, and an argument to pass when the
|
106 |
|
|
* action routine is called.
|
107 |
|
|
*/
|
108 |
|
|
typedef volatile void *MENU_ARG;
|
109 |
|
|
typedef void (*MENU_RTN) (MENU_ARG arg);
|
110 |
|
|
typedef struct menuItem
|
111 |
|
|
{
|
112 |
|
|
char *itemName; /* string to print with the menu */
|
113 |
|
|
MENU_RTN actionRoutine; /* routine to call when item is chosen */
|
114 |
|
|
MENU_ARG arg; /* argument to actionRoutine */
|
115 |
|
|
} MENU_ITEM;
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
/*
|
119 |
|
|
* Menu options
|
120 |
|
|
*
|
121 |
|
|
* These options control the display of the menu.
|
122 |
|
|
*
|
123 |
|
|
* MENU_OPT_NONE - The normal behavior. The menu is always displayed before
|
124 |
|
|
* prompting the user for a choice.
|
125 |
|
|
*
|
126 |
|
|
* MENU_OPT_SUPPRESS_DISP - The menu is displayed before prompting the user
|
127 |
|
|
* for a choice except after executing a previously valid choice. This option
|
128 |
|
|
* is useful for large menus consisting of simple commands that produce only
|
129 |
|
|
* a line or two of output. In this case, after the user executes a valid
|
130 |
|
|
* choice, the redisplay of a large menu may cause output to scroll off the
|
131 |
|
|
* screen. The menu is redisplayed if the user enters an invalid choice.
|
132 |
|
|
*/
|
133 |
|
|
#define MENU_OPT_NONE 0x00
|
134 |
|
|
#define MENU_OPT_SUPPRESS_DISP 0x01
|
135 |
|
|
#define MENU_OPT_VALUE 0x02
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
MENU_ARG menu (MENU_ITEM menuTable[],
|
141 |
|
|
int numMenuItems,
|
142 |
|
|
char *title,
|
143 |
|
|
unsigned long options);
|
144 |
|
|
|