Index: trunk/kernel/devices/dev_icu.h
===================================================================
--- trunk/kernel/devices/dev_icu.h	(revision 1)
+++ trunk/kernel/devices/dev_icu.h	(revision 3)
@@ -35,14 +35,14 @@
  * acting in all clusters containing cores. He is in charge of concentrating all IRQs
  * (interrupt requests) generated by peripherals to signal the completion of an I/O 
- * operation. Each IRQ should be routed to the core that started the I/O operation. 
+ * operation. Each IRQ is routed to the core that started the I/O operation. 
  * The ICU device must also help the kernel to select the ISR (Interrupt Service Routine)
  * that must be executed by the target core.
  *
- * This component can be implemented as a dedicated hardware, centralized or distributed
+ * This component can be implemented as a dedicated hardware component distributed
  * in all clusters, or emulated in software, as long as it implements the specified API.
  * For the TSAR architecture, this generic ICU device is implemented by the two hardware
  * components soclib_xicu and and soclib_iopic, and their associated drivers.
  *
- * ALMOS-MKH defines three types of IRQs, that are handled iby this ICU device:
+ * ALMOS-MKH defines three types of IRQs, that are handled by this ICU device:
  * - HWI : The HardWare Interrupts are generated by local internal peripherals.
  *   They are connected to the local ICU, to be routed to a given local core.
@@ -72,10 +72,10 @@
  * uses three interrupts vectors, implemented as three arrays (HWI/WTI/PTI),
  * stored in the core descriptor. Each entry in one interrupt vector array contains
- * an extended pointer on the device descriptor that is the "source" of the interrupt.
- * This device descriptor contains a link to the ISR to be executed.
+ * a pointer on the chdev descriptor that is the "source" of the interrupt.
+ * This chdev descriptor contains a link to the ISR to be executed.
  *
  * The ICU peripheral does not execute I/O operations, but is just acting as a 
- * dynamically configurable interrupt router for another I/O operation.
- * Therefore, ALMOS-MKH does not use the iCU device waiting queue, but calls directly 
+ * dynamically configurable interrupt router for other I/O operations.
+ * Therefore, ALMOS-MKH does not use the ICU device waiting queue, but calls directly 
  * the ICU driver blocking functions, using the device lock to get exclusive access to 
  * the ICU device state.
@@ -84,5 +84,5 @@
 /****  Forward declarations  ****/
 
-struct device_s;
+struct chdev_s;
 
 /*****************************************************************************************
@@ -127,58 +127,54 @@
 /*****************************************************************************************
  * This function makes two initialisations:
- * - It initialises the ICU specific fields of the device descriptor.
+ * - It initialises the ICU specific fields of the chdev descriptor.
  * - it initialises the implementation specific ICU hardware device and associated
  *   data structures if required.
- * It must be executed once in the cluster containing the ICU device descriptor.
- *****************************************************************************************
- * @ icu_xp     : extended pointer on ICU device descriptor.
- * @ hwi_nr     : number of HWI irqs.
- * @ wti_nr     : number of WTI irqs.
- * @ pti_nr     : number of PTI irqs.
- ****************************************************************************************/
-void dev_icu_init( xptr_t    icu_xp,
-                   uint32_t  hwi_nr,
-                   uint32_t  wti_nr,
-                   uint32_t  pti_nr );
-
-/*****************************************************************************************
- * This function enables the routing of a given IRQ, to a given core in a remote cluster.
- * This IRQ is identified by its type (HWI/WTI/PTI) and index in the remote ICU.
+ * It must be called by a local thread.
+ *****************************************************************************************
+ * @ icu     : pointer on ICU chdev descriptor.
+ * @ hwi_nr  : number of HWI irqs.
+ * @ wti_nr  : number of WTI irqs.
+ * @ pti_nr  : number of PTI irqs.
+ ****************************************************************************************/
+void dev_icu_init( struct chdev_s  * icu,
+                   uint32_t          hwi_nr,
+                   uint32_t          wti_nr,
+                   uint32_t          pti_nr );
+
+/*****************************************************************************************
+ * This function enables the routing of a given IRQ, to a given core in the local cluster.
+ * This IRQ is identified by its type (HWI/WTI/PTI) and index in the local ICU.
  * The target core is identified by its local index.
- * As it uses remote accesses, it can be executed by any thread in any cluster.
- * - It unmask the selected IRQ in the remote ICU. 
- * - It registers the extended pointer on the "source" device descriptor in the
+ * It must be called by a local thread.
+ * - It unmask the selected IRQ in the ICU. 
+ * - It registers the pointer on the "source" chdev descriptor in the
  *   relevant interrupt vector of the selected core.
- * - It register the IRQ type and index in the "source" device descriptor.
- *****************************************************************************************
- * @ cxy        : remote cluster identifier (can be the local custer).
- * @ lid        : local index of selected core in remote cluster.
+ * - It register the IRQ type and index in the "source" chdev descriptor.
+ *****************************************************************************************
+ * @ lid        : local index of selected core.
  * @ irq_type   : HWI/WTI/PTI.
- * @ irq_id     : IRQ index in remote ICU
- * @ src_dev_xp : extended pointer on device descriptor source of IRQ.
- ****************************************************************************************/
-void dev_icu_enable_irq( cxy_t      cxy,
-                         lid_t      lid,
-                         uint32_t   irq_type,
-                         uint32_t   irq_id,
-                         xptr_t     src_dev_xp );
-
-/*****************************************************************************************
- * This function disables one given IRQ for a given core in a remote cluster.
- * This IRQ is identified by its type (HWI/WTI/PTI) and index in the remote ICU.
+ * @ irq_id     : IRQ index in ICU
+ * @ chdev      : pointer on source chdev descriptor.
+ ****************************************************************************************/
+void dev_icu_enable_irq( lid_t             lid,
+                         uint32_t          irq_type,
+                         uint32_t          irq_id,
+                         struct chdev_s  * chdev );
+
+/*****************************************************************************************
+ * This function disables one given IRQ for a given core in the local cluster.
+ * This IRQ is identified by its type (HWI/WTI/PTI) and index in the local ICU.
  * The core is identified by its local index.
- * As it uses remote accesses, it can be executed by any thread in any cluster.
- * - It mask the selected IRQ in the remote ICU. 
- * - It removes the extended pointer on the "source" device descriptor from the
+ * It must be called by a local thread.
+ * - It mask the selected IRQ in the ICU. 
+ * - It removes the pointer on the "source" chdev descriptor from the
  *   relevant interrupt vector of the selected core.
- * - The IRQ type and index fields are not modified in the "source" device descriptor.
- *****************************************************************************************
- * @ cxy       : remote cluster identifier (can be the local custer).
+ * - The IRQ type and index fields are not modified in the "source" chdev descriptor.
+ *****************************************************************************************
  * @ lid       : local index of selected core in remote cluster.
  * @ irq_type  : HWI/WTI/PTI.
  * @ irq_id    : IRQ index.
  ****************************************************************************************/
-void dev_icu_disable_irq( cxy_t      cxy,
-                          lid_t      lid,
+void dev_icu_disable_irq( lid_t      lid,
                           uint32_t   irq_type,
                           uint32_t   irq_id );
@@ -187,4 +183,5 @@
  * This function set the period value for a timer identified by the PTI index,
  * in the local ICU device descriptor.
+ * It must be called by a local thread.
  *****************************************************************************************
  * @ pti_id    : PTI index.
@@ -197,4 +194,5 @@
  * This function acknowledge a PTI IRQ for a timer identified by the PTI index,
  * in the local ICU device descriptor.
+ * It must be called by a local thread.
  *****************************************************************************************
  * @ pti_id    : PTI index.
@@ -204,5 +202,6 @@
 /*****************************************************************************************
  * This function send an IPI (Inter Processor Interrupt) to a core identified by
- * its cluster identifier and local index. 
+ * its cluster identifier and local index.
+ * It can be called by any thread running in any cluster. 
  * This IPI force a context switch, and the handling of pending RPC(s).
  *****************************************************************************************
@@ -226,6 +225,7 @@
 
 /*****************************************************************************************
- * This function implements the WTI mailbox allocator. It is used by all I/O operations
- * for completion signaling.
+ * This function implements the WTI mailbox allocator for the local ICU.
+ * These mailbox are used by I/O operations for completion signaling.
+ * It must be called by a thread running in the cluster containing the target ICU.
  * If there is no mailbox available, the client thread must deschedule and retry later.
  * If N is the total number of WTI mailboxes in a cluster, and NC the number of cores,
@@ -240,4 +240,5 @@
 /*****************************************************************************************
  * This function releases a dynamically allocated WTI mailbox.
+ * It must be called by a thread running in the cluster containing the target ICU.
  * It does not access the hardware device.
  *****************************************************************************************
@@ -247,14 +248,11 @@
 
 /*****************************************************************************************
- * This function returns an extended pointer on a WTI mailbox identified by its
- * cluster identifier and local index in ICU.
- * WARNING: we assume that all ICU hardware devices have the same local base address.
- *****************************************************************************************
- * @ cxy      : mailbox cluster identifier
- * @ wti_id   : mailbox WTI index.
- * @ returns extended pointer on mailbox register.
- ****************************************************************************************/
-xptr_t  dev_icu_wti_xptr( cxy_t    cxy,
-                          uint32_t wti_id );
+ * This function returns a pointer on the WTI mailbox identified by its index
+ * in the local ICU device.
+ *****************************************************************************************
+ * @ wti_id   : WTI mailbox index.
+ * @ returns pointer on mailbox register.
+ ****************************************************************************************/
+uint32_t * dev_icu_wti_ptr( uint32_t wti_id );
 
 #endif  /* _DEV_ICU_H_ */
