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

📄 pc_users.c

📁 基于nucleus操作系统的GPRS无线数据传输终端全套源文件。包括支持ARM7的BSP,操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
            if (p->context_handle == context_handle)
                return(YES);

        p = user_heap;
        for (i = 0; i < NUM_USERS; i++, p++)
        {
            if (!p->context_handle)
            {
                pc_memfill(p, sizeof(FILE_SYSTEM_USER), (UINT8) 0);
                p->context_handle = context_handle;
                SET_RTFS_TASKNO(i);
                NU_Change_Preemption(preempt_status);
                return(YES);
            }
        }
    }
    NU_Change_Preemption(preempt_status);

    return(NO);
}


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       NU_Release_File_User                                            
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       When a task is through with RTFS it should call here. This frees
*       up a user structure so it may be used by other tasks callers to 
*       (NU_Become_File_User).                                          
*                                                                       
*       Subsequent API calls will fail if this routine has been called. 
*                                                                       
* AUTHOR                                                                
*                                                                       
*       Takahiro Takahashi
*                                                                       
* INPUTS                                                                
*                                                                       
*       None.                                                           
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       None.                                                           
*                                                                       
*************************************************************************/
VOID NU_Release_File_User(VOID)                                 /*__fn__*/
{
INT16       driveno;


    if (NU_Check_File_User())
    {
        for (driveno = 0; driveno < NDRIVES; driveno++)
        {
            if (fs_user->lcwd[driveno])
            {
                pc_freeobj(fs_user->lcwd[driveno]);
                fs_user->lcwd[driveno] = NULL;
            }
        }
        pc_memfill(fs_user, sizeof(FILE_SYSTEM_USER), (UINT8) 0);

        /*  Release the Task Pointer to Task ID conversion.  */
        NUFP_Remove_User(GET_RTFS_TASKNO());
    }
}

/* INT NU_Check_File_User() - 

   Description:

   Returns:
*/


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       NU_Check_File_User                                              
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       The API prolog code calls this if ENABLE_MULTI_TASKING is turned
*       on. If the the current task is registered as an RTFS user it    
*       returns YES otherwise it returns NO and the PROLOG code causes  
*       the API call to fail.                                           
*                                                                       
* AUTHOR                                                                
*                                                                       
*       Takahiro Takahashi
*                                                                       
* INPUTS                                                                
*                                                                       
*       None.                                                           
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       YES                                 if the task may use the file
*                                            system.                    
*       NO                                  if not registered.          
*                                                                       
*************************************************************************/
INT NU_Check_File_User(VOID)                                    /*__fn__*/
{
UINT16      i;


    i = GET_RTFS_TASKNO();
    if ( (i < NUM_USERS) &&
         (user_heap[i].context_handle ==  GET_CONTEXT_HANDLE()) )
    {
        return(YES);
    }
    pc_report_error(PCERR_BAD_USER);
    return(NO);
}

#endif      /* NUM_USERS > 1 */


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       fs_current_user_structure                                       
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       This function is called every time the user or the file system  
*       kernel invokes the fs_user macro. It returns the task's private 
*       FILE_SYSTEM_USER structure that was allocated by calling        
*       NU_Become_File_User(). If the program has a bug in it and calls 
*       fs_user without having first called NU_Become_File_User(), a    
*       default structure is returned so the system doesn't crash, and  
*       pc_report_error() is called.                                    
*                                                                       
* AUTHOR                                                                
*                                                                       
*       Takahiro Takahashi
*                                                                       
* INPUTS                                                                
*                                                                       
*       None.                                                           
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       Current task's FILE_SYSTEM_USER structure pointer.              
*                                                                       
*************************************************************************/
PFILE_SYSTEM_USER fs_current_user_structure(VOID)
{

#if (NUM_USERS > 1)
INT16       i;


    i = GET_RTFS_TASKNO();
    if ( (i < NUM_USERS) && (user_heap[i].context_handle ==  GET_CONTEXT_HANDLE()) )
    {
        return(user_heap + i);
    }
    else
    {
        pc_report_error(PCERR_BAD_USER);
        return(&default_user);
    }
#else   /* NUM_USERS == 1 */

    return(&default_user);
#endif
}

⌨️ 快捷键说明

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