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

📄 gfdfilesys.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:


/* DMD_List_Protect is a list protection structure used to block any other
   thread from access to the created dynamic memory pool list.  */
   
TC_PROTECT      DMD_List_Protect;

/* IOD_Created_Drivers_List is the head pointer of the linked list of 
   created I/O drivers.  If the list is NU_NULL, there are no I/O drivers
   created.  */
   
CS_NODE        *IOD_Created_Drivers_List;


/* IOD_Total_Drivers contains the number of currently created 
   I/O drivers.  */

UNSIGNED        IOD_Total_Drivers;


/* IOD_List_Protect is a list protection structure used to block any other
   thread from access to the created drivers list.  */
   
TC_PROTECT      IOD_List_Protect;

UINT32  TLS_Unused_Parameter;
UNSIGNED SMD_Total_Semaphores;

VOID    CSC_Place_On_List(CS_NODE **head, CS_NODE *new_node);
VOID    CSC_Priority_Place_On_List(CS_NODE **head, CS_NODE *new_node); 
VOID    CSC_Remove_From_List(CS_NODE **head, CS_NODE *node); 
STATUS  EVC_Retrieve_Events(NU_EVENT_GROUP *event_group_ptr, 
                        UNSIGNED requested_events, OPTION operation, 
                        UNSIGNED *retrieved_events, UNSIGNED suspend);  
STATUS  EVC_Set_Events(NU_EVENT_GROUP *event_group_ptr, UNSIGNED events, 
                                                OPTION operation);
STATUS  SMC_Obtain_Semaphore(NU_SEMAPHORE *semaphore_ptr,  UNSIGNED suspend);
STATUS  SMC_Release_Semaphore(NU_SEMAPHORE *semaphore_ptr);
STATUS  DMC_Create_Memory_Pool(NU_MEMORY_POOL *pool_ptr, CHAR *name, 
                        VOID *start_address, UNSIGNED pool_size, 
                        UNSIGNED min_allocation, OPTION suspend_type);
STATUS  DMC_Deallocate_Memory(VOID *memory);
STATUS  PMC_Allocate_Partition(NU_PARTITION_POOL *pool_ptr, 
                                VOID **return_pointer, UNSIGNED suspend);
STATUS  PMC_Create_Partition_Pool(NU_PARTITION_POOL *pool_ptr, CHAR *name, 
                        VOID *start_address, UNSIGNED pool_size, 
                        UNSIGNED partition_size, OPTION suspend_type);
STATUS  PMC_Deallocate_Partition(VOID *partition);
STATUS  SMC_Create_Semaphore(NU_SEMAPHORE *semaphore_ptr, CHAR *name, 
                           UNSIGNED initial_count, OPTION suspend_type);
void *TCT_Current_Thread();
/********************************************************************************************************/
//                           PRROGRAM
/********************************************************************************************************/
VOID NU_Printf(CHAR *string, ...) 
{
	UNUSED_PARAMETER(string);
}


/*************************************************************************/
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the change preemption   */
/*      service.  If the current thread is not a task thread, this       */
/*      request is ignored.                                              */
/*                                                                       */
/*************************************************************************/
OPTION   TCSE_Change_Preemption(OPTION preempt)
{
	OPTION old_preempt;
	UW psr;
	psr = ent_cri();
	if(g_ubSysStat & 0x1){
		old_preempt = NU_NO_PREEMPT;
	}else{
		old_preempt = NU_PREEMPT;
	}
	if(preempt == NU_NO_PREEMPT){
		dis_dsp();
	}else{
		ena_dsp();
	}
	ret_cri(psr);
/* Return the previous preemption posture.  */
    return(old_preempt);
}

/*******************************************************************************************************************/
/*                                             semaphore                                                           */              
/*******************************************************************************************************************/


/*************************************************************************/
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the create semaphore function.                                */
/*************************************************************************/
STATUS  SMCE_Create_Semaphore(NU_SEMAPHORE *semaphore_ptr, CHAR *name,UNSIGNED initial_count, OPTION suspend_type)
{
	SM_SCB         *semaphore;                  /* Semaphore control blk ptr */
STATUS          status;                     /* Completion status         */


    /* Move input semaphore pointer into internal pointer.  */
    semaphore =  (SM_SCB *) semaphore_ptr;

    /* Check for a NULL semaphore pointer or an already created semaphore.  */
    if ((semaphore == NU_NULL) || (semaphore -> sm_id == SM_SEMAPHORE_ID))
    
        /* Invalid semaphore control block pointer.  */
        status =  NU_INVALID_SEMAPHORE;
        
    else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY))
    
        /* Invalid suspension type.  */
        status =  NU_INVALID_SUSPEND;
        
    else
    
        /* Call the actual service to create the semaphore.  */
        status =  SMC_Create_Semaphore(semaphore_ptr, name, initial_count,
                                                        suspend_type);
        
    /* Return completion status.  */
    return(status);
}
//pc_memory.c
/*************************************************************************/
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the obtain semaphore function.                                */
/*************************************************************************/
STATUS  SMCE_Obtain_Semaphore(NU_SEMAPHORE *semaphore_ptr, UNSIGNED suspend)
{
	
       SMC_Obtain_Semaphore(semaphore_ptr, suspend);
   

}
//pc_locks.c
/*************************************************************************/
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the release semaphore function.                               */
/*************************************************************************/
STATUS  SMCE_Release_Semaphore(NU_SEMAPHORE *semaphore_ptr)
{

      SMC_Release_Semaphore(semaphore_ptr);
}
//pc_locks.c
/************************************************************************************************************************/
/*                                                       Thread                                                         */
/************************************************************************************************************************/
VOID  TCCE_Task_Sleep(UNSIGNED ticks)
{
	if (ticks <= 0)
         	return;
	dly_tsk((int)ticks);
}
//pc_locks.c 
VOID  TCCE_Relinquish(VOID)
{
	PRI tskpri;
	
	tskpri = g_pCurTsk->bPriority;
	rot_rdq(tskpri); 
}
//pc_locks.c
NU_TASK  *TCC_Current_Task_Pointer(VOID)
{
	  /* Determine if a task thread is executing.  */
	if ((g_pCurTsk->bPriority > 0) && (g_pCurTsk->bPriority < 8)){  
            	TCD_Current_Thread = (void *)(((int)(g_pCurTsk - (&g_sTskcb[0])))/(sizeof(T_TSKCB)));
        /* Task thread is running, return the pointer.  */
       		return((NU_TASK *) TCD_Current_Thread);
       	}
	else
    
        /* No, task thread is not running, return a NU_NULL.  */
        return(NU_NULL);
}
//nufp.c
/************************************************************************************************************************/
/*                                                   EVENT   															*/
/************************************************************************************************************************/


/*************************************************************************/
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the create event group function.                              */
/*                                                                       */
/*************************************************************************/    
STATUS  EVCE_Create_Event_Group(NU_EVENT_GROUP *event_group_ptr, CHAR *name)
{
EV_GCB         *event_group;                /* Event control block ptr   */
STATUS          status;                     /* Completion status         */


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

    /* Check for a NULL event group pointer or an already created event 
       group.  */
    if ((event_group == NU_NULL) || (event_group -> ev_id == EV_EVENT_ID))
    
        /* Invalid event group control block pointer.  */
        status =  NU_INVALID_GROUP;
        
    else
    
        /* Call the actual service to create the event group.  */
        status =  EVC_Create_Event_Group(event_group_ptr, name);
        
    /* Return completion status.  */
    return(status);
}
//pc_memory.c
/*************************************************************************/
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the set events function.                                      */
/*                                                                       */
/*************************************************************************/
STATUS  EVCE_Set_Events(NU_EVENT_GROUP *event_group_ptr, UNSIGNED events,OPTION operation)
{
	EV_GCB         *event_group;                /* Event control block ptr   */

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

    
}
//pc_locks.c
/*************************************************************************/
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameter supplied  */
/*      to the retrieve events function.                                 */
/*                                                                       */
/*************************************************************************/
STATUS  EVCE_Retrieve_Events(NU_EVENT_GROUP *event_group_ptr,UNSIGNED requested_events, OPTION operation,UNSIGNED *retrieved_events, UNSIGNED suspend) 
{
	EV_GCB         *event_group;                /* Event control block ptr   */
	                 


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

    
          EVC_Retrieve_Events(event_group_ptr, requested_events,
                                        operation, retrieved_events, suspend);

    /* Return the completion status.  */

} 
//pc_locks.c
/***********************************************************************************************************************************/
/*															DYNAMIC MEMORY                                                         */
/***********************************************************************************************************************************/
STATUS  DMCE_Create_Memory_Pool(NU_MEMORY_POOL *pool_ptr, CHAR *name,VOID *start_address, UNSIGNED pool_size,UNSIGNED min_allocation, OPTION suspend_type)
{
	DM_PCB         *pool;                       /* Pool control block ptr    */
STATUS          status;                     /* Completion status         */
UNSIGNED        adjusted_min;               /* Adjusted size of minimum  */
UNSIGNED        adjusted_pool;              /* Adjusted size of pool     */


    /* Move input pool pointer into internal pointer.  */
    pool =  (DM_PCB *) pool_ptr;

    /* Adjust the minimum allocation size to something that is evenly 
       divisible by the number of bytes in an UNSIGNED data type.  */
    adjusted_min = ((min_allocation + sizeof(UNSIGNED) - 1)/sizeof(UNSIGNED)) *
                                                        sizeof(UNSIGNED);

    /* Adjust the pool size to something that is evenly divisible by the 
       number of bytes in an UNSIGNED data type.  */
    adjusted_pool = ((pool_size + sizeof(UNSIGNED) - 1)/sizeof(UNSIGNED)) *
                                                        sizeof(UNSIGNED);

    /* Check for a NULL dynamic memory pool control block pointer or a control
       block that is already created.  */
    if ((pool == NU_NULL) || (pool -> dm_id == DM_DYNAMIC_ID))
    
        /* Invalid dynamic memory pool control block pointer.  */
        status =  NU_INVALID_POOL;
        
    else if (start_address == NU_NULL)
    
        /* Invalid memory pointer.  */
        status =  NU_INVALID_MEMORY;
        
    else if ((adjusted_min == 0) || 
                ((adjusted_min + (2 * DM_OVERHEAD)) > adjusted_pool))
    
        /* Pool could not even accommodate one allocation.  */
        status =  NU_INVALID_SIZE;
        
    else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY))
    
        /* Invalid suspension type.  */
        status =  NU_INVALID_SUSPEND;
        
    else
    
        /* Call the actual service to create the dynamic memory pool.  */
        status =  DMC_Create_Memory_Pool(pool_ptr, name, start_address, 
                                    pool_size, min_allocation, suspend_type);
        
    /* Return completion status.  */
    return(status);
}

STATUS  DMCE_Allocate_Memory(NU_MEMORY_POOL *pool_ptr, VOID **return_pointer,UNSIGNED size, UNSIGNED suspend)
{
	DM_PCB         *pool;                       /* Pool control block ptr    */
	STATUS          status;                     /* Completion status         */


    /* Move input pool pointer into internal pointer.  */
    pool =  (DM_PCB *) pool_ptr;

    /* Determine if dynamic memory pool pointer is invalid.  */
    if (pool == NU_NULL)
    

⌨️ 快捷键说明

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