Subversion Repositories Kolibri OS

Rev

Rev 892 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 892 Rev 1066
Line 1... Line 1...
1
typedef struct
1
typedef struct
2
{
2
{
-
 
3
  link_t   link;
-
 
4
  addr_t   base;
-
 
5
  size_t   size;
-
 
6
  addr_t   pte[0];
-
 
7
 
-
 
8
}mmap_t;
-
 
9
 
-
 
10
 
-
 
11
typedef struct
-
 
12
{
3
  link_t buddy_link;        /**< link to the next free block inside one  order */
13
  link_t buddy_link;        /**< link to the next free block inside one  order */
4
  count_t refcount;         /**< tracking of shared frames  */
14
  u16_t   refcount;           /**< tracking of shared frames  */
5
  u32_t buddy_order;        /**< buddy system block order */
15
  u16_t   buddy_order;        /**< buddy system block order */
6
  void *parent;             /**< If allocated by slab, this points there */
16
  void *parent;             /**< If allocated by slab, this points there */
7
} frame_t;
17
} frame_t;
Line 8... Line 18...
8
 
18
 
-
 
19
typedef struct
9
typedef struct {
20
{
10
  SPINLOCK_DECLARE(lock);   /**< this lock protects everything below */
21
  SPINLOCK_DECLARE(lock);   /**< this lock protects everything below */
11
  pfn_t base;               /**< frame_no of the first frame in the frames array */
22
  pfn_t base;               /**< frame_no of the first frame in the frames array */
Line 12... Line 23...
12
  count_t count;            /**< Size of zone */
23
  count_t count;            /**< Size of zone */
Line 42... Line 53...
42
 
53
 
Line 43... Line 54...
43
 
54
 
44
 
55
 
45
#define PAGE_SIZE    4096
-
 
46
#define FRAME_WIDTH  12
-
 
Line 47... Line 56...
47
 
56
#define PAGE_SIZE    4096
48
#define BUDDY_SYSTEM_INNER_BLOCK  0xff
57
#define PAGE_WIDTH     12
Line 49... Line 58...
49
 
58
 
50
 
59
 
51
# define PA2KA(x) (((addr_t) (x)) + OS_BASE)
60
# define PA2KA(x) (((addr_t) (x)) + OS_BASE)
52
# define KA2PA(x) (((addr_t) (x)) - OS_BASE)
61
# define KA2PA(x) (((addr_t) (x)) - OS_BASE)
53
 
62
 
54
static inline count_t SIZE2FRAMES(size_t size)
63
static inline count_t SIZE2FRAMES(size_t size)
Line 55... Line 64...
55
{
64
{
56
	if (!size)
65
	if (!size)
57
		return 0;
66
		return 0;
58
  return (count_t) ((size - 1) >> FRAME_WIDTH) + 1;
67
  return (count_t) ((size - 1) >> PAGE_WIDTH) + 1;
Line 59... Line 68...
59
}
68
}
60
 
69
 
61
static inline addr_t PFN2ADDR(pfn_t frame)
70
static inline addr_t PFN2ADDR(pfn_t frame)
62
{
71
{
Line 63... Line 72...
63
  return (addr_t) (frame << FRAME_WIDTH);
72
  return (addr_t) (frame << PAGE_WIDTH);
-
 
73
}
Line 64... Line 74...
64
}
74
 
65
 
75
static inline pfn_t ADDR2PFN(addr_t addr)
Line 66... Line -...
66
static inline pfn_t ADDR2PFN(addr_t addr)
-
 
67
{
-
 
Line 68... Line 76...
68
	return (pfn_t) (addr >> FRAME_WIDTH);
76
{
69
};
77
    return (pfn_t) (addr >> PAGE_WIDTH);
Line 70... Line -...
70
 
-
 
71
void init_mm();
-
 
Line 72... Line 78...
72
 
78
};
Line 73... Line 79...
73
void* __fastcall frame_get_parent(pfn_t pfn);
79
 
74
void  __fastcall frame_set_parent(pfn_t pfn, void *data);
80
void init_mm();
Line 75... Line 81...
75
 
81
void init_pg_slab();
76
void frame_free(pfn_t frame);
82
 
-
 
83
void* __fastcall frame_get_parent(pfn_t pfn);
-
 
84
void  __fastcall frame_set_parent(pfn_t pfn, void *data);
-
 
85