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

📄 console.c

📁 dvr
💻 C
字号:
/*
********************************************************************************
*
* (c) Copyright 2002, Vineyard Technologies, Inc.
*
* Filename : console.c
* Programmer(s): Steve KyeongHyeon Lee
* Created : 2003/05/07
* Modified :
*
* Description : Console command processing for debugging
********************************************************************************
*/

#include "types.h"
#ifdef CONIF

//###############################################################################
//Standard Includes
//###############################################################################
#include "8052reg.h"
#include <stdio.h>
#include <absacc.h>

//###############################################################################
// Includes
//###############################################################################
#include "sio.h"
#include "gio.h"
#include "console.h"
#include "lib.h"
#include "ghdd.h"
#include "i2c.h"
#ifdef TEST_G1PP
#include "bfpga.h"
#endif
#ifdef DEBUG_LANRPT
#include "socket.h"
#endif
#include "rmcon.h"


//###############################################################################
// External variables and functions
//###############################################################################
extern xdata u8 gv_encoder_mode;
extern xdata u16 gv_delay;
extern xdata u32 gv_int0_cnt;
#ifdef TEST_G1PP
extern xdata u32 gv_check_ready_counter;
#endif

//###############################################################################
// Global data structure
//###############################################################################
xdata u8 cmd_line[80];
xdata u8 cmd_len = 0;
xdata u8 cmd_special_key=0;
//###############################################################################
// Function prototypes
//###############################################################################


//###############################################################################
// Static Function prototypes
//###############################################################################
static void console_parse( u8* line );

//=============================================================================
// Process console commands
//=============================================================================
void console_process(void)
{
	xdata u8 rx_size;
	xdata u8 ch;
	static u8 flag = 0;
	
	if(flag==0){
		printf("\n\r>");
		flag = 1;
	}
	
	rx_size = sio_rbuflen();
	if(rx_size!=0){
		ch = sio_getchar();

		if((ch&0xF0)==0x40) // remote control key value
		{
			rmcon_sendkey( ch );
		}
		else
		{
			// process special key
			if(ch=='='||ch=='-')
			{
				cmd_special_key = ch;
				cmd_len = 0;
				console_parse(0);
				return;
			}
			cmd_special_key = 0;
			printf("%c", (u8)ch, (u16)ch); // echo
			cmd_line[cmd_len] = ch;
			if(ch == '\b'){ // back space key
				cmd_len--;
			}
			else{
				cmd_len = (cmd_len<79)? cmd_len+1: 0; // If over, the command line buffer will be clear
			}
			if(ch==0x0D){ // CR --> one line
				cmd_line[--cmd_len] = '\0';
				printf("\n\r");
				console_parse( cmd_line );
				cmd_len = 0; // clear local line buffer
				printf("\n\r> ");
		    }
		}
	}

}

//=============================================================================
// Parse console commands and execute
//=============================================================================
static void console_parse( u8* line )
{
	xdata u16	base_addr=0x8000;
	xdata u8 	data8;
	xdata u16 	addr16;
#ifdef DEBUG_I2C_WRITE
	xdata u8	sub8, v8;
#endif
#if defined(DEBUG_HDD_DUMP)
	xdata u32	val32;
	xdata u16	val16;
	xdata u32	v32a;
	xdata u32	v32b;
#endif



	if(!mem_cmp(line, "help", 4)){
		
		printf("\n\r rd{g|n} AA    -- read  g1 or fpga reg (AA is offset)");
		printf("\n\r wt{g|n} AA XX -- write g1 or fpga reg");		
#ifdef TEST_G1PP
		printf("\n\r list  -- list   current values for setting G1pp regs");
		printf("\n\r setup X4 X6 X7 X8 X9 XA XB -- Xn is hex and n is offset of g1pp reg");
		printf("\n\r startenc {v|a|b} -- v:video, a:audio, b:both");
		printf("\n\r stopenc {v|a|b} -- v:video, a:audio, b:both");
		printf("\n\r status -- show g1pp status register");
		printf("\n\r cvb    -- clear encoder video buffer");
		printf("\n\r +      -- increase network speed");
		printf("\n\r -      -- decrease network speed");
#endif		
#ifdef DEBUG_LANRPT
		printf("\n\r sock {c|v} -- (c)ontrol, (v)ideo sock status");
#endif
		printf("\n\r reboot");
		
#ifdef DEBUG_HDD_BW
		printf("\n\r hdd_bw SS CCCC A -- S:sector cnt, C is the number of LBA, A is option");
		printf("\n\r                0: Read HDD");
		printf("\n\r                1: Read MEM only");
#endif

#if defined(DEBUG_HDD_REPORT) || defined(DEBUG_HDD_DUMP)
		printf("\n\r hdd_report");
		printf("\n\r hdd_dump  {0|1} LLLLLLLL SSSS CCCC -- L is LBA, S is size(Bytes)");
		printf("\n\r hdd_clear {0|1}");
//		printf("\n\r hdd_rw LLLLLLLL TTTTTTTT CCCCCCCC -- L:LBA, T:Sector#, C:cnt");
//		printf("\n\r hdd_cache {0|1} -- 0:disable, 1:enable");
#endif

#ifdef DEBUG_I2C_WRITE
		printf("\n\r i2cw DD SS VV -- DD:device SS:subaddr VV:value");
#endif
		printf("\n\r");
	}

#ifdef DEBUG_I2C_WRITE
	if(!mem_cmp(line, "i2cw", 4)){
		data8 = hatoc( &line[5] );
		sub8 = hatoc( &line[8] );
		v8 = hatoc( &line[11] );
		i2c_pkt_write(data8, sub8, v8);
	}
#endif

#ifdef DEBUG_HDD_BW
	if(!mem_cmp(line, "hdd_bw", 6)){
		data8 = hatoc( &line[7] );
		addr16 = hatoi( &line[10] );
		hdd_bw(data8, addr16, line[15]);
	}
#endif

	if(!mem_cmp(line, "reboot", 6)){
		reboot();
	}

#ifdef DEBUG_HDD_DUMP			
	if(!mem_cmp(line, "hdd_report", 10)){
		hdd_report();
	}

//	if(!mem_cmp(line, "hdd_cache", 9)){
//		hdd_cache_enable('0'-line[10]);
//	}
	
	if(!mem_cmp(line, "hdd_dump", 8)){
		val32 = hatol( &line[11] );
		val16 = hatoi( &line[20] );
		addr16 = hatoi( &line[25] );
		hdd_dump('0'-line[9], val32, val16, addr16);
	}
		
	if(!mem_cmp(line, "hdd_clear", 9)){
		hdd_clear('0'-line[10]);
	}
	
	#if 0
	if(!mem_cmp(line, "hdd_rw", 6)){
		val32 = hatol( &line[7] );
		v32a  = hatol( &line[16] );
		v32b  = hatol( &line[25] );
		hdd_rw_test(val32, v32a, v32b);
	}
	#endif	
	
#endif

	if(!mem_cmp(line, "rd", 2)){	 // memory read : > mr 8002
		if(line[2]=='n')
		{
			lan_enable();
			base_addr = 0xc000;
		}
		//else dv03_enable();

		addr16 = hatoc( &line[4] ) + base_addr;
		data8 = *(u8*)addr16;
		printf("\n\rREAD ADDR=0x%04x DATA=0x%02x\n\r", addr16, (u16)data8);
		dv03_enable();
	}

	if(!mem_cmp(line, "wt", 2)){	 // memory write : > mw 8002 55
		if(line[2]=='n')
		{
			lan_enable();
			base_addr = 0xc000;
		}
		//else dv03_enable();

		addr16 = hatoc( &line[4] ) + base_addr;
		data8 = hatoc( &line[7] );
		XBYTE[addr16] = data8;
		printf("\n\rWRITE ADDR=0x%04x DATA=0x%02x (read=0x%02x)\n\r", addr16, (u16)data8, (u16)XBYTE[addr16]);
		dv03_enable();
	}


#ifdef TEST_G1PP
	if(!mem_cmp(line, "list", 4)){
		printf("\n\r SETUP ENC_DCTH ENC_ACTH RC_DFR RC_DQL RC_PQL0 RC_PQL1");
		printf("\n\r X4    X6       X7       X8     X9     XA      XB");
		printf("\n\r %02x    %02x       %02x       %02x     %02x     %02x      %02x",
			(u16)vBFREG_SETUP,
			(u16)vBFREG_ENC_DCTH,
			(u16)vBFREG_ENC_ACTH,
			(u16)vBFREG_RC_DFR,
			(u16)vBFREG_RC_DQL,
			(u16)vBFREG_RC_PQL0,
			(u16)vBFREG_RC_PQL1);
	}
	if(!mem_cmp(line, "setup", 5)){
		vBFREG_SETUP = hatoc(&line[6]);
		vBFREG_ENC_DCTH = hatoc(&line[9]);
		vBFREG_ENC_ACTH = hatoc(&line[12]);
		vBFREG_RC_DFR = hatoc(&line[15]);
		vBFREG_RC_DQL = hatoc(&line[18]);
		vBFREG_RC_PQL0 = hatoc(&line[21]);
		vBFREG_RC_PQL1 = hatoc(&line[24]);
	}
	if(!mem_cmp(line, "startenc", 8)){
		lan_enable();
		if(line[9]=='v') BFREG_SETUP |= 0x80;	
		if(line[9]=='a') BFREG_SETUP |= 0x08;
		if(line[9]=='b') BFREG_SETUP |= 0x88;
	}
	if(!mem_cmp(line, "stopenc", 7)){
		lan_enable();
		if(line[8]=='v') BFREG_SETUP &= 0x7f;	
		if(line[8]=='a') BFREG_SETUP &= 0xf7;
		if(line[8]=='b') BFREG_SETUP &= 0x77;
	}
	
	if(!mem_cmp(line, "status", 6)){
		lan_enable();
		printf("\n\rSETUP [04] VEN=%d VM=%d VR=%d VBCLR=%d AEN=%d RCEN=%d SRST=%d START=%d",
			(int)((BFREG_SETUP&0x80)>>7),
			(int)((BFREG_SETUP&0x40)>>6),
			(int)((BFREG_SETUP&0x20)>>5),
			(int)((BFREG_SETUP&0x10)>>4),
			(int)((BFREG_SETUP&0x08)>>3),
			(int)((BFREG_SETUP&0x04)>>2),
			(int)((BFREG_SETUP&0x02)>>1),
			(int) (BFREG_SETUP&0x01) );			
		printf("\n\rSTATUS[05] TXINT=%d WNINT=%d VBOF=%d ABOF=%d READY=%d (move_start=%d)",
			(int)((BFREG_STATUS&0x80)>>7),
			(int)((BFREG_STATUS&0x40)>>6),
			(int)((BFREG_STATUS&0x20)>>5),
			(int)((BFREG_STATUS&0x10)>>4),
			(int) (BFREG_STATUS&0x01),
			(int)gv_bfpga_move_start);			
		BFREG_STATUS |= 0x30; // clear over flow bits
	}
#ifdef RESET_VBOF	
	if(!mem_cmp(line, "cvb", 3))
	{
		bfpga_check_vbof(1);
	}
#endif	
#endif		
#ifdef DEBUG_LANRPT
	if(!mem_cmp(line, "sock", 4))
	{
		if(line[5]=='c') SOCK_dump_channel(0);
		if(line[5]=='v') SOCK_dump_channel(1);
	}	
#endif


	//=============================================================================
	// process special key
	//=============================================================================
	if(cmd_special_key)
	{
#ifdef TEST_G1PP
		if(cmd_special_key=='-')	// increase network speed
		{
			if(gv_check_ready_counter < 0x7fffffff)
				gv_check_ready_counter += 10;
		}
		if(cmd_special_key=='=')	// decrease network speed
		{
			if(gv_check_ready_counter > 0)
			{
				if(gv_check_ready_counter < 10)
					gv_check_ready_counter = 0;
				else
					gv_check_ready_counter -= 10;
			}
		}
		printf("\n\r<%lu>", gv_check_ready_counter);
#endif
	}

	dv03_enable();
}



#endif // CONIF


⌨️ 快捷键说明

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