199767f8919635c4928607450d9e0abb932109ceToomas Soome/******************************************************************************
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Instantiation of environment variables, structures, and other globals.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Revision information:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 20AUG2004 kb_admin initial creation
199767f8919635c4928607450d9e0abb932109ceToomas Soome * BEGIN_KBDD_BLOCK
199767f8919635c4928607450d9e0abb932109ceToomas Soome * No warranty, expressed or implied, is included with this software. It is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * provided "AS IS" and no warranty of any kind including statutory or aspects
199767f8919635c4928607450d9e0abb932109ceToomas Soome * relating to merchantability or fitness for any purpose is provided. All
199767f8919635c4928607450d9e0abb932109ceToomas Soome * intellectual property rights of others is maintained with the respective
199767f8919635c4928607450d9e0abb932109ceToomas Soome * owners. This software is not copyrighted and is intended for reference
199767f8919635c4928607450d9e0abb932109ceToomas Soome *****************************************************************************/
199767f8919635c4928607450d9e0abb932109ceToomas Soome/******************************* GLOBALS *************************************/
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar boot_commands[MAX_BOOT_COMMANDS][MAX_INPUT_SIZE];
199767f8919635c4928607450d9e0abb932109ceToomas Soome/************************** PRIVATE FUNCTIONS ********************************/
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * int ReadCharFromEnvironment(char *)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This private function reads characters from the enviroment variables
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to service the command prompt during auto-boot or just to setup the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * default environment. Returns positive value if valid character was
199767f8919635c4928607450d9e0abb932109ceToomas Soome * set in the pointer. Returns negative value to signal input stream
199767f8919635c4928607450d9e0abb932109ceToomas Soome * terminated. Returns 0 to indicate _wait_ condition.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome ch = boot_commands[currentIndex][currentOffset++];
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (ch == '\0' || (currentOffset >= MAX_INPUT_SIZE)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (-1);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*************************** GLOBAL FUNCTIONS ********************************/
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * void WriteCommandTable(void)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This global function write the current command table to the non-volatile
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; i < MAX_BOOT_COMMANDS; ++i) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* We're executing in low RAM so addr in ram == offset in eeprom */
199767f8919635c4928607450d9e0abb932109ceToomas Soome WriteEEPROM((unsigned)&BootCommandSection, env_table,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * void SetBootCommand(int index, char *command)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This global function replaces the specified index with the string residing
199767f8919635c4928607450d9e0abb932109ceToomas Soome * at command. Execute this function with a NULL string to clear the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * associated command index.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome p_memset(boot_commands[index], 0, MAX_INPUT_SIZE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; i < MAX_INPUT_SIZE; ++i) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * void DumpBootCommands(void)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This global function displays the current boot commands.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; i < MAX_BOOT_COMMANDS; ++i) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (j = 0; j < MAX_INPUT_SIZE; ++j) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * void LoadBootCommands(void)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This global function loads the existing boot commands from raw format and
199767f8919635c4928607450d9e0abb932109ceToomas Soome * coverts it to the standard, command-index format. Notice, the processed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * boot command table has much more space allocated than the actual table
199767f8919635c4928607450d9e0abb932109ceToomas Soome * stored in non-volatile memory. This is because the processed table
199767f8919635c4928607450d9e0abb932109ceToomas Soome * exists in RAM which is larger than the non-volatile space.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome p_memset((char*)boot_commands, 0, sizeof(boot_commands));
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (index = 0; (index < MAX_BOOT_COMMANDS) && size; ++index) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (j = 0; (j < MAX_INPUT_SIZE) && size; ++j) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * void ExecuteEnvironmentFunctions(void)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This global function executes applicable entries in the environment.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END