Subversion Repositories Kolibri OS

Rev

Rev 859 | Rev 888 | 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 PG_MAP        1
  33.  
  34.  
  35. #define PAGE_SIZE    4096
  36. #define FRAME_WIDTH  12
  37.  
  38. #define BUDDY_SYSTEM_INNER_BLOCK  0xff
  39.  
  40.  
  41. # define PA2KA(x) (((addr_t) (x)) + OS_BASE)
  42. # define KA2PA(x) (((addr_t) (x)) - OS_BASE)
  43.  
  44. static inline count_t SIZE2FRAMES(size_t size)
  45. {
  46.         if (!size)
  47.                 return 0;
  48.   return (count_t) ((size - 1) >> FRAME_WIDTH) + 1;
  49. }
  50.  
  51. static inline addr_t PFN2ADDR(pfn_t frame)
  52. {
  53.   return (addr_t) (frame << FRAME_WIDTH);
  54. }
  55.  
  56. static inline pfn_t ADDR2PFN(addr_t addr)
  57. {
  58.         return (pfn_t) (addr >> FRAME_WIDTH);
  59. };
  60.  
  61. void init_mm();
  62.  
  63. addr_t __fastcall core_alloc(u32_t order);
  64. void __fastcall core_free(addr_t frame);
  65.  
  66. pfn_t alloc_page() __attribute__ ((deprecated));
  67. pfn_t __stdcall alloc_pages(count_t count) __asm__ ("_alloc_pages") __attribute__ ((deprecated));
  68.  
  69. void frame_free(pfn_t frame);
  70.  
  71. void __fastcall frame_set_parent(pfn_t pfn, void *data);
  72. void* __fastcall frame_get_parent(pfn_t pfn);
  73.  
  74. void* __fastcall heap_alloc(size_t size, u32_t flags) ;
  75.