📄 window.c
字号:
base_reg = REG_IO_MAP0_START_ADDR_LO;
break;
case SOCKET0_FIRST_IO_WINDOW+1:
case SOCKET1_FIRST_IO_WINDOW+1:
base_reg = REG_IO_MAP1_START_ADDR_LO;
break;
}
//
// Set the I/O window's mapping
//
PCICIndex(sock, base_reg); // REG_IO_MAPn_START_ADDR_LO
base_reg++;
PCICDataWrite((UINT8)pWindowState->uOffset);
PCICIndex(sock, base_reg); // REG_IO_MAPn_START_ADDR_HI
base_reg++;
PCICDataWrite((UINT8)(pWindowState->uOffset >> 8));
address = pWindowState->uOffset + pWindowState->uSize - 1;
PCICIndex(sock, base_reg); // REG_IO_MAPn_END_ADDR_LO
base_reg++;
PCICDataWrite((UINT8)address);
PCICIndex(sock, base_reg); // REG_IO_MAPn_END_ADDR_HI
PCICDataWrite((UINT8)(address >> 8));
//
// Set the window's data path width
//
PCICIndex(sock, REG_IO_WINDOW_CONTROL);
tmp = PCICDataRead();
#if 0 // LKY 2001.12
tmp_mask = ICR_0_WAIT_STATE;
#else
tmp_mask = 0;
#endif
if (pWindowState->fState & WIN_STATE_16BIT) {
tmp_mask |= ICR_0_IOCS16|ICR_0_IO_16BIT;
}
if (!(uWindow & 1)) {
tmp &= 0x0f;
tmp_mask <<= 4;
tmp |= tmp_mask;
} else {
tmp &= 0xf0;
tmp |= tmp_mask;
}
PCICDataWrite(tmp);
tmp_mask = PCICDataRead();
if (tmp_mask != tmp) {
DEBUGMSG(1,
(TEXT("PCMCIA:PDCardSetWindow window %d REG_IO_WINDOW_CONTROL = 0x%x (expected 0x%x\r\n"),
uWindow, tmp_mask, tmp));
}
//
// Set the card type to I/O
//
PCICIndex(sock, REG_INTERRUPT_AND_GENERAL_CONTROL);
tmp = PCICDataRead();
tmp |= INT_CARD_IS_IO;
PCICDataWrite(tmp);
} else {
//
// Memory window setup
//
if (sock) {
base_reg = (uWindow - SOCKET1_FIRST_MEMORY_WINDOW) * 8;
} else {
base_reg = uWindow * 8;
}
//
// Set the window to its predetermined host system address range
//
tmp = MEM_WIN0_START_ADDR_LO + (uWindow * MEM_WIN0_END_ADDR_LO);
PCICIndex(sock, (UINT8)(base_reg + REG_MEM_MAP0_START_ADDR_LO));
PCICDataWrite(tmp);
tmp += MEM_WIN0_END_ADDR_LO - 1;
PCICIndex(sock, (UINT8)(base_reg + REG_MEM_MAP0_END_ADDR_LO));
PCICDataWrite(tmp);
//
// Set the window's data path width
//
if (pWindowState->fState & WIN_STATE_16BIT) {
tmp = MSH_MEM_16BIT;
} else {
tmp = 0;
}
PCICIndex(sock, (UINT8)(base_reg + REG_MEM_MAP0_START_ADDR_HI));
PCICDataWrite(tmp);
PCICIndex(sock, (UINT8)(base_reg + REG_MEM_MAP0_END_ADDR_HI));
PCICDataWrite(MTH_WAIT_STATE_BIT0|MTH_WAIT_STATE_BIT1);
//
// Set the window's card offset
// (REG_MEM_MAP0_START_ADDR_HI only has 4 bits of address)
//
// LKY. 2001.12 add Missing code!!!
PCICIndex(sock, (UINT8)(base_reg + REG_MEM_MAP0_START_ADDR_HI));
tmp = PCICDataRead();
start = (UINT32)(tmp & 0x0f);
start <<= 8;
PCICIndex(sock, (UINT8)(base_reg + REG_MEM_MAP0_START_ADDR_LO));
start |= PCICDataRead();
start <<= 12;
DEBUGMSG(1,
(TEXT("PCMCIA:PDCardSetWindow mapping window %d @ 0x%x to card offset 0x%x\r\n"),
uWindow, start, pWindowState->uOffset));
address = pWindowState->uOffset & 0xFFFFF000;
pWindowState->uOffset = address;
start = address - start;
start >>= 12;
PCICIndex(sock, (UINT8)(base_reg + REG_MEM_MAP0_ADDR_OFFSET_LO));
PCICDataWrite((UINT8)start);
start >>= 8;
//
// Set the window's memory space characteristics
//
tmp = (UINT8)(start & 0x3f);
if (pWindowState->fState & WIN_STATE_ATTRIBUTE) {
DEBUGMSG(1,
(TEXT("PCMCIA:PDCardSetWindow mapping window %d to attribute space\r\n"),
uWindow));
tmp |= MOH_REG_ACTIVE;
}
PCICIndex(sock, (UINT8)(base_reg + REG_MEM_MAP0_ADDR_OFFSET_HI));
PCICDataWrite(tmp);
} // else memory window
}
//
// Enable or disable this window as requested.
//
PCICIndex(sock, REG_WINDOW_ENABLE);
tmp = PCICDataRead()|WIN_MEMCS16_DECODE;
tmp_mask = EnableMask[uWindow];
if (pWindowState->fState & WIN_STATE_ENABLED) {
tmp |= tmp_mask;
} else {
tmp &= ~tmp_mask;
}
PCICDataWrite(tmp);
#ifdef DEBUG
DeltaSocketRegisters(v_WinState[uWindow].uSocket);
#endif
if (bUserMode) {
LeaveCriticalSection(&g_PCIC_Crit);
}
v_WinState[uWindow].fState = pWindowState->fState;
v_WinState[uWindow].uSize = pWindowState->uSize;
v_WinState[uWindow].uOffset = pWindowState->uOffset;
//
if (uWindow >= SOCKET0_FIRST_IO_WINDOW) {
pWindowState->uOffset = 0;
}
DEBUGMSG (1,(TEXT("--PDCardSetWindow\n\r")));
return CERR_SUCCESS;
} // PDCardSetWindow
//
// PDCardInquireWindow
//
// @func STATUS | PDCardInquireWindow | Report the characteristics and capabilities
// of a memory or I/O window
// @rdesc Returns one of the CERR_* error codes in cardserv.h
//
STATUS
PDCardInquireWindow(
UINT32 uWindow, // @parm Window number (the first window is 0)
PPDCARD_WINDOW_INFO pWinInfo // @parm Pointer to a PDCARD_WINDOW_INFO structure.
)
{
UINT uBase;
if (uWindow < SOCKET1_FIRST_MEMORY_WINDOW) {
pWinInfo->fSockets = 1;
} else if (uWindow < SOCKET0_FIRST_IO_WINDOW) {
pWinInfo->fSockets = 2;
} else if (uWindow < SOCKET1_FIRST_IO_WINDOW) {
pWinInfo->fSockets = 1;
} else if (uWindow < PCMCIA_NUM_WINDOWS) {
pWinInfo->fSockets = 2;
} else {
return CERR_BAD_WINDOW;
}
uBase = v_WinState[uWindow].uBase;
// LKY 2001.12 (Window 0 -> attribute memory, others -> Common memory)
if (uWindow == 0) {
pWinInfo->fWindowCaps = WIN_CAP_ATTRIBUTE;
pWinInfo->fMemoryCaps = MEM_CAP_PRG_BASE|MEM_CAP_8BIT|MEM_CAP_16BIT;
pWinInfo->uMemFirstByte = uBase;
pWinInfo->uMemLastByte = uBase+PCMCIA_MEM_WIN_SIZE-1;
pWinInfo->uMemMinSize = 4096;
pWinInfo->uMemMaxSize = PCMCIA_MEM_WIN_SIZE;
pWinInfo->uMemGranularity = 4096;
pWinInfo->uMemBase = 0;
pWinInfo->uMemOffset = 0;
pWinInfo->fSlowest = WIN_SPEED_EXP_10MS|WIN_SPEED_MANT_12|WIN_SPEED_USE_WAIT;
pWinInfo->fFastest = WIN_SPEED_EXP_1NS|WIN_SPEED_MANT_12|WIN_SPEED_USE_WAIT;
}
else if (uWindow < SOCKET0_FIRST_IO_WINDOW) {
pWinInfo->fWindowCaps = WIN_CAP_COMMON;
pWinInfo->fMemoryCaps = MEM_CAP_PRG_BASE|MEM_CAP_8BIT|MEM_CAP_16BIT;
pWinInfo->uMemFirstByte = uBase;
pWinInfo->uMemLastByte = uBase+PCMCIA_MEM_WIN_SIZE-1;
pWinInfo->uMemMinSize = 4096;
pWinInfo->uMemMaxSize = PCMCIA_MEM_WIN_SIZE;
pWinInfo->uMemGranularity = 4096;
pWinInfo->uMemBase = 0;
pWinInfo->uMemOffset = 0;
pWinInfo->fSlowest = WIN_SPEED_EXP_10MS|WIN_SPEED_MANT_12|WIN_SPEED_USE_WAIT;
pWinInfo->fFastest = WIN_SPEED_EXP_1NS|WIN_SPEED_MANT_12|WIN_SPEED_USE_WAIT;
} else {
pWinInfo->fWindowCaps = WIN_CAP_IO|WIN_CAP_WAIT;
pWinInfo->fIOCaps = IO_CAP_PRG_BASE|IO_CAP_8BIT|IO_CAP_16BIT;
pWinInfo->uIOFirstByte = uBase;
pWinInfo->uIOLastByte = uBase+PCMCIA_IO_WIN_SIZE-1;
pWinInfo->uIOMinSize = 1;
pWinInfo->uIOMaxSize = PCMCIA_IO_WIN_SIZE;
pWinInfo->uIOGranularity = 1;
pWinInfo->uAddressLines = 16;
}
return CERR_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -