?? usrconfig.c
字號:
/* usrConfig.c - user-defined system configuration library *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"#include "vxWorks.h" #include "config.h" #include "usrConfig.h" #include "usrDepend.c" #include "usrKernel.c" #include "usrExtra.c" #if CPU==SIMNTextern int simUpMutex;extern int win_ReleaseMutex(int hMutex);#endif#ifdef INCLUDE_HTTP#include "http/httpLib.h" #endif#ifdef INCLUDE_COMextern int comLibInit ();#endif#ifdef INCLUDE_DCOMextern int dcomLibInit ();#endif#ifdef INCLUDE_WDB#define FREE_MEM_START_ADRS (FREE_RAM_ADRS + WDB_POOL_SIZE)#else#define FREE_MEM_START_ADRS FREE_RAM_ADRS#endif#ifdef INCLUDE_INITIAL_MEM_ALLOCATION#define MEM_POOL_START_ADRS \ (ROUND_UP(FREE_MEM_START_ADRS, (INITIAL_MEM_ALIGNMENT)) + \ (INITIAL_MEM_SIZE))#else /* INCLUDE_INITIAL_MEM_ALLOCATION */#define MEM_POOL_START_ADRS FREE_MEM_START_ADRS#endif /* INCLUDE_INITIAL_MEM_ALLOCATION */int consoleFd; /* fd of initial console device */char consoleName[20]; /* console device name, eg. "/tyCo/0" */SYMTAB_ID statSymTbl; /* system error status symbol table id*/SYMTAB_ID standAloneSymTbl; /* STANDALONE version symbol table id */SYMTAB_ID sysSymTbl; /* system symbol table id */BOOT_PARAMS sysBootParams; /* parameters from boot line */int sysStartType; /* type of boot (WARM, COLD, etc) *//* Two magic cookies used to detect data section misalignment */#define TRAP_VALUE_1 0x12348765#define TRAP_VALUE_2 0x5a5ac3c3LOCAL volatile UINT32 trapValue1 = TRAP_VALUE_1;LOCAL volatile UINT32 trapValue2 = TRAP_VALUE_2;/********************************************************************************* usrInit - user-defined system initialization routine** This is the first C code executed after the system boots. This routine is* called by the assembly language start-up routine sysInit() which is in the* sysALib module of the target-specific directory. It is called with* interrupts locked out. The kernel is not multitasking at this point.** This routine starts by clearing BSS; thus all variables are initialized to 0,* as per the C specification. It then initializes the hardware by calling* sysHwInit(), sets up the interrupt/exception vectors, and starts kernel* multitasking with usrRoot() as the root task.** RETURNS: N/A** SEE ALSO: kernelLib** ARGSUSED0*/void usrInit ( int startType ) { while (trapValue1 != TRAP_VALUE_1 || trapValue2 != TRAP_VALUE_2) { } #if (CPU_FAMILY == SPARC) excWindowInit (); /* SPARC window management */#endif#ifdef INCLUDE_SYS_HW_INIT_0 SYS_HW_INIT_0 ();#endif /* INCLUDE_SYS_HW_INIT_0 */ /* configure data and instruction cache if available and leave disabled */#ifdef INCLUDE_CACHE_SUPPORT /* * SPR 73609: If a cache is not to be enabled, don't require * its mode to be defined. Instead, default it to disabled. */# if (!defined(USER_D_CACHE_ENABLE) && !defined(USER_D_CACHE_MODE))# define USER_D_CACHE_MODE CACHE_DISABLED# endif /* !USER_D_CACHE_ENABLE && !USER_D_CACHE_MODE */# if (!defined(USER_I_CACHE_ENABLE) && !defined(USER_I_CACHE_MODE))# define USER_I_CACHE_MODE CACHE_DISABLED# endif /* !USER_I_CACHE_ENABLE && !USER_I_CACHE_MODE */ cacheLibInit (USER_I_CACHE_MODE, USER_D_CACHE_MODE);#endif /* INCLUDE_CACHE_SUPPORT */#if CPU_FAMILY!=SIMNT && CPU_FAMILY!=SIMSPARCSUNOS && CPU_FAMILY!=SIMHPPA && CPU_FAMILY!=SIMSPARCSOLARIS /* don't assume bss variables are zero before this call */ bzero (edata, end - edata); /* zero out bss variables */#endif /* CPU_FAMILY!=SIMNT && CPU_FAMILY!=SIMSPARCSUNOS && CPU_FAMILY!=SIMHPPA && CPU_FAMILY!=SIMSPARCSOLARIS */#if (CPU_FAMILY == PPC) /* * Immediately after clearing the bss, ensure global stdin * etc. are ERROR until set to real values. This is used in * target/src/arch/ppc/excArchLib.c to improve diagnosis of * exceptions which occur before I/O is set up. */ ioGlobalStdSet (STD_IN, ERROR); ioGlobalStdSet (STD_OUT, ERROR); ioGlobalStdSet (STD_ERR, ERROR);#endif /* CPU_FAMILY == PPC */ sysStartType = startType; /* save type of system start */ intVecBaseSet ((FUNCPTR *) VEC_BASE_ADRS); /* set vector base table */#if (CPU_FAMILY == AM29XXX) excSpillFillInit (); /* am29k stack cache managemt */#endif#ifdef INCLUDE_EXC_HANDLING# if (CPU_FAMILY == PPC) && defined(INCLUDE_EXC_SHOW) /* * Do this ahead of excVecInit() to set up _func_excPanicHook, in case * the enabling of Machine Check there allows a pending one to occur. * excShowInit() will be called again later, harmlessly. */ excShowInit ();# endif /* CPU_FAMILY == PPC && defined(INCLUDE_EXC_SHOW) */ excVecInit (); /* install exception vectors */#endif /* INCLUDE_EXC_HANDLING */ sysHwInit (); /* initialize system hardware */ usrKernelInit (); /* configure the Wind kernel */#ifdef INCLUDE_USB # ifdef INCLUDE_OHCI_PCI_INIT sysUsbPciOhciInit ();# endif#endif#ifdef INCLUDE_CACHE_SUPPORT#ifdef USER_I_CACHE_ENABLE cacheEnable (INSTRUCTION_CACHE); /* enable instruction cache */#endif /* USER_I_CACHE_ENABLE */#ifdef USER_D_CACHE_ENABLE cacheEnable (DATA_CACHE); /* enable data cache */#endif /* USER_D_CACHE_ENABLE */#if (CPU == MC68060)#ifdef USER_B_CACHE_ENABLE cacheEnable (BRANCH_CACHE); /* enable branch cache */#endif /* USER_B_CACHE_ENABLE */#endif /* (CPU == MC68060) */#endif /* INCLUDE_CACHE_SUPPORT */ /* start the kernel specifying usrRoot as the root task */ kernelInit ((FUNCPTR) usrRoot, ROOT_STACK_SIZE, (char *) MEM_POOL_START_ADRS, sysMemTop (), ISR_STACK_SIZE, INT_LOCK_LEVEL); }/********************************************************************************* usrRoot - the root task*** RETURNS: N/A*/void usrRoot ( char * pMemPoolStart, unsigned memPoolSize ) { char tyName [20]; int ix;#ifdef INCLUDE_MEM_MGR_FULL memInit (pMemPoolStart, memPoolSize); #else memPartLibInit (pMemPoolStart, memPoolSize);#endif /* INCLUDE_MEM_MGR_FULL */#ifdef INCLUDE_SHOW_ROUTINES memShowInit (); #endif /* INCLUDE_SHOW_ROUTINES */#if defined(INCLUDE_MMU_BASIC) || defined(INCLUDE_MMU_FULL) || \ defined(INCLUDE_MMU_MPU) usrMmuInit (); #endif /* defined(INCLUDE_MMU_BASIC, INCLUDE_MMU_FULL, INCLUDE_MMU_MPU) */ sysClkConnect ((FUNCPTR) usrClock, 0); sysClkRateSet (SYS_CLK_RATE); sysClkEnable (); #ifdef INCLUDE_FAST_DRAM cacheCreateInternalDataRAM((UINT32 *)FD_ORIGIN, FD_NUMLINES);#endif#ifdef INCLUDE_SELECT selectInit (NUM_FILES);#endif /* INCLUDE_SELECT */#ifdef INCLUDE_IO_SYSTEM iosInit (NUM_DRIVERS, NUM_FILES, "/null"); consoleFd = NONE; /* assume no console device */#ifdef INCLUDE_TYCODRV_5_2#ifdef INCLUDE_TTY_DEV if (NUM_TTY > 0) { tyCoDrv (); for (ix = 0; ix < NUM_TTY; ix++) { sprintf (tyName, "%s%d", "/tyCo/", ix); (void) tyCoDevCreate (tyName, ix, 512, 512); if (ix == CONSOLE_TTY) strcpy (consoleName, tyName); } consoleFd = open (consoleName, O_RDWR, 0); (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE); (void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL); }#endif /* INCLUDE_TTY_DEV */#else /* !INCLUDE_TYCODRV_5_2 */#ifdef INCLUDE_TTY_DEV if (NUM_TTY > 0) { ttyDrv(); for (ix = 0; ix < NUM_TTY; ix++) {#if (defined(INCLUDE_WDB) && (WDB_COMM_TYPE == WDB_COMM_SERIAL)) if (ix == WDB_TTY_CHANNEL) continue;#endif sprintf (tyName, "%s%d", "/tyCo/", ix); (void) ttyDevCreate (tyName, sysSerialChanGet(ix), 512, 512); if (ix == CONSOLE_TTY) { strcpy (consoleName, tyName); consoleFd = open (consoleName, O_RDWR, 0); (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE); (void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL); } } }#endif /* INCLUDE_TTY_DEV */#ifdef INCLUDE_PC_CONSOLE pcConDrv (); for (ix = 0; ix < N_VIRTUAL_CONSOLES; ix++) { sprintf (tyName, "%s%d", "/pcConsole/", ix); (void) pcConDevCreate (tyName,ix, 512, 512); if (ix == PC_CONSOLE) { strcpy (consoleName, tyName); consoleFd = open (consoleName, O_RDWR, 0); (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE); (void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL); } }#endif /* INCLUDE_PC_CONSOLE */#endif /* !INCLUDE_TYCODRV_5_2 */ ioGlobalStdSet (STD_IN, consoleFd); ioGlobalStdSet (STD_OUT, consoleFd); ioGlobalStdSet (STD_ERR, consoleFd);#endif /* INCLUDE_IO_SYSTEM */#ifdef INCLUDE_SYM_TBL hashLibInit (); symLibInit (); #ifdef INCLUDE_SHOW_ROUTINES symShowInit (); #endif /* INCLUDE_SHOW_ROUTINES */#endif /* INCLUDE_SYM_TBL */#if defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK)#ifdef INCLUDE_EXC_SHOW excShowInit ();#endif excInit (); /* initialize exception handling */#endif /* defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK) */#ifdef INCLUDE_LSTLIB lstLibInit ();#endif#ifdef INCLUDE_LOGGING logInit (consoleFd, MAX_LOG_MSGS); # ifdef INCLUDE_LOG_STARTUP logMsg ("logging started to %s [%d], queue size %d\n", consoleName, consoleFd, MAX_LOG_MSGS, 4,5,6); taskDelay (2); # endif /* INCLUDE_LOG_STARTUP */#endif /* INCLUDE_LOGGING */#ifdef INCLUDE_SIGNALS sigInit (); #endif /* INCLUDE_SIGNALS */#ifdef INCLUDE_DEBUG dbgInit (); #endif /* INCLUDE_DEBUG */#ifdef INCLUDE_PIPES pipeDrv (); #endif /* INCLUDE_PIPES */#ifdef INCLUDE_STDIO stdioInit (); #ifdef INCLUDE_SHOW_ROUTINES stdioShowInit ();#endif /* INCLUDE_SHOW_ROUTINES */#endif /* INCLUDE_STDIO */#if defined(INCLUDE_POSIX_SIGNALS) && defined(INCLUDE_SIGNALS) sigqueueInit (NUM_SIGNAL_QUEUES); #endif#ifdef INCLUDE_POSIX_SEM semPxLibInit ();#ifdef INCLUDE_SHOW_ROUTINES semPxShowInit ();#endif /* INCLUDE_SHOW_POUTINES */#endif /* INCLUDE_POSIX_SEM */ /* initialize POSIX threads */#ifdef INCLUDE_POSIX_PTHREADS pthreadLibInit ();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -