[目次]

 1.概要 ------------------------------------------------------------------ 1

 2.ソースリスト
  2.1 エントリ・プログラム (c_entry.s) -------------------------------- 2
  2.2 メイン関数 (itp_main.c) ----------------------------------------- 4
  2.3 初期診断メイン・プログラム (itp.c) ------------------------------ 5
  2.4 I/Oアドレス定義ファイル (def.h) ------------------------------ 13
  2.5 初期診断プログラム用シンボル定義ファイル (itp_def.h) ------------ 16
  2.6 I/O操作用関数群 (io.c) --------------------------------------- 17

 3.メイク・ファイル (itp.mak) -------------------------------------------- 19

 4.コマンド・ファイル (itp.cmd) ------------------------------------------ 20


1.概要

 「初期診断プログラムのソースリスト」は、初期診断プログラムを構成するすべてのソースリスト、及び実行形式ファイル作成に必要なメイク・ファイル,コマンド・ファイルを収録する。


2.ソース・リスト

2.1 エントリ・プログラム (c_entry.s)

 ***********************************************************************************
 *                                                                                 *
 *          Department of Electronics & Control Engineering  N.C.T.                *
 * ------------------------------------------------------------------------------- *
 *                    c_entry.s -- C Start-up Routine   (for all C programs)       *
 *                                                                                 *
 ***********************************************************************************

	OPT		CASE

ENTRY	IDNT
	SECTION		code,,C

	XDEF		ENTRY

	XREF		????STACKTOP
	XREF		__initcopy			* Initialize variables copy ()
	XREF		_main				* C's main()

	DC.L		????STACKTOP			* SSP on Cold Start
	DC.L		$0F00008			* Entry Point

ENTRY:
	MOVEA.L		#????STACKTOP,SP		* Stack Pointer
	MOVEA.L		#0,A6				* Frame Pointer Initialization
	MOVE		#$2700,SR			* Disable interrupt

*
*	THE FOLLOWING CODE CLEARS THE ZEROVARS SECTION
*
*		from /mirs/sawa/demo68k/entry.s
*

	LEA		.STARTOF.(zerovars),A0	* START OF THE SECTION
	MOVE.L		#.SIZEOF.(zerovars),D1	* LENGTH OF THE SECTION
	MOVE.L		D1,D0				* SAVE IN D0 ALSO
	LSR.L		#2,D1				* NUMBER OF LONG WORDS TO MOVE
	BRA.S		CLROVARS1			* SKIP FIRST CLEAR
CLROVARS:
	CLR.L		(A0)+				* CLEAR THE ADDRESS
CLROVARS1:
	DBF		D1,CLROVARS			* DECREMENT LONG WORD COUNT & TEST
	SUBI.L		#$10000,D1			* SIMULATE BORROW FROM LOW 16 BITS
	CMPI.L		#-1,D1				* IS LONG WORD COUNT == -1
	BNE.S		CLROVARS			* NO -- KEEP CLEARING
*
	ANDI.L		#3,D0				* SHOULD INDIVIDUAL BYTES BE CLEAR
	BRA.S		CLROVARS2			* SKIP FIRST CLEAR
CLROVARS3:
	CLR.B		(A0)+				* CLEAR ONE MORE BYTE
CLROVARS2:
	DBF		D0,CLROVARS3			* DECREMENT BYTE COUNT & TEST


	JSR		__initcopy(PC)			* ROM INITIALIZATION

	JSR		_main				* Call main()

LSTOP:	
	STOP		#$2700				* Halt until Level 7 Interrupt
	BRA.S		LSTOP
	RTS

*
*	end of SECTION code
*

	SECTION 	zerovars,,D			* DATA SECTION

*
*	FORCE SECTION vars TO FOLLOW SECTIONS code AND zerovars IN
*	MEMORY. THIS IS DONE EVEN THOUGH THERE IS NO CODE IN
*	SECTION vars.
*

	SECTION 	vars,,D				* INITIALIZED DATA


	END		ENTRY


2.2 メイン関数 (itp_main.c)

/***********************************************************************************/
/*                                                                                 */
/*          Department of Electronics & Control Engineering  N.C.T.                */
/* ------------------------------------------------------------------------------- */
/*              itp_main.c -- MIRS main program ("itp_main.c" is temporary)        */
/*                                                                                 */
/***********************************************************************************/

#include "def.h"

extern void	itp();

extern int	outportb();

int	led[LED_NO];			/*	buffer for 7seg.LED		*/
int	green,red;			/*	data for GREEN/RED LED	*/


main()
{
	itp();				/*	call ITP	*/

	while(1);
}


/*	timer interrupt routine	*/
void interrupt  tmint()		
{
	outportb(MSR,TMRST);		/*	timer reset	*/
}


/*	switch interrupt routine	*/
void interrupt  swint()
{
	outportb(PSR0,0x08);		/*	clear H4S	*/
}


/*	touch sensor interrupt routine	*/
void interrupt  tsint()
{
}


/* supersonic wave sensor interrupt routine */
void interrupt  sssint()
{
}


void interrupt  psint() /* photo sensor interrupt routine */
{
}


2.3 初期診断メイン・プログラム (itp.c)

/***********************************************************************************/
/*                                                                                 */
/*          Department of Electronics & Control Engineering  N.C.T.                */
/* ------------------------------------------------------------------------------- */
/*                       itp.c -- ITP program (including system initialize)        */
/*                                                                                 */
/***********************************************************************************/

#include "def.h"
#include "itp_def.h"

extern int	inportb(),outportb(),outportl();

int	cpu(),rom(),ram(),ram_chk(),mmi(),re_ts(),pwm(),sss_ps();
void	itp();
void	rtc_clr();
void	tm_init(),led_init()mmi_init(),re_ts_init(),pwm_init(),sss_ps_init();
void	led_set(),led_set_all();

extern int	led[LED_NO];		/*	buffer for 7seg.LED		*/
extern int	green,red;		/*	data for GREEN/RED LED	*/

char	d0,d1,d2,d3,d4,d5,d6,d7;	/*	data for CPU test		*/


void	itp()
{
	rtc_clr();			/*	clear RTC			*/
	led_init();			/*	initialize 7seg.LED		*/

	if ( cpu() != 0 ) while(1);
	if ( rom() != 0 ) while(1);
	if ( ram() != 0 ) while(1);
	if ( mmi() != 0 ) while(1);
	if ( re_ts() != 0 ) while(1);
	if ( pwm() != 0 ) while(1);
	if ( sss_ps() != 0 ) while(1);

	tm_init();			/*	initialize timer		*/

	led_set_all(0);
}


/*	CPU test	*/
int	cpu()
{
	led_set_all(1);

	d0 = d1 = d2 = d3 = d4 = d5 = d6 = d7 = 1;

	asm(" EOR D0,D0 ");
	asm(" MOVE.B D0,_d0 ");
	asm(" EOR D1,D1 ");
	asm(" MOVE.B D1,_d1 ");
	asm(" EOR D2,D2 ");
	asm(" MOVE.B D2,_d2 ");
	asm(" EOR D3,D3 ");
	asm(" MOVE.B D3,_d3 ");
	asm(" EOR D4,D4 ");
	asm(" MOVE.B D4,_d4 ");
	asm(" EOR D5,D5 ");
	asm(" MOVE.B D5,_d5 ");
	asm(" EOR D6,D6 ");
	asm(" MOVE.B D6,_d6 ");
	asm(" EOR D7,D7 ");
	asm(" MOVE.B D7,_d7 ");

	if ( (d0 | d1 | d2 | d3 | d4 | d5 | d6 | d7) != 0 ) return (1);

	return (0);
}


/*	ROM test	*/
int	rom()
{
	unsigned char	*p;
	unsigned int	sum_e,sum_o;
	unsigned int	chk_sum_e,chk_sum_o;
	long int	ctr;

	green = 1;
	led_set_all(2);

	p = (unsigned char *)ROM_START;
	sum_e = sum_o = 0;
	for ( ctr = 0 ; ctr < ROM_SIZE ; ctr++ ) {	/*	seek check_sum		*/ 
		sum_e += (unsigned int)*p;
		sum_e &= 0xffff;
		p++;
		sum_o += (unsigned int)*p;
		sum_o &= 0xffff;
		p++;
	}
	p = (unsigned char *)CHK_SUM_E;
	chk_sum_e = (unsigned int)(*p*0x100+*(p+1));
	p = (unsigned char *)CHK_SUM_O;
	chk_sum_o = (unsigned int)(*p*0x100+*(p+1));

	green = 0;
	led_set_all(2);

	if ( sum_e != chk_sum_e ) return(1);
	if ( sum_o != chk_sum_o ) return(1);

	return (0);
}


/*	RAM test	*/
int	ram()
{
	red = 1;
	led_set_all(3);

	if ( ram_chk(STACKTOP,RAM_END) != 0 ) {
		red = 0;
		led_set(3);
		return (1);
	}

	red = 0;
	led_set_all(3);

	return (0);
}


int	ram_chk( start_adrs, end_adrs )
char	*start_adrs,*end_adrs;
{
	char	*p;
	int	flag;

	flag = 0;
	p = start_adrs;
	while ( flag == 0 && p < end_adrs ) {
		*p = 0x00;				/*	clear RAM with 0x00	*/ 
		if ( *p != 0x00 ) flag = 1;
		*p = 0xff;				/*	fill RAM with 0xff	*/
		if ( *p != 0xff ) flag = 1;
		p++;
	}

	return (flag);
}


/*	Man-Machine board test	*/
int	mmi()
{
	int	judge;

	led_set_all(4);

	mmi_init();

	/*	port return test	*/
	outportb(PBDR0,0x00);
	if ( inportb(PBDR0) & 0x20 != 0x00 ) return (1);
	outportb(PBDR0,0x10);
	if ( inportb(PBDR0) & 0x20 != 0x20 ) return (1);

	/*	judgement signal check	*/
	judge = inportb(PBDR0) & 0x40;
	if ( judge != 0x00 ) return (1);

	return (0);
}


/*	routary encoder & touch sensor board test	*/
int	re_ts()
{
	int	data_r,data_l,data_rh,data_rl,data_lh,data_ll,ts_data;

	led_set_all(5);

	re_ts_init();

	/*	counter value check	*/
	data_rl = inportb(EDRL) & 0xff;
	data_rh = inportb(EDRH) & 0x0f;
	data_ll = inportb(EDLL) & 0xff;
	data_lh = inportb(EDLH) & 0x0f;

	data_r = ( data_rh << 8 ) + data_rl;
	if ((data_r & 0x800) != 0) data_r = (data_r | 0xfffff000);
	data_l = ( data_lh << 8 ) + data_ll;
	if ((data_l & 0x800) != 0) data_l = (data_l | 0xfffff000);

	if ( data_r != 0x000 ) return (1);
	if ( data_l != 0x000 ) return (1);

	/*	touch sensor data check	*/
	ts_data = inportb(EDRH) & 0xf0;
	if ( ts_data != 0x00 ) return (1);

	return (0);
}


/*	PWM circuit test	*/
int	pwm()
{
	int	ret_data;

	led_set_all(6);

	pwm_init();

	/*	port return test	*/
	outportb(PADR1,0x00);
	ret_data = inportb(PCDR1) & 0x01;
	if ( ret_data != 0x00 ) return (1);
	outportb(PADR1,0x01);
	ret_data = inportb(PCDR1) & 0x01;
	if ( ret_data != 0x01 ) return (1);
	outportb(PBDR1,0x00);
	ret_data = inportb(PCDR1) & 0x02;
	if ( ret_data != 0x00 ) return (1);
	outportb(PBDR1,0x01);
	ret_data = inportb(PCDR1) & 0x02;
	if ( ret_data != 0x02 ) return (1);

	return (0);
}


/*	supersonic wave sensor & photo sensor circuit test	*/
int	sss_ps()
{
	int	ch,ret_data,flag;

	led_set_all(7);

	outportb(PGCR2,0x00);
	outportb(PACR2,0x80);		/*	submode 1x	*/
	outportb(PADDR2,0x03);
	outportb(PGCR2,0x00);		/*	mode 0		*/

	/*	port return test	*/
	flag = 0;
	for ( ch = 0 ; ch < SSS_NO ; ch++ ) {
		outportb(PADR2,ch);
		ret_data = (inportb(PADR2) & 0x30) >> 4;
		if ( ret_data != ch ) flag = 1;
	}

	sss_ps_init();

	return (flag);
}


/*	real time clock clear		*/
void	rtc_clr()
{
	int	rtc_base;
	int	i;

	rtc_base=0xfdfe00;

	outportb(MSR,0x44);
	for ( i=3 ; rtc_base+ i<0xfdfe40 ; i+=2 ) outportb(rtc_base+i,0x00);

	outportb(MSR,0x04);
	for ( i=3 ; rtc_base+ i<0xfdfe0a ; i+=2 ) outportb(rtc_base+i,0x00);
}


/*	real time clock initialize	*/
void	tm_init()
{
	outportb(MSR,0x40);
	outportb(RTMR,0x00);
	outportb(OMR,0x00);
	outportb(ICR1,0x00);

	asm(" XREF	_tmint ");
	asm(" MOVE.L	#$078,A0 ");
	asm(" MOVE.L	#_tmint,(A0) ");
}


/*	7seg.LED unit initialize	*/
void	led_init()
{
	green = red = 0;

	/*	initialize PI/T 0	*/
	outportb(PGCR0,0x00);		/*	clear PGCR0	*/
	outportb(PSRR0,0x1e);
	outportb(PACR0,0xa0);		/*	submode 1x	*/
	outportb(PADDR0,0xff);	/*	all output	*/
	outportb(PGCR0,0x22);		/*	mode 0		*/
	outportb(TCR0,0x00);		/*	clear TCR0	*/
	outportl(CPR0,0x00003f);	/*	TOUT 2kHz	*/
	outportb(TCR0,0x41);		/*	square wave	*/
}


/*	Man-Machine board initialize		*/
void	mmi_init()
{
	/*	initialize PI/T 0	*/
	outportb(PGCR0,0x00);		/*	clear PGCR0	*/
	outportb(PBCR0,0x80);		/*	submode 1x	*/
	outportb(PBDDR0,0x10);
	outportb(PGCR0,0x22);		/*	mode 0		*/ 

	/*	set vector for switch interrupt	*/
	asm(" XREF	_swint "); 
	asm(" MOVEA.L	#$06c,A0	* LEVEL 3  PI/T interrupt ");
	asm(" MOVE.L	#_swint,(A0) ");
}


/*	routary encoder & touch sensor board initialize	*/
void	re_ts_init()
{
	/*	initialize RE/TS	*/
	outportb(TSIE,0x00);
	outportb(CRST,0x03);			/*	counter reset		*/

	/*	set vector for interrupt	*/
	asm(" XREF	_tsint 	");
	asm(" MOVEA.L	#$130,A0	* 130(h) = 76(d) * 4 ");
	asm(" MOVE.L	#_tsint,(A0) ");
}


/*	PWM circuit initialize	*/
void	pwm_init()
{
	/*	initialize PI/T 1	*/
	outportb(PGCR1,0x00);
	outportb(PSRR1,0x00);	
	outportb(PACR1,0x80);			/*	submode 1x		*/
	outportb(PADDR1,0xff);		/*	all output		*/
	outportb(PBCR1,0x80);			/*	submode 1x		*/
	outportb(PBDDR1,0xff);		/*	all output		*/
	outportb(PCDDR1,0x00);
	outportb(PGCR1,0x00);			/*	mode 0			*/
	outportb(TCR1,0x00);			/*	clear TCR1		*/
	outportl(CPR1,0x000001);		/*	TOUT 125kHz		*/
	outportb(TCR1,0x41);			/*	square wave		*/
}


/*	supersonic wave sensor & photo sensor circuit initialize		*/
void	sss_ps_init()
{
	/*	initialize PI/T 2	*/
	outportb(PGCR2,0x00);
	outportb(PSRR2,0x1c);
	outportb(PACR2,0x79);			/*	submode 01		*/
	outportb(PADDR2,0x03);
	outportb(PBCR2,0x30);			/*	submode 00		*/
	outportb(PBDDR2,0x00);		/*	all input		*/
	outportb(PGCR2,0x38);			/*	mode 0			*/
	outportb(TCR2,0x00);			/*	clear	TCR2		*/
	outportl(CPR2,SSS_LIMIT);		/*	count for ss-wave to	
							 go & return 3 meter	*/
	outportb(TCR2,0xb2);			/*	device watchdog*/

	/*	set vector for interrupt	*/
	asm(" XREF	_sssint ");
	asm(" MOVEA.L	#$120,A0	*	120(h) = 72(d) * 4 ");
	asm(" MOVE.L	#_sssint,(A0) ");

	asm(" XREF	_psint ");
	asm(" MOVEA.L	#$128,A0	*	128(h) = (72+2)(d) * 4 ");
	asm(" MOVE.L	#_psint,(A0) ");

	outportb(PIVR2,72);			/*	set vector number	*/
}


/*	7seg.LED set routine (1)	*/
void	led_set( led_no, data )
int	led_no,data;
{
	led[led_no] = data;

	outportb(PADR0,green*0x80+red*0x40+led_no*0x10+data);
	/*	making latch enable pulse	*/
	outportb(PACR0,0xa0);
	outportb(PACR0,0xa8);
	outportb(PACR0,0xa0);
}


/*	7seg.LED set routine (ALL)	*/
void	led_set_all( data )
int	data;
{
	int	d3,d2,d1,d0;

	d3 = data/1000;
	data %= 1000;
	d2 = data/100;
	data %= 100;
	d1 = data/10;
	d0 = data%10;

	led[3] = d3;
	led[2] = d2;
	led[1] = d1;
	led[0] = d0;

	led_set(3,d3);
	led_set(2,d2);
	led_set(1,d1);
	led_set(0,d0);
}


2.4 I/Oアドレス定義ファイル (def.h)

/***********************************************************************************/
/*                                                                                 */
/*          Department of Electronics & Control Engineering  N.C.T.                */
/* ------------------------------------------------------------------------------- */
/*                                    def.h -- I/O address definition file         */
/*                                                                                 */
/***********************************************************************************/

/*	addresses of PI/T 0 registers	*/

#define 	PGCR0	0xfdfc01	/*	Port General Control Reg.	*/
#define 	PSRR0	0xfdfc03	/*	Port Select Request Reg.	*/
#define 	PADDR0	0xfdfc05	/*	Port A Data Direction Reg.	*/
#define 	PBDDR0	0xfdfc07	/*	Port B Data Direction Reg.	*/
#define 	PCDDR0	0xfdfc09	/*	Port C Data Direction Reg.	*/
#define 	PIVR0	0xfdfc0b	/*	Port Interrupt Vector Reg.	*/
#define 	PACR0	0xfdfc0d	/*	Port A Control Reg.		*/
#define 	PBCR0	0xfdfc0f	/*	Port B Control Reg.		*/
#define 	PADR0	0xfdfc11	/*	Port A Data Reg.		*/
#define 	PBDR0	0xfdfc13	/*	Port B Data Reg.		*/
#define 	PAAR0	0xfdfc15	/*	Port A Alternate Reg.		*/
#define 	PBAR0	0xfdfc17	/*	Port B Alternate Reg.		*/
#define 	PCDR0	0xfdfc19	/*	Port C Data Reg.		*/
#define 	PSR0	0xfdfc1b	/*	Port Status Reg.		*/
#define 	TCR0	0xfdfc21	/*	Timer Control Reg.		*/
#define 	TIVR0	0xfdfc23	/*	Timer Interrupt Vector Reg.	*/
#define 	CPR0	0xfdfc25	/*	Counter Preload Reg.		*/
#define 	CNTR0	0xfdfc2d	/*	Counter Reg.			*/
#define 	TSR0	0xfdfc35	/*	Timer Status Reg.		*/


/*	I/O Base Address	*/

#define 	IO_BASE	0xfc6000


/*	IP A base address	*/

#define  	IP_A	IO_BASE


/*	addresses of rotary encoder/touch sensor	*/

#define  	EDRL	IP_A+0x01	/*	Encoder Data of Right (Low)	*/ 
#define  	EDRH	IP_A+0x03	/*	Encoder Data of Right (High)	*/
#define  	EDLL	IP_A+0x05	/*	Encoder Data of Left (Low)	*/
#define  	EDLH	IP_A+0x07	/*	Encoder Data of Left (High)	*/
#define  	CRST	IP_A+0x09	/*	Counter Reset			*/
#define  	TSIE	IP_A+0x0b	/*	Touch Sensor Interrupt Enable*/


/*	IP B base address	*/

#define   IP_B	IO_BASE+0x0100


/*	addresses of PI/T 1 registers	*/

#define  	PGCR1	IP_B+0x01	/*	Port General Control Reg.	*/
#define  	PSRR1	IP_B+0x03	/*	Port Select Request Reg.	*/
#define  	PADDR1	IP_B+0x05	/*	Port A Data Direction Reg.	*/
#define  	PBDDR1	IP_B+0x07	/*	Port B Data Direction Reg.	*/
#define  	PCDDR1	IP_B+0x09	/*	Port C Data Direction Reg.	*/
#define  	PIVR1	IP_B+0x0b	/*	Port Interrupt Vector Reg.	*/
#define  	PACR1	IP_B+0x0d	/*	Port A Control Reg.		*/
#define  	PBCR1	IP_B+0x0f	/*	Port B Control Reg.		*/
#define  	PADR1	IP_B+0x11	/*	Port A Data Reg.		*/
#define  	PBDR1	IP_B+0x13	/*	Port B Data Reg.		*/
#define  	PAAR1	IP_B+0x15	/*	Port A Alternate Reg.		*/
#define  	PBAR1	IP_B+0x17	/*	Port B Alternate Reg.		*/
#define  	PCDR1	IP_B+0x19	/*	Port C Data Reg.		*/
#define  	PSR1	IP_B+0x1b	/*	Port Status Reg.		*/
#define  	TCR1	IP_B+0x21	/*	Timer Control Reg.		*/
#define  	TIVR1	IP_B+0x23	/*	Timer Interrupt Vector Reg.	*/
#define  	CPR1	IP_B+0x25	/*	Counter Preload Reg.		*/
#define  	CNTR1	IP_B+0x2d	/*	Counter Reg.			*/
#define  	TSR1	IP_B+0x35	/*	Timer Status Reg.		*/


/*	addresses of PI/T 2 registers	*/

#define  	PGCR2	IP_B+0x41	/*	Port General Control Reg.	*/
#define  	PSRR2	IP_B+0x43	/*	Port Select Request Reg.	*/
#define  	PADDR2	IP_B+0x45	/*	Port A Data Direction Reg.	*/
#define  	PBDDR2	IP_B+0x47	/*	Port B Data Direction Reg.	*/
#define  	PCDDR2	IP_B+0x49	/*	Port C Data Direction Reg.	*/
#define  	PIVR2	IP_B+0x4b	/*	Port Interrupt Vector Reg.	*/
#define  	PACR2	IP_B+0x4d	/*	Port A Control Reg.		*/
#define  	PBCR2	IP_B+0x4f	/*	Port B Control Reg.		*/
#define  	PADR2	IP_B+0x51	/*	Port A Data Reg.		*/
#define  	PBDR2	IP_B+0x53	/*	Port B Data Reg.		*/
#define  	PAAR2	IP_B+0x55	/*	Port A Alternate Reg.		*/
#define  	PBAR2	IP_B+0x57	/*	Port B Alternate Reg.		*/
#define  	PCDR2	IP_B+0x59	/*	Port C Data Reg.		*/
#define  	PSR2	IP_B+0x5b	/*	Port Status Reg.		*/
#define  	TCR2	IP_B+0x61	/*	Timer Control Reg.		*/
#define  	TIVR2	IP_B+0x63	/*	Timer Interrupt Vector Reg.	*/
#define  	CPR2	IP_B+0x65	/*	Counter Preload Reg.		*/
#define  	CNTR2	IP_B+0x6d	/*	Counter Reg.			*/
#define  	TSR2	IP_B+0x75	/*	Timer Status Reg.		*/


/*	addresses of RTC(real time clock)	*/

#define  	MSR	0xfdfe01	/*	RTC Main Status Reg.		*/
#define  	RTMR	0xfdfe03	/*	RTC Real Time Mode Reg.	*/
#define  	OMR	0xfdfe05	/*	RTC Output Mode Reg.		*/
#define  	ICR0	0xfdfe07	/*	RTC Interrupt Control Reg. 0	*/
#define  	ICR1	0xfdfe09	/*	RTC Interrupt Control Reg. 1	*/


/*	VMEbus IRQ-mask register	*/

#define  	VIMR	0xfdff01


/*	data of timer interrupt reset	*/

#define  	TMRST	0x44		/*	Timer Interrupt Reset		*/


/*	data for supersonic wave sensor	*/

#define  	SSS_LIMIT	(int)(3*8000000/32/340*2)


/*	number of 7seg.LED	*/

#define  	LED_NO	4


/*	number of supersonic wave sensor	*/

#define  	SSS_NO	4


2.5 初期診断プログラム用シンボル定義ファイル (itp_def.h)

/***********************************************************************************/
/*                                                                                 */
/*          Department of Electronics & Control Engineering  N.C.T.                */
/* ------------------------------------------------------------------------------- */
/*                                     itp_def.h -- definition file for ITP        */
/*                                                                                 */
/***********************************************************************************/

/*	addresses for ROM (128K) check	*/

#define	ROM_START	0xf00000	/*	ROM start address	 		*/
#define	ROM_SIZE	0x00fffe	/*	check size of ROM (0000-fffd)	*/
#define	CHK_SUM_E	0xf1fffc	/*	check sum address (even byte)	*/
#define	CHK_SUM_O	0xf1fffe	/*	check sum address (odd byte)		*/


/*	addresses for RAM (512K) check	*/

#define	STACKTOP	0x004000	/*	stacktop address	*/
#define	RAM_END		0x07ffff	/*	RAM end address	*/


2.6 I/O操作用関数群 (io.c)

/***********************************************************************************/
/*                                                                                 */
/*          Department of Electronics & Control Engineering  N.C.T.                */
/* ------------------------------------------------------------------------------- */
/*                                  io.c -- I/O accessing functions program        */
/*                                                                                 */
/***********************************************************************************/

int	inportb(),outportb(),inportl(),outportl();

/*	input byte data from I/O port	*/
int	inportb( port )
char	*port;
{
	return((int)*port);
}

/*	output byte data to I/O port	*/
int	outportb( port, data )
char	*port;
int	data;
{
	return(*port = data);
}

/*	input long word data from I/O port	*/
int	inportl( port )
char	*port;
{
	int data;
	unsigned char hbyte,mbyte,lbyte;

	hbyte = *(port+0x02);
	mbyte = *(port+0x04);
	lbyte = *(port+0x06);

	data = (int)(hbyte*0x010000+mbyte*0x000100+lbyte);

	return( data );
}

/*	output long word data to I/O port	*/
int	outportl( port, data )
char	*port;
int	data;
{
	unsigned char hbyte,mbyte,lbyte;

	hbyte = (unsigned char)((data & 0xff0000)>>16);
	mbyte = (unsigned char)((data & 0x00ff00)>> 8);
	lbyte = (unsigned char) (data & 0x0000ff);

	*(port+0x02) = hbyte;
	*(port+0x04) = mbyte;
	*(port+0x06) = lbyte;

	return( data );
}



3.メイク・ファイル (itp.mak)

TARGET = itp
OBJS= c_entry.o itp_main.o itp.o io.o
CMDFILE=itp.cmd
MCCOPT=-c -g -Gm -nKc -nQ

$(TARGET).x: $(OBJS);
	lnk68k -M -c $(CMDFILE) -o $(TARGET).x
.c.o:
	mcc68k $(MCCOPT) $<
.s.o:
	mcc68k $(MCCOPT) $<



4.コマンド・ファイル (itp.cmd)

*list c,d,o,p,x,s,t

debug_symbols				;list p
listabs publics			;list d
listabs internal			;list s
listmap crossref			;list c
listmap internal			;list t
listmap publics			;list x

order	code,const

sect 	code =		$0F00000    	;Code Section Begin Adrs.
sect	strings =	$0F04000	;String Section Adrs.
sect	zerovars =	$6000		;Buffer Section Adrs.
sect	vars =		$4000		;Un-initialized Data Section Adrs.

public	????STACKTOP = $4000 		;Top of the Stack Area

load 	c_entry.o
load	itp_main.o

load	itp.o
load   io.o

load	/usr/mri/lib/mcc68kab.lib

format	s

end


'94MIRS V-Project仕様書体系へ戻る