⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syslib.c

📁 VxWorks下AMD79C973网卡的驱动程序源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    	    dosFsInit (NUM_DOSFS_FILES);	/* initialize DOS-FS */	if (usrTffsConfig (sysWarmTffsDrive, FALSE, "/vxboot/") == ERROR)	    {	    printErr ("usrTffsConfig failed.\n");	    return (ERROR);	    }	}#endif	/* INCLUDE_TFFS */#if	(defined(INCLUDE_FD) || defined(INCLUDE_ATA) || defined(INCLUDE_TFFS))    if ((sysWarmType == SYS_WARM_FD) || (sysWarmType == SYS_WARM_ATA) || 	(sysWarmType == SYS_WARM_TFFS))	{        int fd;        if ((fd = open ("/vxboot/bootrom.sys", O_RDWR, 0644)) == ERROR)	    {            if ((fd = open ("/vxboot/bootrom.dat", O_RDWR, 0644)) == ERROR)		{                printErr ("Can't open \"%s\"\n", "bootrom.{sys,dat}");	        return (ERROR);		}            if (read (fd, (char *)pDst, 0x20) == ERROR) /* a.out header */	        {	        printErr ("Error during read file: %x\n", errnoGet ());	        return (ERROR);                }	    }        /* read text and data, write them to the memory */        if (read (fd, (char *)pDst, 0x98000) == ERROR)	    {	    printErr ("Error during read file: %x\n", errnoGet ());	    return (ERROR);            }        close (fd);        sysClkDisable ();	/* disable the system clock interrupt */	sysIntInitPIC ();	/* reset the used interrupt controllers */        (*pEntry) (startType);	}#endif	/* (INCLUDE_FD) || (INCLUDE_ATA) || (INCLUDE_TFFS) */    intLock ();#ifdef INCLUDE_ELC    elcdetach (0);#endif /* INCLUDE_ELC */#ifdef INCLUDE_ULTRA    ultradetach (0);#endif /* INCLUDE_ULTRA */    sysClkDisable ();    sysWait ();    sysOutByte (COMMAND_8042, 0xfe);	/* assert SYSRESET */    sysWait ();    sysOutByte (COMMAND_8042, 0xff);	/* NULL command */    sysReboot ();			/* crash the global descriptor table */    return (OK);	/* in case we ever continue from ROM monitor */    }/********************************************************************************* sysIntInitPIC - initialize the interrupt controller** This routine initializes the interrupt controller.** RETURNS: N/A** ARGSUSED0*/LOCAL void sysIntInitPIC (void)    {#if	defined(VIRTUAL_WIRE_MODE)    {    int addrLo;		/* page aligned Local APIC Base Address */    int lengthLo;	/* length of Local APIC registers */    loApicInit ();    i8259Init ();    /* add an entry to the sysMmuPhysDesc[] for Local APIC */    addrLo   = ((int)loApicBase / PAGE_SIZE) * PAGE_SIZE;    lengthLo = (int)loApicBase - addrLo + LOAPIC_LENGTH;    if ((lengthLo % PAGE_SIZE) != 0)	lengthLo = (lengthLo / PAGE_SIZE + 1) * PAGE_SIZE;        sysMmuMapAdd ((void *)addrLo, lengthLo, 		  VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO);    }#elif	defined(SYMMETRIC_IO_MODE)    {    int addrLo;		/* page aligned Local APIC Base Address */    int addrIo;		/* page aligned IO APIC Base Address */    int lengthLo;	/* length of Local APIC registers */    int lengthIo;	/* length of IO APIC registers */    loApicInit ();    i8259Init ();    ioApicInit ();    /* add an entry to the sysMmuPhysDesc[] for Local APIC and IO APIC */    addrLo   = ((int)loApicBase / PAGE_SIZE) * PAGE_SIZE;    lengthLo = (int)loApicBase - addrLo + LOAPIC_LENGTH;    if ((lengthLo % PAGE_SIZE) != 0)	lengthLo = (lengthLo / PAGE_SIZE + 1) * PAGE_SIZE;        addrIo   = ((int)ioApicBase / PAGE_SIZE) * PAGE_SIZE;    lengthIo = (int)ioApicBase - addrIo + IOAPIC_LENGTH;    if ((lengthIo % PAGE_SIZE) != 0)	lengthIo = (lengthIo / PAGE_SIZE + 1) * PAGE_SIZE;        if (addrLo == addrIo)	{        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_DEBUGUINT32 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);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -