irq_threads.c File Reference

IRQ threads handling client requests and IRQs. More...

#include <omega0_proto.h>
#include <l4/sys/types.h>
#include <l4/sys/ipc.h>
#include <l4/sys/ktrace.h>
#include <l4/util/util.h>
#include <l4/rmgr/librmgr.h>
#include <l4/log/l4log.h>
#include <l4/omega0/client.h>
#include <l4/util/rdtsc.h>
#include <l4/util/spin.h>
#include <l4/util/macros.h>
#include <stdio.h>
#include "globals.h"
#include "irq_threads.h"
#include "create_threads.h"
#include "config.h"

Go to the source code of this file.

Data Structures

struct  client_ipc_t

Enumerations

enum  client_ipc_enum { RET_HANDLE, RET_REPLY, RET_WAIT }
 return codes for IPC handling functions More...

Functions

static int signal_single_user_thread (int irq, client_chain *c, client_ipc_t *ipc)
 Signal a single user thread. Assume, the client is waiting.
static int signal_user_threads (int irq, client_ipc_t *ipc)
 Signal all user threads waiting on this irq and await new request.
static void irq_enable (int num)
static int irq_consume (int irq)
 Actually consume an irq.
void check_auto_consume (int irq, client_chain *c)
 Checks if the given client is a candidate for auto-consuming an irq.
static int handle_user_request (int irq, client_ipc_t *ipc)
 Handle clients requests.
static void attach_irq (int num)
 Attach to a specified irq.
void irq_handler (int num)
 Handler function for one irq.
int attach_irqs (void)
 Initialize the local irq acceptor threads.


Detailed Description

IRQ threads handling client requests and IRQs.

Date:
2007-04-27
Author:
Jork Loeser <jork.loeser@inf.tu-dresden.de>

Christian Helmuth <ch12@os.inf.tu-dresden.de>

L4V2 protocol:

Recent Fiasco extends this protocol:

Definition in file irq_threads.c.


Enumeration Type Documentation

return codes for IPC handling functions

Enumerator:
RET_HANDLE 
RET_REPLY 
RET_WAIT 

Definition at line 44 of file irq_threads.c.


Function Documentation

static void attach_irq ( int  num  )  [static]

Attach to a specified irq.

If the irq is available, its available flag is set to 1, otherwise it is cleared.

Definition at line 372 of file irq_threads.c.

int attach_irqs ( void   ) 

Initialize the local irq acceptor threads.

This function will attach to all irqs possible and initialize the corresponding structures. At the standard-pc-x86 architecture, we have irqs 0 to 15. Try to attach to all of them. This is done by creating 16 threads, one per irq. Threads start at lthread+1.

create_threads_sync() is external to allow overloading in other pkgs.

Definition at line 519 of file irq_threads.c.

void check_auto_consume ( int  irq,
client_chain c 
)

Checks if the given client is a candidate for auto-consuming an irq.

Auto-consuming is possible, if:

  • the client is marked as in service (got a notification)
  • the clients's occurence-number matches that of the IRQ
  • the IRQ is in service
  • this client was the last (i.e., the number if waiting clients = 1)

Maybe some of the conditions follow from others.

Precondition:
The irq-mutex must be hold outside.

Definition at line 201 of file irq_threads.c.

static int handle_user_request ( int  irq,
client_ipc_t ipc 
) [static]

Handle clients requests.

Actions:

  • wait - wait until next irq
  • mask - mask the (unmasked) irq
  • unmask - unmask the (masked) irq
  • consume - previously occured irq consumed, may occur again

If an wait operation occures while the in_service flag is set, the client cannot handle the irq. Do nothing. At least one client should send the consume action.

If the OMEGA0_STRATEGY_AUTO_CONSUME option is set, a consume operation is automatically done if all clients are waiting an no client consumed the irq explicitely (i.e., sent a consume action).

Requests from unregistered clients are ignored silently.

If a client has to be awaken, this function uses reply-and wait and awaits the next request.

Parameters:
ipc in: contains client id and its dwords. out: contains ipc parameters of newly arrived request (if retval=RET_HANDLE)
Return values:
RET_HADNLE ipc contains the next request. Handle it.
RET_REPLY Return an ipc to the client and wait for next request.
RET_WAIT No additional action needed, wait for next request.
<0 error, send back to client and wait for next request.

Definition at line 249 of file irq_threads.c.

static int irq_consume ( int  irq  )  [inline, static]

Actually consume an irq.

The function checks if the IRQ is in service, and if so, it consumes it according to the current policy. After that, the in-service flag is reset.

Returns:
0 if the IRQ was in service, -1 else.

Definition at line 176 of file irq_threads.c.

static void irq_enable ( int  num  )  [inline, static]

Enable IRQ in kernel

Definition at line 159 of file irq_threads.c.

void irq_handler ( int  num  ) 

Handler function for one irq.

After calling attach_irq(), return an IPC to the management thread and wait for incoming IRQs.

Definition at line 410 of file irq_threads.c.

static int signal_single_user_thread ( int  irq,
client_chain c,
client_ipc_t ipc 
) [static]

Signal a single user thread. Assume, the client is waiting.

Parameters:
ipc If !0, the last client-reply will await a new request. IPC will contain newly-arrived client-request uppon return.
Return values:
0 OK. If ipc was !0, ipc contains the new client request.
!0 ipc was not 0, and IPC-operation failed. Either send or receive. Anyway, don't use ipc.

Definition at line 68 of file irq_threads.c.

static int signal_user_threads ( int  irq,
client_ipc_t ipc 
) [static]

Signal all user threads waiting on this irq and await new request.

Note:
This does not allow multiple lines per irq up to now, because this requires multiple threads per client at the server.
Parameters:
ipc If !0, the last client-reply will await a new request. IPC will contain newly-arrived client-request uppon return.
Return values:
0 OK. If ipc was !0, ipc contains the new client request.
!0 ipc was not 0, and IPC-operation failed, or none was notified. Either send receive. Anyway, don't use ipc.

Definition at line 127 of file irq_threads.c.


Generated on Wed Apr 11 06:38:07 2012 for Omega0 DROPS Interrupt Service by  doxygen 1.5.6