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

📄 sysinit.c

📁 psos for mips bsp
💻 C
📖 第 1 页 / 共 3 页
字号:
/* @(#) pSOSystem MIPS/V2.5.0: configs/sysinit.c (mip) 4.23 99/01/25 16:27:33 */
/* $Revision: \main\20010426_1.4_integration_branch\5 $                                                        */
/* $Date:     Thu Apr 11 13:39:41 2002 $                                                        */
//***********************************************************************/
/*                                                                     */
/*   MODULE:  configs/std/sysinit.c                                    */
/*   DATE:    99/01/25                                                 */
/*   PURPOSE: Main system configuration file                           */
/*                                                                     */
/*---------------------------------------------------------------------*/
/*                                                                     */
/*           Copyright 1991 - 1998, 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"                                         */
/*     * Answers given to questions in the startup configuration       */
/*       dialog, if it is enabled                                      */
/*                                                                     */
/***********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

#define _SYSINIT_C 1
#include "sys_conf.h"
#include "bsp.h"
#include <drv_intf.h>
#include <bspfuncs.h>
#include <pna.h>
#include <configs.h>
#include <sysvars.h>
#include <apdialog.h>
#include <version.h>
#include <gendefs.h>
#include <exc.h>

#if BSP_NEW_SERIAL
#include <disi.h>
#endif

#if (BSP_USE_SERIAL_MUX == YES)
void InitSerialMux(void);
#endif

/*---------------------------------------------------------------------*/
/* User defined Tick Handler. If can be set to point to user defined   */
/* function, Which will be called from the Timer ISR                   */
/* anchor->psosct->kc_ticks2sec times_per_second.                      */
/*---------------------------------------------------------------------*/
void (*PssUserTickHandler)(void);

#if (BSP_SMEM && SC_PSOSM && (BSP_INT_MODE == 0))
extern void  ki_check(void);
extern UCHAR KiUp;
#endif

/*---------------------------------------------------------------------*/
/* This flag is cleared during .bss clearing at startup time.  It is   */
/* set to 1 by the task start callout in this module.                  */
/*---------------------------------------------------------------------*/
unsigned long PsosUpFlag;


#if (VERSION != BSP_VERSION)
    #error "BSP_VERSION and pSOSystem VERSION do not match!"
#endif

#if SC_PSOS && SC_PSOSM
    #error "Cannot use both pSOS+ and pSOS+m!"
#endif

#if ((SC_PSOS || SC_PSOSM) && SC_QBIND)

#if ((SC_PSOS == USEROM) || (SC_PSOSM == USEROM))
    #error "Quick bindings are not supported in case USEROM for pSOS+!"
#endif

#if (SC_PSOS)
extern void QuickSvcCallPsos(void);
#else
extern void QuickSvcCallPsosm(void);
#endif

static void (* volatile dummy)(void);

#endif


#if SC_PSOSM
     #define PSOS_INIT pSOSm_Init
#else
     #define PSOS_INIT pSOS_Init
#endif

extern ULONG Dialog(void);

#if (SC_PNA || SC_PNET || SC_PSKT)
NETWORK_CALLS network_calls;
#endif

/*---------------------------------------------------------------------*/
/* Compile-time checks                                                 */
/*---------------------------------------------------------------------*/
#if (SC_DEV_SERIAL && BSP_SERIAL)
    #if(SC_DEV_SERIAL > SC_DEVMAX)
        #error "SC_DEV_SERIAL cannot be > SC_DEVMAX"
    #endif
#endif
#if SC_DEV_TIMER
    #if(SC_DEV_TIMER > SC_DEVMAX)
        #error "SC_DEV_TIMER cannot be > SC_DEVMAX"
    #endif
    #if (!SC_PSOS && !SC_PSOSM)
        #error "Must have pSOS+ or pSOS+m in system to use tick timer!"
    #endif
#endif
#if SC_DEV_RAMDISK
    #if(SC_DEV_RAMDISK > SC_DEVMAX)
        #error "SC_DEV_RAMDISK cannot be > SC_DEVMAX"
    #endif
#endif
#if (SC_DEV_SCSI && BSP_SCSI)
    #if(SC_DEV_SCSI > SC_DEVMAX)
        #error "SC_DEV_SCSI cannot be > SC_DEVMAX"
    #endif
#endif
#if (SC_DEV_TFTP)
    #if(SC_DEV_TFTP > SC_DEVMAX)
        #error "SC_DEV_TFTP cannot be > SC_DEVMAX"
    #endif
#endif

/*---------------------------------------------------------------------*/
/* External function declarations                                      */
/*---------------------------------------------------------------------*/
extern ULONG Print(char *format, ...);

#if !BSP_NEW_SERIAL
    extern void SerialSetup(ULONG, ULONG, ULONG);
#endif

#define MAGIC 0x05291989
#define ALIGN(addr, boundary) ((addr + boundary - 1) & ~(boundary - 1))

extern UCHAR FreeMemStart[];
#if (__ghs || _DIAB_TOOL)
extern UCHAR TextEnd[];
extern UCHAR DataStart[];
extern UCHAR DataEnd[];
#endif	/* __ghs || _DIAB_TOOL */

const char MemErrMsg[] =
  "System Initialization Failed: insufficient memory available!";

NV_Parms NVVars;

#define  PROBE_CON_SER_PORT  SC_PROBE_CONSOLE

#if BSP_NEW_SERIAL
    /*-----------------------------------------------------------------*/
    /* Set up the non pSOS port array.                                 */
    /*-----------------------------------------------------------------*/
    int Non_pSOSChan[SC_NumNon_pSOSChan+2];
    int NumNon_pSOSChan;
    int SysBaud;
    USHORT SysConsole;
#endif

    int Non_pSOSChan[SC_NumNon_pSOSChan+2];
    int NumNon_pSOSChan;
    int SysBaud;
    USHORT SysConsole;

extern UCHAR *BspSetup(UCHAR *,  NODE_CT *);
extern UCHAR *PnaSetup(UCHAR *,  NODE_CT *);
#if ((!SC_PNA) && (SC_PNET))
extern UCHAR *PnetSetup(UCHAR *,  NODE_CT *);
#endif
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 *PlmSetup(UCHAR *,  NODE_CT *);
#if SC_POSIX
extern UCHAR *PosixSetup(UCHAR *,  NODE_CT *);
#endif

#if (SC_PROFILER)
extern void ProfilerSysStartCO(void);
#endif
#if (SC_RTEC)
extern void RtecSysStartCO(void);
#endif
extern void BspSysStartCO(void);
extern void PsosSysStartCO(void);
#if ((!SC_PNA) && (SC_PNET))
extern void PnetSysStartCO(void);
#endif
#if SC_POSIX
extern void PosixSysStartCO(void);
#endif

#if ((SC_PSOS == USEROM) || (SC_PSOSM == USEROM))

#if (SC_BOOT_ROM == YES)
#error "Must not use SC_PSOS or SC_PSOSM USEROM with SC_BOOT_ROM code"
#endif /* SC_BOOT_ROM */

ULONG (*pSOS_tmp)(void);
#else
extern void PSOS_INIT(void);
#endif

#if (SC_PROBE == USEROM)

#if (SC_BOOT_ROM == YES)
#error "Must not use SC_PROBE USEROM with SC_BOOT_ROM code"
#endif /* SC_BOOT_ROM */

ULONG (*pROBE_tmp)(void);
#else
extern long pROBE_Init(void);  /* pROBE+ initialization entry point */
#endif
ULONG result = 0; /* used as return value in 1284 function */


static const struct SD_parms SysVarsDefaults =
    {
    SC_SD_DEBUG_MODE,
    RBUG_DRV_SERIAL, 
    0, 0,
    SD_STARTUP_DELAY,
    SD_DEF_BAUD,
    SD_VME_BASE_ADDR,
    SD_DEF_GTWY_IP,
    SD_LAN1,
    0, 0, 0,
    SD_LAN1_IP,
    SD_LAN1_SUBNET_MASK,
    SD_SM_NODE,
    SD_NISM,
    0, 0, 0,
    SD_NISM_IP,
    SD_NISM_SUBNET_MASK,
    SD_NISM_DIRADDR,
    SD_KISM,
    SD_KISM_DIRADDR,
    };


#if BSP_NEW_SERIAL
                                                    
    extern UCHAR *GSblkSetup(UCHAR *, ULONG, ULONG *);
    extern void SerialInit(void);

    /*-----------------------------------------------------------------*/
    /* Global variables set here used by dipi                          */
    /*-----------------------------------------------------------------*/
    int ProbeCon, ProbeHst;

#endif
    /*-----------------------------------------------------------------*/
    /* Global variables set here used by dipi                          */
    /*-----------------------------------------------------------------*/
    int ProbeCon, ProbeHst;


#if !BSP_NEW_SERIAL && BSP_PARALLEL
  extern UCHAR *GSblkSetup(UCHAR *, ULONG, ULONG *);
#endif
 
NODE_CT *oldanchor;
NODE_CT NodeCfg;

int probe_active = FALSE;
/***********************************************************************/
/*  SysVectChk: Check whether or not a particular vector should be     */
/*              set or not.                                            */
/*      INPUTS: VectorOffset: offset of vector to check                */
/*                                                                     */
/*     RETURNS: 1 if OK to modify the vector, 0 if it should be left   */
/*              alone.                                                 */
/*       NOTES: This should be called by SysSetVector() so that it can */
/*              avoid modifying vectors that the user does not want    */
/*              changed.                                               */
/*              The user can specify that vectors should be left       */
/*              untouched by defining *one* of the following symbols   */
/*              in sys_conf.h: VECTORS_SET_ONLY or VECTORS_DONT_SET.   */
/*              If one of these symbols is defined its value should    */
/*              be a list of vector offsets (such as 0x100, 0x200,     */
/*              etc) separated by commas.  For example:                */
/*                #define VECTORS_DONT_SET  0x400, 0x800               */
/*              would prevent the system from modifying vectors 0x400  */
/*              and 0x800.                                             */
/*                                                                     */
/***********************************************************************/
#if defined(VECTORS_SET_ONLY) && defined(VECTORS_DONT_SET)
#error "Can't specify both VECTORS_SET_ONLY and VECTORS_DONT_SET"
#endif
unsigned long SysVectChk(unsigned long VectorOffset)
{
  UNUSED_PARAMETER(VectorOffset);
#if defined(VECTORS_SET_ONLY)
    static unsigned long SpecialVectors[] = {VECTORS_SET_ONLY, 0};
    unsigned long *p;
 
    p = SpecialVectors;
    while (*p != 0)
        if (*p++ == VectorOffset) return 1;
    return 0;
#elif defined(VECTORS_DONT_SET)
    static unsigned long SpecialVectors[] = {VECTORS_DONT_SET, 0};
    unsigned long *p;
 
    p = SpecialVectors;
    while (*p != 0)
        if (*p++ == VectorOffset) return 0;
    return 1;
#else
    return 1;
#endif
}

/*******************************************************************/
/*    CheckSum: Calculate the checksum for a STORAGE structure     */
/*                                                                 */
/*      INPUTS: StructPtr - ptr to structure to checksum           */
/*              StructSize - size of structure in bytes            */
/*     RETURNS: Checksum for the structure                         */
/*        NOTE: We consider the "checksum" to be simply the sum of */
/*              the individual bytes in the structure              */
/*                                                                 */
/*******************************************************************/
ULONG CheckSum(void *StructPtr, int StructSize)
{
UCHAR *p = (UCHAR *)StructPtr;
USHORT tot = 0;

while(StructSize--)
    tot += *p++ & 0xFF;
return tot;
}

⌨️ 快捷键说明

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