📄 pckernel.c
字号:
/*
* EBS - RTFS (Real Time File Manager)
*
* Copyright EBS Inc. 1996
* All rights reserved.
* This code may not be redistributed in source or linkable object form
* without the consent of its author.
*/
/******************************************************************************
PC_KERNEL - System specific process management routines.
Summary
Routines in this file provide system specific process management
functionality.
Required functions:
pc_kernel_init - Initialize process management system
pc_kernel_shutdown - Release process management system
pc_free_all_users() - Detach all tasks from a drive
DATESTR *pc_getsysdate() - Get system date and put in rtfs format
******************************************************************************/
// This is used only in RTIP enviroment
// Not used in ERTFS_STAND_ALONE mode
#include <pcdisk.h>
/* BOOLEAN pc_kernel_init() - Initialize process management system
*
* Initialize the run time system so the kernel support services will be
* available when requested.
*
* When this routine is finished executing the following process resources
* should be functional.
*
* In any implementation including single tasking single threaded:
* pc_free_all_users() should be functional
*
*/
BOOLEAN ks_resource_init(void);
/* Pc_kernel_init - Initialize kernel resources.
*/
BOOLEAN pc_kernel_init(void) /* __fn__ */
{
return(ks_resource_init());
}
/* Pc_kernel_shutdown - Release kernel resources.
*
* This routine is only called if pc_memory_free() is called. Most embedded
* systems won't need to do this so implementing the function is typically
* unnecessary. If implementation is needed then the resources alocated
* by pc_kernel_init() should be put in such a state that a subsequant call
* to that function will succeed.
*
* */
void pc_kernel_shutdown(void) /* __fn__ */
{
}
PSYSTEM_USER get_system_user();
#if (RTIPREL)
/* The old way */
extern struct system_user KS_FAR user_table[CFG_USER_TASKS];
#else
PSYSTEM_USER os_get_user_by_index(int taskindex);
#endif
void pc_free_user(void) /*__fn__*/
{
int i;
PSYSTEM_USER s;
s = get_system_user();
if (s)
{
for (i = 0; i < NDRIVES; i++)
{
if (s->lcwd[i])
{
pc_freeobj((DROBJ *) s->lcwd[i]);
s->lcwd[i] = 0;
}
}
}
}
/* pc_free_all_users() - Run down the user list releasing drive resources
*
* This routine is called by RTFS when it closes a drive.
* The routine must release the current directory object for that drive
* for each user. If a user does not have a CWD for the drive it should
* not call pc_freeobj.
*
* In the reference port we cycle through our array of user structures
* to provide the enumeration. Other implementations are equally valid.
*/
void pc_free_all_users(int driveno) /*__fn__*/
{
int i;
#if (RTIPREL)
/* The old way */
for (i = 0; i < CFG_USER_TASKS; i++)
{
if (user_table[i].lcwd[driveno])
{
pc_freeobj(user_table[i].lcwd[driveno]);
user_table[i].lcwd[driveno] = 0;
}
}
#else
PSYSTEM_USER s;
for (i = 0; ; i++)
{
s = os_get_user_by_index(i);
if (s)
{
if (s->lcwd[driveno])
{
pc_freeobj((DROBJ *)s->lcwd[driveno]);
s->lcwd[driveno] = 0;
}
}
else
break;
}
#endif
}
// SPR: added INCLUDE_RTIP
#if (0)
#if (!INCLUDE_RTIP)
//#if (!defined(ERTFS_SA))
//DM: added os_exit_task(). Is normally in OS.C, but rest of OS.C not
// needed for ERTFS
void os_exit_task(void)
{
/* release RTFS user */
pc_free_user();
/* give up the table entry in the errno table */
release_errno();
KS_EXIT_TASK();
}
//#endif
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -