Download YAMON™ Reference Manual
Transcript
Shell The maximum number of commands registered is defined by the symbol MAX_COMMANDS (50) in shell/ shell_init.c. 6.2.2 Command Invocation Repeating the above example, assume the user has created an environment variable ‘test’ using the following command: setenv test Hello Now, assume the user enters the following line: echo $test “world !” The shell will pass the following arguments to the function registered with name ‘echo’: argc = 3 argv[0] = “echo” argv[1] = “Hello” argv[2] = “world !” The shell will change line (print ‘\n’) before passing control to a command. The shell will not change line before printing the new prompt upon command return. 6.2.3 Error Reporting The command function returns an error code as described in Chapter 4, “Error Handling” on page 25. The following generic code indicates “no error”: OK A command may request additional information to be displayed by setting the string pointer ‘shell_error_data’. This should always be done in case of illegal options, in which case ‘shell_error_data’ should point to the string containing the illegal option. A command may also include a hint for solving a specific error by setting the string pointer ‘shell_error_hint’. The shell looks up the error text using SYSCON as described in Chapter 4, “Error Handling” on page 25 and displays it. 6.2.4 Command Input/Output The following subsections describe how shell commands may receive data from the UART and transmit data to the UART. 6.2.4.1 Input Commands may receive characters from the terminal by calling the following functions implemented in sys/sys.c and defined in include/sys_api.h: bool sys_getchar( UINT32 port, 37 MIPS® YAMON™ Reference Manual, Revision 02.20 Copyright © 1999-2011 MIPS Technologies Inc. All rights reserved.