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

📄 genint.c

📁 C语言编写的监控中心终端程序。基于GPRS上传收发数据功能
💻 C
字号:
#include "config.h"
#include "global.h"
#include "regmap.h"
#include "memmap.h"
#include "avd.h"
#include "dma.h"
#include "func.h"
#include "sio.h"
#include "cpu.h"
#include "fifo.h"
#include "intdef.h"
#include "stc.h"
#include "uart.h"
#include "vpp.h"
#include "fs9660.h"

/*
#define	VERBOSE
*/

#ifndef SIMULATION_FAST
/*
#define	MONE_INTR
*/
#endif

#if 0
#ifdef MONE_INTR
#define	INTR_epp_write(x)	epp_write(x)
#else
#define	INTR_epp_write(x)	(void)0
#endif
#endif

void exception_panic(void)
{
#if 0
    UINT32		REG;

//  epp_write_wait("EXCEPTION PANIC\n");

    asm volatile ("mfc0 $16, $12; nop; move %0, $16":"=r" (REG)::"$16");

//  psprintf(LineBuffer, "STATUS %08x\n", REG);
//  epp_write_wait(LineBuffer);

    asm volatile ("mfc0 $16, $13; nop; move %0, $16":"=r" (REG)::"$16");

//  psprintf(LineBuffer, "CAUSE  %08x %s\n", REG, exception_list[(REG & 0x3c) >> 2]);
//  epp_write_wait(LineBuffer);

    asm volatile ("mfc0 $16, $14; nop; move %0, $16":"=r" (REG)::"$16");

//  psprintf(LineBuffer, "EPC    %08x\n", REG);
//  epp_write_wait(LineBuffer);

    asm volatile ("mfc0 $16, $8; nop; move %0, $16":"=r" (REG)::"$16");

//  psprintf(LineBuffer, "BadVA %08x\n", REG);
//  epp_write_wait(LineBuffer);

#if 1
    asm volatile ("move %0, $29":"=r" (REG));

//  psprintf(LineBuffer, "SP     %08x\n", REG);
//  epp_write_wait(LineBuffer);
#endif

//  psprintf(LineBuffer, "INTRF  %08x\n", regs0->intr_status);
//  epp_write_wait(LineBuffer);

    while (1)
	regs0->stamp = 0xdead;
#endif
}

void intr_decerr(void)
{
//  epp_write("DECERR\n");
//  psprintf(LineBuffer, "decode $%x parsing $%x\n", picture_decoding_entry, picture_parsing_entry);
//  epp_write(LineBuffer);
//  psprintf(LineBuffer, "vbv_y $%x  barrier $%x\n", vbv_y, video_parsing_barrier);
//  epp_write(LineBuffer);
//  psprintf(LineBuffer, "VLD status %04x\n", regs0->vld_status);
//  epp_write(LineBuffer);
}

void intr_pic_end(void)
{
    /*
     ** update barrier
     */
#if 0
//  int			barrier = video_parsing_barrier;
//  if (!IsRPicStart)
    if (!IsRPicStart && IsVPicEnd)	/* no-picture-pending.. */
	video_parsing_barrier = video_parsing_barrier_saved;
#endif
#if 0
    {
	char		lbuf[64];

	psprintf(lbuf, "\t\t\t\t\t\t\tPICEND %04x %04x\n", video_parsing_barrier, barrier);
	epp_write(lbuf);
    }
#endif
}

void intr_field_end(void)
{
    /*
     ** Update VPP register
     **
     ** Caution : please do not fill too much code here, long executive time in
     **           interrupt sub-routine will lead to some error condition.
     **
     */
    int			abnormal_play;
    UINT16		pic_wait_time;

//  if (!MENU_SLIST() && !MENU_PSEG())	/* selection list or segement don't need,or Menu disappear */
    {
//	charles 2002/4/22 for stop -> no logo problem
	if (!IsRPicStart && !IsVPicEnd /* && (show_logo == 0) */) {
	    pic_end_count++;
	    if (adv_search_time != 0)
		pic_wait_time = 180;
	    else
		pic_wait_time = 60;

//	    FW/BW need 60 (1 second) // stop->logo 20 (1/3 second)
	    if (pic_end_count > pic_wait_time) {
//		maybe we need to set a variable to distinguish them...
		regs0->vld_ctrl = 1;
		regs0->vld_ctrl = 0;
		pic_end_count = 0;

		if (IsAVDRealTime()) {
		    regs0->reset = 0x30;
		    regs0->reset = 0;
		}
	    }
	}
	else
	    pic_end_count = 0;
    }

    if (vpp_disable_video)
	return;

#if VIDEO_COMPRESS==MEM_411666
//  SNR improvement
    if (play_hires == 1) {
	field_exchange = NORMAL_FRAME;	/* enable video:Line buffer disable */
	regs0->luma_offset = 0;
//	play_hires = 0;
    }
    else {
	field_exchange = (field_exchange & 0xff00) | 7;	/* enable video */
    }
#else
//  For show logo and play HI-RES picture.
    if ((play_hires == 1) || (decode_pic_count < 3)) {
//	Joseph 20021113 add for 1) video -> Return to Menu 2) Next/Prev video flicking issue
	if (cd_type_loaded == CDSVCD) {
	    if (show_logo) {
		field_exchange = NORMAL_FRAME;
		regs0->luma_offset = 0;
	    }
	    else if (decode_pic_count >= 1) {
		field_exchange = NORMAL_FRAME;
		regs0->luma_offset = 0;
	    }
	}
	else {
	    field_exchange = NORMAL_FRAME;	/* enable video */
	    regs0->luma_offset = 0;
	}
    }
    else {
	if (cd_type_loaded == CDSVCD) {
	    abnormal_play = (IsAVDPaused() || /* (I_Cnt_On == 1) || */
		(!progressive_sequence & int_frame_pic) ||			// JJDing 2002/10/23,Intech
		(CheckUIRepAB(REPEAT_FIND_B)) || (error_conceal == 1) ||
		(CheckUIState(VCD_STATE_FORWARD)) || (pic_filter_en == 1) ||
		(CheckUIState(VCD_STATE_BACKWARD)) || (IsNM9frame()) ||		// JJDing 2002/08/21
		(IsNMPreview()) ||						// JJDing 2002/08/21
		(video_slow != 0) || ((pic_lasted > 9) && (decode_pic_count > 2)) ||
		((GotoSkipFrm > 0) && (decode_pic_count > 2))) ||
		(((IsAVDDecodeNTSC() && IsAVDDisplayPAL()) ||
		(IsAVDDecodePAL() && IsAVDDisplayNTSC())));

            if (abnormal_play) {	// JJDing 2002/05/07 During GOTO seeking
//		pause and show logo is NOT allowed
//		JJDing remarked. 2002/08/21
//		JJDing,skip when Digest.
//		if (IsNM9frame() || IsNMPreview()) return;

//		epp_write("Q");

		vpp_ratio = vpp_zoom;

		if (vpp_zoom < 2)
		    vpp_ratio = 1;

		if (IsTopField)
		    field_exchange = SINGLE_FIELD_TOP_FIELD;
		if (IsBottomField) {
		    if (IsAVDDecodeNTSC()) {
			if (IsAVDDisplayPAL())	// shift half line
			    field_exchange = (SINGLE_FIELD_TOP_FIELD |
				((427 / (2 * vpp_ratio)) << VINT_INITIAL_VALUE));
			else
			    field_exchange = (SINGLE_FIELD_TOP_FIELD |
				((512 / (2 * vpp_ratio)) << VINT_INITIAL_VALUE));
		    }	// IsAVDDecodeNTSC()
		    if (IsAVDDecodePAL()) {
			if (IsAVDDisplayNTSC())
			    field_exchange = (SINGLE_FIELD_TOP_FIELD |
				((614 / (2 * vpp_ratio)) << VINT_INITIAL_VALUE));
			else
			    field_exchange = (SINGLE_FIELD_TOP_FIELD |
				((512 / (2 * vpp_ratio)) << VINT_INITIAL_VALUE));
		    }	// IsAVDDecodePAL()
		}	// IsBottomField
	    }		// abnormal play
	    else {	// normal playback
//		epp_write("%");
		if (progressive_sequence & int_frame_pic & !int_sec_field) {
		    field_exchange = NORMAL_FRAME;	/* enable video */
		    regs0->luma_offset = 0;
		}
		else if (!int_frame_pic) {
		    field_exchange = NORMAL_FIELD;	/* enable video */
		    regs0->luma_offset = FIELD_CHROMA_REPOSTION;
		}
		else {
		    field_exchange = NORMAL_FIELD;	/* enable video */
		    regs0->luma_offset = 0;
		}

/*		if (!int_frame_pic)
		    regs0->luma_offset = FIELD_CHROMA_REPOSTION;
		else
		    regs0->luma_offset = 0;	*/
	    }	// normal playback
	}	// SVCD
	else {	// VCD configuration
	    field_exchange = MPEG1_FRAME;	/* enable video ,mpeg1 only frame src, line buffer enable */
	    regs0->luma_offset = 0;
	}
    }
#endif

    // ***************************************** //
    //		field exchange setup
    // ***************************************** //

    regs0->field_exchange = field_exchange;

//  regs0->dis_pic_id = dis_pic_id;
    regs0->v_filter_mode = v_filter_mode;
    regs0->h_exp_mode = h_filter_mode;

//  regs0->chroma_field_rep = 1;	// Joseph 20021217 disable it according to RD's comment
    regs0->dis_x_start = zoomX_pic_start;	// 0;
    regs0->dis_y_start = zoomY_pic_start;	// 0;

//  regs0->y_clip = 0xdc10;
//  regs0->luma_offset = 0x1c8;
    regs0->dis_offset = (((zoomY_start / 2) & 0xff) << 8) |
			(((zoomX_start / 2) & 0xff) << 0);
//  regs0->dis_offset = 0x0000;			// 0x2020;

    regs0->dis_x_size = zoomX_size;		// width;
    regs0->dis_y_size = zoomY_size;		// height;
//  regs0->dis_tv_std = IsAVDDisplayPAL() ? 1 : 0;
//  regs0->dis_tv_out = 1 << 3;	// RF_VOUT_SWAP_LC;	// for emualtion (IsAVDDisplayPAL()) ?  RF_VOUT_SWAP_LC : 0;

#if VIDEO_COMPRESS==MEM_411666
    if (((dis_width <= 352) && (IsAVDDisplayPAL() &&
	(decode_type == DECODE_TYPE_PAL) /* IsAVDDecodePAL() */ && (vpp_zoom < 2))) ||
	((dis_width <= 352) && (IsAVDDisplayNTSC() &&
	(decode_type == DECODE_TYPE_NTSC) /* !IsAVDDecodePAL() */ && (vpp_zoom < 2)))) {
//	epp_write("rrr...\n");
	regs0->luma_offset = (1 << 10);		// snr enable
	regs0->v_filter_mode = 256;		// vertical interpolation
	field_exchange = field_exchange | (128 << VINT_INITIAL_VALUE);	// initial value
	regs0->field_exchange = field_exchange;
    }
    else {
//	epp_write("ppp...\n");
	regs0->luma_offset = 0;
	regs0->v_filter_mode = v_filter_mode;
	field_exchange = field_exchange & 0x002f;
	regs0->field_exchange = field_exchange;
    }
#endif

//  regs0->dis_tv_out = 0;
//  regs0->dis_tv_out = 1 << 3;		// kevinlu 2002/11/19
}

#define	is_decode_ignore_top_field_first()	1

/*
** FUNCTION
** intr_timer0
*/
void intr_timer0(void)
{
//  UINT32		x = regs0->iop_data[7];		/* IR code */

#if 0
    timer0_count = timer0_count + 1;
    regs0->stamp = timer0_count;
/*  if ((timer0_count % 100) == 1)
	epp_write_wait("timer0\n");	*/
    if (x & 0x100) {
	psprintf(LineBuffer, "IR %x\n", x);
	epp_write(LineBuffer);
	ir_receive_data = x;
	x ^= 0x100;

	regs0->iop_data[7] = x;
    }
#endif
}

/*
** FUNCTION
** intr_timer1
*/
void intr_timer1(void)
{
}

/*
** FUNCTION
** intr_uart
*/
#if 0	// def SUPPORT_EPP_DBG
UINT8			data[5];

#include "config.h"
#include "regmap.h"
#define	UART_DATA		(regs0->uart0_data)
#define	UART_LSR		(regs0->uart0_lsr)
#define	UART_MSR		(regs0->uart0_msr)
#define	UART_LCR		(regs0->uart0_lcr)
#define	UART_MCR		(regs0->uart0_mcr)
#define	UART_DIV_L		(regs0->uart0_div_l)
#define	UART_DIV_H		(regs0->uart0_div_h)
#define	UART_ISC		(regs0->uart0_isc)

#define	IsUARTCmdTxFull()	(!(UART_LSR & 0x01))
#define	IsUARTCmdRxEmpty()	(!(UART_LSR & 0x02))

extern BYTE		*uart_buf;
void intr_uart(void)
{
/*
    UartRecv(data, 1);
    UartSend(data, 1);
    psprintf(LineBuffer, "%02x\n", data[0]);
    epp_write_wait(LineBuffer);
*/

    int			wp = uart_wp;
    int			rp = uart_rp;

    if (regs0->uart0_isc & 0x01) {
	while (wp != rp && UART0_tx_rdy()) {
	    regs0->uart0_data = uart_buf[rp];
	    rp = rp + 1;
	    if (rp > FIFOS)
		rp = 0;
	}
    }
    if (rp == wp)
	regs0->uart0_isc = 0;
    uart_rp = rp;
    regs0->intr_status = INTR_UART;
}
#endif

void intr_iop_unmap(void)
{
//  epp_write_wait("IOP UNMAP..\n");
}

void intr_watchdog(void)
{
    int			watchdog_reg;

    watchdog_reg = regs0->watchdog;
//  psprintf(LineBuffer, "WATCHDOG REG=%04x\n", watchdog_reg);
//  epp_write(LineBuffer);
    regs0->watchdog = 0x8001;
    watchdog_reg = regs0->watchdog;
//  psprintf(LineBuffer, "WATCHDOG REG=%04x\n", watchdog_reg);
//  epp_write(LineBuffer);
}

⌨️ 快捷键说明

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