📄 nufp.c
字号:
/************************************************************************
*
* 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
*
* NUFP.C FILE 2.2
*
* COMPONENT
*
* Nucleus File
*
* DESCRIPTION
*
* This file contains the routines necessary to intitialize
* the Nucleus PLUS environment for file system usage.
*
* DATA STRUCTURES
*
* NUFP_TASK_POINTER Task ID list.
*
* FUNCTIONS
*
* NUFP_Current_Task_ID Replaces the Nucleus PLUS
* Task Pointer to a Task ID.
* NUFP_Remove_User Responsible from removing a
* user from the
* NUFP_TASK_POINTER table.
*
* DEPENDENCIES
*
* nucleus.h System definitions
* pcdisk.h File common definitions
*
*************************************************************************/
#include "nucleus.h"
#include "pcdisk.h"
#if (RAMDISK)
#if (!RAMDISK_FROMPOOL)
#include <malloc.h>
#endif
#endif
/* The following manifests were taken from PCDISK.H since this is the
only place that they are used. These numbers are the overhead that
must be taken into consideration when allocating space for certain
Nucleus PLUS objects. See the code below for usage. */
#define ALLOC_SIZE 20
#define PARTITION_SIZE 20
/* The following table maintains a mapping between Nucleus PLUS pointers
and Task IDs. */
NU_TASK *NUFP_TASK_POINTER[NUM_USERS];
/* The following declarations are used for intialization of the Nucleus
PLUS tasking environment for the Nucleus FILE system. */
//廖怡白加入 2002.7.24
extern NU_MEMORY_POOL System_Memory;
/* The following definitions are the pointers that are used to access the
various Fixed Memory Partitions used by Nucleus FILE. */
NU_PARTITION_POOL NUF_USER_PARTITION;
NU_PARTITION_POOL NUF_DRIVE_PARTITION;
NU_PARTITION_POOL NUF_FILE_PARTITION;
NU_PARTITION_POOL NUF_BLOCK_PARTITION;
NU_PARTITION_POOL NUF_DROBJ_PARTITION;
NU_PARTITION_POOL NUF_FINODE_PARTITION;
NU_PARTITION_POOL NUF_FAT_PARTITION_A;
NU_PARTITION_POOL NUF_FAT_PARTITION_B;
NU_PARTITION_POOL NUF_FAT_PARTITION_C;
NU_PARTITION_POOL NUF_FAT_PARTITION_D;
NU_PARTITION_POOL NUF_FAT_PARTITION_E;
NU_PARTITION_POOL NUF_FAT_PARTITION_F;
NU_PARTITION_POOL NUF_FAT_PARTITION_G;
NU_PARTITION_POOL NUF_FAT_PARTITION_H;
NU_PARTITION_POOL NUF_FAT_PARTITION_I;
NU_PARTITION_POOL NUF_FAT_PARTITION_J;
NU_PARTITION_POOL NUF_FAT_PARTITION_K;
NU_PARTITION_POOL NUF_FAT_PARTITION_L;
//NU_PARTITION_POOL NUF_RAMDISK_PARTITION;
/* The following is a definition which allows the Event IDs normally used
by Nucleus RTX to be converted to pointers which are used by Nucleus
PLUS. */
NU_EVENT_GROUP NUFP_RTX_To_PLUS_Events[NUF_NUM_EVENTS];
/* The following is the definition of the Semaphore used by Nucleus FILE.
It actually replaces the ID used by the Nucleus RTX version of Nucleus
FILE. */
//NU_SEMAPHORE NUF_FILE_SYSTEM_MUTEX;
//IMPORT NU_SEMAPHORE NUF_FILE_SYSTEM_MUTEX;
extern UCOUNT g_Error_Info[REPORT_ERROR_NUM]; //Daniel
//加入结束
/************************************************************************
* FUNCTION
*
* NUFP_Current_Task_ID
*
* DESCRIPTION
*
* This function convert a Task Pointer to a Task ID.
*
*
* AUTHOR
*
* Neil F. Henderson, Accelerated Technology, Inc.
*
* INPUTS
*
* None.
*
* OUTPUTS
*
* task_id The id of the task that
* represents the task pointer.
*
*************************************************************************/
INT NUFP_Current_Task_ID(VOID)
{
NU_TASK *current_task_ptr;
INT task_id;
/* Intialize the task_id. */
task_id = 0;
/* Get the Task Pointer to the current task. */
current_task_ptr = NU_Current_Task_Pointer();
/* Search for the Task Pointer. */
for (task_id = 0; task_id < NUM_USERS; task_id++)
{
/* If we found the entry, then return the ID. */
if (NUFP_TASK_POINTER[task_id] == current_task_ptr)
return(task_id);
}
/* There is not one already established, so find a blank spot,
set up the pointer, and return the ID. */
for (task_id = 0; task_id < NUM_USERS; task_id++)
{
/* If we found a blank entry, then return the ID. */
if (NUFP_TASK_POINTER[task_id] == NU_NULL)
{
/* Save the entry so that we find it next time. */
NUFP_TASK_POINTER[task_id] = current_task_ptr;
/* Return the associated ID. */
return(task_id);
}
}
/* We did not find an empty entry for a new task. That means that the
user did a no no. We need to invoke some kind of error handler here. */
return(-1);
} /* end of NUFP_Current_Task_ID. */
/************************************************************************
* FUNCTION
*
* NUFP_Remove_User
*
* DESCRIPTION
*
* This function is responsible from removing a user from the
* NUFP_TASK_POINTER table.
*
* AUTHOR
*
* Neil F. Henderson, Accelerated Technology, Inc.
*
* INPUTS
*
* task_id Converted task ID from PLUS
* task pointer
*
* OUTPUTS
*
* NUFP_TASK_POINTER Updated to remove the task
* pointed to by the ID.
*
*************************************************************************/
VOID NUFP_Remove_User(INT task_id)
{
/* Remove the task pointer. */
NUFP_TASK_POINTER[task_id] = NU_NULL;
}
/************************************************************************/
/* */
/* FUNCTION "NUFP_Initialize" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function prepares the file system environment for use */
/* by a Nucleus PLUS program. It creates all of the Nucleus */
/* PLUS components that are reqiured by the Nucleus FILE System. */
/* */
/* AUTHOR */
/* */
/* Neil F. Henderson Accelerated Technology, Inc. */
/* */
/* CALLED FROM */
/* */
/* Application_Initialize The function called by the Nucleus */
/* PLUS kernel to begin the tasking */
/* environment. */
/* */
/* ROUTINES CALLED */
/* */
/* */
/* */
/* INPUTS */
/* */
/* OUTPUTS */
/* */
/* */
/************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -