📄 hd465window.c
字号:
/*
Copyright(c) 1998,1999 SIC/Hitachi,Ltd.
Module Name:
window.c
Revision History:
26th April 1999 Released
23rd September 1999 Released
*/
extern CRITICAL_SECTION gPddWindowCrit;
extern PCMCIA_REGISTER_LAYOUT PcmciaRegisters[];
PDCARD_WINDOW_STATE v_WinState[PCMCIA_NUM_WINDOWS] = {
{ /* PCMCIA attribute memory window 0 - 16 bit */
0, /* socket number */
WIN_STATE_ENABLED | WIN_STATE_ATTRIBUTE, /* state flags */
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_10 | WIN_SPEED_USE_WAIT,
PCMCIA_ATTR_WIN_SIZE,
PCMCIA0_ATTR_WIN_BASE,
0 /* card offset */
},
{ /* PCMCIA attribute memory window 1 - 16 bit */
1, /* socket number */
WIN_STATE_ENABLED | WIN_STATE_ATTRIBUTE, /* state flags */
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_10 | WIN_SPEED_USE_WAIT,
PCMCIA_ATTR_WIN_SIZE,
PCMCIA1_ATTR_WIN_BASE,
0 /* card offset */
},
{ /* PCMCIA common memory window 0 - 16 bit */
0, /* socket number */
WIN_STATE_ENABLED, /* state flags */
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_10 | WIN_SPEED_USE_WAIT,
PCMCIA_CMN_WIN_SIZE,
PCMCIA0_CMN_WIN_BASE,
0
},
{ /* PCMCIA common memory window 1 - 16 bit */
1, /* socket number */
WIN_STATE_ENABLED, /* state flags */
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_10 | WIN_SPEED_USE_WAIT,
PCMCIA_CMN_WIN_SIZE,
PCMCIA1_CMN_WIN_BASE,
0
},
{ /* PCMCIA I/O window 0 - 8 bit */
0, /* socket number */
WIN_STATE_ENABLED | WIN_STATE_MAPS_IO,
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_10 | WIN_SPEED_USE_WAIT,
PCMCIA_IO_WIN_SIZE,
PCMCIA0_IO_WIN_BASE,
0
},
{ /* PCMCIA I/O window 1 - 8 bit */
1, /* socket number */
WIN_STATE_ENABLED | WIN_STATE_MAPS_IO,
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_10 | WIN_SPEED_USE_WAIT,
PCMCIA_IO_WIN_SIZE,
PCMCIA1_IO_WIN_BASE,
0
}
};
PDCARD_WINDOW_INFO v_WinInfo[PCMCIA_NUM_WINDOWS] = {
{ // This first entry describes the capabilities of attribute memory window 0
1, // bit representation of socket 0
WIN_CAP_ATTRIBUTE,
MEM_CAP_16BIT|MEM_CAP_8BIT, // memory capabilities
0, // I/O capabilities
PCMCIA0_ATTR_WIN_BASE,
PCMCIA0_ATTR_WIN_BASE + PCMCIA_ATTR_WIN_SIZE - 1,
4096, // min size of 1 page.
PCMCIA_ATTR_WIN_SIZE, // max size
4096, // granularity of 1 page.
0, // base address alignment
0, // card offset alignment
0, // I/O first byte
0, // I/O last byte
0, // I/O min size
0, // I/O max size
0, // I/O granularity
0, // I/O address lines
WIN_SPEED_EXP_10MS | WIN_SPEED_MANT_12 | WIN_SPEED_USE_WAIT, // mem slowest
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_12 | WIN_SPEED_USE_WAIT, // mem fastest
},
{ // This first entry describes the capabilities of attribute memory window 1
2, // bit representation of socket 1
WIN_CAP_ATTRIBUTE,
MEM_CAP_16BIT|MEM_CAP_8BIT, // memory capabilities
0, // I/O capabilities
PCMCIA1_ATTR_WIN_BASE,
PCMCIA1_ATTR_WIN_BASE + PCMCIA_ATTR_WIN_SIZE - 1,
4096, // min size of 1 page.
PCMCIA_ATTR_WIN_SIZE, // max size
4096, // granularity of 1 page.
0, // base address alignment
0, // card offset alignment
0, // I/O first byte
0, // I/O last byte
0, // I/O min size
0, // I/O max size
0, // I/O granularity
0, // I/O address lines
WIN_SPEED_EXP_10MS | WIN_SPEED_MANT_12 | WIN_SPEED_USE_WAIT, // mem slowest
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_12 | WIN_SPEED_USE_WAIT, // mem fastest
},
{ // This first entry describes the capabilities of common memory window 0
1, // bit representation of socket 0
WIN_CAP_COMMON,
MEM_CAP_16BIT | MEM_CAP_8BIT | MEM_CAP_PRG_SIZE | MEM_CAP_OFF_ALIGN, // memory capabilities
0, // I/O capabilities
PCMCIA0_CMN_WIN_BASE,
PCMCIA0_CMN_WIN_BASE + PCMCIA_CMN_WIN_SIZE - 1,
4096, // min size of 1 page.
PCMCIA_CMN_WIN_SIZE, // max size
4096, // granularity of 1 page.
0x10000000, // base address alignment
0, // card offset alignment
0, // I/O first byte
0, // I/O last byte
0, // I/O min size
0, // I/O max size
0, // I/O granularity
0, // I/O address lines
WIN_SPEED_EXP_10MS | WIN_SPEED_MANT_12 | WIN_SPEED_USE_WAIT, // mem slowest
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_12 | WIN_SPEED_USE_WAIT, // mem fastest
},
{ // This first entry describes the capabilities of common memory window 1
2, // bit representation of socket 1
WIN_CAP_COMMON,
MEM_CAP_16BIT|MEM_CAP_8BIT| MEM_CAP_PRG_SIZE | MEM_CAP_OFF_ALIGN, // memory capabilities
0, // I/O capabilities
PCMCIA1_CMN_WIN_BASE,
PCMCIA1_CMN_WIN_BASE + PCMCIA_CMN_WIN_SIZE - 1,
4096, // min size of 1 page.
PCMCIA_CMN_WIN_SIZE, // max size
4096, // granularity of 1 page.
0x10000000, // base address alignment
0, // card offset alignment
0, // I/O first byte
0, // I/O last byte
0, // I/O min size
0, // I/O max size
0, // I/O granularity
0, // I/O address lines
WIN_SPEED_EXP_10MS | WIN_SPEED_MANT_12 | WIN_SPEED_USE_WAIT, // mem slowest
WIN_SPEED_EXP_1NS | WIN_SPEED_MANT_12 | WIN_SPEED_USE_WAIT, // mem fastest
},
{ // This entry describes the capabilities of I/O window 0
1, // bit representation of socket 0
WIN_CAP_IO | WIN_CAP_WAIT,
0, // memory capabilities
IO_CAP_8BIT | MEM_CAP_16BIT, // I/O capabilities
0, // memory first byte
0, // memory last byte
0, // min size
0, // max size
0, // granularity of 1 page.
0, // base address alignment
0, // card offset alignment
PCMCIA0_IO_WIN_BASE, // I/O first byte
PCMCIA0_IO_WIN_BASE+PCMCIA_IO_WIN_SIZE-1, // I/O last byte
4096, // I/O min size
PCMCIA_IO_WIN_SIZE, // I/O max size
4096, // I/O granularity
0, // I/O address lines
0, // mem slowest
0, // mem fastest
},
{ // This entry describes the capabilities of I/O window 1
2, // bit representation of socket 1
WIN_CAP_IO | WIN_CAP_WAIT,
0, // memory capabilities
IO_CAP_8BIT | MEM_CAP_16BIT, // I/O capabilities
0, // memory first byte
0, // memory last byte
0, // min size
0, // max size
0, // granularity of 1 page.
0, // base address alignment
0, // card offset alignment
PCMCIA1_IO_WIN_BASE, // I/O first byte
PCMCIA1_IO_WIN_BASE+PCMCIA_IO_WIN_SIZE-1, // I/O last byte
4096, // I/O min size
PCMCIA_IO_WIN_SIZE, // I/O max size
4096, // I/O granularity
0, // I/O address lines
0, // mem slowest
0, // mem fastest
}
};
//
// PDCardGetWindow
//
// @func STATUS | PDCardGetWindow | Report the current state of a memory or I/O window
// @rdesc Returns one of the CERR_* error codes in cardserv.h
//
STATUS
PDCardGetWindow(
UINT32 uWindow, // @parm Window number (the first window is 0)
PPDCARD_WINDOW_STATE pWindowState // @parm Pointer to a PDCARD_WINDOW_STATE structure.
)
{
if (uWindow >= PCMCIA_NUM_WINDOWS)
{
return CERR_BAD_WINDOW;
}
DEBUGMSG(ZONE_PDD, (TEXT("PDCardGetWindow: %x\r\n"), uWindow));
EnterCriticalSection(&gPddWindowCrit);
memcpy(pWindowState, &(v_WinState[uWindow]), sizeof(PDCARD_WINDOW_STATE));
LeaveCriticalSection(&gPddWindowCrit);
return CERR_SUCCESS;
}
//
// PDCardSetWindow
//
// @func STATUS | PDCardSetWindow | Change the characteristics of a memory or I/O window
// @rdesc Returns one of the CERR_* error codes in cardserv.h
//
STATUS
PDCardSetWindow(
UINT32 uWindow, // @parm Window number (the first window is 0)
PPDCARD_WINDOW_STATE pWindowState // @parm Pointer to a PDCARD_WINDOW_STATE structure.
)
{
BOOL PrevMode;
int nBaseSpeed = 0;
if (uWindow >= PCMCIA_NUM_WINDOWS)
{
return CERR_BAD_WINDOW;
}
DEBUGMSG(ZONE_PDD, (TEXT("PDCardSetWindow: %x\r\n"), uWindow));
// This function is responsible for changing the access speed, the
// bus size and the windows mapping
EnterCriticalSection(&gPddWindowCrit);
// check to see if we are trying to turn this into an I/O window
if ((pWindowState->fState & WIN_STATE_MAPS_IO) &&
(!(v_WinState[uWindow].fState & WIN_STATE_MAPS_IO)))
{
LeaveCriticalSection(&gPddWindowCrit);
return CERR_BAD_ATTRIBUTE;
}
if (!(pWindowState->fState & WIN_STATE_MAPS_IO))
{
// check to see if they are trying to switch between common and attr
if ((pWindowState->fState & WIN_STATE_ATTRIBUTE) &&
(!(v_WinState[uWindow].fState & WIN_STATE_ATTRIBUTE)))
{
DEBUGMSG(ZONE_PDD, (TEXT("PDCardSetWindow : Trying to set a attr to common \r\n")));
LeaveCriticalSection(&gPddWindowCrit);
return CERR_BAD_ATTRIBUTE;
}
if ((!(pWindowState->fState & WIN_STATE_ATTRIBUTE)) &&
(v_WinState[uWindow].fState & WIN_STATE_ATTRIBUTE))
{
DEBUGMSG(ZONE_PDD, (TEXT("PDCardSetWindow : Trying to set a common to attr \r\n")));
LeaveCriticalSection(&gPddWindowCrit);
return CERR_BAD_ATTRIBUTE;
}
}
// check to see if they tried to disable the window, this action is not supported
/* // We do not need check this.
if (!(pWindowState->fState & WIN_STATE_ENABLED))
{
DEBUGMSG(ZONE_PDD, (TEXT("PDCardSetWindow : Trying to Disable the window \r\n")));
LeaveCriticalSection(&gPddWindowCrit);
return CERR_BAD_ATTRIBUTE;
}
*/
// check to see if they need to change the bus-size of the window
if ((pWindowState->fState & WIN_STATE_16BIT) !=
(v_WinState[uWindow].fState & WIN_STATE_16BIT))
{
PrevMode = SetKMode(TRUE);
if (pWindowState->fState & WIN_STATE_16BIT)
{
if (v_WinState[uWindow].uSocket == 0)
{
//BCR2 =((BCR2 & (~BSC_BCR2_A6SZ)) | BSC_BCR2_A6SZ_16);
ChangeBusSize(TRUE,TRUE);
}
else
{
//BCR2 =((BCR2 & (~BSC_BCR2_A5SZ)) | BSC_BCR2_A5SZ_16);
ChangeBusSize(FALSE,TRUE);
}
}
else
{
if (v_WinState[uWindow].uSocket == 0)
{
//BCR2 =((BCR2 & (~BSC_BCR2_A6SZ)) | BSC_BCR2_A6SZ_8);
ChangeBusSize(TRUE,FALSE);
}
else
{
//BCR2 =((BCR2 & (~BSC_BCR2_A5SZ)) | BSC_BCR2_A5SZ_8);
ChangeBusSize(FALSE,FALSE);
}
}
SetKMode(PrevMode);
DEBUGMSG(ZONE_PDD,(TEXT("PCMCIA : switched to %d bit width.\r\n"), (pWindowState->fState & WIN_STATE_16BIT)?16:8));
}
// still need to handle changing the access time, not yet implemented
v_WinState[uWindow].fSpeed = pWindowState->fSpeed;
// is the offset out of our range ? */
if ((pWindowState->uOffset & MASK_16MB_UPPER) > MASK_16MB_AVAIL)
{
DEBUGMSG(ZONE_PDD, (TEXT("Invalid offset \r\n")));
LeaveCriticalSection(&gPddWindowCrit);
return CERR_BAD_OFFSET;
}
// Does the size cross a 16M boundary?
if (((pWindowState->uOffset + (pWindowState->uSize-1)) & MASK_16MB_UPPER) !=
(pWindowState->uOffset & MASK_16MB_AVAIL))
{
DEBUGMSG(ZONE_PDD, (TEXT("Invalid size \r\n")));
LeaveCriticalSection(&gPddWindowCrit);
return CERR_BAD_SIZE;
}
if (v_WinState[uWindow].uOffset != (pWindowState->uOffset & MASK_16MB_AVAIL))
{
v_WinState[uWindow].uOffset = (pWindowState->uOffset & MASK_16MB_AVAIL);
WRITE_REGISTER_USHORT(PcmciaRegisters[pWindowState->uSocket].pGCR,
((READ_REGISTER_USHORT(PcmciaRegisters[pWindowState->uSocket].pGCR) &
~CC_PCMCIA_GCR_ADDR_MASK) | ((pWindowState->uOffset & MASK_16MB_AVAIL)>>23)));
DEBUGMSG( ZONE_PDD, (TEXT("Modified the Base addr of socket %d\r\n"), pWindowState->uSocket));
}
v_WinState[uWindow].fState = pWindowState->fState;
LeaveCriticalSection(&gPddWindowCrit);
DEBUGMSG(ZONE_PDD, (TEXT("Printing Window %d\r\n"), uWindow));
return CERR_SUCCESS;
}
//
// 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.
)
{
if (uWindow >= PCMCIA_NUM_WINDOWS)
{
return CERR_BAD_WINDOW;
}
DEBUGMSG(ZONE_PDD, (TEXT("PDCardInquireWindow\r\n")));
EnterCriticalSection(&gPddWindowCrit);
memcpy(pWinInfo, &v_WinInfo[uWindow], sizeof(PDCARD_WINDOW_INFO));
LeaveCriticalSection(&gPddWindowCrit);
return CERR_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -