Ejemplo n.º 1
0
/* Load a binary file into memory via the UART
   If its an elf file, copy it into the correct memory areas
   and execute it.
*/   
void load_run( int type, unsigned int address )
{
    int file_size;        
    
    /* testing tyhe boot loader itself in simulation */
    if ( type == 2 ) {
        print_help();
        _core_status();        
        print_spaces(16);
        _testpass();
        }
        
    /* Load a file but don't run it */    
    else if ( type == 1 ) {
        /* Load a file using the xmodem protocol */
        printf  ("Send file w/ 1K Xmodem protocol from terminal emulator now...\n");

                                  /*       Destination,    Destination Size */
        file_size = xmodemReceive((char *) FILE_LOAD_BASE, FILE_MAX_SIZE);   
        if (file_size < 0 || file_size > FILE_MAX_SIZE) {
            printf ("Xmodem error file size 0x%x \n", file_size);
            return;
            }
            
        printf("\nelf split\n");
        elfsplitter(FILE_LOAD_BASE, file_size);
        }

    /* Hello world special start address - simulations only */    
    else if ( type == 4 ) {
        _jump_to_program(0x0080e400);
        }


    /* Load a binary file into memory */    
    else if ( type == 5 ) {
                                  /*       Destination,    Destination Size */
        file_size = xmodemReceive((char *) address, FILE_MAX_SIZE);   
        if (file_size < 0 || file_size > FILE_MAX_SIZE) {
            printf ("Xmodem error file size 0x%x \n", file_size);
            return;
            }
        }

    /* Run the program */    
    else  {    
        printf("j 0x%08x\n", JUMP_ADR);
        /* Flush the uart tx buffer with spaces */
        print_spaces(16);
        printf("\n");
        /* pc jump */
        _jump_to_program(JUMP_ADR);
        _testpass();
        }
}
Ejemplo n.º 2
0
/* Disable interrupts
   Load new values into the interrupt vector memory space
   Jump to address 0
*/
void reboot()
{
   int i;
   
   /* Disable all interrupts */
   /* Disable ethmac_int interrupt */                                    
   /* Disable timer 0 interrupt in interrupt controller */
   *(unsigned int *) ( ADR_AMBER_IC_IRQ0_ENABLECLR ) = 0x120;

   for(i=0;i<MEM_BUF_ENTRIES;i++)
       if (elf_mem0_g->entry[i].valid)
           *(char *)(i) = elf_mem0_g->entry[i].data;
           
   if (udp_file_g->linux_boot)
      _jump_to_program(LINUX_JUMP_ADR);
   else
      _restart();
}