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

📄 mpc8xx_hi.c

📁 motorola 针对coldfire 5275 评估板的Dbug bootloader源程序
💻 C
📖 第 1 页 / 共 4 页
字号:
#endif

/*********************************************************************/
#ifdef Mpc8xx_smc1
static void
irmd_smc1 (MPC8XX_IMM *imm, char *reg, int regread, uint32 value)
{
    IRMD(smc1, SMCMR, 32)
    IRMD(smc1, SMCE,  32)
    IRMD(smc1, SMCM,  32)

    if (!display_all)
        printf(INVREG,reg);
}
#endif

/*********************************************************************/
#ifdef Mpc8xx_smc2
static void
irmd_smc2 (MPC8XX_IMM *imm, char *reg, int regread, uint32 value)
{
    IRMD(smc2, SMCMR, 32)
    IRMD(smc2, SMCE,  32)
    IRMD(smc2, SMCM,  32)

    if (!display_all)
        printf(INVREG,reg);
}
#endif

/*********************************************************************/
#ifdef Mpc8xx_spi
static void
irmd_spi (MPC8XX_IMM *imm, char *reg, int regread, uint32 value)
{
    IRMD(spi, SPMODE, 16)
    IRMD(spi, SPIE,    8)
    IRMD(spi, SPIM,    8)
    IRMD(spi, SPCOM,   8)

    if (!display_all)
        printf(INVREG,reg);
}
#endif

/*********************************************************************/
#ifdef Mpc8xx_pip
static void
irmd_pip (MPC8XX_IMM *imm, char *reg, int regread, uint32 value)
{
    IRMD(pip, PIPC,   16)
    IRMD(pip, PTPR,   16)
    IRMD(pip, PBDIR,  32)
    IRMD(pip, PBPAR,  32)
    IRMD(pip, PBODR,  32)
    IRMD(pip, PBDAT,  32)

    if (!display_all)
        printf(INVREG,reg);
}
#endif

/*********************************************************************/
#ifdef Mpc8xx_si
static void
irmd_si (MPC8XX_IMM *imm, char *reg, int regread, uint32 value)
{
    IRMD(si, SIMODE, 32)
    IRMD(si, SIGMR,   8)
    IRMD(si, SISTR,   8)
    IRMD(si, SICMR,   8)
    IRMD(si, SICR,   32)
    IRMD(si, SIRP,   32)

    if (!display_all)
        printf(INVREG,reg);
}
#endif

/*********************************************************************/
#ifdef Mpc8xx_usb
static void
irmd_usb (MPC8XX_IMM *imm, char *reg, int regread, uint32 value)
{
    IRMD(usb, USMOD,    8)
    IRMD(usb, USADR,    8)
    IRMD(usb, USCOM,    8)
    IRMD(usb, USEP0,    16)
    IRMD(usb, USEP1,    16)
    IRMD(usb, USEP2,    16)
    IRMD(usb, USEP3,    16)
    IRMD(usb, USBER,    16)
    IRMD(usb, USBMR,    16)
    IRMD(usb, USBS,     8)

    if (!display_all)
        printf(INVREG,reg);
}
#endif

/*********************************************************************/
#ifdef Mpc8xx_video
static void
irmd_video (MPC8XX_IMM *imm, char *reg, int regread, uint32 value)
{
    IRMD(video, VCCR,   16)
    IRMD(video, VSR,    8)
    IRMD(video, VCMR,   8)
    IRMD(video, VBCB,   32)
    IRMD(video, VFCR0,  32)
    IRMD(video, VFAA0,  32)
    IRMD(video, VFBA0,  32)
    IRMD(video, VFCR1,  32)
    IRMD(video, VFAA1,  32)
    IRMD(video, VFBA1,  32)

    if (!display_all)
        printf(INVREG,reg);
}
#endif

/*********************************************************************/
#ifdef Mpc8xx_lcd
static void
irmd_lcd (MPC8XX_IMM *imm, char *reg, int regread, uint32 value)
{
    IRMD(lcd, LCCR,     32)
    IRMD(lcd, LCHCR,    32)
    IRMD(lcd, LCVCR,    32)
    IRMD(lcd, LCFAA,    32)
    IRMD(lcd, LCFBA,    32)
    IRMD(lcd, LCSR,     8)

    if (!display_all)
        printf(INVREG,reg);
}
#endif

/*********************************************************************/
static const struct module_t
{
    char        *module;
    void        (*func)(MPC8XX_IMM *, char *, int, uint32);
} MODULE[] =
{
#ifdef Mpc8xx_brgs
    {"BRGS",        irmd_brgs},
#endif
#ifdef Mpc8xx_clock
    {"CLOCK",       irmd_clock},
#endif
#ifdef Mpc8xx_clockey
    {"CLOCKEY",     irmd_clockey},
#endif
#ifdef Mpc8xx_cp
    {"CP",          irmd_cp},
#endif
#ifdef Mpc8xx_cpic
    {"CPIC",        irmd_cpic},
#endif
#ifdef Mpc8xx_cpmtimer
    {"CPMTIMER",    irmd_cpmtimer},
#endif
#ifdef Mpc8xx_dma
    {"DMA",         irmd_dma},
#endif
#ifdef Mpc8xx_i2c
    {"I2C",         irmd_i2c},
#endif
#ifdef Mpc8xx_lcd
    {"LCD",         irmd_lcd},
#endif
#ifdef Mpc8xx_memc
    {"MEMC",        irmd_memc},
#endif
#ifdef Mpc8xx_pcmcia
    {"PCMCIA",      irmd_pcmcia},
#endif
#ifdef Mpc8xx_pip
    {"PIP",         irmd_pip},
#endif
#ifdef Mpc8xx_portio
    {"PORTIO",      irmd_portio},
#endif
#ifdef Mpc8xx_scc1
    {"SCC1",        irmd_scc1},
#endif
#ifdef Mpc8xx_scc2
    {"SCC2",        irmd_scc2},
#endif
#ifdef Mpc8xx_scc3
    {"SCC3",        irmd_scc3},
#endif
#ifdef Mpc8xx_scc4
    {"SCC4",        irmd_scc4},
#endif
#ifdef Mpc8xx_si
    {"SI",          irmd_si},
#endif
#ifdef Mpc8xx_sit
    {"SIT",         irmd_sit},
#endif
#ifdef Mpc8xx_sitkey
    {"SITKEY",      irmd_sitkey},
#endif
#ifdef Mpc8xx_siu
    {"SIU",         irmd_siu},
#endif
#ifdef Mpc8xx_smc1
    {"SMC1",        irmd_smc1},
#endif
#ifdef Mpc8xx_smc2
    {"SMC2",        irmd_smc2},
#endif
#ifdef Mpc8xx_spi
    {"SPI",         irmd_spi},
#endif
#ifdef Mpc8xx_usb
    {"USB",         irmd_usb},
#endif
#ifdef Mpc8xx_video
    {"VIDEO",       irmd_video},
#endif
} ;

#define MODULE_SIZE (int)(sizeof(MODULE)/sizeof(struct module_t))
#if 0
/*************************************************/
void
mpc8xx_ird (int argc, char **argv)
{
    /*
     * Display Internal Memory Module contents.
     */
    MPC8XX_IMM *imm = mpc8xx_get_immp();
    char *rstr;
    char mstr[20];
    int mi;

    (void)argc;

    display_all = FALSE;
    displayed = 0;

    if (argv[1] == NULL)
    {
        printf("Internal Memory at %#08X", imm);
        for (mi = 0; mi < MODULE_SIZE; ++mi)
        {
            if ((mi % 8) == 0)
            {
                printf("\nModules: ");
            }
            printf("%s ",MODULE[mi].module);
        }
        printf("\n");
        return;
    };

    /*
     * Pick out module name and Point to register name
     */
    mi = 0;
    rstr = argv[1];
    while (*rstr != '.')
    {
        mstr[mi++] = *rstr;
        if (*++rstr == '\0')
        {
            rstr = NULL;
            break;
        }
    }
    mstr[mi] = '\0';
    if (*rstr == '.')
        ++rstr;

    /*
     * Display the module contents
     */
    for (mi = 0; mi < MODULE_SIZE; ++mi)
    {
        if (strcasecmp(MODULE[mi].module,mstr) == 0)
        {
            if (rstr == NULL)
            {
                display_all = TRUE;
                printf("Module: %s\n",MODULE[mi].module);
            }
            MODULE[mi].func(imm, rstr, REGREAD, 0);
            return;
        }
    }

    printf(INVMOD,argv[1]);
}
#endif
/*********************************************************************/
void
mpc8xx_irm (int argc, char **argv)
{
    MPC8XX_IMM *imm = mpc8xx_get_immp();
    uint32 value;
    char *rstr;
    char mstr[20];
    int mi, success;

    display_all = FALSE;
    displayed = 0;

    if (argc == 1)
    {
        printf("Internal Memory at %#08X", imm);
        for (mi = 0; mi < MODULE_SIZE; ++mi)
        {
            if ((mi % 8) == 0)
            {
                printf("\nModules: ");
            }
            printf("%s ",MODULE[mi].module);
        }
        printf("\n");
        return;
    };

    /*
     * Pick out module name and Point to register name
     */
    mi = 0;
    rstr = argv[1];
    while (*rstr != '.')
    {
        mstr[mi++] = *rstr;
        if (*++rstr == '\0')
        {
            rstr = NULL;
            break;
        }
    }
    mstr[mi] = '\0';
    if (rstr != NULL)
    {
        if (*rstr == '.')
            ++rstr;
    }

    /*
     * Get the new value
     */
    if (argc == 3)
    {
        if (rstr == NULL)
        {
            printf("Error:  Invalid Register:  %s\n",argv[1]);
            return;
        }
        value = get_value(argv[2],&success,16);
        if (success == 0)
        {
            printf(INVALUE,argv[2]);
            return;
        }
    }
    else
        value = 0;

    /*
     * Determine which module
     */
    for (mi = 0; mi < MODULE_SIZE; ++mi)
    {
        if (strcasecmp(MODULE[mi].module,mstr) == 0)
        {
            if (argc == 3)  /* modify operation */
            {
                MODULE[mi].func(imm, rstr, REGWRITE, value);
            }
            else
            {
                /* display operation */
                if (rstr == NULL)
                {
                    display_all = TRUE;
                    printf("Module: %s\n",MODULE[mi].module);
                }
                MODULE[mi].func(imm, rstr, REGREAD, 0);
            }
            return;
        }
    }

    printf(INVMOD,argv[1]);
}

/*********************************************************************/
void
mpc8xx_call (int argc, char **argv)
{
    /*
     * This routine calls a subroutine from the command line
     * and returns control to dBUG upon return.
     */
    uint32 param;
    int index, success;

    param = get_value(argv[1],&success,BASE);
    if (success == 0)
    {
        printf(INVALUE,argv[1]);
        return;
    }
    CPU_REG_SRR0 = param;
    CPU_REG_LR = (uint32)&asm_return_from_call;

    for (index = 2; index < argc; ++index)
    {
        param = get_value(argv[index],&success,BASE);
        if (success == 0)
        {
            printf(INVALUE,argv[index]);
            return;
        }

        switch (index)
        {
            case 2:
                CPU_REG_R3 = param;
                break;
            case 3:
                CPU_REG_R4 = param;
                break;
            case 4:
                CPU_REG_R5 = param;
                break;
            case 5:
                CPU_REG_R6 = param;
                break;
            case 6:
                CPU_REG_R7 = param;
                break;
            case 7:
                CPU_REG_R8 = param;
                break;
            case 8:
                CPU_REG_R9 = param;
                break;
            case 9:
                CPU_REG_R10 = param;
                break;
            case 10:
                CPU_REG_R11 = param;
                break;
            default:
                break;
        }
    }
    cpu_switch_context(FALSE);
}

/*********************************************************************/
void
mpc8xx_rsr_display (void)
{
    MPC8XX_IMM *imm = mpc8xx_get_immp();
    uint32 rsr;

    rsr = imm->clock.RSR;

    if (rsr & (MPC8XX_CLOCK_RSR_EHRS | MPC8XX_CLOCK_RSR_ESRS))
    {
        printf("Power-on Reset ");
        rsr &= ~(MPC8XX_CLOCK_RSR_EHRS | MPC8XX_CLOCK_RSR_ESRS);
    }

    if (rsr & MPC8XX_CLOCK_RSR_EHRS)
        printf("Hard ");
    if (rsr & MPC8XX_CLOCK_RSR_ESRS)
        printf("Soft ");
    if (rsr & MPC8XX_CLOCK_RSR_LLRS)
        printf("Loss of Lock ");
    if (rsr & MPC8XX_CLOCK_RSR_SWRS)
        printf("Software Watchdog ");
    if (rsr & MPC8XX_CLOCK_RSR_SCRS)
        printf("Check Stop ");
    if (rsr & MPC8XX_CLOCK_RSR_DBSRS)
        printf("Debug Hard ");
    if (rsr & MPC8XX_CLOCK_RSR_JTRS)
        printf("Debug Soft ");

    printf("\n");
}

/*********************************************************************/
char *
cpu_get_spr_name (int spr)
{
    int index;

    if ((index = find_spr(spr)) != -1)
    {
        return registers[index].reg_name;
    }

    return NULL;
}

/*********************************************************************/

⌨️ 快捷键说明

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