Index: trunk/kernel/mm/ppm.h
===================================================================
--- trunk/kernel/mm/ppm.h	(revision 625)
+++ trunk/kernel/mm/ppm.h	(revision 632)
@@ -51,20 +51,23 @@
  *
  * The main service provided by the PMM is the dynamic allocation of physical pages
- * from the "kernel_heap" section. This low-level allocator implements the buddy 
+ * from the "kernel_heap" section. This low-level allocator implements the "buddy" 
  * algorithm: an allocated block is an integer number n of small pages, where n 
- * is a power of 2, and ln(n) is called order.
- * This allocator being shared by the local threads, the free_page lists rooted 
- * in the PPM descriptor are protected by a local busylock, because it is used
- * by the idle_thread during kernel_init().
- *
- * Another service is to register the dirty pages in a specific dirty_list, that is
+ * is a power of 2, and ln(n) is called order. The free_pages_root[] array contains
+ * the roots ot the local lists of free pages for different sizes, as required by
+ * the "buddy" algorithm. 
+ * The local threads can access these free_lists by calling the ppm_alloc_pages() and
+ * ppm_free_page() functions, but the remote threads can access the same free lists,
+ * by calling the ppm_remote_alloc_pages() and ppm_remote_free_pages functions.
+ * Therefore, these free lists are protected by a remote_busy_lock.
+ * 
+ * Another service is to register the dirty pages in a specific local dirty_list,
  * also rooted in the PPM, in order to be able to synchronize all dirty pages on disk.
  * This dirty list is protected by a specific remote_queuelock, because it can be
- * modified by a remote thread, but it contains only local pages.
+ * modified by a remote thread.
  ****************************************************************************************/
 
 typedef struct ppm_s
 {
-	busylock_t          free_lock;          /*! lock protecting free_pages[] lists      */
+	remote_busylock_t   free_lock;          /*! lock protecting free_pages[] lists      */
 	list_entry_t        free_pages_root[CONFIG_PPM_MAX_ORDER];  /*! roots of free lists */
 	uint32_t            free_pages_nr[CONFIG_PPM_MAX_ORDER];    /*! free pages number   */
@@ -80,21 +83,23 @@
 
 /*****************************************************************************************
- * This is the low-level physical pages allocation function.
- * It allocates N contiguous physical pages. N is a power of 2.
- * In normal use, it should not be called directly, as the recommended way to get
- * physical pages is to call the generic allocator defined in kmem.h.
- *****************************************************************************************
- * @ order        : ln2( number of 4 Kbytes pages)
- * @ returns a pointer on the page descriptor if success / NULL otherwise
+ * This local allocator must be called by a thread running in local cluster. 
+ * It allocates n contiguous physical 4 Kbytes pages from the local cluster, where 
+ * n is a power of 2 defined by the <order> argument. 
+ * In normal use, it should not be called directly, as the recommended way to allocate
+ * physical pages is to call the generic allocator defined in kmem.h.
+ *****************************************************************************************
+ * @ order     : ln2( number of 4 Kbytes pages)
+ * @ returns a local pointer on the page descriptor if success / NULL if error.
  ****************************************************************************************/
 page_t * ppm_alloc_pages( uint32_t order );
 
 /*****************************************************************************************
- * This is the low-level physical pages release function. It takes the lock protecting
- * the free_list before register the released page in the relevant free_list.
+ * This function must be called by a thread running in local cluster to release
+ * physical pages. It takes the lock protecting the free_lists before register the 
+ * released page in the relevant free_list.
  * In normal use, you do not need to call it directly, as the recommended way to free
  * physical pages is to call the generic allocator defined in kmem.h.
  *****************************************************************************************
- * @ page         : pointer to the page descriptor to be released
+ * @ page   : local pointer on the page descriptor to be released
  ****************************************************************************************/
 void ppm_free_pages( page_t * page );
@@ -105,15 +110,42 @@
  * there is no concurrent access issue.
  *****************************************************************************************
- * @ page         : pointer to the page descriptor to be released
+ * @ page   : local pointer on the page descriptor to be released
  ****************************************************************************************/
 void ppm_free_pages_nolock( page_t * page );
 
 /*****************************************************************************************
- * This function check if a page descriptor pointer is valid.
- *****************************************************************************************
- * @ page         : pointer on a page descriptor
- * @ returns true if valid / false otherwise.
- ****************************************************************************************/
-inline bool_t ppm_page_is_valid( page_t * page );
+ * This remote  allocator can be called by any thread running in any cluster. 
+ * It allocates n contiguous physical 4 Kbytes pages from cluster identified 
+ * by the <cxy> argument, where n is a power of 2 defined by the <order> argument. 
+ * In normal use, it should not be called directly, as the recommended way to allocate
+ * physical pages is to call the generic allocator defined in kmem.h.
+ *****************************************************************************************
+ * @ cxy       : remote cluster identifier.
+ * @ order     : ln2( number of 4 Kbytes pages)
+ * @ returns an extended pointer on the page descriptor if success / XPTR_NULL if error.
+ ****************************************************************************************/
+xptr_t  ppm_remote_alloc_pages( cxy_t    cxy,
+                                uint32_t order );
+
+/*****************************************************************************************
+ * This function can be called by any thread running in any cluster to release physical
+ * pages to a remote cluster. It takes the lock protecting the free_list before register
+ * the released page in the relevant free_list.
+ * In normal use, you do not need to call it directly, as the recommended way to free
+ * physical pages is to call the generic allocator defined in kmem.h.
+ *****************************************************************************************
+ * @ cxy       : remote cluster identifier.
+ * @ page      : local pointer on the page descriptor to be released in remote cluster.
+ ****************************************************************************************/
+void ppm_remote_free_pages( cxy_t    cxy,
+                            page_t * page );
+
+/*****************************************************************************************
+ * This debug function can be called by any thread running in any cluster to display
+ * the current PPM state of a remote cluster.
+ *****************************************************************************************
+ * @ cxy       : remote cluster identifier.
+ ****************************************************************************************/
+void ppm_remote_display( cxy_t cxy );
 
 
@@ -172,17 +204,18 @@
 
 /*****************************************************************************************
- * This function prints the PPM allocator status in the calling thread cluster.
- *****************************************************************************************
- * string   : character string printed in header
- ****************************************************************************************/
-void ppm_display( void );
-
-/*****************************************************************************************
- * This function checks PPM allocator consistency.
- *****************************************************************************************
- * @ ppm      : pointer on PPM allocator.
+ * This function can be called by any thread running in any cluster.
+ * It displays the PPM allocator status in cluster identified by the <cxy> argument.
+ *****************************************************************************************
+ * @ cxy   : remote cluster
+ ****************************************************************************************/
+void ppm_remote_display( cxy_t cxy );
+
+/*****************************************************************************************
+ * This function must be called by a thread running in local cluster.
+ * It checks the consistency of the local PPM allocator.
+ *****************************************************************************************
  * @ return 0 if PPM is OK / return -1 if PPM not consistent.
  ****************************************************************************************/
-error_t ppm_assert_order( ppm_t * ppm );
+error_t ppm_assert_order( void );
 
 
