Subversion Repositories Kolibri OS

Rev

Rev 888 | Rev 890 | 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. typedef struct
  27. {
  28.     link_t  link;
  29.     link_t  adj;
  30.     addr_t  base;
  31.     size_t  size;
  32.     void   *parent;
  33.     u32_t   state;
  34. }md_t;
  35.  
  36.  
  37. #define PG_MAP        1
  38. #define PG_WRITE      2
  39. #define PG_USER       4
  40.  
  41. #define PG_SW         3
  42. #define PG_UW         7
  43.  
  44.  
  45.  
  46. #define PAGE_SIZE    4096
  47. #define FRAME_WIDTH  12
  48.  
  49. #define BUDDY_SYSTEM_INNER_BLOCK  0xff
  50.  
  51.  
  52. # define PA2KA(x) (((addr_t) (x)) + OS_BASE)
  53. # define KA2PA(x) (((addr_t) (x)) - OS_BASE)
  54.  
  55. static inline count_t SIZE2FRAMES(size_t size)
  56. {
  57.         if (!size)
  58.                 return 0;
  59.   return (count_t) ((size - 1) >> FRAME_WIDTH) + 1;
  60. }
  61.  
  62. static inline addr_t PFN2ADDR(pfn_t frame)
  63. {
  64.   return (addr_t) (frame << FRAME_WIDTH);
  65. }
  66.  
  67. static inline pfn_t ADDR2PFN(addr_t addr)
  68. {
  69.         return (pfn_t) (addr >> FRAME_WIDTH);
  70. };
  71.  
  72. void init_mm();
  73.  
  74. void* __fastcall frame_get_parent(pfn_t pfn);
  75. void  __fastcall frame_set_parent(pfn_t pfn, void *data);
  76.  
  77. void frame_free(pfn_t frame);
  78.  
  79.  
  80. addr_t __fastcall core_alloc(u32_t order);
  81. void   __fastcall core_free(addr_t frame);
  82.  
  83. pfn_t alloc_page() __attribute__ ((deprecated));
  84.  
  85.  
  86. md_t* __fastcall md_alloc(size_t size, u32_t flags);
  87. void* __fastcall mem_alloc(size_t size, u32_t flags);
  88. void  __fastcall mem_free(void *mem);
  89.  
  90.