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

📄 gfdfilesys.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
    
    /* Initialize the array of ready HISR list pointers.  */
    for (i = 0; i < TC_HISR_PRIORITIES; i++)
    {
        TCD_Active_HISR_Heads[i] =  NU_NULL;
        TCD_Active_HISR_Tails[i] =  NU_NULL;
    }

    /* Initialize the LISR interrupt control data structures.  */
    for (i = 0; i < NU_MAX_VECTORS; i++)
        TCD_Registered_LISRs[i] =  NU_FALSE;
        
    for (i = 0; i < NU_MAX_LISRS; i++)
        TCD_LISR_Pointers[i] =  NU_NULL;

    /* Initialize the interrupt processing variables.  */
    TCD_Interrupt_Count =  0;
    TCD_Stack_Switched =   0;
    
    /* Initialize the task control protection structures.  */
    TCD_List_Protect.tc_tcb_pointer =           NU_NULL;
    TCD_System_Protect.tc_tcb_pointer =         NU_NULL;
    TCD_LISR_Protect.tc_tcb_pointer =           NU_NULL;
    TCD_HISR_Protect.tc_tcb_pointer =           NU_NULL;

    /* Initialize the interrupt level to enable all interrupts.  */
    TCD_Interrupt_Level =  NU_ENABLE_INTERRUPTS;
}
VOID  MBI_Initialize(VOID)
{

    /* Initialize the created mailbox list to NU_NULL.  */
    MBD_Created_Mailboxes_List =  NU_NULL;
    
    /* Initialize the total number of created mailboxes to 0.  */
    MBD_Total_Mailboxes =  0;
    
    /* Initialize the list protection structure.  */
    MBD_List_Protect.tc_tcb_pointer =      NU_NULL;
}
void  QUI_Initialize(VOID)
{

    /* Initialize the created queue list to NU_NULL.  */
    QUD_Created_Queues_List =  NU_NULL;
    
    /* Initialize the total number of created queues to 0.  */
    QUD_Total_Queues =  0;
    
    /* Initialize the list protection structure.  */
    QUD_List_Protect.tc_tcb_pointer =      NU_NULL;
}
VOID  PII_Initialize(VOID)
{

    /* Initialize the created pipe list to NU_NULL.  */
    PID_Created_Pipes_List =  NU_NULL;
    
    /* Initialize the total number of created pipes to 0.  */
    PID_Total_Pipes =  0;
    
    /* Initialize the list protection structure.  */
    PID_List_Protect.tc_tcb_pointer =      NU_NULL;
}
VOID  SMI_Initialize(VOID)
{

    /* Initialize the created semaphore list to NU_NULL.  */
    SMD_Created_Semaphores_List =  NU_NULL;
    
    /* Initialize the total number of created semaphores to 0.  */
    SMD_Total_Semaphores =  0;
    
    /* Initialize the list protection structure.  */
    SMD_List_Protect.tc_tcb_pointer =      NU_NULL;
}
void  EVI_Initialize(VOID)
{

    /* Initialize the created event group list to NU_NULL.  */
    EVD_Created_Event_Groups_List =  NU_NULL;
    
    /* Initialize the total number of created event groups to 0.  */
    EVD_Total_Event_Groups =  0;
    
    /* Initialize the list protection structure.  */
    EVD_List_Protect.tc_tcb_pointer =      NU_NULL;
}
VOID  PMI_Initialize(VOID)
{

    /* Initialize the created partition pool list to NU_NULL.  */
    PMD_Created_Pools_List =  NU_NULL;
    
    /* Initialize the total number of created pools to 0.  */
    PMD_Total_Pools =  0;
    
    /* Initialize the list protection structure.  */
    PMD_List_Protect.tc_tcb_pointer =      NU_NULL;
}
VOID  DMI_Initialize(VOID)
{

    /* Initialize the created dynamic memory pool list to NU_NULL.  */
    DMD_Created_Pools_List =  NU_NULL;
    
    /* Initialize the total number of created pools to 0.  */
    DMD_Total_Pools =  0;
    
    /* Initialize the list protection structure.  */
    DMD_List_Protect.tc_tcb_pointer =      NU_NULL;
}

void  IOI_Initialize(VOID)
{

    /* Initialize the created I/O driver list to NU_NULL.  */
    IOD_Created_Drivers_List =  NU_NULL;
    
    /* Initialize the total number of created I/O drivers to 0.  */
    IOD_Total_Drivers =  0;
    
    /* Initialize the list protection structure.  */
    IOD_List_Protect.tc_tcb_pointer =      NU_NULL;
}

VOID    CSC_Place_On_List(CS_NODE **head, CS_NODE *new_node)                      
{                                                                      
                                                                       
    /* Determine if the list in non-empty.  */                         
    if (*head)                                                         
    {                                                                  
                                                                       
        /* The list is not empty.  Add the new node to the end of      
           the list.  */                                               
        new_node -> cs_previous =               (*head) -> cs_previous;
        (new_node -> cs_previous) -> cs_next =  new_node;              
        new_node -> cs_next =                   (*head);               
        (new_node -> cs_next) -> cs_previous =  new_node;              
    }                                                                  
    else                                                               
    {                                                                  
                                                                       
        /* The list is empty, setup the head and the new node.  */     
        (*head) =  new_node;                                           
        new_node -> cs_previous =  new_node;                           
        new_node -> cs_next =      new_node;                           
    }                                                                  
}
VOID    CSC_Priority_Place_On_List(CS_NODE **head, CS_NODE *new_node)                                                                             
{                                                                           
                                                                            
CS_NODE         *search_ptr;                /* List search pointer       */ 
                                                                            
    /* Determine if the list in non-empty.  */                              
    if (*head)                                                              
    {                                                                       
                                                                            
        /* Search the list to find the proper place for the new node.  */   
        search_ptr =  (*head);                                              
                                                                            
        /* Check for insertion before the first node on the list.  */       
        if (search_ptr -> cs_priority > new_node -> cs_priority)            
        {                                                                   
                                                                            
            /* Update the head pointer to point at the new node.  */        
            (*head) =  new_node;                                            
        }                                                                   
        else                                                                
        {                                                                   
                                                                            
            /* We know that the new node is not the highest priority and    
               must be placed somewhere after the head pointer.  */         
                                                                            
            /* Move search pointer up to the next node since we are trying  
               to find the proper node to insert in front of. */            
            search_ptr =  search_ptr -> cs_next;                            
            while ((search_ptr -> cs_priority <= new_node -> cs_priority) &&
                   (search_ptr != (*head)))                                 
            {                                                               
                                                                            
                /* Move along to the next node.  */                         
                search_ptr =  search_ptr -> cs_next;                        
            }                                                               
        }                                                                   
                                                                            
        /* Insert before search pointer.  */                                
        new_node -> cs_previous =               search_ptr -> cs_previous;  
        (new_node -> cs_previous) -> cs_next =  new_node;                   
        new_node -> cs_next =                   search_ptr;                 
        (new_node -> cs_next) -> cs_previous =  new_node;                   
    }                                                                       
    else                                                                    
    {                                                                       
                                                                            
        /* The list is empty, setup the head and the new node.  */          
        (*head) =  new_node;                                                
        new_node -> cs_previous =  new_node;                                
        new_node -> cs_next =      new_node;                                
    }                                                                       
}  
VOID    CSC_Remove_From_List(CS_NODE **head, CS_NODE *node)
{

    /* Determine if this is the only node in the system.  */
    if (node -> cs_previous == node)
    {
    
        /* Yes, this is the only node in the system.  Clear the node's
           pointers and the head pointer.  */
        (*head) =              NU_NULL;
    }
    else
    {
    
        /* Unlink the node from a multiple node list.  */
        (node -> cs_previous) -> cs_next =  node -> cs_next;
        (node -> cs_next) -> cs_previous =  node -> cs_previous;
        
        /* Check to see if the node to delete is at the head of the
           list. */
        if (node == *head)
        
            /* Move the head pointer to the node after.  */
            *head =  node -> cs_next;
    }
}

STATUS  EVC_Create_Event_Group(NU_EVENT_GROUP *event_group_ptr, CHAR *name)
{
	UW psr;
	R1 EV_GCB      *event_group;                /* Event control block ptr   */
	INT             i;                          /* Working index variable    */


    /* Move input event group pointer into internal pointer.  */
    event_group =  (EV_GCB *) event_group_ptr;



    /* First, clear the event group ID just in case it is an old Event Group
       Control Block.  */
    event_group -> ev_id =             0;
    
    /* Fill in the event group name.  */
    for (i = 0; i < NU_MAX_NAME; i++)
        event_group -> ev_name[i] =  name[i];    

    /* Clear the flags of the event group.  */
    event_group -> ev_current_events =  0;
    
    /* Clear the suspension list pointer.  */
    event_group -> ev_suspension_list =  NU_NULL;

    /* Clear the number of tasks waiting on the event_group counter.  */
    event_group -> ev_tasks_waiting =  0;
    
    /* Initialize link pointers.  */
    event_group -> ev_created.cs_previous =    NU_NULL;
    event_group -> ev_created.cs_next =        NU_NULL;

    /* Protect against access to the list of created event_groups.  */
   
    psr = ent_cri();
	

    i =(INT)(event_group_ptr - &NUFP_Events[0])/sizeof(NU_EVENT_GROUP);
    /* At this point the event_group is completely built.  The ID can now be 
       set and it can be linked into the created event_group list.  */
    event_group -> ev_id =  EV_EVENT_ID;

    /* Link the event group into the list of created event groups and 
       increment the total number of event groups in the system.  */ 
    CSC_Place_On_List(&EVD_Created_Event_Groups_List,
                                        &(event_group -> ev_created));
    EVD_Total_Event_Groups++;
    if((i >= 0) && (i <= 20)){
	    g_sFlgcb[i+8].uhFlgPtn = 0;
	    g_sFlgcb[i+8].uhWaiPtn = 0;    // wait pattern 
	    g_sFlgcb[i+8].bWaiMode = 0;    // wait flag mode 
    }
    /* Release protection against access to the list of created event 
       groups.  */
    ret_cri(psr);

    /* Return successful completion.  */
    return(NU_SUCCESS);
} 
STATUS  EVC_Retrieve_Events(NU_EVENT_GROUP *event_group_ptr, 
                        UNSIGNED requested_events, OPTION operation, 
                        UNSIGNED *retrieved_events, UNSIGNED suspend)
{
	UW psr;
	R1 EV_GCB      *event_group;                /* Event control block ptr   */
	R2 EV_SUSPEND  *suspend_ptr;                /* Pointer to suspend block  */
	EV_SUSPEND      suspend_block;              /* Suspension block          */
	R3 UNSIGNED     compare;                    /* Event comparison variable */
	TC_TCB         *task;                       /* Pointer to task           */
	STATUS          status;                     /* Completion status         */
	INT i;
	static UINT flgptn;
    /* Move input event group pointer into internal pointer.  */
    	event_group =  (EV_GCB *) event_group_ptr;
	psr = ent_cri();
    	i =(INT)(event_group_ptr - &NUFP_Events[0])/sizeof(NU_EVENT_GROUP);
	ret_cri(psr);
	twai_flg(&flgptn,(i+9), 0x000000FF,TWF_ORW, suspend);
  
} 
STATUS  EVC_Set_Events(NU_EVENT_GROUP *event_group_ptr, UNSIGNED events, 
                                                OPTION operation)
{
	UW psr;
	R1 EV_GCB      *event_group;                /* Event control block ptr   */
	R2 EV_SUSPEND  *suspend_ptr;                /* Pointer to suspension blk */
	R3 EV_SUSPEND  *next_ptr;                   /* Pointer to next suspend   */
	R4 EV_SUSPEND  *last_ptr;                   /* Last suspension block ptr */
	UNSIGNED        consume;                    /* Event flags to consume    */
	UNSIGNED        compare;                    /* Event comparison variable */
	INT             preempt;                    /* Preemption required flag  */
	static UINT flgptn;
	INT i;
    /* Move input event group pointer into internal pointer.  */
    event_group =  (EV_GCB *) event_group_ptr;
      psr = ent_cri();
      i =(INT)(event_group_ptr - &NUFP_Events[0])/sizeof(NU_EVENT_GROUP);
      ret_cri(psr);
      set_flg((i+9), 0);
}

STATUS  DMC_Allocate_Memory(NU_MEMORY_POOL *pool_ptr, VOID **return_pointer, 
                                        UNSIGNED size, UNSIGNED suspend)
{
	UW psr;
	R1 DM_PCB      *pool;                       /* Pool control block ptr    */
	R2 DM_SUSPEND  *suspend_ptr;                /* Pointer to suspend block  */

⌨️ 快捷键说明

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