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

📄 ioc.c

📁 nucleus 2006 source code
💻 C
📖 第 1 页 / 共 2 页
字号:
/*      driver                              Driver control block pointer */
/*      request                             User's I/O request           */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_SUCCESS                          If service is successful     */
/*                                                                       */
/*************************************************************************/
STATUS  IOC_Request_Driver(NU_DRIVER *driver , NU_DRIVER_REQUEST *request)
{
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_REQUEST_DRIVER_ID, (UNSIGNED) driver,
                                       (UNSIGNED) request, (UNSIGNED) 0);

#endif

#ifdef NU_PROFILE_PLUS

    PRF_PLUS_IOC_REQUEST_DRIVER_0

#endif /* NU_PROFILE_PLUS */

    /* Call the specified I/O Driver.  */
    (*(driver -> nu_driver_entry)) (driver, request);

    /* Return to user mode */
    NU_USER_MODE();

    /* Return the completion status.  */
    return(NU_SUCCESS);
}


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      IOC_Resume_Driver                                                */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function resumes a task previously suspended inside of an   */
/*      I/O driver.  Typically, this function is called from within an   */
/*      I/O driver.                                                      */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*      IOCE_Resume_Driver                  Error checking shell         */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      [HIC_Make_History_Entry]            Make entry in history log    */
/*      TCC_Resume_Task                     Resume a suspended task      */
/*      TCT_Control_To_System               Transfer control to higher   */
/*                                            priority task              */
/*      [TCT_Check_Stack]                   Stack checking function      */
/*      TCT_Get_Current_Protect             Pickup current protection    */
/*      TCT_Set_Current_Protect             Set current protection       */
/*      TCT_System_Protect                  Protect against system access*/
/*      TCT_System_Unprotect                Release system protection    */
/*      TCT_Unprotect                       Release system protection    */
/*      TCT_Unprotect_Specific              Release specific protection  */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      task                                Pointer of task to resume    */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_SUCCESS                          If service is successful     */
/*                                                                       */
/*************************************************************************/
STATUS  IOC_Resume_Driver(NU_TASK *task)
{

TC_PROTECT     *save_protect;               /* Saved protect pointer     */
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_RESUME_DRIVER_ID, (UNSIGNED) task,
                                                (UNSIGNED) 0, (UNSIGNED) 0);

#endif

    /* Pickup current protection. */
    save_protect =  TCT_Get_Current_Protect();

    /* Protect against system access.  */
    TCT_System_Protect();

#ifdef NU_PROFILE_PLUS

    PRF_PLUS_IOC_RESUME_DRIVER_0

#endif /* NU_PROFILE_PLUS */

    /* Resume the specified task.  */
    if (TCC_Resume_Task(task, NU_DRIVER_SUSPEND))
    {
        /* Only unprotect if there is protection in place. */
        if (save_protect)
        {
            /* Release protection caller had.  */
            TCT_Unprotect_Specific(save_protect);
        }

        /* Transfer control to the system if the resumed task function
           detects a preemption condition.  */
        TCT_Control_To_System();
    }
    else
    {

        /* Determine if there was protection previously in force.  */
        if (save_protect)
        {

            /* Switch to original protection.  */
            TCT_Set_Current_Protect(save_protect);

            /* Release system protection.  */
            TCT_System_Unprotect();
        }
        else

            /* Release system protection.  */
            TCT_Unprotect();
    }

    /* Return to user mode */
    NU_USER_MODE();

    /* Return the completion status.  */
    return(NU_SUCCESS);
}



/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      IOC_Suspend_Driver                                               */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function suspends a task inside of an I/O driver.  It is    */
/*      the responsibility of the I/O driver to keep track of tasks      */
/*      waiting inside of an I/O driver.                                 */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*      IOCE_Suspend_Driver                 Error checking shell         */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      [HIC_Make_History_Entry]            Make entry in history log    */
/*      TCC_Suspend_Task                    Suspend calling task         */
/*      TCT_Current_Thread                  Current task thread          */
/*      [TCT_Check_Stack]                   Stack checking function      */
/*      TCT_Get_Current_Protect             Pickup current protect ptr   */
/*      TCT_Set_Suspend_Protect             Setup suspend protect field  */
/*      TCT_System_Protect                  Protect against system access*/
/*      TCT_Unprotect_Specific              Release user protection      */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      terminate_routine                   Termination/Timeout cleanup  */
/*                                            routine                    */
/*      information                         Information pointer of the   */
/*                                            cleanup routine            */
/*      timeout                             Suspension timeout request   */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_SUCCESS                          If service is successful     */
/*                                                                       */
/*************************************************************************/
STATUS  IOC_Suspend_Driver(VOID (*terminate_routine)(VOID *),
                                        VOID *information, UNSIGNED timeout)
{

TC_PROTECT  *suspend_protect;               /* Current protection        */
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_SUSPEND_DRIVER_ID, (UNSIGNED) terminate_routine,
                                (UNSIGNED) information, (UNSIGNED) timeout);

#endif


    /* Pickup current protect.  */
    suspend_protect =  TCT_Get_Current_Protect();

    /* Setup system protection.  */
    TCT_System_Protect();

#ifdef NU_PROFILE_PLUS 

    PRF_PLUS_IOC_SUSPEND_DRIVER_0

#endif /* NU_PROFILE_PLUS */

    /* If no protection exists, don't unprotect. */
    if (suspend_protect)
    {
        /* Release initial protection.  */
        TCT_Unprotect_Specific(suspend_protect);

        /* Save suspend protect for timeout and terminate.  */
        TCT_Set_Suspend_Protect(suspend_protect);
    }

    /* Suspend the calling task.  */
    TCC_Suspend_Task((NU_TASK *) TCT_Current_Thread(), NU_DRIVER_SUSPEND,
                                terminate_routine, information, timeout);

    /* Return to user mode */
    NU_USER_MODE();

    /* Return the completion status.  */
    return(NU_SUCCESS);
}





⌨️ 快捷键说明

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