⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m5275evb.c

📁 motorola 针对coldfire 5275 评估板的Dbug bootloader源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
                                   MCF_GPIO_PAR_FECI2C_PAR_MDC1);
            MCF_GPIO_PAR_FEC1HL = (0    |
                                   MCF_GPIO_PAR_FEC1HL_PAR_FEC1L |
                                   MCF_GPIO_PAR_FEC1HL_PAR_FEC1H);
        }
        #endif
        
        /* Get user programmed MAC address */
        board_get_ethaddr(mac);

        /* Initialize the network interface structure */
        nif_init(&nif1);
        nif1.ch = DBUG_ETHERNET_PORT;
        nif1.mtu = ETH_MTU;
        nif1.send = fec_send;
        memcpy(nif1.hwa, mac, 6);

        #ifdef DEBUG_PRINT
            printf("Ethernet Address is %02X:%02X:%02X:%02X:%02X:%02X\n",\
                    nif1.hwa[0], nif1.hwa[1], nif1.hwa[2],\
                    nif1.hwa[3], nif1.hwa[4], nif1.hwa[5]);
        #endif
        
        /* Initialize the dBUG Ethernet port */
        fec_eth_setup(DBUG_ETHERNET_PORT,FEC_MODE_MII, mac);

        /* Turn Instruction Cache ON */
        mcf5xxx_wr_cacr(0
            | MCF5XXX_CACR_CENB
            | MCF5XXX_CACR_CINV
            | MCF5XXX_CACR_DISD
            | MCF5XXX_CACR_CEIB
            | MCF5XXX_CACR_CLNF_00);
        
        /* Enable interrupts */
        board_irq_enable();
    }
#endif

    return TRUE;
}
/********************************************************************/
void
board_dlio_done (void)
{
    /*
     * Download complete, clean up
     */
#ifdef DBUG_NETWORK
    int vector;

    if (uif_dlio == UIF_DLIO_NETWORK)
    {
        /* Disable interrupts */
        board_irq_disable();

        /* Disable the Instruction Cache */
        mcf5xxx_wr_cacr(MCF5XXX_CACR_CINV);

        /* Disable the dBUG Ethernet port */
        fec_eth_stop(DBUG_ETHERNET_PORT);

        #if (DBUG_ETHERNET_PORT == 0)
        {
        	for (vector = (64 + 23); vector <= (64 + 35); vector++) 
        	{
	            /* Unregister the FEC interrupt handler */
	            isr_remove_handler(ISR_DBUG_ISR,(void *)fec_irq_handler);
	            
	            /* Disable interrupts to the ColdFire core */
                MCF_INTC0_ICRn(vector - 64) = 0;
	        }
		}
		#else
        {
        	for (vector = (128 + 23); vector <= (128 + 35); vector++) 
        	{
	            /* Unregister the FEC interrupt handler */
	            isr_remove_handler(ISR_DBUG_ISR,(void *)fec_irq_handler);
	            
	            /* Disable interrupts to the ColdFire core */
                MCF_INTC1_ICRn(vector - 64) = 0;
	        }
		}
		#endif
		
        
        /* Disable the FEC interrupts in the mask register */   
        #if (DBUG_ETHERNET_PORT == 0)
        {
            MCF_INTC0_IMRL |= (MCF_INTC0_IMRL_INT_MASK23 |
                               MCF_INTC0_IMRL_INT_MASK24 |
                               MCF_INTC0_IMRL_INT_MASK25 |
                               MCF_INTC0_IMRL_INT_MASK26 |
                               MCF_INTC0_IMRL_INT_MASK27 |
                               MCF_INTC0_IMRL_INT_MASK28 |
                               MCF_INTC0_IMRL_INT_MASK29 |
                               MCF_INTC0_IMRL_INT_MASK30 |
                               MCF_INTC0_IMRL_INT_MASK31);
            MCF_INTC0_IMRH |= (MCF_INTC0_IMRH_INT_MASK32 |
                               MCF_INTC0_IMRH_INT_MASK33 |
                               MCF_INTC0_IMRH_INT_MASK34 |
                               MCF_INTC0_IMRH_INT_MASK35);
        }
        #else
        {
            MCF_INTC1_IMRL |= (MCF_INTC1_IMRL_INT_MASK23 |
                               MCF_INTC1_IMRL_INT_MASK24 |
                               MCF_INTC1_IMRL_INT_MASK25 |
                               MCF_INTC1_IMRL_INT_MASK26 |
                               MCF_INTC1_IMRL_INT_MASK27 |
                               MCF_INTC1_IMRL_INT_MASK28 |
                               MCF_INTC1_IMRL_INT_MASK29 |
                               MCF_INTC1_IMRL_INT_MASK30 |
                               MCF_INTC1_IMRL_INT_MASK31);
            MCF_INTC1_IMRH |= (MCF_INTC1_IMRH_INT_MASK32 |
                               MCF_INTC1_IMRH_INT_MASK33 |
                               MCF_INTC1_IMRH_INT_MASK34 |
                               MCF_INTC1_IMRH_INT_MASK35);
        }
        #endif
    }
#endif
}
/********************************************************************/
int
board_dlio_getchar (void)
{
    /* Download character input routine */
    int ch;
 
    switch (uif_dlio)
    {
#ifdef DBUG_NETWORK
        case UIF_DLIO_NETWORK:
            ch = tftp_in_char();
            break;
#endif
        case UIF_DLIO_CONSOLE:
        default:
            ch = board_getchar();
            break;
    }
    return ch;
}
/********************************************************************/
int
board_dlio_vda (ADDRESS addr)
{
    /*  Determines if the given address is valid for downloads */

    if (((addr >= USER_SPACE) && 
            (addr < SDRAM_SIZE))
        || ((addr >= EXT_SRAM_ADDRESS) &&
            (addr < (EXT_SRAM_ADDRESS + EXT_SRAM_SIZE)))
        || ((addr >= SRAM_ADDRESS) && 
            (addr < (SRAM_ADDRESS + SRAM_SIZE))))
        return 1;
    else
        return 0;
}
/********************************************************************/
#ifdef DBUG_NETWORK
int
board_dlio_filetype (char *filename, char *ext)
{
    (void)filename;
    (void)ext;

    return UIF_DLIO_UNKNOWN;
}
#endif

/********************************************************************/
void
board_reset (void)
{
    /*
     * Initiate software reset
     */
    MCF_RCM_RCR = 
        MCF_RCM_RCR_SOFTRST | MCF_RCM_RCR_FRCRSTOUT;
}
/********************************************************************/
void
board_irq_enable (void)
{
    asm_set_ipl(0);
}
/********************************************************************/
void
board_irq_disable (void)
{
    asm_set_ipl(6);
}
/********************************************************************/
void
update_board_params (uint8 *data, int length, uint32 offset)
{
    /*
     * This function copies the PARAM section of the Flash
     * into SRAM, modifies the SRAM copy of PARAM with 'data'
     * for 'length' bytes, then writes the updated copy into
     * Flash again.
     */
    extern uint8 __PARAMS_START[];
    uint8 *target = (uint8 *)(__PARAMS_START + offset);
    int index, pbytes;
    int amd_flash_program(ADDRESS, ADDRESS, int, int, 
                        void (*)(void), void (*)(char));
 
    board_irq_disable();
 
    memcpy((void*)__PARAMS_START,(void*)PARAMS_ADDRESS,(uint32)PARAMS_SIZE); 
 
    for (index = 0; index < length; ++index)
    {
        *target++ = *data++;
    }
 
    pbytes = amd_flash_program((ADDRESS)PARAMS_ADDRESS, (ADDRESS)__PARAMS_START,
                            (uint32)PARAMS_SIZE, TRUE, NULL, NULL);
                 
    if (pbytes != PARAMS_SIZE)
    {
        printf("Flash programming error:  %#X bytes of %#X written!\n",
            pbytes, PARAMS_SIZE);
    }
}
/********************************************************************/
/*
 * Additional commands and SET/SHOW options for this board.
 */
/********************************************************************/

const char MEM_STR[] = "  %-14s   %#08X   %#08X   %d-bit\n";
const char PRT_STR[] = "  %-14s   %#08X   %#08X\n";
const char CS_STR[]  = "  CS%d  %s\n";  

void
mmap (int argc, char **argv)
{
    (void)argc;
    (void)argv;

    printf("\n");
    printf("      Type           Start         End      Port Size\n");
    printf("  ---------------------------------------------------\n");
    printf(MEM_STR, "SDRAM",        SDRAM_ADDRESS, 
                                    SDRAM_ADDRESS + SDRAM_SIZE - 1, 32);

    printf(MEM_STR, "SRAM (Int)",   SRAM_ADDRESS, 
                                    SRAM_ADDRESS + SRAM_SIZE - 1, 32);

    printf(MEM_STR, "SRAM (Ext)",   EXT_SRAM_ADDRESS, 
                                    EXT_SRAM_ADDRESS + EXT_SRAM_SIZE - 1, 32);

    printf(MEM_STR, "IPSBAR",       IPSBAR_ADDRESS, 
                                    IPSBAR_ADDRESS + 0x3FFFFFFF, 32);


    printf(MEM_STR, "Flash (Ext)",  FLASH_ADDRESS,  
                                    FLASH_ADDRESS + FLASH_SIZE - 1, 16);
    printf("\n");
    printf("   Protected         Start         End\n");
    printf("  ----------------------------------------\n");
    printf(PRT_STR, "dBUG Code",    DBUG_ADDRESS, 
                                    DBUG_ADDRESS + DBUG_SIZE - 1);
                                    
    printf(PRT_STR, "dBUG Data",    VECTOR_RAM, 
                                    USER_SPACE - 1);
    printf("\n");
    printf("    Chip Selects\n");
    printf("  ----------------\n");
    printf(CS_STR, 0, "Ext Flash");
    printf(CS_STR, 1, "Ext SRAM");
    printf("\n");
}
/********************************************************************/
void
dldbug (int argc, char **argv)
{
    char answer[UIF_MAX_LINE];
    void download_dbug (void (*)(void));
    
    (void)argc;
    (void)argv;

    /*
     * Print message
     */
    printf("Erase Flash, download and program new dBUG image to Flash...\n");
    printf("Type \"yes\" to continue: ");
    get_line(answer);
    if (strncmp("yes",answer,3) != 0)
        return;
     
    /*
     * Jump to USER_SPACE and begin serial download and programming
     * of new dBUG image
     */
    download_dbug((void*)(AMD_FLASH_ADDRESS + 0x400));   
}
/********************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -