#ifndef _WIN32

#pragma SAVE
#pragma REGPARMS

extern CCHAR cOrMask[8];
extern CCHAR cAndMask[8];

BOOLEAN	Ac97CheckIrq();														// Ac97.a51
void	Ac97Input(UCHAR iDmaHi, UCHAR iDmaLo, UCHAR iSdramIndex);
void	Ac97Output(UCHAR iDmaHi, UCHAR iDmaLo, UCHAR iSdramIndex);
void	Ac97StartCodec();
void	Ac97StopCodec();
void	Ac97WriteReg(UCHAR iAddr, UCHAR iDataHi, UCHAR iDataLo);				
UCHAR	Ac97ReadReg(UCHAR iAddr, BOOLEAN bHiByte);

void	DspDownloadCode(UCHAR iIndexHigh, UCHAR iIndexLow, USHORT iSize);	// Dsp.c
void	DspExecuteAndWait(USHORT iAddr);		// wait until finished
void	DspExecute(USHORT iAddr);	// no wait								// DspExec.a51
USHORT	DspReadDMC(USHORT addr);											// dsp_mem1.a51
void	DspWriteDMC(USHORT addr, USHORT dmcdata);							
void	DspWritePMIn(USHORT addr, USHORT datalowword, USHORT datahighword);	
USHORT	DspReadDMY(USHORT addr);											// dsp_mem2.a51
ULONG	DspReadPMIn(USHORT addr);											
void	DspWriteDMY(USHORT addr, USHORT dmydata);							

void	XdataSlow();														// Xdata.c
void	XdataNormal();

void L3ClockOn();															// l3_led.c
void L3ClockOff();
void L3ClockBlink();

void L3ModeOn();
void L3ModeOff();
//void L3ModeBlink();

void L3DataOn();
void L3DataOff();
//void L3DataBlink();

// Functions in led.c
// Notice: those LED functions can not be used in an interrupt routine
void Led_Init();
void Led_On(UCHAR iIndex);
void Led_Off(UCHAR iIndex);
void Led_Blink(UCHAR iIndex);
void Cam_LedOn(UCHAR iIndex);
void Cam_LedOff(UCHAR iIndex);
//void Cam_LedBlink(UCHAR iIndex);

	UCHAR	P_HIBYTE(USHORT worddata);											// p_macro.a51
	UCHAR	P_LOBYTE(USHORT worddata);
	USHORT	P_LOWORD(ULONG longdata);
	USHORT	P_HIWORD(ULONG longdata);
	USHORT	P_MAKEWORD(UCHAR lowbyte, UCHAR highbyte);
	ULONG	P_MAKELONG(USHORT lowword, USHORT highword);

	ULONG	PXCHAR2ULONG(PXCHAR src);
	void	ULONG2PUCHAR(ULONG src, PUCHAR dst);
	ULONG	PXCHAR2ULONG_L(PXCHAR src);
	void	ULONG2PUCHAR_L(ULONG src, PUCHAR dst);
	USHORT	PXCHAR2USHORT(PXCHAR src);
	void	USHORT2PXCHAR(USHORT src, PXCHAR dst);
	USHORT	PXCHAR2USHORT_L(PXCHAR src);
	void	USHORT2PXCHAR_L(USHORT src, PXCHAR dst);

// Notice: those mem, str and other dual pointer related functions can not be used in an interrupt routine
PXCHAR	p_memcpy_c2x(PXCHAR dst, PCCHAR src, UCHAR count);					// p_memcpy.a51
PXCHAR	p_memcpy_c2x_0(PXCHAR dst, PCCHAR src, UCHAR count);
PXCHAR	p_wmemcpy_c2x(PXCHAR dst, PCCHAR src, USHORT count);

PXCHAR	p_memcpy_x2x(PXCHAR dst, PXCHAR src, UCHAR count);
PXCHAR	p_memcpy_x2x_0(PXCHAR dst, PXCHAR src, UCHAR count);
PXCHAR	p_wmemcpy_x2x(PXCHAR dst, PXCHAR src, USHORT count);

UCHAR	p_memcmp_c2x(PXCHAR dst, PCCHAR src, UCHAR count);					// p_memcmp.a51
UCHAR	p_memcmp_x2x(PXCHAR dst, PXCHAR src, UCHAR count);

PXCHAR	p_memset_x(PXCHAR dst, UCHAR val, UCHAR count);

PXCHAR	p_strcpy_c2x(PXCHAR dst, PCCHAR src);								// p_strcpy.a51
PXCHAR	p_strcpy_x2x(PXCHAR dst, PXCHAR src);

UCHAR	p_strlen_x(PXCHAR dst);												// p_strlen.a51
UCHAR	p_strlen_c(PCCHAR dst);

PXCHAR	p_strcat_c2x(PXCHAR dst, PCCHAR src);								// p_strcat.a51
PXCHAR	p_strcat_x2x(PXCHAR dst, PXCHAR src);

PCCHAR	p_strchr_c(PCCHAR string, UCHAR ch);								// p_strchr.a51
PXCHAR	p_strchr_x(PXCHAR string, UCHAR ch);
//UCHAR	p_toupper(UCHAR iChar);

UCHAR	p_strcmp_c2x(PXCHAR dst, PCCHAR src);								// p_strcmp.a51
UCHAR	p_strcmp_x2x(PXCHAR dst, PXCHAR src);

//PXCHAR	p_codecpy_c2x(PXCHAR dst, PCCHAR src, UCHAR count);					// p_codcpy.a51
PXCHAR	p_codecpy_x2x(PXCHAR dst, PXCHAR src, UCHAR count);					// p_codcpy.a51

void	p_outp(USHORT port, PXCHAR src, USHORT len);							// p_ioport.a51
void	p_setp(USHORT port, UCHAR val, UCHAR len);
void	p_inp(USHORT port, PXCHAR dst, USHORT len);

ULONG	short_sum(PXCHAR pBuf, USHORT iLength);
USHORT	ip_checksum(ULONG lSum);

void	sdram_write(UCHAR high, UCHAR low, UCHAR dwordnum);					// sdram_wr.a51
void	sdram_read(UCHAR high, UCHAR low, UCHAR dwordnum);					// sdram_rd.a51
void	sdram_read_table(USHORT pos);										// sdram_dsp.a51	

PXCHAR	p_memcpy_i2x(PXCHAR dst, PICHAR src, UCHAR count);					// memcpy_i.a51
PICHAR	p_memcpy_x2i(PICHAR dst, PXCHAR src, UCHAR count);

USHORT	PCCHAR2USHORT(PCCHAR src);											// c2ushort.a51


void	Run_33Mhz();														// Run_33M.c
void	Run_47Mhz();														// 47Mhz, 2 wait state
void	Run_22Mhz();														// Run_22M.c
void	Run_46Mhz();														// 45.6Mhz, 5 wait state
void	Run_11Mhz();														// Run_11M.c
void	Run_12Mhz();
void	Run_26Mhz();
void	Run_37Mhz();														// 36.75Mhz, 2 wait state
void	Run_40Mhz();														// 40Mhz, 11	wait state
void	Run_41Mhz();														// 41Mhz, 4 wait state 

void	PLL2_Ac97();														// PLL4Ac97.c

void	SwitchPage(UCHAR iPage);											// SwitchPg.c

UCHAR	F_Test(UCHAR x, UCHAR y, UCHAR z);									// md5_fast.a51
ULONG	F_FUN(PXCHAR px, PXCHAR py, PXCHAR pz);	
ULONG	H_FUN(PXCHAR px, PXCHAR py, PXCHAR pz);
ULONG	I_FUN(PXCHAR px, PXCHAR py, PXCHAR pz);
ULONG	ROTATE_LEFT_FUN(PXCHAR pa, UCHAR iNum);
void	PXCHAR2PXLONG_L(PXLONG DST, PXCHAR SRC, UCHAR LEN);            

void	flash_write_mx29lv00x(PXCHAR dst, PXCHAR src);						// flash_wr.a51
void	flash_write_mt28f016(PXCHAR dst, PXCHAR src);

BOOLEAN	p_strcmp_nocase_c2x(PXCHAR dst, PCCHAR src);			// p_nocase.a51
BOOLEAN	p_strcmp_nocase_x2x(PXCHAR dst, PXCHAR src);
BOOLEAN	p_memcmp_nocase_c2x(PXCHAR dst, PCCHAR src, UCHAR count);
BOOLEAN	p_memcmp_nocase_x2x(PXCHAR dst, PXCHAR src, UCHAR count);

BOOLEAN	p_String2IP(PXCHAR pString, PXCHAR pIp);							// p_cnvt.c
void	p_IP2String(PXCHAR pIP, PXCHAR pString);
void	p_Mac2String(PXCHAR pMac, PXCHAR pString);
UCHAR	p_IsNewLine(PXCHAR pData);
BOOLEAN	p_String2Mac(PXCHAR pString, PXCHAR pMac);

#define p_tolower(x)		((x) >= 'A' && (x) <= 'Z') ? ((x) + 0x20) : (x)
#define p_toupper(x)		((x) >= 'a' && (x) <= 'z') ? ((x) - 0x20) : (x)

PXCHAR	p_strcat_char2x(PXCHAR pDst, UCHAR iSrc); 

PXCHAR	p_memcpy_mac(PXCHAR dst, PXCHAR src);
PXCHAR	p_memcpy_ip(PXCHAR dst, PXCHAR src);
UCHAR	p_memcmp_ip(PXCHAR dst, PXCHAR src);
PXCHAR	p_memset_ip_0(PXCHAR dst);

extern volatile  BOOLEAN Task_bCaller, Task_bConnected;
extern  BOOLEAN Task_bLogoned, Task_bCallHold, Task_bOnHold, Task_bCallTransfer, Task_bRingBack, Task_bConnecting, Task_bDisconnecting, Task_bNewMessage, Task_bCallWaiting;
BOOLEAN IsFunctionMode();

UCHAR	G7231GetFrameLen(UCHAR iFirst);										// p_misc.c
USHORT	ParseDnsAddr(PXCHAR pSrc, PXCHAR pDstIP, PXCHAR pDstDns);
BOOLEAN IsInCall();

BOOLEAN	IsPrivateIP(PXCHAR pIP);											// p_proxy.c
BOOLEAN	IsPublicIP(PXCHAR pIP);
BOOLEAN	IsValidIP(PXCHAR pIP);
BOOLEAN IsBroadcastIP(PXCHAR pPeerIP);
PXCHAR	ProxyGetLocalIP(PXCHAR pCompareIP);

UCHAR	p_getKeyId(UCHAR iChar);											// p_keyid.c
UCHAR	p_getAsciiKey(UCHAR iChar);

void	p_srand(USHORT iSeed);												// p_rand.c
USHORT	p_rand();
UCHAR	p_rand_char();
void	p_rand_array(PXCHAR pDst, UCHAR iLen);
USHORT	p_randseed_from_mac();

USHORT	p_atoi(PXCHAR pBuf, UCHAR iRadix);									// p_atoi.c

void	p_itoa(USHORT iVal, PXCHAR pBuf, UCHAR iRadix);						// p_itoa.c

ULONG	p_atol(PXCHAR pBuf, UCHAR iRadix);													// p_atol.c

// Functions in solofile.c
#define FILE_READ_MAX_SIZE	655000
#define FILE_WRITE_MAX_SIZE	2097152
#define FILE_ONE_PAGE_SIZE	64000
#define FILE_FULL_PAGE_SIZE	65536

BOOLEAN SoloFileOpen(UCHAR iSdramHi, BOOLEAN bWrite, ULONG lMaxSize);
ULONG SoloFileClose();
ULONG SoloFileGetSize();
//	ULONG SoloFileGetLimit();
void SoloFileSetLimit(ULONG lMaxSize);
BOOLEAN SoloFileWrite(PXCHAR pBuf, UCHAR iLength);
BOOLEAN SoloFileWriteSdramCache(UCHAR iLength);
//	BOOLEAN SoloFileWriteLarge(PXCHAR pBuf, USHORT iLength);
BOOLEAN SoloFileRead(PXCHAR pBuf, UCHAR iLength);
//	BOOLEAN SoloFileSeek(ULONG lPos);
void SoloFileCloseRead();
BOOLEAN SoloFileIsWriting();
BOOLEAN SoloFileIsRunning();

#pragma RESTORE     

#endif

