📄 pciboot.cpp
字号:
// LoadFile.cpp : Defines the entry point for the console applicaDSPon.
//
#include "stdafx.h"
#include "PciBoot.h"
#include "..\..\inc\DSP100.h"
#include "..\..\inc\reg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only applicaDSPon object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// iniDSPalize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC iniDSPalizaDSPon failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your applicaDSPon's behavior here.
CString strHello;
strHello.LoadString(IDS_HELLO);
cout << (LPCTSTR)strHello << endl;
}
//Add code
DSPSTATUS status = DSP_OK;
HDSP100 hdsp = NULL;
DWORD dwSize = 0;
DWORD dwRVal = 0;
DWORD dwMask = 0;
DWORD dwShift = 0;
DWORD dwData = 0;
DWORD dwSegment = 0;
DWORD dwOffset = 0;
HANDLE hMap = NULL;
BYTE *pBuffer = NULL;
HANDLE hFile = INVALID_HANDLE_VALUE;
DWORD *pDSPProg = new DWORD[16 * 1024];
ASSERT(pDSPProg);
status = BeginDSP100(1, &hdsp);
//Lock 4m memory window
status = DSP100LockMem(hdsp, -1, -1 , &hMap, (PVOID *)&pBuffer);
if (DSP_SUCCESS(status)) {
//Initialize PCI only read zone
dwSegment = 0x8000ffe0 / 0x400000;
dwSegment |= 0x400;
dwOffset = 0x8000ffe0 % 0x400000;
DSP100WritePortULong(hdsp, DSPP, dwSegment);
ZeroMemory(pBuffer + dwOffset, 32 * 4);
printf("DSP zone 0x%0x \n", *(DWORD *)(pBuffer + dwOffset));
//Set dsp program code
pDSPProg[0] = 0x020D0D28;
pDSPProg[1] = 0x020D0D68;
pDSPProg[2] = 0x017FF028;
pDSPProg[3] = 0x01400068;
pDSPProg[4] = 0x02080274;
status = DSP100WritePortULong(hdsp, DSPP, 0x400);
//Reset DSP
status = DSP100ReadPortULong(hdsp, HDCR, &dwData);
if (DSP_SUCCESS(status)) {
dwData |= 0x1;
status = DSP100WritePortULong(hdsp, HDCR, dwData);
}
CopyMemory(pBuffer, (BYTE *)pDSPProg, 5 * 4);
//Set DSPINT and release dsp from reset
status = DSP100ReadPortULong(hdsp, HDCR, &dwData);
if (DSP_SUCCESS(status)) {
dwData |= 0x2;
status = DSP100WritePortULong(hdsp, HDCR, dwData);
}
//Read PCI read only zone
dwSegment = 0x8000ffe0 / 0x400000;
dwSegment |= 0x400;
dwOffset = 0x8000ffe0 % 0x400000;
DSP100WritePortULong(hdsp, DSPP, dwSegment);
printf("DSP zone 0x%x \n", *(DWORD *)(pBuffer + dwOffset));
//Read PCIIEN
dwSegment = RSTSRC / 0x400000;
dwSegment |= 0x400;
dwOffset = RSTSRC % 0x400000;
DSP100WritePortULong(hdsp, DSPP, dwSegment);
printf("DSP RSTSRC 0x%0x \n", *(DWORD *)(pBuffer + dwOffset));
//Read RSTSRC again
DSP100WritePortULong(hdsp, DSPP, dwSegment);
printf("DSP RSTSRC 0x%0x \n", *(DWORD *)(pBuffer + dwOffset));
//Read PCIIEN
dwSegment = PCIIEN / 0x400000;
dwSegment |= 0x400;
dwOffset = PCIIEN % 0x400000;
DSP100WritePortULong(hdsp, DSPP, dwSegment);
printf("DSP RSTSRC 0x%0x \n", *(DWORD *)(pBuffer + dwOffset));
//Unlock
status = DSP100UnlockMem(hdsp, hMap);
}
status = EndDSP100(hdsp);
delete []pDSPProg;
return nRetCode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -