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

📄 sysinit.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的操作系统pSOS。包括全部源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/***********************************************************************/
/*                                                                     */
/*   MODULE:  sysinit.c   1.72						                   */
/*   DATE:    2002-03-18                                               */
/*   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 _psos_slow_entry();
extern char _psos_version_str[];

extern void pROBE_Init(void);	/* pROBE+ initialization entry point */

#ifndef TIMEDOCTOR_ENABLE
extern void root(void);
#else
extern void monitorroot(void);
extern void CO_switch(ULONG oldtid, void *entering_tcb,
		      ULONG newtid, void *leaving_tcb);
#endif

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 iojent 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) _psos_slow_entry;
    pSOSHead.version_str_ptr = (INT32) _psos_version_str;

    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;

static void** global_tsdanchor;

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;
    PsosCfg.kc_nio              = SC_DEVMAX + 1;
    PsosCfg.kc_iojtable         = PsosIO;
#ifndef TIMEDOCTOR_ENABLE
    PsosCfg.kc_rootsadr         = root;
#else
    PsosCfg.kc_rootsadr         = monitorroot;
#endif
    PsosCfg.kc_rootsstk         = KC_ROOTSSTK;
    PsosCfg.kc_rootustk         = KC_ROOTUSTK;
    PsosCfg.kc_rootmode         = KC_ROOTMODE;
    PsosCfg.kc_startco          = TaskStartCallout;

#ifdef KC_DELETECO
    PsosCfg.kc_deleteco         = KC_DELETECO;
#endif

#ifndef TIMEDOCTOR_ENABLE
#ifdef KC_SWITCHCO
    PsosCfg.kc_switchco         = KC_SWITCHCO;
#endif
#else
    PsosCfg.kc_switchco         = CO_switch;

⌨️ 快捷键说明

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