/* AppWarmStart(): * This function is provided to allow the application to partially * restart the monitor. It supports the situation where an application * run but the monitor has not already been initialized. This would be * the case if some type of debugger (JTAG or BDM probably) was attached * to the target and it was used to download and run the application. * If this type of debug connection does not support the ability to run * after the monitor runs, then the application must be able to somehow * get the monitor initialized without having it go through a complete * warmstart. * This will only run through the stack space provided by the application. */ void AppWarmStart(ulong mask) { /* First initialize monitor bss space (skipping over MonStack[]): */ if(mask & WARMSTART_BSSINIT) { umonBssInit(); } StateOfMonitor = INITIALIZE; /* Initialize some of the real fundamental stuff regardless of * the incoming mask. */ init0(); /* Subset of init1(): */ if(mask & WARMSTART_IOINIT) { initCPUio(); InitRemoteIO(); if(ConsoleBaudRate == 0) { ConsoleBaudRate = DEFAULT_BAUD_RATE; } devInit(ConsoleBaudRate); } init2(); _init3(mask); }
/* init1(): * This is the first level of initialization (aside from the most fundamental * stuff that must be done in reset.s) that is done after the system resets. */ void init1(void) { initCPUio(); /* Configure all chip-selects, parallel IO * direction registers, etc... This may have * been done already in reset.s */ vinit(); /* Initialize the CPU's vector table. */ InitRemoteIO(); /* Initialize all application-settable IO functions */ if(ConsoleBaudRate == 0) { ConsoleBaudRate = DEFAULT_BAUD_RATE; } devInit(ConsoleBaudRate); }
/* InitUART(): Fed the baudrate. */ int Init403UART(int baud) { int divisor, brdl, brdh; if (baud == 0) baud = ConsoleBaudRate; /* Keep track of the last baud rate, so that it can be used if the */ /* incoming baudrate is NULL. */ ConsoleBaudRate = baud; /* Compute Baud Rate Divisor value */ divisor = (MON_CPU_CLOCK/(16*baud)) - 1; brdl = divisor & 0xff; brdh = divisor / 0x100; /* Initialize 403GCX UART: */ CPU_SPU_SPRC = 0; /* Disable xmitter and receiver */ CPU_SPU_SPTC = 0; CPU_SPU_SPLS = 0xf8; /* Clear bits in line status reg */ CPU_SPU_BRDL = brdl; /* Set baud rate divisor lsb */ CPU_SPU_BRDH = brdh; /* Set baud rate divisor msb */ CPU_SPU_SPCTL = 0x38; /* Set DTR & RTS, 8 bits, no parity */ CPU_SPU_SPRC = 0x80; /* Enable receiver */ CPU_SPU_SPTC = 0x80; /* Enable transmitter */ CPU_SPU_SPHS = 0xc0; /* Clear bits in handshake reg */ InitRemoteIO(); return(0); }