mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
Remove.
This commit is contained in:
@@ -1,84 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file intr.h
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* XXX: It is unclear if the type "intr_t" should be defined when
|
|
||||||
* _POSIX_INTERRUPT_CONTROL is not.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INTR_H
|
|
||||||
#define _INTR_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#if defined(_POSIX_INTERRUPT_CONTROL)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 22.2 Concepts, P1003.4b/D8, p. 73
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef int intr_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 22.3.1 Associate a User-Written ISR with an Interrupt, P1003.4b/D8, p. 74
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return codes from an interrupt handler
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define INTR_HANDLED_NOTIFY 0 /* ISR handled this interrupt, notify */
|
|
||||||
/* the thread that registered the */
|
|
||||||
/* ISR that the interrupt occurred. */
|
|
||||||
#define INTR_HANDLED_DO_NOT_NOTIFY 1 /* ISR handled this interrupt, but */
|
|
||||||
/* do NOT perform notification. */
|
|
||||||
#define INTR_NOT_HANDLED 2 /* ISR did not handle this interrupt, */
|
|
||||||
/* let the next handler try. */
|
|
||||||
|
|
||||||
int intr_capture(
|
|
||||||
intr_t intr,
|
|
||||||
int (*intr_handler)( void *area ),
|
|
||||||
volatile void *area,
|
|
||||||
size_t areasize
|
|
||||||
);
|
|
||||||
|
|
||||||
int intr_release(
|
|
||||||
intr_t intr,
|
|
||||||
int (*intr_handler)( void *area )
|
|
||||||
);
|
|
||||||
|
|
||||||
int intr_lock(
|
|
||||||
intr_t intr
|
|
||||||
);
|
|
||||||
|
|
||||||
int intr_unlock(
|
|
||||||
intr_t intr
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 22.3.2 Await Interrupt Notification, P1003.4b/D8, p. 76
|
|
||||||
*/
|
|
||||||
|
|
||||||
int intr_timed_wait(
|
|
||||||
int flags,
|
|
||||||
const struct timespec *timeout
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/* end of include file */
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file rtems/posix/intr.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* rtems/posix/intr.h
|
|
||||||
*
|
|
||||||
* This include file contains all the private support information for
|
|
||||||
* POSIX Interrupt Manager.
|
|
||||||
*
|
|
||||||
* COPYRIGHT (c) 1989-1999.
|
|
||||||
* On-Line Applications Research Corporation (OAR).
|
|
||||||
*
|
|
||||||
* The license and distribution terms for this file may be
|
|
||||||
* found in the file LICENSE in this distribution or at
|
|
||||||
* http://www.rtems.com/license/LICENSE.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _RTEMS_POSIX_INTR_H
|
|
||||||
#define _RTEMS_POSIX_INTR_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <rtems/score/isr.h>
|
|
||||||
#include <rtems/score/object.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Data Structure used to manage each POSIX Interrupt Vector
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int number_installed;
|
|
||||||
int lock_count;
|
|
||||||
int deferred_count;
|
|
||||||
Chain_Control Handlers;
|
|
||||||
} POSIX_Interrupt_Control;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Data Structure used to manage a POSIX Interrupt Handler
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Objects_Control Object;
|
|
||||||
int is_active;
|
|
||||||
intr_t vector;
|
|
||||||
Thread_Control *server;
|
|
||||||
int (*handler)( void *area );
|
|
||||||
volatile void *user_data_area;
|
|
||||||
} POSIX_Interrupt_Handler_control;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following defines the information control block used to manage
|
|
||||||
* this class of objects.
|
|
||||||
*/
|
|
||||||
|
|
||||||
POSIX_EXTERN Objects_Information _POSIX_Interrupt_Handlers_Information;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following is an array which is used to manage the set of
|
|
||||||
* interrupt handlers installed on each vector.
|
|
||||||
*/
|
|
||||||
|
|
||||||
POSIX_EXTERN POSIX_Interrupt_Control
|
|
||||||
_POSIX_Interrupt_Information[ ISR_NUMBER_OF_VECTORS ];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Interrupt_Manager_initialization
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This routine performs the initialization necessary for this manager.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void _POSIX_Interrupt_Manager_initialization(
|
|
||||||
uint32_t maximum_interrupt_handlers
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Interrupt_Allocate
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This function allocates a interrupt handler control block from
|
|
||||||
* the inactive chain of free interrupt handler control blocks.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE POSIX_Interrupt_Handler_control *
|
|
||||||
_POSIX_Interrupt_Allocate( void );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Interrupt_Free
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This routine frees a interrupt handler control block to the
|
|
||||||
* inactive chain of free interrupt handler control blocks.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE void _POSIX_Interrupt_Free (
|
|
||||||
POSIX_Interrupt_Handler_control *the_intr
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Interrupt_Get
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This function maps interrupt handler IDs to interrupt handler control
|
|
||||||
* blocks. If ID corresponds to a local interrupt handler, then it returns
|
|
||||||
* the_intr control pointer which maps to ID and location
|
|
||||||
* is set to OBJECTS_LOCAL. if the interrupt handler ID is global and
|
|
||||||
* resides on a remote node, then location is set to OBJECTS_REMOTE,
|
|
||||||
* and the_intr is undefined. Otherwise, location is set
|
|
||||||
* to OBJECTS_ERROR and the_intr is undefined.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE POSIX_Interrupt_Control *_POSIX_Interrupt_Get (
|
|
||||||
Objects_Id id,
|
|
||||||
Objects_Locations *location
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Interrupt_Is_null
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This function returns TRUE if the_intr is NULL and FALSE otherwise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE boolean _POSIX_Interrupt_Is_null (
|
|
||||||
POSIX_Interrupt_Handler_control *the_intr
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Interrupt_Handler
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This function XXX.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void _POSIX_Interrupt_Handler(
|
|
||||||
ISR_Vector_number vector
|
|
||||||
);
|
|
||||||
|
|
||||||
#include <rtems/posix/intr.inl>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/* end of include file */
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file rtems/posix/threadsup.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* threadsup.h
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _RTEMS_POSIX_THREADSUP_H
|
|
||||||
#define _RTEMS_POSIX_THREADSUP_H
|
|
||||||
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <rtems/score/coresem.h>
|
|
||||||
#include <rtems/score/tqdata.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
pthread_attr_t Attributes;
|
|
||||||
int detachstate;
|
|
||||||
Thread_queue_Control Join_List;
|
|
||||||
int schedpolicy;
|
|
||||||
struct sched_param schedparam;
|
|
||||||
int ss_high_priority;
|
|
||||||
Watchdog_Control Sporadic_timer;
|
|
||||||
|
|
||||||
sigset_t signals_blocked;
|
|
||||||
sigset_t signals_pending;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* POSIX Interrupts
|
|
||||||
*/
|
|
||||||
uint32_t interrupts_installed;
|
|
||||||
CORE_semaphore_Control Interrupt_Semaphore;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* POSIX Cancelability
|
|
||||||
*/
|
|
||||||
int cancelability_state;
|
|
||||||
int cancelability_type;
|
|
||||||
int cancelation_requested;
|
|
||||||
Chain_Control Cancellation_Handlers;
|
|
||||||
|
|
||||||
} POSIX_API_Control;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/* end of include file */
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file rtems/posix/intr.inl
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* rtems/posix/intr.inl
|
|
||||||
*
|
|
||||||
* This include file contains the static inline implementation of the private
|
|
||||||
* inlined routines for POSIX Interrupt Manager
|
|
||||||
*
|
|
||||||
* COPYRIGHT (c) 1989-1999.
|
|
||||||
* On-Line Applications Research Corporation (OAR).
|
|
||||||
*
|
|
||||||
* The license and distribution terms for this file may be
|
|
||||||
* found in the file LICENSE in this distribution or at
|
|
||||||
* http://www.rtems.com/license/LICENSE.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _RTEMS_POSIX_INTR_INL
|
|
||||||
#define _RTEMS_POSIX_INTR_INL
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Allocate
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE POSIX_Interrupt_Handler_control *
|
|
||||||
_POSIX_Interrupt_Allocate( void )
|
|
||||||
{
|
|
||||||
return (POSIX_Interrupt_Handler_control *)
|
|
||||||
_Objects_Allocate( &_POSIX_Interrupt_Handlers_Information );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Free
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE void _POSIX_Interrupt_Free (
|
|
||||||
POSIX_Interrupt_Handler_control *the_intr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
_Objects_Free( &_POSIX_Interrupt_Handlers_Information, &the_intr->Object );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Get
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE POSIX_Interrupt_Control *_POSIX_Interrupt_Get (
|
|
||||||
Objects_Id id,
|
|
||||||
Objects_Locations *location
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return (POSIX_Interrupt_Control *)
|
|
||||||
_Objects_Get( &_POSIX_Interrupt_Handlers_Information, id, location );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Is_null
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE boolean _POSIX_Interrupt_Is_null (
|
|
||||||
POSIX_Interrupt_Handler_control *the_intr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return !the_intr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/* end of include file */
|
|
||||||
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file rtems/posix/intr.inl
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* rtems/posix/intr.inl
|
|
||||||
*
|
|
||||||
* This include file contains the macro implementation of the private
|
|
||||||
* inlined routines for POSIX Interrupt Manager
|
|
||||||
*
|
|
||||||
* COPYRIGHT (c) 1989-1999.
|
|
||||||
* On-Line Applications Research Corporation (OAR).
|
|
||||||
*
|
|
||||||
* The license and distribution terms for this file may be
|
|
||||||
* found in the file LICENSE in this distribution or at
|
|
||||||
* http://www.rtems.com/license/LICENSE.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _RTEMS_POSIX_INTR_INL
|
|
||||||
#define _RTEMS_POSIX_INTR_INL
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Allocate
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _POSIX_Interrupt_Allocate() \
|
|
||||||
(POSIX_Interrupt_Handler_control *) \
|
|
||||||
_Objects_Allocate( &_POSIX_Interrupt_Handlers_Information )
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Free
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _POSIX_Interrupt_Free( _the_intr ) \
|
|
||||||
_Objects_Free( &_POSIX_Interrupt_Handlers_Information, &(_the_intr)->Object )
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Get
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _POSIX_Interrupt_Get( _id, _location ) \
|
|
||||||
(POSIX_Interrupt_Control *) \
|
|
||||||
_Objects_Get( &_POSIX_Interrupt_Handlers_Information, (_id), (_location) )
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Is_null
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _POSIX_Interrupt_Is_null( _the_intr ) \
|
|
||||||
(!(_the_intr))
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/* end of include file */
|
|
||||||
|
|
||||||
@@ -1,349 +0,0 @@
|
|||||||
/*
|
|
||||||
* NOTE: Each task has an interrupt semaphore associated with it.
|
|
||||||
* No matter which interrupt occurs that it has registered,
|
|
||||||
* the same semaphore is used.
|
|
||||||
*
|
|
||||||
* This whole interrupt scheme may have been eliminated in a later draft.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <intr.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <rtems/system.h>
|
|
||||||
#include <rtems/score/isr.h>
|
|
||||||
#include <rtems/score/coresem.h>
|
|
||||||
#include <rtems/score/thread.h>
|
|
||||||
#include <rtems/score/watchdog.h>
|
|
||||||
#include <rtems/posix/intr.h>
|
|
||||||
#include <rtems/posix/time.h>
|
|
||||||
#include <rtems/posix/threadsup.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _POSIX_Interrupt_Manager_initialization
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
*
|
|
||||||
* This routine performs the initialization necessary for this manager.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void _POSIX_Interrupt_Manager_initialization(
|
|
||||||
uint32_t maximum_interrupt_handlers
|
|
||||||
)
|
|
||||||
{
|
|
||||||
uint32_t index;
|
|
||||||
POSIX_Interrupt_Control *the_vector;
|
|
||||||
|
|
||||||
_Objects_Initialize_information(
|
|
||||||
&_POSIX_Interrupt_Handlers_Information, /* object information table */
|
|
||||||
OBJECTS_POSIX_API, /* object API */
|
|
||||||
OBJECTS_POSIX_INTERRUPTS, /* object class */
|
|
||||||
maximum_interrupt_handlers, /* maximum objects of this class */
|
|
||||||
sizeof( POSIX_Interrupt_Handler_control ),
|
|
||||||
/* size of this object's control block */
|
|
||||||
FALSE, /* TRUE if names for this object are strings */
|
|
||||||
0 /* maximum length of each object's name */
|
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
|
||||||
,
|
|
||||||
FALSE, /* TRUE if this is a global object class */
|
|
||||||
NULL /* Proxy extraction support callout */
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
for ( index=0 ; index < CPU_INTERRUPT_NUMBER_OF_VECTORS ; index++ ) {
|
|
||||||
the_vector = &_POSIX_Interrupt_Information[ index ];
|
|
||||||
|
|
||||||
the_vector->number_installed = 0;
|
|
||||||
the_vector->lock_count = 0;
|
|
||||||
the_vector->deferred_count = 0;
|
|
||||||
_Chain_Initialize_empty( &the_vector->Handlers );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* 22.3.1 Associate a User-Written ISR with an Interrupt, P1003.4b/D8, p. 74
|
|
||||||
*/
|
|
||||||
|
|
||||||
int intr_capture(
|
|
||||||
intr_t intr,
|
|
||||||
int (*intr_handler)( void *area ),
|
|
||||||
volatile void *area,
|
|
||||||
size_t areasize
|
|
||||||
)
|
|
||||||
{
|
|
||||||
POSIX_Interrupt_Handler_control *the_intr;
|
|
||||||
POSIX_Interrupt_Control *the_vector;
|
|
||||||
POSIX_API_Thread_Support_Control *thread_support;
|
|
||||||
proc_ptr old_handler;
|
|
||||||
|
|
||||||
if ( !_ISR_Is_vector_number_valid( intr ) ||
|
|
||||||
!_ISR_Is_valid_user_handler( intr_handler ) )
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
|
||||||
|
|
||||||
the_intr = _POSIX_Interrupt_Allocate();
|
|
||||||
|
|
||||||
if ( !the_intr ) {
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
the_vector = &_POSIX_Interrupt_Information[ intr ];
|
|
||||||
|
|
||||||
the_intr->vector = intr;
|
|
||||||
the_intr->handler = intr_handler;
|
|
||||||
the_intr->user_data_area = area;
|
|
||||||
the_intr->server = _Thread_Executing;
|
|
||||||
the_intr->is_active = TRUE;
|
|
||||||
|
|
||||||
thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
|
|
||||||
thread_support->interrupts_installed++;
|
|
||||||
|
|
||||||
/* XXX should we malloc the semaphore on the fly??? if so we probably need to
|
|
||||||
release it when the thread has released all interrupts and keep
|
|
||||||
a count of how many it has installed. CURRENTLY NO.. ALLOCATED w/TCB
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is sufficient to have the handlers invoked in the opposite
|
|
||||||
* order of installation. The loop invoking them can then go from
|
|
||||||
* the front of the list to the end.
|
|
||||||
*/
|
|
||||||
|
|
||||||
_Chain_Prepend( &the_vector->Handlers, &the_intr->Object.Node );
|
|
||||||
|
|
||||||
if ( !the_vector->number_installed++ )
|
|
||||||
_ISR_Install_vector(
|
|
||||||
intr,
|
|
||||||
(proc_ptr) _POSIX_Interrupt_Handler,
|
|
||||||
&old_handler
|
|
||||||
);
|
|
||||||
|
|
||||||
_Objects_Open( &_POSIX_Interrupt_Handlers_Information, &the_intr->Object, 0 );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Normally, an Id would be returned here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* 22.3.1 Associate a User-Written ISR with an Interrupt, P1003.4b/D8, p. 74
|
|
||||||
*/
|
|
||||||
|
|
||||||
int intr_release(
|
|
||||||
intr_t intr,
|
|
||||||
int (*intr_handler)( void *area )
|
|
||||||
)
|
|
||||||
{
|
|
||||||
boolean found;
|
|
||||||
POSIX_Interrupt_Handler_control *the_intr;
|
|
||||||
POSIX_Interrupt_Control *the_vector;
|
|
||||||
POSIX_API_Thread_Support_Control *thread_support;
|
|
||||||
Chain_Node *the_node;
|
|
||||||
|
|
||||||
if ( !_ISR_Is_valid_user_handler( intr_handler ) )
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Since interrupt handlers do not have a user visible id, there is
|
|
||||||
* no choice but to search the entire set of active interrupt handlers
|
|
||||||
* to find this one.
|
|
||||||
*/
|
|
||||||
|
|
||||||
found = FALSE;
|
|
||||||
|
|
||||||
the_vector = &_POSIX_Interrupt_Information[ intr ];
|
|
||||||
|
|
||||||
the_node = _Chain_Head( &the_vector->Handlers );
|
|
||||||
|
|
||||||
for ( ; !_Chain_Is_tail( &the_vector->Handlers, the_node ) ; ) {
|
|
||||||
the_intr = (POSIX_Interrupt_Handler_control *) the_node;
|
|
||||||
|
|
||||||
if ( the_intr->handler == intr_handler ) {
|
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
the_node = the_node->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !found ) {
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !_Thread_Is_executing( the_intr->server ) ) {
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
return EINVAL; /* XXX should be ENOISR; */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* OK now we have found the interrupt handler and can do some work.
|
|
||||||
*/
|
|
||||||
|
|
||||||
_Chain_Extract( &the_intr->Object.Node );
|
|
||||||
|
|
||||||
the_intr->is_active = FALSE;
|
|
||||||
|
|
||||||
the_vector->number_installed -= 1;
|
|
||||||
|
|
||||||
thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
|
|
||||||
thread_support->interrupts_installed--;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* It is unnecessary to flush the semaphore since the handler can only
|
|
||||||
* be "removed" by the thread which installed it. Thus it cannot be
|
|
||||||
* blocked on the semaphore or it would not be executing this routine.
|
|
||||||
*/
|
|
||||||
|
|
||||||
_Objects_Close( &_POSIX_Interrupt_Handlers_Information, &the_intr->Object );
|
|
||||||
|
|
||||||
_POSIX_Interrupt_Free( the_intr );
|
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* 22.3.1 Associate a User-Written ISR with an Interrupt, P1003.4b/D8, p. 74
|
|
||||||
*/
|
|
||||||
|
|
||||||
int intr_lock(
|
|
||||||
intr_t intr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
POSIX_Interrupt_Control *the_vector;
|
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
|
||||||
|
|
||||||
the_vector = &_POSIX_Interrupt_Information[ intr ];
|
|
||||||
|
|
||||||
the_vector->lock_count++;
|
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* 22.3.1 Associate a User-Written ISR with an Interrupt, P1003.4b/D8, p. 74
|
|
||||||
*/
|
|
||||||
|
|
||||||
int intr_unlock(
|
|
||||||
intr_t intr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
POSIX_Interrupt_Control *the_vector;
|
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
|
||||||
|
|
||||||
the_vector = &_POSIX_Interrupt_Information[ intr ];
|
|
||||||
|
|
||||||
if ( !--the_vector->lock_count ) {
|
|
||||||
while ( --the_vector->deferred_count ) {
|
|
||||||
_POSIX_Interrupt_Handler( intr );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 22.3.2 Await Interrupt Notification, P1003.4b/D8, p. 76
|
|
||||||
*/
|
|
||||||
|
|
||||||
int intr_timed_wait(
|
|
||||||
int flags,
|
|
||||||
const struct timespec *timeout
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Watchdog_Interval ticks;
|
|
||||||
POSIX_API_Thread_Support_Control *thread_support;
|
|
||||||
|
|
||||||
ticks = _POSIX_Timespec_to_interval( timeout );
|
|
||||||
|
|
||||||
thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
|
|
||||||
|
|
||||||
_Thread_Disable_dispatch();
|
|
||||||
|
|
||||||
_CORE_semaphore_Seize(
|
|
||||||
&thread_support->Interrupt_Semaphore,
|
|
||||||
0, /* XXX does id=0 hurt in this case? */
|
|
||||||
TRUE,
|
|
||||||
ticks
|
|
||||||
);
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
|
|
||||||
return _Thread_Executing->Wait.return_code; /* XXX should be POSIX */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*PAGE
|
|
||||||
*
|
|
||||||
* _POSIX_Interrupt_Handler
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
void _POSIX_Interrupt_Handler(
|
|
||||||
ISR_Vector_number vector
|
|
||||||
)
|
|
||||||
{
|
|
||||||
POSIX_Interrupt_Handler_control *the_intr;
|
|
||||||
POSIX_Interrupt_Control *the_vector;
|
|
||||||
POSIX_API_Thread_Support_Control *thread_support;
|
|
||||||
Chain_Node *the_node;
|
|
||||||
int status;
|
|
||||||
|
|
||||||
the_vector = &_POSIX_Interrupt_Information[ vector ];
|
|
||||||
|
|
||||||
the_node = _Chain_Head( &the_vector->Handlers );
|
|
||||||
|
|
||||||
for ( ; !_Chain_Is_tail( &the_vector->Handlers, the_node ) ; ) {
|
|
||||||
the_intr = (POSIX_Interrupt_Handler_control *) the_node;
|
|
||||||
|
|
||||||
status = (*the_intr->handler)( (void *) the_intr->user_data_area );
|
|
||||||
|
|
||||||
switch ( status ) {
|
|
||||||
case INTR_HANDLED_NOTIFY:
|
|
||||||
thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
|
|
||||||
|
|
||||||
_CORE_semaphore_Surrender(
|
|
||||||
&thread_support->Interrupt_Semaphore,
|
|
||||||
0, /* XXX is id=0 a problem */
|
|
||||||
0 /* XXX is this a problem (mp support)*/
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case INTR_HANDLED_DO_NOT_NOTIFY:
|
|
||||||
return;
|
|
||||||
|
|
||||||
case INTR_NOT_HANDLED:
|
|
||||||
default: /* this should not happen */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
the_node = the_node->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX
|
|
||||||
*
|
|
||||||
* This is an unhandled interrupt!!!
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user