Index: trunk/kernel/devices/dev_txt.h
===================================================================
--- trunk/kernel/devices/dev_txt.h	(revision 690)
+++ trunk/kernel/devices/dev_txt.h	(revision 1)
@@ -1,6 +1,6 @@
 /*
  * dev_txt.h - TXT (Text Terminal) generic device API definition.
- *
- * Author  Alain Greiner    (2016,2017,2018,2019))
+ * 
+ * Author  Alain Greiner    (2016)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -25,40 +25,23 @@
 #define _DEV_TXT_H_
 
-#include <kernel_config.h>
-#include <hal_kernel_types.h>
-#include <xlist.h>
-#include <remote_busylock.h>
+#include <almos_config.h>
+#include <hal_types.h>
 
 /****  Forward declarations  ****/
 
-struct chdev_s ;
+struct device_s ;
 
 /******************************************************************************************
  *     Generic Text Terminal device definition.
  *
- * This multi-channels generic TXT device provides access to a text terminal.
- *
- * It supports two operations that must be implemented by the driver cmd() function:
+ * This multi-channels generic TXT device provide access to a text terminal.
+ * It supports three operation types :
  * - TXT_READ : read a single character from the text terminal identified by its channel
  *   index, using a descheduling strategy for the calling thread.
  * - TXT_WRITE : write a character string to the text terminal identified by its channel
  *   index, using a descheduling strategy for the calling thread.
- *
- * It supports one operation, that must be implemented by the driver aux() function  
- * - TXT_SYNC_WRITE write a character string to the TXT0 kernel terminal, using a busy 
- *   waiting strategy for the calling thread. 
+ * - TXT_SYNC_WRITE : write a character string to the terminal identified by its channel
+ *   index, using a busy waiting strategy for the calling thread. 
  *****************************************************************************************/
-
-/******************************************************************************************
- * This defines the (implementation independant) extension for the generic TXT device.
- *****************************************************************************************/
-
-typedef struct txt_extend_s
-{
-    xptr_t            owner_xp;  /*! ext. pointer on current process owner (reference)   */
-    xlist_entry_t     root;      /*! root of list of processes attached to same TXT      */
-    remote_busylock_t lock;      /*! lock protecting this list                           */
-}
-txt_extend_t;
 
 /******************************************************************************************
@@ -69,25 +52,24 @@
 enum txt_impl_e
 {
-    IMPL_TXT_TTY =   0,
-    IMPL_TXT_RS2 =   1,
-    IMPL_TXT_MTY =   2,
+    IMPL_TXT_TTY =   0,     
+    IMPL_TXT_X86 =   1,  
 }
 txt_impl_t;
 
 /******************************************************************************************
- * This defines the arguments passed to the driver CMD function.
+ * This defines the (implementation independant) command passed to the driver.
  *****************************************************************************************/
 
-typedef enum
+enum
 {
     TXT_READ       = 0,
     TXT_WRITE      = 1,
     TXT_SYNC_WRITE = 2,
-} dev_txt_cmd_t;
+};
 
 typedef struct txt_command_s
 {
     xptr_t      dev_xp;    /*! extended pointer on the relevant TXT device descriptor    */
-    uint32_t    type;      /*! TXT_READ / TXT_WRITE                                      */
+    uint32_t    type;      /*! TXT_READ / TXT_WRITE / TXT_SYNC_WRITE                     */
     xptr_t      buf_xp;    /*! extended pointer on characters array                      */
     uint32_t    count;     /*! number of characters in buffer (must be 1 if to_mem)      */
@@ -97,42 +79,23 @@
 
 /******************************************************************************************
- * This defines the arguments passed to the driver AUX function.
- * This function implement the TXT_SYNC_WRITE operation.
+ * This function completes the TXT device descriptor initialisation,
+ * namely the link with the implementation specific driver.
+ * The func, impl, channel, is_rxt, base, and size fields must be previously initialised.
+ * It calls the specific driver initialisation function, to initialise the hardware
+ * device and the driver specific data structures when required.
+ * It creates the associated server thread.
+ * It can be executed in another cluster than cluster containing the device descriptor
+ * or the hardware device itself.
+ ******************************************************************************************
+ * @ xp_dev     : extended pointer on TXT device descriptor.
  *****************************************************************************************/
-
-typedef struct txt_sync_args_s
-{
-    xptr_t       dev_xp;    /*! extended pointer on the TXT0_TX device descriptor        */
-    const char * buffer;    /*! local pointer on characters array                        */
-    uint32_t     count;     /*! number of characters in buffer                           */
-    uint32_t     channel;   /*! channel, aka which tty to write to                       */
-}
-txt_sync_args_t;
+void dev_txt_init( xptr_t xp_dev );
 
 /******************************************************************************************
- * This function returns a printable string for the command type.
- ******************************************************************************************
- * @ type     : command type (TXT_READ / TXT_WRITE / TXT_SYNC_WRITE)
- *****************************************************************************************/
-const char * dev_txt_type_str( dev_txt_cmd_t type );
-
-/******************************************************************************************
- * This function completes the TXT chdev descriptor initialisation,
- * namely the link with the implementation specific driver.
- * The func, impl, channel, is_rxt, base fields have been previously initialised.
- * It calls the specific driver initialisation function, to initialise the hardware
- * device and the driver specific data structures when required.
- * It creates the associated server thread and allocates a WTI from local ICU.
- * It must be executed by a thread running in cluster containing the chdev descriptor.
- ******************************************************************************************
- * @ chdev     : local pointer on TXT device descriptor.
- *****************************************************************************************/
-void dev_txt_init( struct chdev_s * chdev );
-
-/******************************************************************************************
- * This blocking function reads a single character from the terminal identified
+ * This blocking function read a single character from the terminal identified
  * by the "channel" argument. The corresponding request is actually registered in the
- * chdev requests queue, and the calling thread is descheduled, blocked until
- * transfer completion. It can be called by any thread running in any cluster.
+ * device pending requests queue, and the calling thread is descheduled, blocked until
+ * transfer completion.
+ * It must be called in the client cluster.
  ******************************************************************************************
  * @ channel   : TXT channel index.
@@ -144,8 +107,9 @@
 
 /******************************************************************************************
- * This blocking function writes characters on the terminal identified
+ * This blocking function writes a character string on the terminal identified
  * by the "channel" argument. The corresponding request is actually registered in the
- * chdev requests queue, and the calling thread is descheduled, blocked until
- * transfer completion. It can be called by any thread running in any cluster.
+ * device pending requests queue, and the calling thread is descheduled, blocked until
+ * transfer completion.
+ * It must be called in the client cluster.
  ******************************************************************************************
  * @ channel   : TXT channel index.
@@ -158,18 +122,35 @@
                        uint32_t        count );
 
-/***************************************************************************************
- * This blocking function is used by the kernel to display a string on the TXT0
- * terminal, without descheduling the calling thread, without registering it
- * in the TXT0 device waiting queue, without using the TXT0 irq, and without
- * interfering with another possible TXT access to another terminal.
- * As it is used for debug, the command arguments <buffer> and <count> are registerd
- * in a specific "txt_sync_args_t" structure passed to the driver "aux" function.
+ /***************************************************************************************
+ * This low-level blocking function is used by the kernel to display one character on a 
+ * given TXT channel without descheduling the calling thread,  without registering it 
+ * in the TXT device waiting queue, and without using the TXT irq. 
  ****************************************************************************************
+ * @ channel   : TXT channel index.
  * @ buffer    : local pointer on source buffer containing the string.
  * @ count     : number of characters.
  * @ returns 0 if success / returns EINVAL if error.
  ***************************************************************************************/
-error_t dev_txt_sync_write( const char     * buffer,
-                            uint32_t         count );
+error_t dev_txt_sync_write( uint32_t   channel,
+                            char     * buffer,
+                            uint32_t   count );
+
+/******************************************************************************************
+ * This function is executed by the server thread associated to the TXT device descriptor.
+ * This thread is created and lauched by the dev_txt_init() function, and is used
+ * by the TXT_READ and TXT_WRITE operation types. It executes an infinite loop to handle
+ * sequencially all commands registered by the client threads in the device waiting queue.
+ *  
+ * The driver CMD function is blocking, and returns only when the command is completed.
+ * can use a busy waiting policy, or block the server thread on the THREAD_BLOCKED_IO_ISR
+ * condition and deschedule, using the ISR to reactivate the server thread.
+ *
+ * When the waiting queue is empty, the server thread blocks on the THREAD_BLOCKED_IO_CMD
+ * condition and deschedule. It is re-activated by a client thread registering a command.
+ ******************************************************************************************
+ * @ dev     : local pointer on device descriptor.
+ *****************************************************************************************/
+void dev_txt_server( struct device_s * dev );
+
 
 #endif	/* _DEV_TXT_H_ */
