Index: generic/include/mm/buddy.h
===================================================================
--- generic/include/mm/buddy.h	(revision 6e8b3c889da1ad6788e93e1ffcc5186dd57a6303)
+++ generic/include/mm/buddy.h	(revision 30187ebf258f432c2c4e53c8b41852e6ea4ec6b0)
@@ -36,9 +36,9 @@
 
 struct buddy_system_operations {
-	link_t *(* find_buddy)(link_t *);		/**< Return pointer to left-side or right-side buddy for block passed as argument. */
-	link_t *(* bisect)(link_t *);			/**< Bisect the block passed as argument and return pointer to the new right-side buddy. */
-	link_t *(* coalesce)(link_t *, link_t *);	/**< Coalesce to buddies into a bigger block. */
-	void (*set_order)(link_t *, __u8);		/**< Set order of block passed as argument. */
-	__u8 (*get_order)(link_t *);			/**< Return order of block passed as argument. */
+	link_t *(* find_buddy)(link_t *);				/**< Return pointer to left-side or right-side buddy for block passed as argument. */
+	link_t *(* bisect)(link_t *);					/**< Bisect the block passed as argument and return pointer to the new right-side buddy. */
+	link_t *(* coalesce)(link_t *, link_t *);			/**< Coalesce to buddies into a bigger block. */
+	void (*set_order)(link_t *, __u8);				/**< Set order of block passed as argument. */
+	__u8 (*get_order)(link_t *);					/**< Return order of block passed as argument. */
 };
 
Index: generic/include/mm/frame.h
===================================================================
--- generic/include/mm/frame.h	(revision 6e8b3c889da1ad6788e93e1ffcc5186dd57a6303)
+++ generic/include/mm/frame.h	(revision 30187ebf258f432c2c4e53c8b41852e6ea4ec6b0)
@@ -1,4 +1,5 @@
 /*
  * Copyright (C) 2005 Jakub Jermar
+ * Copyright (C) 2005 Sergey Bondari
  * All rights reserved.
  *
@@ -39,6 +40,11 @@
 #define FRAME_PANIC	2	/* panic on failure */
 
-#define FRAME2ADDR(zone, frame)		((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
-#define ADDR2FRAME(zone, addr)		(&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
+#define FRAME2ADDR(zone, frame)			((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
+#define ADDR2FRAME(zone, addr)			(&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
+#define FRAME_INDEX(zone, frame)		((count_t)((frame) - (zone)->frames))
+#define IS_BUDDY_LEFT_BLOCK(zone, frame)	((FRAME_INDEX((zone), (frame)) % (1 >> ((frame)->buddy_order + 1))) == 0)
+#define IS_BUDDY_RIGHT_BLOCK(zone, frame)	((FRAME_INDEX((zone), (frame)) % (1 >> ((frame)->buddy_order + 1))) == (1 >> (frame)->buddy_order))
+
+
 
 struct zone {
@@ -52,5 +58,5 @@
 	count_t busy_count;	/**< number of frame_t structures not in free list */
 	
-	buddy_system_t * buddy_system; /**< buddy system allocator for the zone */
+	buddy_system_t * buddy_system; /**< buddy system for the zone */
 	int flags;
 };
@@ -59,5 +65,5 @@
 	count_t refcount;	/**< when == 0, the frame is in free list */
 	link_t link;		/**< link to zone free list when refcount == 0 */
-	__u8 order;		/**< buddy system  block order */
+	__u8 buddy_order;	/**< buddy system block order */
 	link_t buddy_link;	/**< link to the next free block inside one order*/
 };
@@ -76,4 +82,5 @@
 extern void frame_not_free(__address addr);
 extern void frame_region_not_free(__address start, __address stop);
+zone_t * get_zone_by_frame(frame_t * frame);
 
 /*
