sysinit.c
来自「PPPoE协议在Psos中的实现源代码」· C语言 代码 · 共 596 行 · 第 1/2 页
C
596 行
/***********************************************************************//* *//* MODULE: sysinit.c 1.67 *//* DATE: 10:23:14 - 99/06/30 *//* PURPOSE: Main system configuration file *//* *//*---------------------------------------------------------------------*//* *//* Copyright 1991 - 1995, Integrated Systems, Inc. *//* ALL RIGHTS RESERVED *//* *//* Permission is hereby granted to licensees of Integrated Systems, *//* Inc. products to use or abstract this computer program for the *//* sole purpose of implementing a product based on Integrated *//* Systems, Inc. products. No other rights to reproduce, use, *//* or disseminate this computer program, whether in part or in *//* whole, are granted. *//* *//* Integrated Systems, Inc. makes no representation or warranties *//* with respect to the performance of this computer program, and *//* specifically disclaims any responsibility for any damages, *//* special or consequential, connected with the use of this program. *//* *//*---------------------------------------------------------------------*//* *//* This code in this module controls the configuration of the *//* operating system. Many configurations are possible, based on *//* these inputs: *//* * Options selected in "sys_conf.h" *//* * The capabilities of the board-support package being used, *//* as defined in "bsp.h" *//* *//***********************************************************************/#include "bsp.h"#include <bspfuncs.h>#include <pna.h>#include <configs.h>#include <sysvars.h>#include <apdialog.h>/*#include "bsp.h" */#include <bspfuncs.h>#include <configs.h>#include "sys_conf.h"#include "cpintf.h"/*---------------------------------------------------------------------*//* External declarations *//*---------------------------------------------------------------------*/static const char MemErrMsg[] ="System Initialization Failed: insufficient memory available!";extern UCHAR *PnaSetup(UCHAR *, NODE_CT *);extern UCHAR *PrepcSetup(UCHAR *, NODE_CT *);extern UCHAR *PsosSetup(UCHAR *, NODE_CT *);extern UCHAR *PhileSetup(UCHAR *, NODE_CT *);extern UCHAR *PrpcSetup(UCHAR *, NODE_CT *);extern UCHAR *ProbeSetup(UCHAR *, NODE_CT *);extern UCHAR *PmontSetup(UCHAR *, NODE_CT *);extern UCHAR *PseSetup(UCHAR *, NODE_CT *);extern UCHAR *PxSetup(UCHAR *, NODE_CT *);extern void ki_call(void);extern INT32 slow_entry();extern void pROBE_Init(void); /* pROBE+ initialization entry point */extern void root(void);extern UCHAR *SetUpDrivers(UCHAR *);typedef void (*fvoidp) ();extern MP_CT MultiprocCfg;extern struct SD_parms SysVars;extern NODE_CT *anchor;extern void *_AppModelIF_CT;extern void TimerIntWrapper();extern INT32 kd_fastjtab[];extern INT32 kd_dbjtab[];extern INT32 kd_slowjtab[];struct pSOS_IO_Jump_Table PsosIO[SC_DEVMAX + 1];extern MP_CT MultiprocCfg;extern NODE_CT NodeCfg;extern pSOS_CT PsosCfg;PSOSHEAD pSOSHead;int BSP_RAM_BASE;int BSP_RAM_END; ULONG PsosNumDntEnts = 0;/*---------------------------------------------------------------------*//* KC_ROOTPRI should be defined in sys_conf.h. However, the *//* sys_conf.h files in some of the older sample applications do not *//* contain this definition. In order to maintain compatibility, *//* it is defined here if it has not been defined in sys_conf.h. *//* It is preferable that it be defined in sys_conf.h, and you should *//* note that this "default" definition will probably be removed from *//* this file in future versions of pSOSystem! *//*---------------------------------------------------------------------*/#ifndef KC_ROOTPRI#define KC_ROOTPRI 230#endif#define TRUNC(addr, boundary) (((addr)) & ~((boundary) - 1))#define ALIGN(addr, boundary) (((addr) + (boundary) - 1) & ~((boundary) - 1))#define MARGIN 1000/***********************************************************************//* TaskStartCallout: Called whenever a task is started *//* *//* INPUTS: Tid: TID of task being started *//* TcbPtr: Address of task's TCB (Task Control Block) *//* NOTE: Calls user handler if supplied *//* *//***********************************************************************/static void TaskStartCallout(unsigned long Tid, void *TcbPtr){#ifdef KC_STARTCO if (KC_STARTCO) { static void (*callout) (ULONG, void *) = (void (*) (ULONG, void *)) KC_STARTCO; (*callout) (Tid, TcbPtr); }#endif}/***********************************************************************//* PsosSetup: Setup pSOS+ or pSOS+m componet *//* *//* INPUTS: FreeMemPtr pointer to free memory area that can be *//* used to allocate memory for this componet. In the case *//* of pSOS+ and pSOS+m all remaining memory will be *//* allocated to region 0. *//* *//* NodeCfg pointer to the systems node configuration *//* table. This will be used to set the psosct and mp_ct *//* elements in the table. *//* *//* RETURNS: The new FreeMemPtr is returned. *//* *//* NOTE: This function should be the last function called in *//* the components initialization because it will use all *//* of the remaining memory to allocate pSOS region 0. *//* *//***********************************************************************/UCHAR *PsosSetup(UCHAR * FreeMemPtr, NODE_CT *x){ int i; /*---------------------------------------------------------------------*/ /* Initializethe pSOS I/O driver table to all "illegal" drivers. */ /*---------------------------------------------------------------------*/ for (i = 0; i <= SC_DEVMAX; i++) { PsosIO[i].dev_init = (void (*) (struct ioparms *)) -1; PsosIO[i].dev_open = (void (*) (struct ioparms *)) -1; PsosIO[i].dev_close = (void (*) (struct ioparms *)) -1; PsosIO[i].dev_read = (void (*) (struct ioparms *)) -1; PsosIO[i].dev_write = (void (*) (struct ioparms *)) -1; PsosIO[i].dev_ioctl = (void (*) (struct ioparms *)) -1; } pSOSHead.fast_entry = (INT32) kd_fastjtab; pSOSHead.debug_entry = (INT32) kd_dbjtab; pSOSHead.slow_entry = (INT32) slow_entry; return SetUpDrivers(FreeMemPtr);}/***********************************************************************//* BuildConfigTables: Build the component configuration tables, using *//* information from the system variables (SysVars). *//* *//* INPUT: FreeMemPtr - Pointer to first byte of available memory *//* *//***********************************************************************/static UCHAR *BuildConfigTables(UCHAR * FreeMemPtr){/* This is where the component's configuration functions are called */#if (SC_PROBE) FreeMemPtr = ProbeSetup(FreeMemPtr, &NodeCfg);#endif#if (SC_PNA) FreeMemPtr = PnaSetup(FreeMemPtr, &NodeCfg);#endif#if (SC_PREPC) FreeMemPtr = PrepcSetup(FreeMemPtr, &NodeCfg); Should not be used; Appmem interface is used instead#else NodeCfg.prepct = (void *) &_AppModelIF_CT;#endif#if (SC_PHILE || SC_DEV_RAMDISK || SC_DEV_SCSI) FreeMemPtr = PhileSetup(FreeMemPtr, &NodeCfg);#endif#if (SC_PRPC) FreeMemPtr = PrpcSetup(FreeMemPtr, &NodeCfg);#endif#if (SC_PX) FreeMemPtr = PxSetup(FreeMemPtr, &NodeCfg);#endif#if (SC_PSE) FreeMemPtr = PseSetup(FreeMemPtr, &NodeCfg);#endif#if (SC_PMONT) FreeMemPtr = PmontSetup(FreeMemPtr, &NodeCfg);#endif#if (SC_PSOS || SC_PSOSM) /*-----------------------------------------------------------------*/ /* PsosSetup() must be called after all other Setup functions. */ /* */ /* If pSOS+ has been configured into the system, the FreeMemPtr is */ /* now part of pSOS+ region zero! So it can't be used to allocate */ /* any more memory after this. */ /*-----------------------------------------------------------------*/ FreeMemPtr = PsosSetup(FreeMemPtr, &NodeCfg);#endif/*---------------------------------------------------------------------*//* Finally, finish up node configuration table and set node anchor to *//* point to it. *//*---------------------------------------------------------------------*/#if (BSP_FPU == YES) NodeCfg.cputype |= 0x100;#endif#if (BSP_MMU == YES) NodeCfg.cputype |= 0x200;#endif anchor = &NodeCfg; return (FreeMemPtr);}/***********************************************************************//* SysInit: Initialize system variables, conduct startup dialog *//* if configured, and set up component configuration *//* tables. *//* *//* NOTE: Interrupts are assumed to be disabled upon entry to *//* this routine. *//* *//***********************************************************************/extern int _node_number;extern int _number_of_nodes;void SysInit(void){ long mem_size; UCHAR *FreeMemPtr; ULONG rn0max; SysVars.DefGtwyIP = SD_DEF_GTWY_IP; SysVars.Lan1 = SD_LAN1; SysVars.Lan1IP = SD_LAN1_IP; SysVars.Lan1SubnetMask = SD_LAN1_SUBNET_MASK; SysVars.SmNode = _node_number+1; SysVars.Kism = _number_of_nodes; PsosCfg.kc_rn0usize = KC_RN0USIZE; PsosCfg.kc_ntask = KC_NTASK; PsosCfg.kc_nqueue = KC_NQUEUE; PsosCfg.kc_nsema4 = KC_NSEMA4; PsosCfg.kc_nmsgbuf = KC_NMSGBUF; PsosCfg.kc_ntimer = KC_NTIMER; PsosCfg.kc_nlocobj = KC_NLOCOBJ; PsosCfg.kc_ticks2sec = KC_TICKS2SEC; PsosCfg.kc_ticks2slice = KC_TICKS2SLICE;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?