199767f8919635c4928607450d9e0abb932109ceToomas Soome/******************************************************************************
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Instantiation of the interactive loader functions.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Revision information:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 20AUG2004 kb_admin initial creation
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 12JAN2005 kb_admin massive changes for tftp, strings, and more
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 05JUL2005 kb_admin save tag address, and set registers on boot
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 Soome/*********************** PRIVATE FUNCTIONS/DATA ******************************/
199767f8919635c4928607450d9e0abb932109ceToomas Soome// argv pointer are either NULL or point to locations in inputBuffer
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic const char *backspaceString = "\010 \010";
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * unsigned BuildIP(void)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This private function packs the test IP info to an unsigned value.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic unsigned
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * int StringToCommand(char *cPtr)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This private function converts a command string to a command code.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; CommandTable[i].command != COMMAND_FINAL_FLAG; ++i)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * int BreakCommand(char *)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This private function splits the buffer into separate strings as pointed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * by argv and returns the number of parameters (< 0 on failure).
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (cCount = 0; cCount < MAX_INPUT_SIZE; ++cCount) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* look for next command */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* in command, find next white space */
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (-1);
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */
199767f8919635c4928607450d9e0abb932109ceToomas Soome SPI_WriteFlash(off, addr + i, FLASH_PAGE_SIZE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; i < KERNEL_LEN; i+= FLASH_PAGE_SIZE) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * void ParseCommand(char *)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This private function executes matching functions.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome // display boot commands
199767f8919635c4928607450d9e0abb932109ceToomas Soome // "e <address>"
199767f8919635c4928607450d9e0abb932109ceToomas Soome // execute at address
199767f8919635c4928607450d9e0abb932109ceToomas Soome void (*execAddr)(unsigned, unsigned);
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* in future, include machtypes (MACH_KB9200 = 612) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome execAddr = (void (*)(unsigned, unsigned))
199767f8919635c4928607450d9e0abb932109ceToomas Soome // "tftp <local_dest_addr filename>"
199767f8919635c4928607450d9e0abb932109ceToomas Soome // tftp download
199767f8919635c4928607450d9e0abb932109ceToomas Soome // "server_ip <server IP 192 200 1 20>"
199767f8919635c4928607450d9e0abb932109ceToomas Soome // set download server address
199767f8919635c4928607450d9e0abb932109ceToomas Soome // "local_ip <local IP 192 200 1 21>
199767f8919635c4928607450d9e0abb932109ceToomas Soome // set ip of this module
199767f8919635c4928607450d9e0abb932109ceToomas Soome // "m <mac address 12 34 56 78 9a bc>
199767f8919635c4928607450d9e0abb932109ceToomas Soome // set mac address using 6 byte values
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; i < 6; i++)
199767f8919635c4928607450d9e0abb932109ceToomas Soome // "k <address>"
199767f8919635c4928607450d9e0abb932109ceToomas Soome LoadKernelFromSpi((char *)p_ASCIIToHex(argv[1]));
199767f8919635c4928607450d9e0abb932109ceToomas Soome // "x <address>"
199767f8919635c4928607450d9e0abb932109ceToomas Soome // download X-modem record at address
199767f8919635c4928607450d9e0abb932109ceToomas Soome while (1) continue;
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * void ServicePrompt(char)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This private function process each character checking for valid commands.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This function is only executed if the character is considered valid.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Each command is terminated with NULL (0) or ''.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* handle backspace BS */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* ************************** GLOBAL FUNCTIONS ********************************/
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * void Bootloader(void *inputFunction)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This global function is the entry point for the bootloader. If the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * inputFunction pointer is NULL, the loader input will be serviced from
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the uart. Otherwise, inputFunction is called to get characters which
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the loader will parse.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * .KB_C_FN_DEFINITION_END
199767f8919635c4928607450d9e0abb932109ceToomas Soome p_memset((void*)inputBuffer, 0, sizeof(inputBuffer));