Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1281 → Rev 1280

/kernel/trunk/arch/amd64/src/interrupt.c
45,7 → 45,7
#include <synch/spinlock.h>
#include <arch/ddi/ddi.h>
#include <interrupt.h>
#include <ipc/irq.h>
#include <ipc/sysipc.h>
 
void print_info_errcode(int n, istate_t *istate)
{
/kernel/trunk/generic/include/ipc/irq.h
File deleted
/kernel/trunk/generic/include/ipc/sysipc.h
30,7 → 30,6
#define __SYSIPC_H__
 
#include <ipc/ipc.h>
#include <ipc/irq.h>
 
__native sys_ipc_call_sync_fast(__native phoneid, __native method,
__native arg1, ipc_data_t *data);
46,7 → 45,9
__native sys_ipc_forward_fast(__native callid, __native phoneid,
__native method, __native arg1);
__native sys_ipc_hangup(int phoneid);
__native sys_ipc_register_irq(__native irq, irq_code_t *ucode);
__native sys_ipc_register_irq(__native irq);
__native sys_ipc_unregister_irq(__native irq);
 
void irq_ipc_bind_arch(__native irq);
 
#endif
/kernel/trunk/generic/include/ipc/ipc.h
210,7 → 210,11
extern int ipc_phone_hangup(phone_t *phone);
extern void ipc_backsend_err(phone_t *phone, call_t *call, __native err);
 
extern int ipc_irq_register(answerbox_t *box, int irq);
extern void ipc_irq_send_notif(int irq);
extern void ipc_irq_unregister(answerbox_t *box, int irq);
 
 
extern answerbox_t *ipc_phone_0;
 
#endif
/kernel/trunk/generic/include/errno.h
41,6 → 41,5
* to close the connection. Used by answerbox
* to close the connection. */
#define EEXISTS -8 /* Entry already exists */
#define EBADMEM -9 /* Bad memory pointer */
 
#endif
/kernel/trunk/generic/src/ipc/irq.c
File deleted
/kernel/trunk/generic/src/ipc/ipc.c
44,7 → 44,6
#include <print.h>
#include <proc/thread.h>
#include <arch/interrupt.h>
#include <ipc/irq.h>
 
/* Open channel that is assigned automatically to new tasks */
answerbox_t *ipc_phone_0 = NULL;
51,6 → 50,14
 
static slab_cache_t *ipc_call_slab;
 
typedef struct {
SPINLOCK_DECLARE(lock);
answerbox_t *box;
} ipc_irq_t;
 
static ipc_irq_t *irq_conns = NULL;
static int irq_conns_size;
 
/* Initialize new call */
static void _ipc_call_init(call_t *call)
{
321,7 → 328,7
ipl = interrupts_disable();
spinlock_lock(&box->irq_lock);
 
request = list_get_instance(box->irq_notifs.next, call_t, list);
request = list_get_instance(box->answers.next, call_t, list);
list_remove(&request->list);
 
spinlock_unlock(&box->irq_lock);
363,6 → 370,26
}
}
 
/** Disconnect all irq's notifications
*
* TODO: It may be better to do some linked list, so that
* we wouldn't need to go through whole array every cleanup
*/
static void ipc_irq_cleanup(answerbox_t *box)
{
int i;
ipl_t ipl;
for (i=0; i < irq_conns_size; i++) {
ipl = interrupts_disable();
spinlock_lock(&irq_conns[i].lock);
if (irq_conns[i].box == box)
irq_conns[i].box = NULL;
spinlock_unlock(&irq_conns[i].lock);
interrupts_restore(ipl);
}
}
 
/** Cleans up all IPC communication of the given task
*
*
416,7 → 443,81
}
}
 
/** Initialize table of interrupt handlers */
static void ipc_irq_make_table(int irqcount)
{
int i;
 
irq_conns_size = irqcount;
irq_conns = malloc(irqcount * (sizeof(*irq_conns)), 0);
for (i=0; i < irqcount; i++) {
spinlock_initialize(&irq_conns[i].lock, "irq_ipc_lock");
irq_conns[i].box = NULL;
}
}
 
void ipc_irq_unregister(answerbox_t *box, int irq)
{
ipl_t ipl;
 
ipl = interrupts_disable();
spinlock_lock(&irq_conns[irq].lock);
if (irq_conns[irq].box == box)
irq_conns[irq].box = NULL;
 
spinlock_unlock(&irq_conns[irq].lock);
interrupts_restore(ipl);
}
 
/** Register an answerbox as a receiving end of interrupts notifications */
int ipc_irq_register(answerbox_t *box, int irq)
{
ipl_t ipl;
 
ASSERT(irq_conns);
 
ipl = interrupts_disable();
spinlock_lock(&irq_conns[irq].lock);
 
if (irq_conns[irq].box) {
spinlock_unlock(&irq_conns[irq].lock);
interrupts_restore(ipl);
return EEXISTS;
}
irq_conns[irq].box = box;
spinlock_unlock(&irq_conns[irq].lock);
interrupts_restore(ipl);
 
return 0;
}
 
/** Notify process that an irq had happend
*
* We expect interrupts to be disabled
*/
void ipc_irq_send_notif(int irq)
{
call_t *call;
 
ASSERT(irq_conns);
spinlock_lock(&irq_conns[irq].lock);
 
if (irq_conns[irq].box) {
call = ipc_call_alloc(FRAME_ATOMIC);
call->flags |= IPC_CALL_NOTIF;
IPC_SET_METHOD(call->data, IPC_M_INTERRUPT);
IPC_SET_ARG1(call->data, irq);
 
spinlock_lock(&irq_conns[irq].box->irq_lock);
list_append(&call->list, &irq_conns[irq].box->irq_notifs);
spinlock_unlock(&irq_conns[irq].box->irq_lock);
 
waitq_wakeup(&irq_conns[irq].box->wq, 0);
}
spinlock_unlock(&irq_conns[irq].lock);
}
 
/** Initilize ipc subsystem */
void ipc_init(void)
{
/kernel/trunk/generic/src/ipc/sysipc.c
35,7 → 35,6
#include <debug.h>
#include <ipc/ipc.h>
#include <ipc/sysipc.h>
#include <ipc/irq.h>
#include <ipc/ipcrsc.h>
#include <arch/interrupt.h>
 
478,14 → 477,13
}
 
/** Connect irq handler to task */
__native sys_ipc_register_irq(__native irq, irq_code_t *ucode)
__native sys_ipc_register_irq(__native irq)
{
if (irq >= IRQ_COUNT)
return -ELIMIT;
 
irq_ipc_bind_arch(irq);
 
return ipc_irq_register(&TASK->answerbox, irq, ucode);
return ipc_irq_register(&TASK->answerbox, irq);
}
 
/* Disconnect irq handler from task */
/kernel/trunk/Makefile
156,7 → 156,6
generic/src/ipc/ipc.c \
generic/src/ipc/sysipc.c \
generic/src/ipc/ipcrsc.c \
generic/src/ipc/irq.c \
generic/src/security/cap.c
 
## Test sources