📄 ct69000.cpp
字号:
//-----------------------------------------------------------------------
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
// Copyright (c) 1999 Microsoft Corporation
//
// written by: ESG Solution Center Munich
//
// Module Name: ct69000.cpp
//
// abstract: Windows CE display driver for C&T 69000
// initialization and mode setup
//
//-----------------------------------------------------------------------
#include "precomp.h"
#include "palette.h" // for 8Bpp we use the natural palette
#include "vmodes.h"
#include "bootarg.h"
//-----------------------------------------------------------------------
//
// description of all available video mode configurations
//
//-----------------------------------------------------------------------
INSTANTIATE_PALETTE
#if BIOSSETUP
ULONG ulBitMask[] = { 0, 0, 0};
GPEMode *gpemodes[] =
{
&gpeMode, // 0
};
#elif FBBPP==8
ULONG ulBitMask[] = { 0, 0, 0};
GPEMode *gpemodes[] =
{
&gpemode640x480x8, // 0
&gpemode800x600x8, // 1 ...
&gpemode1024x768x8
};
VGAPortData *vgamodes[] =
{
vgamode640x480x8,
vgamode800x600x8,
vgamode1024x768x8
};
#elif FBBPP==16
ULONG ulBitMask[] = { 0xf800, 0x7e0, 0x1f};
GPEMode *gpemodes[] =
{
&gpemode640x480x16,
&gpemode800x600x16,
&gpemode1024x768x16
};
VGAPortData *vgamodes[] =
{
vgamode640x480x16,
vgamode800x600x16,
vgamode1024x768x16
};
#elif FBBPP==24
ULONG ulBitMask[] = { 0xff0000, 0x00ff00, 0x0000ff};
GPEMode *gpemodes[] =
{
&gpemode640x480x24,
&gpemode800x600x24
};
VGAPortData *vgamodes[] =
{
vgamode640x480x24,
vgamode800x600x24
};
#endif
#define N_GPEMODES (sizeof(gpemodes)/sizeof(GPEMode *))
//
// use same debug zones as gpe, but in high word
//
INSTANTIATE_GPE_ZONES(
GPE_MSG_ERROR |
GPE_MSG_WARNING |
//GPE_MSG_PERF |
//GPE_MSG_TEMP |
//GPE_MSG_ENTER |
//GPE_MSG_INIT |
//GPE_MSG_BLT_HI |
//GPE_MSG_BLT_LO |
//GPE_MSG_CREATE |
//GPE_MSG_FLIP |
//GPE_MSG_LINE |
//GPE_MSG_HW |
//GPE_MSG_POLY |
//GPE_MSG_CURSOR |
//CT69K_MSG_ERROR |
//CT69K_MSG_WARNING |
//CT69K_MSG_PERF |
//CT69K_MSG_TEMP |
//CT69K_MSG_FUNCTION |
//CT69K_MSG_INIT |
CT69K_MSG_BLTLO |
CT69K_MSG_BLTHI |
CT69K_MSG_SURF |
//CT69K_MSG_FLIP |
//CT69K_MSG_LINE |
//CT69K_MSG_HW |
//CT69K_MSG_POLYGON |
//CT69K_MSG_CURSOR |
//CT69K_MSG_DDRAW |
0
,"DDI Driver","unused1","unused2")
//
// for initialization, a translation from I/O space to linear space
// might be needed
//
ULONG CT69000::VGAtoLinear[] = {
0x780 ,// 0x3c0
0x781 ,// 0x3c1
0x784 ,// 0x3c2
0x40000 ,// 0x3c3 bang!
0x788 ,// 0x3c4
0x789 ,// 0x3c5
0x78c ,// 0x3c6
0x78d ,// 0x3c7
0x790 ,// 0x3c8
0x791 ,// 0x3c9
0x794 ,// 0x3ca
0x40000 ,// 0x3cb bang!
0x798 ,// 0x3cc
0x40000 ,// 0x3cd bang!
0x79c ,// 0x3ce
0x79d ,// 0x3cf
0x7a0 ,// 0x3d0
0x7a1 ,// 0x3d1
0x7a4 ,// 0x3d2
0x7a5 ,// 0x3d3
0x7a8 ,// 0x3d4
0x7a9 ,// 0x3d5
0x7ac ,// 0x3d6
0x7ad ,// 0x3d7
0x40000 ,// 0x3d8
0x40000 ,// 0x3d9
0x7b4 ,// 0x3da
0x40000 ,// 0x3db
0x40000 ,// 0x3dc
0x40000 ,// 0x3dd
0x40000 ,// 0x3de
0x40000 // 0x3df
};
//-----------------------------------------------------------------------
//
// BOOL APIENTRY GPEEnableDriver
//
// Workaround for problems exporting from .lib
//
//-----------------------------------------------------------------------
BOOL APIENTRY GPEEnableDriver(
ULONG iEngineVersion, ULONG cj,
DRVENABLEDATA *pded, PENGCALLBACKS pEngCallbacks);
//-----------------------------------------------------------------------
//
// DrvEnableDriver
//
// main entry point for a display driver
//
//-----------------------------------------------------------------------
BOOL APIENTRY
DrvEnableDriver(ULONG iEngineVersion, ULONG cj,
DRVENABLEDATA *pded, PENGCALLBACKS pEngCallbacks)
{
DEBUGMSG(CT69K_ZONE_INIT,(TEXT("GPEEnableDriver()\r\n")));
//
// instantiate gpe
//
return GPEEnableDriver(iEngineVersion, cj, pded, pEngCallbacks);
}
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
static GPE *pGPE = (GPE *)NULL;
//-----------------------------------------------------------------------
//
// Main entry point for a GPE-compliant driver
//
//-----------------------------------------------------------------------
GPE *
GetGPE()
{
DEBUGMSG(CT69K_ZONE_INIT, (TEXT("GetGPE\n\r")));
if(!pGPE)
pGPE = new CT69000();
return pGPE;
}
//-----------------------------------------------------------------------
//
// CT69000::ListRegs( PUCHAR pIndexReg, BYTE bStart, BYTE bStop)
//
// list content of chip initialization to debug output
//
// bBase---Index register base address
// bStart--Index Start
// bStop---index Stop
//
//-----------------------------------------------------------------------
VOID
CT69000::ListRegs( PUCHAR pIndexReg, BYTE bStart, BYTE bStop)
{
BYTE bIndex, bData;
for ( bIndex=bStart; bIndex <= bStop; bIndex++)
{
WRITE_PORT_UCHAR( pIndexReg, bIndex);
bData=READ_PORT_UCHAR(pIndexReg+1);
DEBUGMSG(CT69K_ZONE_INIT, (TEXT("{0x%04x,0x%02x,0x%02x},\r\n"),
(WORD) pIndexReg, bIndex, bData));
}
}
//-----------------------------------------------------------------------
//
// CT69000::CT69000()
//
// hardware initialization
// finds ct69000 and mapping of linear region. shows also how to find a
// pci card by scanning the bus
//
//-----------------------------------------------------------------------
CT69000::CT69000()
{
DEBUGMSG(CT69K_ZONE_INIT, (TEXT("CT69000::CT69000\r\n")));
#if DXPAK
// load ddraw support
hDDStub = LoadLibrary(TEXT("ddstub.dll"));
#endif
m_ulVideoMemorySize = CT69000_VIDEOMEMORYSIZE;
m_pPatternMemory= NULL;
m_pCursorMemory= NULL;
m_pCtrlRegister= NULL;
m_pFrameBuffer = NULL;
m_ulPhysFrameBuffer = 0;
m_pVMHeap = NULL;
m_iCursorRegion= 0;
m_bHasVGARegs=TRUE;
m_bChip69030=FALSE;
#if BIOSSETUP
DWORD oldMode;
PBOOT_ARGS pargs;
BOOT_ARGS args;
DEBUGMSG(GPE_ZONE_INIT,(TEXT("--using BIOS setup method\r\n")));
oldMode = SetKMode(TRUE);
pargs = (PBOOT_ARGS)(*(PBYTE *)BOOT_ARG_PTR_LOCATION);
if (pargs != 0)
{
// there is some misaligned in the structures in loadcepc..
// pargs = (PBOOT_ARGS)((DWORD)pargs - 0xc);
pargs = (PBOOT_ARGS)((DWORD)pargs | 0x80000000);
RETAILMSG( 1, (TEXT(" args: %08lx size=%ld\r\n"), pargs, pargs->dwLen));
args=*pargs;
}
SetKMode(oldMode);
// set rest of ModeInfo values
gpeMode.modeId = 0;
gpeMode.width = args.cxDisplayScreen;
gpeMode.height = args.cyDisplayScreen;
gpeMode.Bpp = args.bppScreen;
gpeMode.frequency = REFRESHRATE; // ?
switch (args.bppScreen)
{
case 8:
gpeMode.format = gpe8Bpp;
break;
case 16:
gpeMode.format = gpe16Bpp;
break;
case 24:
gpeMode.format = gpe24Bpp;
break;
case 32:
gpeMode.format = gpe32Bpp;
break;
default:
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("Invalid BPP value passed to driver - %d\r\n"), args.bppScreen));
gpeMode.format = gpeUndefined;
break;
}
m_pMode = &gpeMode;
if (args.bppScreen != 8)
{
ulBitMask[0]=((1 << args.RedMaskSize) - 1) << args.RedMaskPosition;
ulBitMask[1]=((1 << args.GreenMaskSize) - 1) << args.GreenMaskPosition;
ulBitMask[2]=((1 << args.BlueMaskSize) - 1) << args.BlueMaskPosition;
} else
{
memset( ulBitMask, 0, sizeof(ulBitMask));
}
#endif //BIOSSETUP
//
// x- and y-offsets here are for the 640x480x16 mode
//
m_ulOvlXOffset=0x8f;
m_ulOvlYOffset=0x1f;
m_ulRefreshRate=REFRESHRATE;
m_ulVideoMode =VIDEOMODE;
//
// initialize some vars via registry
//
HKEY hActiveKey = (HKEY) INVALID_HANDLE_VALUE;
LPCTSTR lpRegistryPath=TEXT("\\Drivers\\ddi_ct69");
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
(LPCTSTR)lpRegistryPath,
0,
0,
&hActiveKey
) == ERROR_SUCCESS)
{
DWORD dwValue;
ULONG ulValueSize = sizeof(dwValue);
#if !BIOSSETUP
//
// check if user selected a mode and overload
//
if (RegQueryValueEx(hActiveKey,
L"Mode",
0,
NULL,
(PUCHAR)&dwValue,
&ulValueSize
) == ERROR_SUCCESS)
{
m_ulVideoMode=(INT)min(dwValue,N_GPEMODES-1);
}
//
// check if user selected a refreshrate
//
if (RegQueryValueEx(hActiveKey,
L"RefreshRate",
0,
NULL,
(PUCHAR)&dwValue,
&ulValueSize
) == ERROR_SUCCESS)
{
m_ulRefreshRate = dwValue;
}
#endif
#if DXPAK
//
// read x and y offsets for DDraw overlays
//
if (RegQueryValueEx(hActiveKey,
L"OvlXOffset",
0,
NULL,
(PUCHAR)&dwValue,
&ulValueSize
) == ERROR_SUCCESS)
{
m_ulOvlXOffset=dwValue;
}
if (RegQueryValueEx(hActiveKey,
L"OvlYOffset",
0,
NULL,
(PUCHAR)&dwValue,
&ulValueSize
) == ERROR_SUCCESS)
{
m_ulOvlYOffset=dwValue;
}
#endif
}
RegCloseKey(hActiveKey);
m_bOverlayOn=FALSE;
m_ulOvlBaseOffset=0;
#if CURSORDEBUG
//
// allow hw accelerations by default
//
m_bBltEmulation=0;
#endif
#if mist
//
// left over from S3?
//
WRITE_PORT_UCHAR( VGA_SETUP_REG, 1); // wake chip
#endif
//
// this code shows how to find a pci adapter when there is
// no other way to get the configuration info. Fortunately
// the ct69000 has a way of reading back the frame buffer
// mapping via some I/O ports.
//
#if SCAN_PCIBUS
//
// the following sequence will find the PCI graphic adapter
// and create mappings for the frame buffer and control regs
//
PCI_COMMON_CONFIG pciConfig;
ULONG ulBusNumber;
ULONG ulSlotNumber;
ULONG ulResult;
ULONG ulBoard=0;
//
// read device and vendor id via I/O ports
//
WORD wVendorId=GetXRPort(0) | (GetXRPort(1) << 8);
WORD wDeviceId=GetXRPort(2) | (GetXRPort(3) << 8);
m_bHasVGARegs=FALSE;
// note: on the PC 104 we search only on the first bus
// on other platforms we might have to search also the
// other buses
for ( ulBusNumber=0; ulBusNumber<1; ulBusNumber++)
{
for (ulSlotNumber=0; ulSlotNumber<256; ulSlotNumber++)
{
ulResult=
HalGetBusData(
PCIConfiguration,
ulBusNumber,
ulSlotNumber,
&pciConfig,
2*sizeof(USHORT)); // only get vendor and deviceid
if (ulResult >= 2*sizeof(USHORT) &&
pciConfig.VendorID==CT69000_VENDORID &&
(pciConfig.DeviceID==CT69000_DEVICEID ||
pciConfig.DeviceID==CT69030_DEVICEID)
)
{
ulBoard++;
ulResult=
HalGetBusData(
PCIConfiguration,
ulBusNumber,
ulSlotNumber,
&pciConfig,
sizeof(pciConfig));
if (pciConfig.DeviceID==CT69030_DEVICEID)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -