Rev 759 | Rev 763 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 759 | Rev 762 | ||
|---|---|---|---|
| Line 37... | Line 37... | ||
| 37 | #include <mm/buddy.h> |
37 | #include <mm/buddy.h> |
| 38 | #include <mm/slab.h> |
38 | #include <mm/slab.h> |
| 39 | 39 | ||
| 40 | #define ONE_FRAME 0 |
40 | #define ONE_FRAME 0 |
| 41 | 41 | ||
| 42 | #define FRAME_KA 1 /* skip frames conflicting with user address space */ |
42 | #define FRAME_KA 0x1 /* skip frames conflicting with user address space */ |
| 43 | #define FRAME_PANIC 2 /* panic on failure */ |
43 | #define FRAME_PANIC 0x2 /* panic on failure */ |
| 44 | #define FRAME_ATOMIC 4 /* do not panic and do not sleep on failure */ |
44 | #define FRAME_ATOMIC 0x4 /* do not panic and do not sleep on failure */ |
| - | 45 | #define FRAME_NO_RECLAIM 0x8 /* Do not start reclaiming when no free memory */ |
|
| 45 | 46 | ||
| 46 | #define FRAME_OK 0 /* frame_alloc return status */ |
47 | #define FRAME_OK 0 /* frame_alloc return status */ |
| 47 | #define FRAME_NO_MEMORY 1 /* frame_alloc return status */ |
48 | #define FRAME_NO_MEMORY 1 /* frame_alloc return status */ |
| 48 | #define FRAME_ERROR 2 /* frame_alloc return status */ |
49 | #define FRAME_ERROR 2 /* frame_alloc return status */ |
| 49 | 50 | ||
| Line 76... | Line 77... | ||
| 76 | 77 | ||
| 77 | struct frame { |
78 | struct frame { |
| 78 | count_t refcount; /**< tracking of shared frames */ |
79 | count_t refcount; /**< tracking of shared frames */ |
| 79 | __u8 buddy_order; /**< buddy system block order */ |
80 | __u8 buddy_order; /**< buddy system block order */ |
| 80 | link_t buddy_link; /**< link to the next free block inside one order */ |
81 | link_t buddy_link; /**< link to the next free block inside one order */ |
| 81 | slab_slab_t *slab; /**< If allocated by slab, this points there */ |
82 | void *parent; /**< If allocated by slab, this points there */ |
| 82 | }; |
83 | }; |
| 83 | 84 | ||
| 84 | struct region { |
85 | struct region { |
| 85 | __address base; |
86 | __address base; |
| 86 | size_t size; |
87 | size_t size; |
| Line 98... | Line 99... | ||
| 98 | extern void zone_attach(zone_t *zone); |
99 | extern void zone_attach(zone_t *zone); |
| 99 | 100 | ||
| 100 | extern void frame_init(void); |
101 | extern void frame_init(void); |
| 101 | extern void frame_initialize(frame_t *frame, zone_t *zone); |
102 | extern void frame_initialize(frame_t *frame, zone_t *zone); |
| 102 | 103 | ||
| 103 | __address frame_alloc(int flags, __u8 order, int * status); |
104 | __address frame_alloc(int flags, __u8 order, int * status, zone_t **pzone); |
| 104 | extern void frame_free(__address addr); |
105 | extern void frame_free(__address addr); |
| 105 | 106 | ||
| 106 | zone_t * get_zone_by_frame(frame_t * frame); |
107 | zone_t * get_zone_by_frame(frame_t * frame); |
| 107 | 108 | ||
| 108 | /* |
109 | /* |
| Line 112... | Line 113... | ||
| 112 | link_t * zone_buddy_bisect(buddy_system_t *b, link_t * block); |
113 | link_t * zone_buddy_bisect(buddy_system_t *b, link_t * block); |
| 113 | link_t * zone_buddy_coalesce(buddy_system_t *b, link_t * buddy_l, link_t * buddy_r); |
114 | link_t * zone_buddy_coalesce(buddy_system_t *b, link_t * buddy_l, link_t * buddy_r); |
| 114 | void zone_buddy_set_order(buddy_system_t *b, link_t * block, __u8 order); |
115 | void zone_buddy_set_order(buddy_system_t *b, link_t * block, __u8 order); |
| 115 | __u8 zone_buddy_get_order(buddy_system_t *b, link_t * block); |
116 | __u8 zone_buddy_get_order(buddy_system_t *b, link_t * block); |
| 116 | void zone_buddy_mark_busy(buddy_system_t *b, link_t * block); |
117 | void zone_buddy_mark_busy(buddy_system_t *b, link_t * block); |
| - | 118 | extern frame_t * frame_addr2frame(__address addr); |
|
| 117 | 119 | ||
| 118 | /* |
120 | /* |
| 119 | * TODO: Implement the following functions. |
121 | * TODO: Implement the following functions. |
| 120 | */ |
122 | */ |
| 121 | extern frame_t *frame_reference(frame_t *frame); |
123 | extern frame_t *frame_reference(frame_t *frame); |