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

📄 inp.c

📁 NecluesRTX RTOS的源码
💻 C
字号:
/************************************************************************/
/*                                                                      */
/*         Copyright 1990-1992 by Accelerated Technology                */
/*                                                                      */
/*  PROPRIETARY RIGHTS of Accelerated Technology are involved in the    */
/*  subject matter of this material.  All manufacturing, reproduction,  */
/*  use, and sales rights pertaining to this subject matter are         */
/*  governed by the license agreement.  The buyer or recipient of this  */
/*  package, implicitly accepts the terms of the license.               */
/*                                                                      */
/************************************************************************/

/************************************************************************/
/*                                                                      */
/*  FILE DESCRIPTION                                                    */
/*                                                                      */
/*  This file contains initialization routines that are processor       */
/*  independent, i.e. portable!                                         */
/*                                                                      */
/*  ROUTINES                                                            */
/*                                                                      */
/*      INP_Initialize                      High level initialization   */
/*      INP_Memory_Alloc                    Low level memory allocation */
/*                                                                      */
/*  NOTES                                                               */
/*                                                                      */
/*      None                                                            */
/*                                                                      */
/************************************************************************/

/* Define necessary include files.  */

#include "nu_defs.h"         /* General constants        */
#include "in_extr.h"         /* Data structure defns     */

/* Nucleus Special string.  */
char NU_Special_String[] = 
     "G,M,D,GB,GL,AG,KL,CR,HR,NH,BH,LP,AP,HA,DL,ME,KC,KH,GF,F,ETC";

/* External function definitions.  */
void  SKP_Initialize(struct IN_TASK_DEFINITION_STRUCT *task_list);
void  QM_Initialize(struct IN_QUEUE_DEFINITION_STRUCT *queue_list);
void  EM_Initialize(unsigned int system_event_groups);
void  RM_Initialize(unsigned int system_resources);
void  CLP_Initialize(void);
void  FM_Initialize(struct IN_FIXED_PARTITION_STRUCT *partition_list);
void  VM_Initialize(unsigned int *start_address, unsigned int *end_address);
void  NU_Initialize(void);
void  SKP_Schedule(void);


/************************************************************************/
/*                                                                      */
/*  FUNCTION                                "INP_Initialize"            */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function is used to coordinate the initialization of all   */
/*      the nucleus components.  After the initialization is complete,  */
/*      control is transferred to the scheduling component.             */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*      IND_Initialize                      Low level initialization    */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      SKP_Initialize                      Scheduler initialize        */
/*      QM_Initialize                       Queue initialize            */
/*      EM_Initialize                       Event Management Initialize */
/*      RM_Initialize                       Resource initialize         */
/*      CLP_Initialize                      Clock initialize            */
/*      FM_Initialize                       Fixed Memory initialize     */
/*      NU_Initialize                       Nucleus service initialize  */
/*     [DS_Initialize]                      Development support init    */
/*      VM_Initialize                       Variable Memory Initialize  */
/*      SKP_Schedule                        Scheduler entrance          */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      Configuration Data Definitions in file "IN_DATA.C"              */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*      System Initialized                                              */
/*                                                                      */
/************************************************************************/
void  INP_Initialize()
{

/* If development flags are set the Development Support initialize routine
   needs to be invoked.  */
#if defined(NU_ENABLE_TIMING) || defined(NU_ENABLE_HISTORY)
void               DS_Initialize();
#endif


    /* Call "SKP_Initialize" to initialize the scheduler.  */
    SKP_Initialize(IN_System_Tasks);
    
    /* Call "QM_Initialize" to initialize the system queues.  */
    QM_Initialize(IN_System_Queues);
    
    /* Call "EM_Initialize" to initialize the event group management list. */
    EM_Initialize(IN_System_Event_Groups);

    /* Call "RM_Initialize" to initialize the resource management list.  */
    RM_Initialize(IN_System_Resources);

    /* Call "CLP_Initialize" to initialize the system clock function.  */
    CLP_Initialize();
    
    /* Call "FM_Initialize" to initialize the fixed sized memory allocation
       structures.  */
    FM_Initialize(IN_Fixed_Partitions);

    /* If development flags are set the Development Support initialize routine
       needs to be invoked.  */
    #if defined(NU_ENABLE_TIMING) || defined(NU_ENABLE_HISTORY)
    DS_Initialize();
    #endif

    /* Call "VM_Initialize" to use the rest of available memory for the 
       variable length memory pool.  Note that this component uses up the
       remaining amount of available system memory.  Hence, no other component
       that requires system memory allocation can initialize after this
       routine is called.  */
    VM_Initialize((unsigned int *) IN_Last_Address_Used, 
                  (unsigned int *) IN_Last_Memory_Address);
    

    /* Call "NU_Initialize" to prepare for application task service 
       requests.  Note that this component must be intialized after most
       of the others since it invokes many of the components to get 
       information needed for error checking.  */
    NU_Initialize();

    /* Start the system by invoking "SKP_Schedule."  Note that "SKP_Schedule"
       will never return.  */
    SKP_Schedule();
}                                           /* end of INP_Initialize    */


/************************************************************************/
/*                                                                      */
/*  FUNCTION                                "INP_Memory_Alloc"          */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function is used for initial memory allocation of nucleus  */
/*      data structures.                                                */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*      ***_Initialize                      All components initialize   */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      IND_Major_System_Error              Stop if not enough memory   */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      size                                Amount of memory requested  */
/*      IN_Last_Address_Used                Allocates from last used    */
/*                                          memory address              */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*      return(start_address)               Start of allocation or NULL */
/*      IN_Last_Address_Used                Modifies last used address  */
/*                                                                      */
/************************************************************************/
unsigned int   *INP_Memory_Alloc(unsigned int size)
{

unsigned int      *start_address;           /* Start address of memory  */
unsigned int      *next_avail_address;      /* Next available address   */

    /* Check if the request can be honored.  */
    if ((IN_Last_Address_Used + size - 1) < IN_Last_Memory_Address)
    {

        /* Everything is okay, allocate and adjust the last used pointer to
               the next unsigned int boundary.  */
        start_address =  (unsigned int *) IN_Last_Address_Used;

        /* Compute the next available address.  (Insure that the next
           available address resides on a unsigned int word boundary.  */
        size =  size + sizeof(unsigned int) - 1;
        next_avail_address =  start_address + (size/sizeof(unsigned int));

        /* Finally, put it back.  */
        IN_Last_Address_Used =  (unsigned int) next_avail_address;
    }
    else
    {
        /* Assign the start address, just for the sake of the compilers.  */
        start_address =  NU_NULL;

        /* Error, call system error handler to stop system.  */
        IND_Major_System_Error(NU_NOT_ENOUGH_MEMORY);
    }
    /* Return the value.  */
    return(start_address);
}                                           /* End of INP_Memory_Alloc  */

⌨️ 快捷键说明

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