?? syslib.c
字號(hào):
sysMmuMapAdd ((void *)addrLo,
max (lengthLo, lengthIo),
VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO);
}
else if ((addrLo < addrIo) && ((addrLo + lengthLo) >= addrIo))
{
sysMmuMapAdd ((void *)addrLo,
max ((addrLo + lengthLo), (addrIo + lengthIo)) - addrLo,
VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO);
}
else if ((addrIo < addrLo) && ((addrIo + lengthIo) >= addrLo))
{
sysMmuMapAdd ((void *)addrIo,
max ((addrLo + lengthLo), (addrIo + lengthIo)) - addrIo,
VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO);
}
else
{
sysMmuMapAdd ((void *)addrLo, lengthLo,
VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO);
sysMmuMapAdd ((void *)addrIo, lengthIo,
VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO);
}
}
#else
i8259Init ();
#endif /* defined(VIRTUAL_WIRE_MODE) */
}
/*******************************************************************************
*
* sysIntLock - lock out all interrupts
*
* This routine saves the mask and locks out all interrupts.
* It should be called in the interrupt disable state(IF bit is 0).
*
* SEE ALSO: sysIntUnlock()
*
* ARGSUSED0
*/
VOID sysIntLock (void)
{
#if defined(VIRTUAL_WIRE_MODE)
loApicIntLock ();
i8259IntLock ();
#elif defined(SYMMETRIC_IO_MODE)
loApicIntLock ();
ioApicIntLock ();
#else
i8259IntLock ();
#endif /* defined(VIRTUAL_WIRE_MODE) */
}
/*******************************************************************************
*
* sysIntUnlock - unlock the PIC interrupts
*
* This routine restores the mask and unlocks the PIC interrupts
* It should be called in the interrupt disable state(IF bit is 0).
*
* SEE ALSO: sysIntLock()
*
* ARGSUSED0
*/
VOID sysIntUnlock (void)
{
#if defined(VIRTUAL_WIRE_MODE)
loApicIntUnlock ();
i8259IntUnlock ();
#elif defined(SYMMETRIC_IO_MODE)
loApicIntUnlock ();
ioApicIntUnlock ();
#else
i8259IntUnlock ();
#endif /* defined(VIRTUAL_WIRE_MODE) */
}
/*******************************************************************************
*
* sysIntDisablePIC - disable a bus interrupt level
*
* This routine disables a specified bus interrupt level.
*
* RETURNS: OK, or ERROR if failed.
*
* ARGSUSED0
*/
STATUS sysIntDisablePIC
(
int irqNo /* IRQ(PIC) or INTIN(APIC) number to disable */
)
{
#if defined(VIRTUAL_WIRE_MODE)
return (i8259IntDisable (irqNo));
#elif defined(SYMMETRIC_IO_MODE)
return (ioApicIntDisable (irqNo));
#else
return (i8259IntDisable (irqNo));
#endif /* defined(VIRTUAL_WIRE_MODE) */
}
/*******************************************************************************
*
* sysIntEnablePIC - enable a bus interrupt level
*
* This routine enables a specified bus interrupt level.
*
* RETURNS: OK, or ERROR if failed.
*
* ARGSUSED0
*/
STATUS sysIntEnablePIC
(
int irqNo /* IRQ(PIC) or INTIN(APIC) number to enable */
)
{
#if defined(VIRTUAL_WIRE_MODE)
return (i8259IntEnable (irqNo));
#elif defined(SYMMETRIC_IO_MODE)
return (ioApicIntEnable (irqNo));
#else
return (i8259IntEnable (irqNo));
#endif /* defined(VIRTUAL_WIRE_MODE) */
}
/*******************************************************************************
*
* sysIntEoiGet - get EOI/BOI function and its parameter
*
* This routine gets EOI function and its parameter for the interrupt controller.
* If returned EOI/BOI function is NULL, intHandlerCreateX86() replaces
* "call _routineBoi/Eoi" in intConnectCode[] with NOP instruction.
*
* RETURNS: N/A
*
* ARGSUSED0
*/
LOCAL void sysIntEoiGet
(
VOIDFUNCPTR * vector, /* interrupt vector to attach to */
VOIDFUNCPTR * routineBoi, /* BOI function */
int * parameterBoi, /* a parameter of the BOI function */
VOIDFUNCPTR * routineEoi, /* EOI function */
int * parameterEoi /* a parameter of the EOI function */
)
{
int vectorNo = IVEC_TO_INUM (vector);
int irqNo;
*routineBoi = NULL; /* set the default value */
*parameterBoi = 0; /* set the default value */
#if defined(VIRTUAL_WIRE_MODE)
if (vectorNo == TIMER_INT_VEC)
{
*routineEoi = loApicIntEoi;
*parameterEoi = TIMER_INT_LVL;
}
else if (vectorNo == SPURIOUS_INT_VEC)
{
*routineEoi = NULL; /* no EOI is necessary */
*parameterEoi = SPURIOUS_INT_LVL;
}
else if (vectorNo == ERROR_INT_VEC)
{
*routineEoi = loApicIntEoi;
*parameterEoi = ERROR_INT_LVL;
}
else
{
irqNo = vectorNo - INT_NUM_IRQ0;
if ((irqNo == 7) || (irqNo == 15))
{
*routineBoi = i8259IntBoi;
*parameterBoi = irqNo;
}
if (irqNo < 8)
*routineEoi = i8259IntEoiMaster;
else
*routineEoi = i8259IntEoiSlave;
*parameterEoi = irqNo;
}
#elif defined(SYMMETRIC_IO_MODE)
if (vectorNo == TIMER_INT_VEC)
{
*routineEoi = loApicIntEoi;
*parameterEoi = TIMER_INT_LVL;
}
else if (vectorNo == SPURIOUS_INT_VEC)
{
*routineEoi = NULL; /* no EOI is necessary */
*parameterEoi = SPURIOUS_INT_LVL;
}
else if (vectorNo == ERROR_INT_VEC)
{
*routineEoi = loApicIntEoi;
*parameterEoi = ERROR_INT_LVL;
}
else
{
for (irqNo = 0; irqNo < NELEMENTS (redTable); irqNo++)
if (redTable [irqNo].vectorNo == vectorNo)
break;
*routineEoi = ioApicIntEoi;
*parameterEoi = irqNo;
}
#else
irqNo = vectorNo - INT_NUM_IRQ0;
if ((irqNo == 7) || (irqNo == 15))
{
*routineBoi = i8259IntBoi;
*parameterBoi = irqNo;
}
if (irqNo < 8)
*routineEoi = i8259IntEoiMaster;
else
*routineEoi = i8259IntEoiSlave;
*parameterEoi = irqNo;
#endif /* defined(VIRTUAL_WIRE_MODE) */
}
/*******************************************************************************
*
* sysIntLevel - get an IRQ(PIC) or INTIN(APIC) number in service
*
* This routine gets an IRQ(PIC) or INTIN(APIC) number in service.
* We assume followings:
* - this function is called in intEnt()
* - IRQ number of the interrupt is at intConnectCode [29]
*
* RETURNS: 0 - (NUMBER_OF_IRQS - 1), or NUMBER_OF_IRQS if we failed to get it.
*
* ARGSUSED0
*/
#ifdef SYS_INT_DEBUG
UINT32 sysIntCount[NUMBER_OF_IRQS + 1];
#endif /* SYS_INT_DEBUG */
int sysIntLevel
(
int arg /* parameter to get the stack pointer */
)
{
UINT32 * pStack;
UCHAR * pInst;
int ix;
int irqNo = NUMBER_OF_IRQS; /* return NUMBER_OF_IRQS if we failed */
pStack = &arg; /* get the stack pointer */
pStack += 3; /* skip pushed volitile registers */
/*
* we are looking for a return address on the stack which point
* to the next instruction of "call _intEnt" in the malloced stub.
* Then get the irqNo at intConnectCode [29].
*/
for (ix = 0; ix < 10; ix++, pStack++)
{
pInst = (UCHAR *)*pStack; /* return address */
if ((*pInst == 0x50) && /* intConnectCode [5] */
((*(int *)(pInst - 4) + (int)pInst) == (int)intEnt))
{
irqNo = *(int *)(pInst + 24); /* intConnectCode [29] */
break;
}
}
#ifdef SYS_INT_DEBUG
sysIntCount[irqNo]++;
#endif /* SYS_INT_DEBUG */
return (irqNo);
}
/****************************************************************************
*
* sysProcNumGet - get the processor number
*
* This routine returns the processor number for the CPU board, which is
* set with sysProcNumSet().
*
* RETURNS: The processor number for the CPU board.
*
* SEE ALSO: sysProcNumSet()
*/
int sysProcNumGet (void)
{
return (sysProcNum);
}
/****************************************************************************
*
* sysProcNumSet - set the processor number
*
* Set the processor number for the CPU board. Processor numbers should be
* unique on a single backplane.
*
* NOTE: By convention, only Processor 0 should dual-port its memory.
*
* RETURNS: N/A
*
* SEE ALSO: sysProcNumGet()
*/
void sysProcNumSet
(
int procNum /* processor number */
)
{
sysProcNum = procNum;
}
/*******************************************************************************
*
* sysDelay - allow recovery time for port accesses
*
* This routine provides a brief delay used between accesses to the same serial
* port chip.
*
* RETURNS: N/A
*/
void sysDelay (void)
{
char ix;
ix = sysInByte (UNUSED_ISA_IO_ADDRESS); /* it takes 720ns */
}
/*******************************************************************************
*
* sysStrayInt - Do nothing for stray interrupts.
*
* Do nothing for stray interrupts.
*/
LOCAL void sysStrayInt (void)
{
sysStrayIntCount++;
}
/*******************************************************************************
*
* sysMmuMapAdd - insert a new mmu mapping
*
* This routine adds a new mmu mapping entry to allow dynamic mappings.
*
* RETURNS: OK or ERROR depending on availability of free mappings.
*/
STATUS sysMmuMapAdd
(
void *address,
UINT length,
UINT initialStateMask,
UINT initialState
)
{
PHYS_MEM_DESC *pMmu;
STATUS result = OK;
pMmu = &sysPhysMemDesc[sysPhysMemDescNumEnt];
if(pMmu->virtualAddr != (void *)DUMMY_VIRT_ADDR)
result = ERROR;
else
{
pMmu->virtualAddr = address;
pMmu->physicalAddr = address;
pMmu->len = length;
pMmu->initialStateMask = initialStateMask;
pMmu->initialState = initialState;
sysPhysMemDescNumEnt += 1;
}
return (result);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -