1 //=============================================================================
3 // test_menu.h - Cyclone Diagnostics
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.
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.
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
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.
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.
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.
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####
41 // Author(s): Scott Coulter, Jeff Frazier, Eric Breeden
47 //####DESCRIPTIONEND####
49 //===========================================================================*/
51 /*****************************************************************************
52 * test_menu.h - Menu dispatching header
54 * modification history
55 * --------------------
56 * 30aug00 ejb Ported from MPC8240 Breeze to StrongARM2 Cygmon
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.
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:
73 IMPORT VOID doTestA ();
74 IMPORT VOID doTestB ();
79 LOCAL MENU_ITEM testMenu[] =
81 {"Test A", doTestA, (MENU_ARG)TESTA_ARG},
82 {"Test B", doTestB, (MENU_ARG)TESTB_ARG},
85 #define NUM_ITEMS NELEMENTS(testMenu)
86 #define MENU_TITLE "Test Menu"
88 Then, in the test top level routine, call the routine menu(), declared as:
90 STATUS menu (menuTable, numMenuItems, title, options)
91 MENU_ITEM menuTable[];
98 status = menu (testMenu, NUM_ITEMS, MENU_TITLE, MENU_OPT_NONE);
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.
108 typedef volatile void *MENU_ARG;
109 typedef void (*MENU_RTN) (MENU_ARG arg);
110 typedef struct menuItem
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 */
121 * These options control the display of the menu.
123 * MENU_OPT_NONE - The normal behavior. The menu is always displayed before
124 * prompting the user for a choice.
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.
133 #define MENU_OPT_NONE 0x00
134 #define MENU_OPT_SUPPRESS_DISP 0x01
135 #define MENU_OPT_VALUE 0x02
140 MENU_ARG menu (MENU_ITEM menuTable[],
143 unsigned long options);