2005-10-14 10:58:59 +02:00
|
|
|
/* The kernel call implemented in this file:
|
2005-04-21 16:53:53 +02:00
|
|
|
* m_type: SYS_IRQCTL
|
|
|
|
*
|
2005-10-14 10:58:59 +02:00
|
|
|
* The parameters for this kernel call are:
|
2005-04-21 16:53:53 +02:00
|
|
|
* m5_c1: IRQ_REQUEST (control operation to perform)
|
|
|
|
* m5_c2: IRQ_VECTOR (irq line that must be controlled)
|
2005-05-02 16:30:04 +02:00
|
|
|
* m5_i1: IRQ_POLICY (irq policy allows reenabling interrupts)
|
2005-07-29 17:26:23 +02:00
|
|
|
* m5_l3: IRQ_HOOK_ID (provides index to be returned on interrupt)
|
|
|
|
* ,, ,, (returns index of irq hook assigned at kernel)
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../system.h"
|
|
|
|
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
#include <minix/endpoint.h>
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
#if USE_IRQCTL
|
|
|
|
|
2005-07-29 17:26:23 +02:00
|
|
|
FORWARD _PROTOTYPE(int generic_handler, (irq_hook_t *hook));
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
2005-05-02 16:30:04 +02:00
|
|
|
* do_irqctl *
|
2005-04-21 16:53:53 +02:00
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_irqctl(m_ptr)
|
|
|
|
register message *m_ptr; /* pointer to request message */
|
|
|
|
{
|
|
|
|
/* Dismember the request message. */
|
2005-05-02 16:30:04 +02:00
|
|
|
int irq_vec;
|
|
|
|
int irq_hook_id;
|
2005-07-29 14:44:42 +02:00
|
|
|
int notify_id;
|
2005-05-12 18:06:37 +02:00
|
|
|
int r = OK;
|
2006-01-27 14:21:12 +01:00
|
|
|
int i;
|
2005-05-02 16:30:04 +02:00
|
|
|
irq_hook_t *hook_ptr;
|
2006-01-27 14:21:12 +01:00
|
|
|
struct proc *rp;
|
|
|
|
struct priv *privp;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-05-19 11:36:44 +02:00
|
|
|
/* Hook identifiers start at 1 and end at NR_IRQ_HOOKS. */
|
|
|
|
irq_hook_id = (unsigned) m_ptr->IRQ_HOOK_ID - 1;
|
2005-05-12 18:06:37 +02:00
|
|
|
irq_vec = (unsigned) m_ptr->IRQ_VECTOR;
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* See what is requested and take needed actions. */
|
|
|
|
switch(m_ptr->IRQ_REQUEST) {
|
|
|
|
|
|
|
|
/* Enable or disable IRQs. This is straightforward. */
|
2005-05-10 13:06:24 +02:00
|
|
|
case IRQ_ENABLE:
|
|
|
|
case IRQ_DISABLE:
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
if (irq_hook_id >= NR_IRQ_HOOKS || irq_hook_id < 0 ||
|
|
|
|
irq_hooks[irq_hook_id].proc_nr_e == NONE) return(EINVAL);
|
|
|
|
if (irq_hooks[irq_hook_id].proc_nr_e != m_ptr->m_source) return(EPERM);
|
2008-11-19 13:26:10 +01:00
|
|
|
if (m_ptr->IRQ_REQUEST == IRQ_ENABLE) {
|
2005-05-10 13:06:24 +02:00
|
|
|
enable_irq(&irq_hooks[irq_hook_id]);
|
2008-11-19 13:26:10 +01:00
|
|
|
}
|
2005-05-10 13:06:24 +02:00
|
|
|
else
|
|
|
|
disable_irq(&irq_hooks[irq_hook_id]);
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
2005-07-19 14:21:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Control IRQ policies. Set a policy and needed details in the IRQ table.
|
|
|
|
* This policy is used by a generic function to handle hardware interrupts.
|
|
|
|
*/
|
2005-05-10 13:06:24 +02:00
|
|
|
case IRQ_SETPOLICY:
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-05-02 16:30:04 +02:00
|
|
|
/* Check if IRQ line is acceptable. */
|
2005-07-19 14:21:36 +02:00
|
|
|
if (irq_vec < 0 || irq_vec >= NR_IRQ_VECTORS) return(EINVAL);
|
2005-05-02 16:30:04 +02:00
|
|
|
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
rp= proc_addr(who_p);
|
2006-01-27 14:21:12 +01:00
|
|
|
privp= priv(rp);
|
|
|
|
if (!privp)
|
|
|
|
{
|
2008-11-19 13:26:10 +01:00
|
|
|
kprintf("do_irqctl: no priv structure!\n");
|
2006-01-27 14:21:12 +01:00
|
|
|
return EPERM;
|
|
|
|
}
|
|
|
|
if (privp->s_flags & CHECK_IRQ)
|
|
|
|
{
|
|
|
|
for (i= 0; i<privp->s_nr_irq; i++)
|
|
|
|
{
|
|
|
|
if (irq_vec == privp->s_irq_tab[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i >= privp->s_nr_irq)
|
|
|
|
{
|
|
|
|
kprintf(
|
|
|
|
"do_irqctl: IRQ check failed for proc %d, IRQ %d\n",
|
|
|
|
m_ptr->m_source, irq_vec);
|
|
|
|
return EPERM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-02 16:30:04 +02:00
|
|
|
/* Find a free IRQ hook for this mapping. */
|
|
|
|
hook_ptr = NULL;
|
|
|
|
for (irq_hook_id=0; irq_hook_id<NR_IRQ_HOOKS; irq_hook_id++) {
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
if (irq_hooks[irq_hook_id].proc_nr_e == NONE) {
|
2005-05-02 16:30:04 +02:00
|
|
|
hook_ptr = &irq_hooks[irq_hook_id]; /* free hook */
|
|
|
|
break;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2005-05-02 16:30:04 +02:00
|
|
|
if (hook_ptr == NULL) return(ENOSPC);
|
|
|
|
|
2005-07-29 14:44:42 +02:00
|
|
|
/* When setting a policy, the caller must provide an identifier that
|
|
|
|
* is returned on the notification message if a interrupt occurs.
|
|
|
|
*/
|
|
|
|
notify_id = (unsigned) m_ptr->IRQ_HOOK_ID;
|
|
|
|
if (notify_id > CHAR_BIT * sizeof(irq_id_t) - 1) return(EINVAL);
|
|
|
|
|
|
|
|
/* Install the handler. */
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
hook_ptr->proc_nr_e = m_ptr->m_source; /* process to notify */
|
2005-07-29 14:44:42 +02:00
|
|
|
hook_ptr->notify_id = notify_id; /* identifier to pass */
|
2005-05-02 16:30:04 +02:00
|
|
|
hook_ptr->policy = m_ptr->IRQ_POLICY; /* policy for interrupts */
|
|
|
|
put_irq_handler(hook_ptr, irq_vec, generic_handler);
|
|
|
|
|
|
|
|
/* Return index of the IRQ hook in use. */
|
2005-05-19 11:36:44 +02:00
|
|
|
m_ptr->IRQ_HOOK_ID = irq_hook_id + 1;
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
2005-05-10 13:06:24 +02:00
|
|
|
|
2005-07-19 14:21:36 +02:00
|
|
|
case IRQ_RMPOLICY:
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
if (irq_hook_id < 0 || irq_hook_id >= NR_IRQ_HOOKS ||
|
|
|
|
irq_hooks[irq_hook_id].proc_nr_e == NONE) {
|
2005-07-19 14:21:36 +02:00
|
|
|
return(EINVAL);
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
} else if (m_ptr->m_source != irq_hooks[irq_hook_id].proc_nr_e) {
|
2005-07-19 14:21:36 +02:00
|
|
|
return(EPERM);
|
|
|
|
}
|
2005-07-20 17:25:38 +02:00
|
|
|
/* Remove the handler and return. */
|
|
|
|
rm_irq_handler(&irq_hooks[irq_hook_id]);
|
2005-07-19 14:21:36 +02:00
|
|
|
break;
|
2005-05-12 18:06:37 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
default:
|
2005-05-12 18:06:37 +02:00
|
|
|
r = EINVAL; /* invalid IRQ_REQUEST */
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2005-05-12 18:06:37 +02:00
|
|
|
return(r);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2005-07-29 17:26:23 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* generic_handler *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE int generic_handler(hook)
|
|
|
|
irq_hook_t *hook;
|
|
|
|
{
|
|
|
|
/* This function handles hardware interrupt in a simple and generic way. All
|
|
|
|
* interrupts are transformed into messages to a driver. The IRQ line will be
|
|
|
|
* reenabled if the policy says so.
|
|
|
|
*/
|
2009-09-15 11:57:22 +02:00
|
|
|
int proc_nr;
|
2005-07-29 17:26:23 +02:00
|
|
|
|
|
|
|
/* As a side-effect, the interrupt handler gathers random information by
|
|
|
|
* timestamping the interrupt events. This is used for /dev/random.
|
|
|
|
*/
|
2009-04-02 17:24:44 +02:00
|
|
|
get_randomness(&krandom, hook->irq);
|
2005-07-29 17:26:23 +02:00
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
/* Check if the handler is still alive.
|
|
|
|
* If it's dead, this should never happen, as processes that die
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
* automatically get their interrupt hooks unhooked.
|
|
|
|
*/
|
2009-09-15 11:57:22 +02:00
|
|
|
if(!isokendpt(hook->proc_nr_e, &proc_nr))
|
2008-11-19 13:26:10 +01:00
|
|
|
minix_panic("invalid interrupt handler", hook->proc_nr_e);
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
|
2005-07-29 17:26:23 +02:00
|
|
|
/* Add a bit for this interrupt to the process' pending interrupts. When
|
|
|
|
* sending the notification message, this bit map will be magically set
|
|
|
|
* as an argument.
|
|
|
|
*/
|
2009-09-15 11:57:22 +02:00
|
|
|
priv(proc_addr(proc_nr))->s_int_pending |= (1 << hook->notify_id);
|
2005-07-29 17:26:23 +02:00
|
|
|
|
|
|
|
/* Build notification message and return. */
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
lock_notify(HARDWARE, hook->proc_nr_e);
|
2005-07-29 17:26:23 +02:00
|
|
|
return(hook->policy & IRQ_REENABLE);
|
|
|
|
}
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
#endif /* USE_IRQCTL */
|
|
|
|
|