📄 ioc.c
字号:
/*************************************************************************/
/* */
/* Copyright Mentor Graphics Corporation 2004 */
/* All Rights Reserved. */
/* */
/* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */
/* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */
/* SUBJECT TO LICENSE TERMS. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* ioc.c Nucleus PLUS 1.15 */
/* */
/* COMPONENT */
/* */
/* IO - Input/Output Driver Management */
/* */
/* DESCRIPTION */
/* */
/* This file contains the core routines for the I/O Driver */
/* Management component. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* IOC_Create_Driver Create an I/O driver */
/* IOC_Delete_Driver Delete an I/O driver */
/* IOC_Request_Driver Make an I/O driver request */
/* IOC_Resume_Driver Resume a task suspended in */
/* an I/O driver */
/* IOC_Suspend_Driver Suspend a task inside an I/O */
/* driver */
/* */
/* DEPENDENCIES */
/* */
/* cs_extr.h Common Service functions */
/* tc_extr.h Thread Control functions */
/* io_extr.h I/O driver functions */
/* hi_extr.h History functions */
/* */
/*************************************************************************/
#define NU_SOURCE_FILE
#include "plus/inc/cs_extr.h" /* Common service functions */
#include "plus/inc/tc_extr.h" /* Thread control functions */
#include "plus/inc/io_extr.h" /* I/O driver functions */
#include "plus/inc/hi_extr.h" /* History functions */
/* Define external inner-component global data references. */
extern CS_NODE *IOD_Created_Drivers_List;
extern UNSIGNED IOD_Total_Drivers;
extern TC_PROTECT IOD_List_Protect;
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* IOC_Create_Driver */
/* */
/* DESCRIPTION */
/* */
/* This function creates an I/O driver and places it on the list of */
/* created I/O drivers. Note that this function does not actually */
/* invoke the driver. */
/* */
/* CALLED BY */
/* */
/* Application */
/* IOCE_Create_Driver Error checking shell */
/* */
/* CALLS */
/* */
/* CSC_Place_On_List Add node to linked-list */
/* [HIC_Make_History_Entry] Make entry in history log */
/* [TCT_Check_Stack] Stack checking function */
/* TCT_Protect Data structure protect */
/* TCT_Unprotect Un-protect data structure */
/* */
/* INPUTS */
/* */
/* driver Driver control block pointer */
/* name Driver's logical name */
/* driver_entry Driver's point of entry */
/* */
/* OUTPUTS */
/* */
/* NU_SUCCESS */
/* */
/*************************************************************************/
STATUS IOC_Create_Driver(NU_DRIVER *driver, CHAR *name,
VOID (*driver_entry)(NU_DRIVER *, NU_DRIVER_REQUEST *))
{
INT i; /* Working index variable */
NU_SUPERV_USER_VARIABLES
/* Switch to supervisor mode */
NU_SUPERVISOR_MODE();
#ifdef NU_ENABLE_STACK_CHECK
/* Call stack checking function to check for an overflow condition. */
TCT_Check_Stack();
#endif
#ifdef NU_ENABLE_HISTORY
/* Make an entry that corresponds to this function in the system history
log. */
HIC_Make_History_Entry(NU_CREATE_DRIVER_ID, (UNSIGNED) driver,
(UNSIGNED) name, (UNSIGNED) driver_entry);
#endif
/* First, clear the driver ID just in case it is an old Driver
Control Block. */
driver -> nu_driver_id = 0;
/* Fill in the driver's name. */
for (i = 0; i < NU_MAX_NAME; i++)
driver -> nu_driver_name[i] = name[i];
/* Save the driver's entry function in the control block. */
driver -> nu_driver_entry = driver_entry;
/* Protect against access to the list of created drivers. */
TCT_Protect(&IOD_List_Protect);
/* At this point the driver is completely built. The ID can now be
set and it can be linked into the created driver list. */
driver -> nu_driver_id = IO_DRIVER_ID;
/* Link the driver into the list of created I/O drivers and increment the
total number of drivers in the system. */
CSC_Place_On_List(&IOD_Created_Drivers_List, (CS_NODE *) driver);
IOD_Total_Drivers++;
#ifdef NU_PROFILE_PLUS
PRF_PLUS_IOC_CREATE_DRIVER_0
#endif /* NU_PROFILE_PLUS */
/* Release protection against access to the list of created I/O drivers. */
TCT_Unprotect();
/* Return to user mode */
NU_USER_MODE();
/* Return successful completion. */
return(NU_SUCCESS);
}
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* IOC_Delete_Driver */
/* */
/* DESCRIPTION */
/* */
/* This function deletes an I/O driver and removes it from the list */
/* of created drivers. Note that this function does not actually */
/* invoke the driver. */
/* */
/* CALLED BY */
/* */
/* Application */
/* IOCE_Delete_Driver Error checking shell */
/* */
/* CALLS */
/* */
/* CSC_Remove_From_List Remove node from list */
/* [HIC_Make_History_Entry] Make entry in history log */
/* [TCT_Check_Stack] Stack checking function */
/* TCT_Protect Protect created list */
/* TCT_Unprotect Release protection */
/* */
/* INPUTS */
/* */
/* driver Driver control block pointer */
/* */
/* OUTPUTS */
/* */
/* NU_SUCCESS */
/* */
/*************************************************************************/
STATUS IOC_Delete_Driver(NU_DRIVER *driver)
{
NU_SUPERV_USER_VARIABLES
/* Switch to supervisor mode */
NU_SUPERVISOR_MODE();
#ifdef NU_ENABLE_STACK_CHECK
/* Call stack checking function to check for an overflow condition. */
TCT_Check_Stack();
#endif
#ifdef NU_ENABLE_HISTORY
/* Make an entry that corresponds to this function in the system history
log. */
HIC_Make_History_Entry(NU_DELETE_DRIVER_ID, (UNSIGNED) driver ,
(UNSIGNED) 0, (UNSIGNED) 0);
#endif
/* Protect against access to the list of created I/O drivers. */
TCT_Protect(&IOD_List_Protect);
#ifdef NU_PROFILE_PLUS
PRF_PLUS_IOC_DELETE_DRIVER_0
#endif /* NU_PROFILE_PLUS */
/* Set the driver ID to 0. */
driver -> nu_driver_id = 0;
/* Remove the driver from the list of created I/O drivers. */
CSC_Remove_From_List(&IOD_Created_Drivers_List, (CS_NODE *) driver);
/* Decrement the total number of created I/O drivers. */
IOD_Total_Drivers--;
/* Release protection against access to the list of created I/O drivers. */
TCT_Unprotect();
/* Return to user mode */
NU_USER_MODE();
/* Return a successful completion. */
return(NU_SUCCESS);
}
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* IOC_Request_Driver */
/* */
/* DESCRIPTION */
/* */
/* This function sends a user request to the specified I/O driver. */
/* */
/* CALLED BY */
/* */
/* Application */
/* IOCE_Request_Driver Error checking shell */
/* */
/* CALLS */
/* */
/* [HIC_Make_History_Entry] Make entry in history log */
/* [TCT_Check_Stack] Stack checking function */
/* */
/* INPUTS */
/* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -