1 /******************************************************************************
5 * Instantiation of environment variables, structures, and other globals.
7 * Revision information:
9 * 20AUG2004 kb_admin initial creation
12 * No warranty, expressed or implied, is included with this software. It is
13 * provided "AS IS" and no warranty of any kind including statutory or aspects
14 * relating to merchantability or fitness for any purpose is provided. All
15 * intellectual property rights of others is maintained with the respective
16 * owners. This software is not copyrighted and is intended for reference
21 *****************************************************************************/
24 #include "loader_prompt.h"
27 /******************************* GLOBALS *************************************/
28 char boot_commands[MAX_BOOT_COMMANDS][MAX_INPUT_SIZE];
30 char env_table[MAX_ENV_SIZE_BYTES];
32 extern char BootCommandSection;
34 /************************** PRIVATE FUNCTIONS ********************************/
37 static int currentIndex;
38 static int currentOffset;
42 * .KB_C_FN_DEFINITION_START
43 * int ReadCharFromEnvironment(char *)
44 * This private function reads characters from the enviroment variables
45 * to service the command prompt during auto-boot or just to setup the
46 * default environment. Returns positive value if valid character was
47 * set in the pointer. Returns negative value to signal input stream
48 * terminated. Returns 0 to indicate _wait_ condition.
49 * .KB_C_FN_DEFINITION_END
52 ReadCharFromEnvironment(int timeout)
56 if (currentIndex < MAX_BOOT_COMMANDS) {
57 ch = boot_commands[currentIndex][currentOffset++];
58 if (ch == '\0' || (currentOffset >= MAX_INPUT_SIZE)) {
70 /*************************** GLOBAL FUNCTIONS ********************************/
74 * .KB_C_FN_DEFINITION_START
75 * void DumpBootCommands(void)
76 * This global function displays the current boot commands.
77 * .KB_C_FN_DEFINITION_END
80 DumpBootCommands(void)
84 for (i = 0; boot_commands[i][0]; i++)
85 printf("0x%x : %s[E]\n", i, boot_commands[i]);
90 * .KB_C_FN_DEFINITION_START
91 * void LoadBootCommands(void)
92 * This global function loads the existing boot commands from raw format and
93 * coverts it to the standard, command-index format. Notice, the processed
94 * boot command table has much more space allocated than the actual table
95 * stored in non-volatile memory. This is because the processed table
96 * exists in RAM which is larger than the non-volatile space.
97 * .KB_C_FN_DEFINITION_END
100 LoadBootCommands(void)
105 p_memset((char*)boot_commands, 0, sizeof(boot_commands));
106 cptr = &BootCommandSection;
107 for (index = 0; *cptr; index++) {
108 for (j = 0; *cptr; j++)
109 boot_commands[index][j] = *cptr++;
116 * .KB_C_FN_DEFINITION_START
117 * void ExecuteEnvironmentFunctions(void)
118 * This global function executes applicable entries in the environment.
119 * .KB_C_FN_DEFINITION_END
122 ExecuteEnvironmentFunctions(void)
128 printf("Autoboot...\n");
129 Bootloader(ReadCharFromEnvironment);