📄 nufp.c
字号:
/************************************************************************/
/* */
/* Copyright 1999 by Accelerated Technology */
/* */
/* 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 buyer or recipient of this */
/* package, implicitly accepts the terms of the license. */
/* */
/************************************************************************/
/************************************************************************/
/* */
/* FILE DESCRIPTION */
/* */
/* */
/* */
/* ROUTINES */
/* */
/* This file contains the routines necessary to intitialize */
/* the Nucleus PLUS environment for file system usage and to */
/* provide compatibility between Nucleus RTX and Nucleus PLUS */
/* versions of the file system. */
/* */
/* NOTES */
/* */
/* None */
/* */
/************************************************************************/
#include "nucleus.h"
#include "pcdisk.h"
#if (RAMDISK)
#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 Nucleus RTX type Task IDs. */
NU_TASK *NUFP_PLUS_To_RTX[NUM_USERS];
/* The following declarations are used for intialization of the Nucleus
PLUS tasking environment for the Nucleus FILE system. */
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_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;
/************************************************************************/
/* */
/* FUNCTION "NUFP_Current_Task_ID" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function replaces the Nucleus RTX equivalent by */
/* converting a Task Pointer to a Task ID. */
/* */
/* */
/* AUTHOR */
/* */
/* Neil F. Henderson Accelerated Technology, Inc. */
/* */
/* CALLED FROM */
/* */
/* GET_CONTEXT_HANDLE Acquires a unique Identifier */
/* for the currently running task */
/* GET_RTFS_TASKNO NU_Current_Task_ID is called within */
/* this macro to acquire an index */
/* into the nu_to_rtfs_task_map table */
/* SET_RTFS_TASKNO Establishes and entry in the */
/* nu_to_rtfs_task_map table */
/* */
/* ROUTINES CALLED */
/* */
/* NU_Current_Task_Pointer Returns a pointer to the current */
/* task */
/* */
/* INPUTS */
/* */
/* None */
/* */
/* OUTPUTS */
/* */
/* task_id The id of the task that represents */
/* the task pointer. */
/* */
/************************************************************************/
signed int NUFP_Current_Task_ID(void)
{
NU_TASK *current_task_ptr;
signed int rtx_id;
/* Intialize the rtx_id. */
rtx_id = 0;
/* Get the Task Pointer to the current task. */
current_task_ptr = NU_Current_Task_Pointer();
/* Search for the Task Pointer. */
for (rtx_id = 0; rtx_id < NUM_USERS; rtx_id++)
{
/* If we found the entry, then return the ID. */
if (NUFP_PLUS_To_RTX[rtx_id] == current_task_ptr)
return(rtx_id);
}
/* There is not one already established, so find a blank spot,
set up the pointer, and return the ID. */
for (rtx_id = 0; rtx_id < NUM_USERS; rtx_id++)
{
/* If we found a blank entry, then return the ID. */
if (NUFP_PLUS_To_RTX[rtx_id] == NU_NULL)
{
/* Save the entry so that we find it next time. */
NUFP_PLUS_To_RTX[rtx_id] = current_task_ptr;
/* Return the associated ID. */
return(rtx_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. */
} /* end of NUFP_Current_Task_ID. */
/************************************************************************/
/* */
/* FUNCTION "NUFP_Remove_User" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is responsible from removing a user from the */
/* NUFP_PLUS_To_RTX table. */
/* */
/* AUTHOR */
/* */
/* Neil F. Henderson Accelerated Technology, Inc. */
/* */
/* CALLED FROM */
/* */
/* NU_Release_File_User Deallocates all of the resources */
/* for the current file user. */
/* */
/* ROUTINES CALLED */
/* */
/* None */
/* */
/* INPUTS */
/* */
/* task_id Converted task ID from PLUS task */
/* pointer */
/* */
/* OUTPUTS */
/* */
/* NUFP_PLUS_To_RTX Updated to remove the task pointed */
/* to by the ID. */
/* */
/************************************************************************/
void NUFP_Remove_User(signed int task_id)
{
/* Remove the task pointer. */
NUFP_PLUS_To_RTX[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 */
/* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -