Index: trunk/kernel/mm/kmem.h
===================================================================
--- trunk/kernel/mm/kmem.h	(revision 619)
+++ trunk/kernel/mm/kmem.h	(revision 635)
@@ -2,6 +2,5 @@
  * kmem.h - kernel unified memory allocator interface
  *
- * Authors  Ghassan Almaless (2008,2009,2010,2011,2012)
- *          Alain Greiner (2016,2017,2018)
+ * Authors  Alain Greiner (2016,2017,2018,2019)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -30,36 +29,12 @@
 
 /*************************************************************************************
- * This enum defines the Kernel Memory Types for dynamically allocated objects.
- * WARNING : this enum must be kepts consistent with use in kmem.c file.
+ * This enum defines the three Kernel Memory Allocaror types: 
  ************************************************************************************/
 
 enum
 {
-    KMEM_PAGE             = 0,   /*! reserved for PPM allocator                     */
-    KMEM_GENERIC          = 1,   /*! reserved for KHM allocator                     */
-    KMEM_KCM              = 2,   /*! kcm_t                                          */
-    KMEM_VSEG             = 3,   /*! vseg_t                                         */
-    KMEM_DEVICE           = 4,   /*! device_t                                       */
-    KMEM_MAPPER           = 5,   /*! mapper_t                                       */
-    KMEM_PROCESS          = 6,   /*! process_t                                      */
-    KMEM_CPU_CTX          = 7,   /*! hal_cpu_context_t                              */
-    KMEM_FPU_CTX          = 8,   /*! hal_fpu_context_t                              */
-    KMEM_GEN_BARRIER      = 9,   /*! generi_cbarrier_t                              */
-
-    KMEM_SMP_BARRIER      = 10,  /*! simple_barrier_t                               */
-    KMEM_DEVFS_CTX        = 11,  /*! fatfs_inode_t                                  */
-    KMEM_FATFS_CTX        = 12,  /*! fatfs_ctx_t                                    */
-    KMEM_VFS_CTX          = 13,  /*! vfs_context_t                                  */
-    KMEM_VFS_INODE        = 14,  /*! vfs_inode_t                                    */
-    KMEM_VFS_DENTRY       = 15,  /*! vfs_dentry_t                                   */
-    KMEM_VFS_FILE         = 16,  /*! vfs_file_t                                     */
-    KMEM_SEM              = 17,  /*! remote_sem_t                                   */
-    KMEM_CONDVAR          = 18,  /*! remote_condvar_t                               */
-    KMEM_MUTEX            = 19,  /*! remote_mutex_t                                 */
-
-    KMEM_DIR              = 20,  /*! remote_dir_t                                   */
-    KMEM_512_BYTES        = 21,  /*! 512 bytes aligned                              */
-
-    KMEM_TYPES_NR         = 22,
+    KMEM_PPM              = 0,   /*! PPM allocator                                  */
+    KMEM_KCM              = 1,   /*! KCM allocator                                  */
+    KMEM_KHM              = 2,   /*! KHM allocator                                  */
 };
 
@@ -79,6 +54,6 @@
 typedef struct kmem_req_s
 {
-    uint32_t      type;   /*! request type                                          */
-    uint32_t      size;   /*! ln2(nb_pages) if PPM / bytes if KHM / unused by KCM   */
+    uint32_t      type;   /*! KMEM_PPM / KMEM_KCM / KMEM_KHM                        */
+    uint32_t      order;  /*! PPM: ln2(pages) / KCM: ln2(bytes) / KHM: bytes        */
     uint32_t      flags;  /*! request attributes                                    */
     void        * ptr;    /*! local pointer on allocated buffer (only used by free) */
@@ -87,47 +62,34 @@
 
 /*************************************************************************************
- * This generic function allocates physical memory in the local cluster
- * as specified by the request descriptor.
- * It uses three specialised physical memory allocators, depending on request type:
- * - PPM (Physical Pages Manager) allocates N contiguous physical pages,
- *       N must be a power of 2.
- * - KHM (Kernel Heap Manager) allocates a physical memory buffer,
- *       that can have any size.
- * - KCM (Kernel Cache Manager) allocates various fixed size objects,
- *       handling a dedicated cache for each object type.
+ * These two functions allocate physical memory in a local or remote cluster
+ * as specified by the kmem_req_t request descriptor, and return a local pointer
+ * on the allocated buffer. It uses three specialised physical memory allocators:
+ * - PPM (Physical Pages Manager) allocates N contiguous small physical pages.
+ *       N is a power of 2, and req.order = ln(N). Implement the buddy algorithm.
+ * - KCM (Kernel Cache Manager) allocates aligned blocks of M bytes from a cache.
+ *       M is a power of 2, and req.order = ln( M ). One cache per block size.
+ * - KHM (Kernel Heap Manager) allocates physical memory buffers of M bytes,
+ *       M can have any value, and req.order = M.
  *************************************************************************************
- * @ req   : local pointer to allocation request.
- * @ return a local pointer on page descriptor if KMEM_PAGE.
- *   return a local pointer to allocated buffer if KCM or KHM.
- *   return NULL if no physical memory available.
+ * @ cxy   : target cluster identifier for a remote access.
+ * @ req   : local pointer on allocation request.
+ * @ return local pointer on allocated buffer if success / return NULL if no memory.
  ************************************************************************************/
 void * kmem_alloc( kmem_req_t * req );
 
+void * kmem_remote_alloc( cxy_t        cxy,
+                          kmem_req_t * req );
+
 /*************************************************************************************
- * This function releases previously allocated physical memory, as specified
- * by the "type" and "ptr" fiels of the kmem-req_t request.
+ * These two functions release previously allocated physical memory, as specified
+ * by the <type> and <ptr> fields of the kmem_req_t request descriptor.
  *************************************************************************************
+ * @ cxy   : target cluster identifier for a remote access.
  * @ req : local pointer to request descriptor.
  ************************************************************************************/
 void  kmem_free ( kmem_req_t * req );
 
-/*************************************************************************************
- * This function returns a printable string for a kmem object type.
- *************************************************************************************
- * @ type   : kmem object type.
- ************************************************************************************/
-char * kmem_type_str( uint32_t type );
-
-/*************************************************************************************
- * This function returns the size (bytes) for a kmem object type.
- *************************************************************************************
- * @ type   : kmem object type.
- ************************************************************************************/
-uint32_t kmem_type_size( uint32_t type );
-
-/*************************************************************************************
- * This function displays the content of the KCM pointers Table
- ************************************************************************************/
-void kmem_print_kcm_table( void );
+void  kmem_remote_free( cxy_t        cxy,
+                        kmem_req_t * req );
 
 
