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

📄 mcf5272_hi.c

📁 motorola自己开发的针对coldfire 5272的Dbug bootloader程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * File:		mcf5272_hi.c
 * Purpose:		Register display/modify routines for MCF5272 modules.
 *
 * Notes:
 *
 */

#include "src/include/dbug.h"

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

/*
 * CPU name string and source code version for display at boot-up.
 */
const char CPU_STR[] = "ColdFire MCF5272";
const int  CPU_VER_MAJOR   = 1;
const char CPU_VER_MINOR   = 'a';

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

static const char FORMAT8[]  = "%6s (%-6s): %02X\n";
static const char FORMAT16[] = "%6s (%-6s): %04X\n";
static const char FORMAT32[] = "%6s (%-6s): %08X\n";
static const char XFORMAT[]	 = "%6s (%-6s): %6s\n";

static const char INVMOD[] = "Error: Invalid Module: %s\n";
static const char NOREG[]  = "XXXXXX";

#define IRMD(MOD,RDREG,WRREG,SIZE)  \
if (regread)											\
{														\
	if ((strcasecmp(#RDREG,reg) == 0) || display_all)	\
	{													\
		rdata = MCF5272_ ## MOD ## _ ## RDREG;	\
		printf(FORMAT ## SIZE, #RDREG, #WRREG, rdata);	\
														\
		pause(&displayed);								\
														\
		if (!display_all) return;						\
	}													\
}														\
else													\
{														\
	if (strcasecmp(#WRREG,reg) == 0)					\
	{													\
		MCF5272_ ## MOD ## _ ## WRREG = (uint ## SIZE) value;	\
		return;											\
	}													\
}

#define IRMD_SIZE(MOD,RDREG,WRREG,SIZE)  \
if (regread)											\
{														\
	if ((strcasecmp(#RDREG,reg) == 0) || display_all)	\
	{													\
		rdata = MCF5272_ ## MOD ## _ ## RDREG(SIZE);	\
		printf(FORMAT ## SIZE, #RDREG, #WRREG, rdata);	\
														\
		pause(&displayed);								\
														\
		if (!display_all) return;						\
	}													\
}														\
else													\
{														\
	if (strcasecmp(#WRREG,reg) == 0)					\
	{													\
		MCF5272_ ## MOD ## _ ## WRREG(SIZE) = (uint ## SIZE) value;	\
		return;											\
	}													\
}

#define IRMD_NOWR(MOD,RDREG,SIZE)  \
if (regread)											\
{														\
	if ((strcasecmp(#RDREG,reg) == 0) || display_all)	\
	{													\
		rdata = MCF5272_ ## MOD ## _ ## RDREG;	\
		printf(FORMAT ## SIZE, #RDREG, NOREG, rdata);	\
														\
		pause(&displayed);								\
														\
		if (!display_all) return;						\
	}													\
}

#define IRMD_NORD(MOD,WRREG,SIZE)  \
if (regread && display_all)								\
{														\
	printf(XFORMAT, NOREG, #WRREG, NOREG);				\
}														\
else													\
{														\
	if (strcasecmp(#WRREG,reg) == 0)					\
	{													\
		MCF5272_ ## MOD ## _ ## WRREG = (uint ## SIZE) value;	\
		return;											\
	}													\
}

static int display_all;
static int displayed;
static uint32 rdata;

/********************************************************************/
static void
irmd_sim (char *reg, int regread, uint32 value)
{
	IRMD_NOWR(SIM,		MBAR,	32);
	IRMD(SIM,	SCR,	SCR,	16);
	IRMD(SIM,	SPR,	SPR,	16);
	IRMD(SIM,	PMR,	PMR,	32);
	IRMD_NORD(SIM,		ALPR,	16);
	IRMD_NOWR(SIM,		DIR,	32);
	IRMD(SIM,	ICR1,	ICR1,	32);
	IRMD(SIM,	ICR2,	ICR2,	32);
	IRMD(SIM,	ICR3,	ICR3,	32);
	IRMD(SIM,	ICR4,	ICR4,	32);
	IRMD_NOWR(SIM,		ISR,	32);
	IRMD(SIM,	PITR,	PITR,	32);
	IRMD(SIM,	PIWR,	PIWR,	32);
	IRMD(SIM,	PIVR,	PIVR,	8);
	IRMD(TIMER,	WRRR,	WRRR,	16);
	IRMD(TIMER,	WIRR,	WIRR,	16);
	IRMD(TIMER,	WCR,	WCR,	16);

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

/********************************************************************/
static void
irmd_cs (char *reg, int regread, uint32 value)
{
	IRMD(CS,	CSBR0,	CSBR0,	32);
	IRMD(CS,	CSOR0,	CSOR0,	32);
	IRMD(CS,	CSBR1,	CSBR1,	32);
	IRMD(CS,	CSOR1,	CSOR1,	32);
	IRMD(CS,	CSBR2,	CSBR2,	32);
	IRMD(CS,	CSOR2,	CSOR2,	32);
	IRMD(CS,	CSBR3,	CSBR3,	32);
	IRMD(CS,	CSOR3,	CSOR3,	32);
	IRMD(CS,	CSBR4,	CSBR4,	32);
	IRMD(CS,	CSOR4,	CSOR4,	32);
	IRMD(CS,	CSBR5,	CSBR5,	32);
	IRMD(CS,	CSOR5,	CSOR5,	32);
	IRMD(CS,	CSBR6,	CSBR6,	32);
	IRMD(CS,	CSOR6,	CSOR6,	32);
	IRMD(CS,	CSBR7,	CSBR7,	32);
	IRMD(CS,	CSOR7,	CSOR7,	32);

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

/********************************************************************/
static void
irmd_gpio (char *reg, int regread, uint32 value)
{

	IRMD(GPIO,	PACNT,	PACNT,	32);
	IRMD(GPIO,	PADDR,	PADDR,	16);
	IRMD(GPIO,	PADAT,	PADAT,	16);
	IRMD(GPIO,	PBCNT,	PBCNT,	32);
	IRMD(GPIO,	PBDDR,	PBDDR,	16);
	IRMD(GPIO,	PBDAT,	PBDAT,	16);
	IRMD(GPIO,	PCDDR,	PCDDR,	16);
	IRMD(GPIO,	PCDAT,	PCDAT,	16);
	IRMD(GPIO,	PDCNT,	PDCNT,	32);

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

/********************************************************************/
static void
irmd_qspi (char *reg, int regread, uint32 value)
{

	IRMD(QSPI,	QMR,	QMR,	16);
	IRMD(QSPI,	QDLYR,	QDLYR,	16);
	IRMD(QSPI,	QWR,	QWR,	16);
	IRMD(QSPI,	QIR,	QIR,	16);
	IRMD(QSPI,	QAR,	QAR,	16);
	IRMD(QSPI,	QDR,	QDR,	16);

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

/********************************************************************/
static void
irmd_pwm (char *reg, int regread, uint32 value)
{

	IRMD(PWM,	PWCR0,	PWCR0,	8);
	IRMD(PWM,	PWCR1,	PWCR1,	8);
	IRMD(PWM,	PWCR2,	PWCR2,	8);
	IRMD(PWM,	PWWD0,	PWWD0,	8);
	IRMD(PWM,	PWWD1,	PWWD1,	8);
	IRMD(PWM,	PWWD2,	PWWD2,	8);

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

/********************************************************************/
static void
irmd_dma (char *reg, int regread, uint32 value)
{
	IRMD(DMA,	DCMR,	DCMR,	32);
	IRMD(DMA,	DCIR,	DCIR,	16);
	IRMD(DMA,	DBCR,	DBCR,	32);
	IRMD(DMA,	DSAR,	DSAR,	32);
	IRMD(DMA,	DDAR,	DDAR,	32);
	
	if (!display_all)
		printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_uart0 (char *reg, int regread, uint32 value)
{
	IRMD(UART0,	UMR,	UMR,	8);
	IRMD(UART0,	USR,	UCSR,	8);
	IRMD_NORD(UART0,	UCR,	8);
	IRMD(UART0,	URB,	UTB,	8);
	IRMD(UART0,	UIPCR,	UACR,	8);
	IRMD(UART0,	UISR,	UIMR,	8);
	IRMD_NORD(UART0,	UBG1,	8);
	IRMD_NORD(UART0,	UBG2,	8);
	IRMD_NOWR(UART0,	UABR1,	8);
	IRMD_NOWR(UART0,	UABR2,	8);
	IRMD(UART0,	UTFCSR,	UTFCSR,	8);
	IRMD(UART0,	URFCSR,	URFCSR,	8);
	IRMD_NOWR(UART0,	UIP,	8);
	IRMD_NORD(UART0,	UOP1,	8);
	IRMD_NORD(UART0,	UOP0,	8);

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

/********************************************************************/
static void
irmd_uart1 (char *reg, int regread, uint32 value)
{
	IRMD(UART1,	UMR,	UMR,	8);
	IRMD(UART1,	USR,	UCSR,	8);
	IRMD_NORD(UART1,	UCR,	8);
	IRMD(UART1,	URB,	UTB,	8);
	IRMD(UART1,	UIPCR,	UACR,	8);
	IRMD(UART1,	UISR,	UIMR,	8);
	IRMD_NORD(UART1,	UBG1,	8);
 	IRMD_NORD(UART1,	UBG2,	8);
	IRMD_NOWR(UART1,	UABR1,	8);
	IRMD_NOWR(UART1,	UABR2,	8);
	IRMD(UART1,	UTFCSR,	UTFCSR,	8);
	IRMD(UART1,	URFCSR,	URFCSR,	8);
	IRMD_NOWR(UART1,	UIP,	8);
	IRMD_NORD(UART1,	UOP1,	8);
	IRMD_NORD(UART1,	UOP0,	8);

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

/********************************************************************/
static void
irmd_sdramc (char *reg, int regread, uint32 value)
{
	IRMD(SDRAMC,	SDCCR,	SDCCR,	16);
	IRMD(SDRAMC,	SDCTR,	SDCTR,	16);

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

/********************************************************************/
static void
irmd_timer0 (char *reg, int regread, uint32 value)
{
	IRMD(TIMER0,	TMR,	TMR,	16);
	IRMD(TIMER0,	TRR,	TRR,	16);
	IRMD_NOWR(TIMER0,		TCR,	16);
	IRMD(TIMER0,	TCN,	TCN,	16);
	IRMD(TIMER0,	TER,	TER,	16);

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

/********************************************************************/
static void
irmd_timer1 (char *reg, int regread, uint32 value)
{
	IRMD(TIMER1,	TMR,	TMR,	16);
	IRMD(TIMER1,	TRR,	TRR,	16);
	IRMD_NOWR(TIMER1,		TCR,	16);
	IRMD(TIMER1,	TCN,	TCN,	16);
	IRMD(TIMER1,	TER,	TER,	16);

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

/********************************************************************/
static void
irmd_timer2 (char *reg, int regread, uint32 value)
{
	IRMD(TIMER2,	TMR,	TMR,	16);
	IRMD(TIMER2,	TRR,	TRR,	16);
	IRMD_NOWR(TIMER2,		TCR,	16);
	IRMD(TIMER2,	TCN,	TCN,	16);
	IRMD(TIMER2,	TER,	TER,	16);

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

/********************************************************************/
static void
irmd_timer3 (char *reg, int regread, uint32 value)
{
	IRMD(TIMER3,	TMR,	TMR,	16);
	IRMD(TIMER3,	TRR,	TRR,	16);
	IRMD_NOWR(TIMER3,		TCR,	16);
	IRMD(TIMER3,	TCN,	TCN,	16);
	IRMD(TIMER3,	TER,	TER,	16);

	if (!display_all)
		printf(INVREG,reg);

⌨️ 快捷键说明

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