Subversion Repositories Kolibri OS

Rev

Rev 859 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. typedef struct
  3. {
  4.   link_t buddy_link;        /**< link to the next free block inside one  order */
  5.   count_t refcount;         /**< tracking of shared frames  */
  6.   u32_t buddy_order;        /**< buddy system block order */
  7.   void *parent;             /**< If allocated by slab, this points there */
  8. } frame_t;
  9.  
  10. typedef struct {
  11.   SPINLOCK_DECLARE(lock);   /**< this lock protects everything below */
  12.   pfn_t base;               /**< frame_no of the first frame in the frames array */
  13.   count_t count;            /**< Size of zone */
  14.  
  15.   frame_t *frames;          /**< array of frame_t structures in this zone */
  16.   count_t free_count;       /**< number of free frame_t structures */
  17.   count_t busy_count;       /**< number of busy frame_t structures */
  18.  
  19.   u32_t max_order;
  20.   link_t order[21];
  21.  
  22.         int flags;
  23. } zone_t;
  24.  
  25.  
  26. # define PA2KA(x) (((u32_t) (x)) + OS_BASE)
  27. # define KA2PA(x) (((u32_t) (x)) - OS_BASE)
  28.  
  29. #define PAGE_SIZE    4096
  30. #define FRAME_WIDTH  12
  31.  
  32. #define BUDDY_SYSTEM_INNER_BLOCK  0xff
  33.  
  34. static inline count_t SIZE2FRAMES(size_t size)
  35. {
  36.         if (!size)
  37.                 return 0;
  38.   return (count_t) ((size - 1) >> FRAME_WIDTH) + 1;
  39. }
  40.  
  41. static inline addr_t PFN2ADDR(pfn_t frame)
  42. {
  43.   return (addr_t) (frame << FRAME_WIDTH);
  44. }
  45.  
  46. static inline pfn_t ADDR2PFN(addr_t addr)
  47. {
  48.         return (pfn_t) (addr >> FRAME_WIDTH);
  49. };
  50.  
  51. void init_mm();
  52.  
  53. pfn_t  core_alloc(u32_t order);
  54.  
  55. pfn_t alloc_page() __attribute__ ((deprecated));
  56. pfn_t __stdcall alloc_pages(count_t count) __asm__ ("_alloc_pages") __attribute__ ((deprecated));
  57.  
  58. void core_free(pfn_t frame);
  59. void frame_free(pfn_t frame);
  60.