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

📄 pc_users.c

📁 移植Nuclues_RTC到coldfire5307在diab下编译通过
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************************************
*                                                                       
*       Copyright (c) 2001 by Accelerated Technology, Inc.              
*                                                                       
*  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 recipient of     
*     this software implicitly accepts the terms of the license.        
*                                                                       
*                                                                       
*************************************************************************

*************************************************************************
* FILE NAME                                     VERSION                 
*                                                                       
*       PC_USERS.C                              FILE  2.2
*                                                                       
* COMPONENT                                                             
*                                                                       
*       Nucleus File                                                    
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       Manage the fs_user structure code.                              
*                                                                       
* DATA STRUCTURES                                                       
*                                                                       
*       None.                                                           
*                                                                       
* FUNCTIONS                                                             
*                                                                       
*       pc_free_all_users                   Free all cwd objects for a  
*                                            drive.                     
*       NU_Become_File_User                 Register a task as an RTFS  
*                                            user.                      
*       NU_Release_File_User                Register task as no longer  
*                                            an RTFS user.              
*       NU_Check_File_User                  Check if task is a          
*                                            registered RTFS user.      
*       fs_current_user_structure           Current task's              
*                                            FILE_SYSTEM_USER structure 
*                                            pointer.                   
*                                                                       
* DEPENDENCIES                                                          
*                                                                       
*       nucleus.h                           System definitions      
*       pcdisk.h                            File common definitions     
*                                                                       
*************************************************************************/

#include    "nucleus.h"
#include    "pcdisk.h"

extern PFILE_SYSTEM_USER    user_heap;
FILE_SYSTEM_USER            default_user;


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       pc_free_all_users                                               
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       Free all cwd objects for a drive.                               
*                                                                       
* AUTHOR                                                                
*                                                                       
*       Takahiro Takahashi
*                                                                       
* INPUTS                                                                
*                                                                       
*       driveno                             Drive丂number               
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       None.                                                           
*                                                                       
*************************************************************************/
VOID pc_free_all_users(INT16 driveno)
{
PFILE_SYSTEM_USER   p; 
INT16               i;


    p = user_heap;
    for (i = 0; i < NUM_USERS; i++, p++)
    {
        if (p->lcwd[driveno])
        {
            pc_freeobj(p->lcwd[driveno]);
            p->lcwd[driveno] = NULL;
        }
    }
}


#if (NUM_USERS > 1)
/* Implement these macros for your kernel*/
/* Return CONTEXT_HANDLE_TYPE that uniquely represents the current task 
   May not be zero. */
/* NUCLEUS - We set GET_CONTEXT_HANDLE() to (NU_Current_Task_ID()+1) so
   we are sure not to get a zero.  If we are using Nucleus PLUS, the task
   ID must be converted to a task pointer.  NUFP_Current_Task_ID performs
   this conversion.  */

extern VOID NUFP_Remove_User(signed int task_id);
#define GET_CONTEXT_HANDLE() (NUFP_Current_Task_ID()+1)


/* Put the (UINT16) X into the task control block of the current task */

/* NUCLEUS - We use an array of ints to map nucleus tasks to rtfs user 
   structures. This is done because RTFS user structures use a lot of 
   core (200 or so bytes). And it it not necessary to have one RTFS user
   structure per nucleus task. We only need one structure per file 
   system user. When a nucleus task calls NU_Become_File_User() it will
   get a map index in this table. GET_RTFS_TASKNO() and SET_RTFS_TASKNO()
   are macros described below */

/* This array is allocated in pc_memory_init(). It has a slot for every
   Nucleus task */
extern INT16 *nu_to_rtfs_task_map;

/*  Nucleus PLUS uses task pointers not IDs.  The call to NUFP_Current_Task_ID
    makes the appropriate conversion.  */
#define SET_RTFS_TASKNO(X) nu_to_rtfs_task_map[NUFP_Current_Task_ID()] = X
/* Return the UINT16 assigned to this task by SET_RTFS_TASK_NO() If  
   SET_RTFS_TASK_NO() was never called, this routine may return a random value*/
#define GET_RTFS_TASKNO()  nu_to_rtfs_task_map[NUFP_Current_Task_ID()]

extern PFILE_SYSTEM_USER user_heap;


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       NU_Become_File_User                                             
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       In a multitasking environment this function must be called by a 
*       task before it may use the API. This reserves a user structure  
*       from the pool of user structures for the task.                  
*                                                                       
* AUTHOR                                                                
*                                                                       
*       Takahiro Takahashi
*                                                                       
* INPUTS                                                                
*                                                                       
*       None.                                                           
*                                                                       
* OUTPUTS                                                               
*                                                                       
*      YES if the task may use the file system                          
*      NO  if too many users already.                                   
*                                                                       
*************************************************************************/
INT NU_Become_File_User(VOID)                                   /*__fn__*/
{
UINT16              i;
PFILE_SYSTEM_USER   p;
OPTION              preempt_status;
CONTEXT_HANDLE_TYPE context_handle;


    preempt_status = NU_Change_Preemption(NU_NO_PREEMPT);
    p = user_heap;
    if (p)
    {
        context_handle = GET_CONTEXT_HANDLE();
        for (i = 0; i < NUM_USERS; i++, p++)

⌨️ 快捷键说明

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