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

📄 misc.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		// SET MAPEN

		mov		al, 0C3h
		out		22h, al
		mov		al, ccr3
		or		al, 10h
		out		23h, al

		// READ GCR

		mov		al, 0B8h
		out		22h, al
		in		al, 23h
		mov		data, al

		// RESTORE CCR3

		mov		al, 0C3h
		out		22h, al
		mov		al, ccr3
		out		23h, al
		popf
	}
	DEBUGMSG( 1,(TEXT("gx_read_gcr = 0x%X\n"),data));
	return(data);
}

//----------------------------------------------------------------------------
// execute_cpu_write
//
// This routine is needed on GX to set the BLT buffer base address values.
// The CPU_WRITE instruction is used to do this.  This is ugly, but the good
// news is that this all goes away for MXi.
//----------------------------------------------------------------------------

void GxVideo::execute_cpu_write(unsigned long reg, unsigned long data)
{
	if (ProcessorID >= 0x40) // processor ID >= 40 for GXm.
	{
		// CPU_WRITE INSTRUCTION ON GXm
		// Changed from GXi since it conflicted with MMX instruction.

		_asm {
			push eax
			push ebx
			
			mov eax, data
			mov ebx, reg
			_emit 00Fh
			_emit 03Ch

			pop ebx
			pop eax
		}
	}
	else
	{
		// CPU_WRITE INSTRUCTION ON GXi

		_asm {
			push eax
			push ebx
			
			mov eax, data
			mov ebx, reg
			_emit 00Fh
			_emit 074h

			pop ebx
			pop eax
		}
	}
}

//----------------------------------------------------------------------------
// execute_cpu_read
//
// This routine is needed on GX to get the BLT buffer base address values.
// The CPU_READ instruction is used to do this.  This is ugly, but the good
// news is that this all goes away for MXi.
//----------------------------------------------------------------------------
unsigned long GxVideo::execute_cpu_read(unsigned long reg)
{
	unsigned long data;

	if (ProcessorID >= 0x40) // processor ID >= 40 for GXm.
	{
		// CPU_WRITE INSTRUCTION ON GXm
		// Changed from GXi since it conflicted with MMX instruction.

		_asm {
			push eax
			push ebx
			
			mov eax, 00h  //Clear the register
			mov ebx, reg
			_emit 00Fh
			_emit 03Dh
			mov data, eax

			pop ebx
			pop eax
		}
	}
	else
	{
		// CPU_WRITE INSTRUCTION ON GXi

		_asm {
			push eax
			push ebx

			mov eax, 00h  //Clear the register
			mov ebx, reg
			_emit 00Fh
			_emit 075h
			mov data, eax

			pop ebx
			pop eax
		}
	}
	return(data);
}

//----------------------------------------------------------------------------
// ResetBB0
//
// This routine is needed on GX to reset the BLT buffer pointer.
//----------------------------------------------------------------------------
void GxVideo::ResetBB0(void)
{
	_asm {
		
		_emit 00Fh
		_emit 072h

	}
}

//----------------------------------------------------------------------------
// ResetBB1
//
// This routine is needed on GX to reset the BLT buffer pointer.
//----------------------------------------------------------------------------
void GxVideo::ResetBB1(void)
{
	_asm {

		_emit 00Fh
		_emit 073h

	}
}



#define CORE_LOGIC_PCI_ADDR	0x80009000

//----------------------------------------------------------------------------
// GetDeviceId
//
// This routine is needed to identitfy what device is present cx5510, 20, 30.
//----------------------------------------------------------------------------
unsigned long GxVideo::GetDeviceId(void)
{
	unsigned long CoreLogicID;

	_asm {
		pushf
		cli
		mov     dx, 0CF8h
		mov     eax, CORE_LOGIC_PCI_ADDR
		out     dx, eax
		mov     dx, 0CFCh
		in      eax, dx
		mov     CoreLogicID, eax
		popf    
	}
	DEBUGMSG( 1,(TEXT("GetDeviceId = 0x%X\n"),CoreLogicID));
	return CoreLogicID;
}


//----------------------------------------------------------------------------
// SelectSolidColor
// 
// This routine is called to load the color for a solid rectangle fill.  
// For GX, this is loaded into the pattern color register.  In addition, 
// the lower byte of the color, if 8 BPP, needs to be duplicated into the 
// upper byte of the 16 bit color value.
//
// For MXi, the LOAD_SOLID_PATTEN request is used.  The color does not 
// need to be duplicated into the upper byte for MXi.
//----------------------------------------------------------------------------

void GxVideo::SelectSolidColor( unsigned long color )
{
	// SET PATTERN COLOR
	// For 8 BPP the color needs to be duplicated into the upper byte.

	if (Display_BPP == 8) 
	{
		color &= 0x00FF;
		color |= (color << 8);
	}
	WAIT_PENDING(GXregisters);
	WRITE_REG16(GXregisters, GP_PAT_COLOR_0, color );
}

unsigned long GxVideo::GetBltSolidColor( GPEBltParms *pBltParms )
{
	unsigned long color = pBltParms->solidColor;

	//Check if we need to do some color conversions
	if (pBltParms->pLookup)
	{
		color = (pBltParms->pLookup)[color];
	}
	if (pBltParms->pConvert)
	{
		color = (pBltParms->pColorConverter->*(pBltParms->pConvert))(color);
	}
	return color;
}


int DpyModeExists(int modeId )
{
	int i;
	DEBUGMSG( 0,(TEXT("DpyModeExists %d\n"),modeId));
	
	//Check if the mode is within the range
	if( modeId<0 || modeId >= numVGAmodes )
		return -99;

	//Loop thru to find if the modeId really exists
	for(i=0; i < NUMBEROFMODES; i++)
	{
		if(DisplayParams[i].gpeMode.modeId == modeId)
		{
			DEBUGMSG( 0,(TEXT("DpyModeExists Found mode %d at %d\n"),modeId, i));
			return i;
		}
	}
	DEBUGMSG( 1,(TEXT("DpyModeExists mode %d not found in %d modes !!!\n"),
					modeId, NUMBEROFMODES));
	return -1;

}

DISPLAYMODE* GetDisplayParams(int modeId )
{
	int count;
	DEBUGMSG( 0,(TEXT("GetDisplayParams %d\n"),modeId));

	//Check to see if modeId exists
	if((count = DpyModeExists(modeId)) < 0)
	{
		DEBUGMSG( 0,(TEXT("GxVideo::GetDisplayParams mode %d, Dosen't exist\n"),modeId ));
		return NULL;
	}
	RETAILMSG(0,(_T("GXVIDEO return count %d\r\n"), count));

	return(&DisplayParams[count]);
}


SCODE GxVideo::GetModeInfo(GPEMode *pMode, int modeId )
{
	int count;
	DEBUGMSG( 0,(TEXT("GetModeInfo %d\n"),modeId));

	//Check to see if modeId exists
	if((count = DpyModeExists(m_resolution)) < 0)
	{
		DEBUGMSG( 0,(TEXT("GxVideo::GetModeInfo mode %d, Dosen't exist\n"),modeId ));
		return E_INVALIDARG;
	}

	pMode->modeId		= DisplayParams[count].gpeMode.modeId;
	pMode->width		= DisplayParams[count].gpeMode.width;
	pMode->height		= DisplayParams[count].gpeMode.height;
	pMode->Bpp			= DisplayParams[count].gpeMode.Bpp;
	pMode->frequency	= DisplayParams[count].gpeMode.frequency;
	pMode->format		= DisplayParams[count].gpeMode.format;

	RETAILMSG( 0,(TEXT("GetModeInfo %d, %X, %X, %X\n"),modeId, pMode->width, pMode->Bpp, pMode->format ));
	return S_OK;
}

int GxVideo::NumModes()
{
	return numVGAmodes;
}

void GxVideo::GetPhysicalVideoMemory(
	unsigned long *pPhysicalMemoryBase,
	unsigned long *pVideoMemorySize )
{
	*pPhysicalMemoryBase = (unsigned long)m_pLAW;
	*pVideoMemorySize = m_nVideoMemorySize;
}

⌨️ 快捷键说明

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