1. MACRO
/*
Cache size
*/
#define L2C_SIZE_256K 0x00 /* L2 cache size 256KB */
#define L2C_SIZE_512K 0x01 /* L2 cache size 512KB */
#define L2C_SIZE_1M 0x02 /* L2 cache size 1MB */
#define L2C_SIZE_2M 0x03 /* L2 cache size 2MB */
#define L2C_SIZE_4M 0x04 /* L2 cache size 4MB */
/* Cache backside type */
#define L2C_TYPE_BS_LWP 0x00 /* Late Write Pipelined */
#define L2C_TYPE_BS_BP 0x01 /* Burst Pipelined */
#define L2C_TYPE_BS_LWNP 0x02 /* Pipelined Burst */
#define L2C_TYPE_BS_BNP 0x03 /* Pipelined Late-Write */
#define L2C_SIZE_256K 0x00 /* L2 cache size 256KB */
#define L2C_SIZE_512K 0x01 /* L2 cache size 512KB */
#define L2C_SIZE_1M 0x02 /* L2 cache size 1MB */
#define L2C_SIZE_2M 0x03 /* L2 cache size 2MB */
#define L2C_SIZE_4M 0x04 /* L2 cache size 4MB */
/* Cache backside type */
#define L2C_TYPE_BS_LWP 0x00 /* Late Write Pipelined */
#define L2C_TYPE_BS_BP 0x01 /* Burst Pipelined */
#define L2C_TYPE_BS_LWNP 0x02 /* Pipelined Burst */
#define L2C_TYPE_BS_BNP 0x03 /* Pipelined Late-Write */
/*
Local driver abstractions, following bus/adaptor model
*/
#define TEMPLATE_SIO_READ8(pChan, reg, result) \
SYS_SIO_READ8(((pChan -> ioBase) + reg),result)
#define TEMPLATE_SIO_WRITE8(pChan, reg, data) \
SYS_SIO_WRITE8(((pChan -> ioBase) + reg),data)
#define TEMPLATE_INT_DISCONNECT(pChan, vec, rtn, arg) \
SYS_SIO_INT_DISCONNECT(((pChan) -> vecBase + vec), rtn, arg)
#define TEMPLATE_PROBE(pChan, offset, dir, size, ptr) \
SYS_SIO_PROBE(( char * )((pChan) -> ioBase + offset), dir, size, ptr)
#define TEMPLATE_SIO_READ8(pChan, reg, result) \
SYS_SIO_READ8(((pChan -> ioBase) + reg),result)
#define TEMPLATE_SIO_WRITE8(pChan, reg, data) \
SYS_SIO_WRITE8(((pChan -> ioBase) + reg),data)
#define TEMPLATE_INT_DISCONNECT(pChan, vec, rtn, arg) \
SYS_SIO_INT_DISCONNECT(((pChan) -> vecBase + vec), rtn, arg)
#define TEMPLATE_PROBE(pChan, offset, dir, size, ptr) \
SYS_SIO_PROBE(( char * )((pChan) -> ioBase + offset), dir, size, ptr)
2. function head
UINT32 sysHawkl2cRangeRead
(
UINT8 busNo, /* Bus number of device */
UINT8 deviceNo, /* Device number of device */
UINT8 funcNo, /* Function number of device */
UINT16 regOffset /* Offset into PCI config space */
)
{
//function body
}
(
UINT8 busNo, /* Bus number of device */
UINT8 deviceNo, /* Device number of device */
UINT8 funcNo, /* Function number of device */
UINT16 regOffset /* Offset into PCI config space */
)
{
//function body
}
3. function declare
/*
forward declarations
*/
#ifndef INCLUDE_PC_CONSOLE
LOCAL void i8042KbdLedSet (I8042_KBD_DEVICE * pKbdDv, UCHAR led);
LOCAL void i8042KbdReset (I8042_KBD_DEVICE * pKbdDv);
LOCAL int i8042KbdWriteData (I8042_KBD_DEVICE * pKbdDv);
LOCAL void i8042KbdInt (I8042_KBD_DEVICE * pKbdDv);
LOCAL int i8042KbdOpen ();
LOCAL STATUS i8042KbdIoctl (I8042_KBD_DEVICE * pKbdDv, int request, int arg);
LOCAL void i8042KbdHrdInit (I8042_KBD_DEVICE * pKbdDv);
#endif /* INCLUDE_PC_CONSOLE */
LOCAL int i8042MseOpen();
LOCAL int i8042MseClose();
LOCAL void i8042MseTxStart();
LOCAL void i8042MseInt (I8042_MSE_DEVICE * pDev);
LOCAL void i8042MseHwInit (I8042_MSE_DEVICE * pI8042MseDevice);
#ifndef INCLUDE_PC_CONSOLE
LOCAL void i8042KbdLedSet (I8042_KBD_DEVICE * pKbdDv, UCHAR led);
LOCAL void i8042KbdReset (I8042_KBD_DEVICE * pKbdDv);
LOCAL int i8042KbdWriteData (I8042_KBD_DEVICE * pKbdDv);
LOCAL void i8042KbdInt (I8042_KBD_DEVICE * pKbdDv);
LOCAL int i8042KbdOpen ();
LOCAL STATUS i8042KbdIoctl (I8042_KBD_DEVICE * pKbdDv, int request, int arg);
LOCAL void i8042KbdHrdInit (I8042_KBD_DEVICE * pKbdDv);
#endif /* INCLUDE_PC_CONSOLE */
LOCAL int i8042MseOpen();
LOCAL int i8042MseClose();
LOCAL void i8042MseTxStart();
LOCAL void i8042MseInt (I8042_MSE_DEVICE * pDev);
LOCAL void i8042MseHwInit (I8042_MSE_DEVICE * pI8042MseDevice);
/* file name: i8042KbdMse.c */
4. struct and assignment
LOCAL
const
struct
partType
{
const UINT8 partTypeNum;
const char * partTypeName;
const UINT8 partTypeNum;
const char * partTypeName;
} partNames[]
=
{
{ 0x00 , " Empty (NULL) Partition " },
{ 0x01 , " MSDOS Partition 12-bit FAT " },
{ 0x02 , " XENIX / (slash) Partition " },
{ 0x03 , " XENIX /usr Partition " },
{ 0x04 , " MSDOS 16-bit FAT <32M Partition " },
{ 0x05 , " MSDOS Extended Partition " },
{ 0x06 , " MSDOS 16-bit FAT >=32M Partition " },
{ 0x07 , " HPFS / NTFS Partition " },
{ 0x08 , " AIX boot or SplitDrive Partition " },
{ 0x09 , " AIX data or Coherent Partition " },
{ 0x0a , " OS/2 Boot Manager Partition " },
{ 0x0b , " Win95 FAT32 Partition " },
{ 0x0c , " Win95 FAT32 (LBA) Partition " },
{ 0x0e , " Win95 FAT16 (LBA) Partition " },
{ 0x0f , " Win95 Extended (LBA) Partition " },
{ 0x10 , " OPUS Partition " },
};
{
{ 0x00 , " Empty (NULL) Partition " },
{ 0x01 , " MSDOS Partition 12-bit FAT " },
{ 0x02 , " XENIX / (slash) Partition " },
{ 0x03 , " XENIX /usr Partition " },
{ 0x04 , " MSDOS 16-bit FAT <32M Partition " },
{ 0x05 , " MSDOS Extended Partition " },
{ 0x06 , " MSDOS 16-bit FAT >=32M Partition " },
{ 0x07 , " HPFS / NTFS Partition " },
{ 0x08 , " AIX boot or SplitDrive Partition " },
{ 0x09 , " AIX data or Coherent Partition " },
{ 0x0a , " OS/2 Boot Manager Partition " },
{ 0x0b , " Win95 FAT32 Partition " },
{ 0x0c , " Win95 FAT32 (LBA) Partition " },
{ 0x0e , " Win95 FAT16 (LBA) Partition " },
{ 0x0f , " Win95 Extended (LBA) Partition " },
{ 0x10 , " OPUS Partition " },
};
5. assignment
/*
(VGA) Display status initialization
*/
pVgaConDv -> memBase = CTRL_MEM_BASE;
pVgaConDv -> colorMode = COLOR_MODE; /* color mode */
pVgaConDv -> sv_col = pVgaConDv -> col = 0 ;
pVgaConDv -> sv_row = pVgaConDv -> row = 0 ;
pVgaConDv -> sv_curAttrib = pVgaConDv -> curAttrib = DEFAULT_ATR;
pVgaConDv -> defAttrib = DEFAULT_ATR;
pVgaConDv -> curChrPos = pVgaConDv -> memBase; /* current position */
pVgaConDv -> sv_rev = pVgaConDv -> rev = FALSE;
pVgaConDv -> ncol = 80 ; /* Number of columns */
pVgaConDv -> nrow = 25 ; /* Number of text rows */
pVgaConDv -> scst = 0 ; /* scroll start */
pVgaConDv -> sced = 24 ; /* scroll end */
pVgaConDv -> autoWrap = TRUE; /* auto Wrap mode */
pVgaConDv -> scrollCheck = FALSE; /* scroll flag off */
pVgaConDv -> charSet = vgaCharTable [TEXT_SET]; /* character set */
pVgaConDv -> vgaMode = TEXT_MODE; /* video mode */
pVgaConDv -> insMode = INSERT_MODE_OFF; /* insert mode */
pVgaConDv -> escFlags = ESC_NORMAL; /* normal character */
pVgaConDv -> escParaCount = 0 ; /* zero parameters */
pVgaConDv -> escQuestion = FALSE; /* ? flag set to false */
pVgaConDv -> memBase = CTRL_MEM_BASE;
pVgaConDv -> colorMode = COLOR_MODE; /* color mode */
pVgaConDv -> sv_col = pVgaConDv -> col = 0 ;
pVgaConDv -> sv_row = pVgaConDv -> row = 0 ;
pVgaConDv -> sv_curAttrib = pVgaConDv -> curAttrib = DEFAULT_ATR;
pVgaConDv -> defAttrib = DEFAULT_ATR;
pVgaConDv -> curChrPos = pVgaConDv -> memBase; /* current position */
pVgaConDv -> sv_rev = pVgaConDv -> rev = FALSE;
pVgaConDv -> ncol = 80 ; /* Number of columns */
pVgaConDv -> nrow = 25 ; /* Number of text rows */
pVgaConDv -> scst = 0 ; /* scroll start */
pVgaConDv -> sced = 24 ; /* scroll end */
pVgaConDv -> autoWrap = TRUE; /* auto Wrap mode */
pVgaConDv -> scrollCheck = FALSE; /* scroll flag off */
pVgaConDv -> charSet = vgaCharTable [TEXT_SET]; /* character set */
pVgaConDv -> vgaMode = TEXT_MODE; /* video mode */
pVgaConDv -> insMode = INSERT_MODE_OFF; /* insert mode */
pVgaConDv -> escFlags = ESC_NORMAL; /* normal character */
pVgaConDv -> escParaCount = 0 ; /* zero parameters */
pVgaConDv -> escQuestion = FALSE; /* ? flag set to false */
/*
action table
*/
LOCAL UCHAR action [ 144 ] =
{ /* Action table for scanCode */
0 , AS, AS, AS, AS, AS, AS, AS, /* scan 0- 7 */
AS, AS, AS, AS, AS, AS, AS, AS, /* scan 8- F */
AS, AS, AS, AS, AS, AS, AS, AS, /* scan 10-17 */
AS, AS, AS, AS, AS, CN, AS, AS, /* scan 18-1F */
AS, AS, AS, AS, AS, AS, AS, AS, /* scan 20-27 */
AS, AS, SH, AS, AS, AS, AS, AS, /* scan 28-2F */
AS, AS, AS, AS, AS, AS, SH, AS, /* scan 30-37 */
AS, AS, CP, 0 , 0 , 0 , 0 , 0 , /* scan 38-3F */
0 , 0 , 0 , 0 , 0 , NM, ST, ES, /* scan 40-47 */
ES, ES, ES, ES, ES, ES, ES, ES, /* scan 48-4F */
ES, ES, ES, ES, 0 , 0 , 0 , 0 , /* scan 50-57 */
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /* scan 58-5F */
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /* scan 60-67 */
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /* scan 68-6F */
AS, 0 , 0 , AS, 0 , 0 , AS, 0 , /* scan 70-77 */
0 , AS, 0 , 0 , 0 , AS, 0 , 0 , /* scan 78-7F */
AS, CN, AS, AS, AS, ST, EX, EX, /* enhanced */
AS, EX, EX, AS, EX, AS, EX, EX /* enhanced */
};
LOCAL UCHAR action [ 144 ] =
{ /* Action table for scanCode */
0 , AS, AS, AS, AS, AS, AS, AS, /* scan 0- 7 */
AS, AS, AS, AS, AS, AS, AS, AS, /* scan 8- F */
AS, AS, AS, AS, AS, AS, AS, AS, /* scan 10-17 */
AS, AS, AS, AS, AS, CN, AS, AS, /* scan 18-1F */
AS, AS, AS, AS, AS, AS, AS, AS, /* scan 20-27 */
AS, AS, SH, AS, AS, AS, AS, AS, /* scan 28-2F */
AS, AS, AS, AS, AS, AS, SH, AS, /* scan 30-37 */
AS, AS, CP, 0 , 0 , 0 , 0 , 0 , /* scan 38-3F */
0 , 0 , 0 , 0 , 0 , NM, ST, ES, /* scan 40-47 */
ES, ES, ES, ES, ES, ES, ES, ES, /* scan 48-4F */
ES, ES, ES, ES, 0 , 0 , 0 , 0 , /* scan 50-57 */
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /* scan 58-5F */
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /* scan 60-67 */
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /* scan 68-6F */
AS, 0 , 0 , AS, 0 , 0 , AS, 0 , /* scan 70-77 */
0 , AS, 0 , 0 , 0 , AS, 0 , 0 , /* scan 78-7F */
AS, CN, AS, AS, AS, ST, EX, EX, /* enhanced */
AS, EX, EX, AS, EX, AS, EX, EX /* enhanced */
};
LOCAL M68681_BAUD baudTable []
=
{
{ 75 , M68681_CSR_RX_75 | M68681_CSR_TX_75, SET2},
{ 110 , M68681_CSR_RX_110 | M68681_CSR_TX_110, SET2},
{ 134 , M68681_CSR_RX_134_5 | M68681_CSR_TX_134_5, SET2},
{ 150 , M68681_CSR_RX_150 | M68681_CSR_TX_150, SET2},
{ 300 , M68681_CSR_RX_300 | M68681_CSR_TX_300, SET2},
{ 600 , M68681_CSR_RX_600 | M68681_CSR_TX_600, SET2},
{ 1200 , M68681_CSR_RX_1200 | M68681_CSR_TX_1200, SET2},
{ 2000 , M68681_CSR_RX_2000 | M68681_CSR_TX_2000, SET2},
{ 2400 , M68681_CSR_RX_2400 | M68681_CSR_TX_2400, SET2},
{ 4800 , M68681_CSR_RX_4800 | M68681_CSR_TX_4800, SET2},
{ 1800 , M68681_CSR_RX_1800 | M68681_CSR_TX_1800, SET2},
{ 9600 , M68681_CSR_RX_9600 | M68681_CSR_TX_9600, SET2},
{ 19200 , M68681_CSR_RX_19200 | M68681_CSR_TX_19200, SET2},
{ 38400 , M68681_CSR_RX_38400 | M68681_CSR_TX_38400, SET1}
};
{
{ 75 , M68681_CSR_RX_75 | M68681_CSR_TX_75, SET2},
{ 110 , M68681_CSR_RX_110 | M68681_CSR_TX_110, SET2},
{ 134 , M68681_CSR_RX_134_5 | M68681_CSR_TX_134_5, SET2},
{ 150 , M68681_CSR_RX_150 | M68681_CSR_TX_150, SET2},
{ 300 , M68681_CSR_RX_300 | M68681_CSR_TX_300, SET2},
{ 600 , M68681_CSR_RX_600 | M68681_CSR_TX_600, SET2},
{ 1200 , M68681_CSR_RX_1200 | M68681_CSR_TX_1200, SET2},
{ 2000 , M68681_CSR_RX_2000 | M68681_CSR_TX_2000, SET2},
{ 2400 , M68681_CSR_RX_2400 | M68681_CSR_TX_2400, SET2},
{ 4800 , M68681_CSR_RX_4800 | M68681_CSR_TX_4800, SET2},
{ 1800 , M68681_CSR_RX_1800 | M68681_CSR_TX_1800, SET2},
{ 9600 , M68681_CSR_RX_9600 | M68681_CSR_TX_9600, SET2},
{ 19200 , M68681_CSR_RX_19200 | M68681_CSR_TX_19200, SET2},
{ 38400 , M68681_CSR_RX_38400 | M68681_CSR_TX_38400, SET1}
};
6. multi-conditions
if
(((partSysType
!=
PART_TYPE_DOSEXT)
&&
(partSysType != PART_TYPE_WIN95_EXT)) &&
((partSysType == PART_TYPE_DOS4) ||
(partSysType == PART_TYPE_WIN95_D4) ||
(partSysType == PART_TYPE_DOS3) ||
(partSysType == PART_TYPE_DOS32) ||
(partSysType == PART_TYPE_DOS32X) ||
(partSysType == PART_TYPE_DOS12)))
{
...
}
(partSysType != PART_TYPE_WIN95_EXT)) &&
((partSysType == PART_TYPE_DOS4) ||
(partSysType == PART_TYPE_WIN95_D4) ||
(partSysType == PART_TYPE_DOS3) ||
(partSysType == PART_TYPE_DOS32) ||
(partSysType == PART_TYPE_DOS32X) ||
(partSysType == PART_TYPE_DOS12)))
{
...
}
if
(pTxBd
->
statusMode
&
SCC_ETHER_TX_BD_W)
{
{
pTxBd
->
statusMode
=
SCC_ETHER_TX_BD_I
|
SCC_ETHER_TX_BD_PAD
|
SCC_ETHER_TX_BD_L | SCC_ETHER_TX_BD_TC |
SCC_ETHER_TX_BD_W | SCC_ETHER_TX_BD_R;
SCC_ETHER_TX_BD_L | SCC_ETHER_TX_BD_TC |
SCC_ETHER_TX_BD_W | SCC_ETHER_TX_BD_R;
}
else
{
else
{
pTxBd
->
statusMode
=
SCC_ETHER_TX_BD_I
|
SCC_ETHER_TX_BD_PAD
|
SCC_ETHER_TX_BD_L | SCC_ETHER_TX_BD_TC |
SCC_ETHER_TX_BD_R;
}
SCC_ETHER_TX_BD_L | SCC_ETHER_TX_BD_TC |
SCC_ETHER_TX_BD_R;
7. if-else
if
(TCIC_GETW (TCIC_DATA)
&
TCIC_SCF1_IOSTS)
{
{
status
|=
(value
&
TCIC_SSTAT_LBAT1)
?
PC_STSCHG :
0
;
}
else
{
status |= (value & TCIC_SSTAT_RDY) ? PC_READY : 0 ;
status |= (value & TCIC_SSTAT_LBAT1) ? PC_BATDEAD : 0 ;
status |= (value & TCIC_SSTAT_LBAT2) ? PC_BATWARN : 0 ;
}
{
status |= (value & TCIC_SSTAT_RDY) ? PC_READY : 0 ;
status |= (value & TCIC_SSTAT_LBAT1) ? PC_BATDEAD : 0 ;
status |= (value & TCIC_SSTAT_LBAT2) ? PC_BATWARN : 0 ;
}
if
(((pRxBd
->
statusMode
&
(SCC_ETHER_RX_BD_F
|
SCC_ETHER_RX_BD_L))
== (SCC_ETHER_RX_BD_F | SCC_ETHER_RX_BD_L))
&& ! (pRxBd -> statusMode & (SCC_ETHER_RX_BD_CL |
SCC_ETHER_RX_BD_OV | SCC_ETHER_RX_BD_CR |
SCC_ETHER_RX_BD_SH | SCC_ETHER_RX_BD_NO |
SCC_ETHER_RX_BD_LG)))
== (SCC_ETHER_RX_BD_F | SCC_ETHER_RX_BD_L))
&& ! (pRxBd -> statusMode & (SCC_ETHER_RX_BD_CL |
SCC_ETHER_RX_BD_OV | SCC_ETHER_RX_BD_CR |
SCC_ETHER_RX_BD_SH | SCC_ETHER_RX_BD_NO |
SCC_ETHER_RX_BD_LG)))
8. for-if-else
for
(ix
=
1
; ix
<=
(featureSelection
&
0x03
); ix
++
)
{
if (ix == 1 )
{
if (ix == 1 )
{
pv = & pConfig -> vcc[ 0 ];
pv = & pConfig -> vcc[ 0 ];
}
else if (ix == 2 )
{
else if (ix == 2 )
{
pv
=
&
pConfig
->
vpp1[
0
];
}
else
{
else
{
pv
=
&
pConfig
->
vpp2[
0
];
}
parameterSelection = * pChar ++ ;
if (parameterSelection & 0x01 )
{
* pv ++ = powerMantissa[( * pChar & 0x78 ) >> 3 ] *
powerExponent[( * pChar & 0x07 )];
while ( * pChar ++ & 0x80 )
;
}
if (parameterSelection & 0x02 )
{
* pv ++ = powerMantissa[( * pChar & 0x78 ) >> 3 ] *
powerExponent[( * pChar & 0x07 )];
while ( * pChar ++ & 0x80 )
;
}
if (parameterSelection & 0x04 )
{
* pv ++ = powerMantissa[( * pChar & 0x78 ) >> 3 ] *
powerExponent[( * pChar & 0x07 )];
while ( * pChar ++ & 0x80 )
;
}
if (parameterSelection & 0x08 )
{
while ( * pChar ++ & 0x80 )
;
}
}
parameterSelection = * pChar ++ ;
if (parameterSelection & 0x01 )
{
* pv ++ = powerMantissa[( * pChar & 0x78 ) >> 3 ] *
powerExponent[( * pChar & 0x07 )];
while ( * pChar ++ & 0x80 )
;
}
if (parameterSelection & 0x02 )
{
* pv ++ = powerMantissa[( * pChar & 0x78 ) >> 3 ] *
powerExponent[( * pChar & 0x07 )];
while ( * pChar ++ & 0x80 )
;
}
if (parameterSelection & 0x04 )
{
* pv ++ = powerMantissa[( * pChar & 0x78 ) >> 3 ] *
powerExponent[( * pChar & 0x07 )];
while ( * pChar ++ & 0x80 )
;
}
if (parameterSelection & 0x08 )
{
while ( * pChar ++ & 0x80 )
;
}
}