Subversion Repositories Kolibri OS

Rev

Rev 854 | Rev 864 | 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. typedef struct
  26. {
  27.    count_t count;
  28.    addr_t  frames[18];
  29. }phismem_t;
  30.  
  31.  
  32. # define PA2KA(x) (((addr_t) (x)) + OS_BASE)
  33. # define KA2PA(x) (((addr_t) (x)) - OS_BASE)
  34.  
  35. #define PAGE_SIZE    4096
  36. #define FRAME_WIDTH  12
  37.  
  38. #define BUDDY_SYSTEM_INNER_BLOCK  0xff
  39.  
  40. static inline count_t SIZE2FRAMES(size_t size)
  41. {
  42.         if (!size)
  43.                 return 0;
  44.   return (count_t) ((size - 1) >> FRAME_WIDTH) + 1;
  45. }
  46.  
  47. static inline addr_t PFN2ADDR(pfn_t frame)
  48. {
  49.   return (addr_t) (frame << FRAME_WIDTH);
  50. }
  51.  
  52. static inline pfn_t ADDR2PFN(addr_t addr)
  53. {
  54.         return (pfn_t) (addr >> FRAME_WIDTH);
  55. };
  56.  
  57. void init_mm();
  58.  
  59. addr_t __fastcall core_alloc(u32_t order);
  60. void __fastcall core_free(addr_t frame);
  61.  
  62. pfn_t alloc_page() __attribute__ ((deprecated));
  63. pfn_t __stdcall alloc_pages(count_t count) __asm__ ("_alloc_pages") __attribute__ ((deprecated));
  64.  
  65. void frame_free(pfn_t frame);
  66.  
  67. void __fastcall frame_set_parent(pfn_t pfn, void *data);
  68. void* __fastcall frame_get_parent(pfn_t pfn);
  69.