Rev 888 | Rev 890 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 888 | Rev 889 | ||
---|---|---|---|
1 | typedef struct |
1 | typedef struct |
2 | { |
2 | { |
3 | link_t buddy_link; /**< link to the next free block inside one order */ |
3 | link_t buddy_link; /**< link to the next free block inside one order */ |
4 | count_t refcount; /**< tracking of shared frames */ |
4 | count_t refcount; /**< tracking of shared frames */ |
5 | u32_t buddy_order; /**< buddy system block order */ |
5 | u32_t buddy_order; /**< buddy system block order */ |
6 | void *parent; /**< If allocated by slab, this points there */ |
6 | void *parent; /**< If allocated by slab, this points there */ |
7 | } frame_t; |
7 | } frame_t; |
8 | 8 | ||
9 | typedef struct { |
9 | typedef struct { |
10 | SPINLOCK_DECLARE(lock); /**< this lock protects everything below */ |
10 | SPINLOCK_DECLARE(lock); /**< this lock protects everything below */ |
11 | pfn_t base; /**< frame_no of the first frame in the frames array */ |
11 | pfn_t base; /**< frame_no of the first frame in the frames array */ |
12 | count_t count; /**< Size of zone */ |
12 | count_t count; /**< Size of zone */ |
13 | 13 | ||
14 | frame_t *frames; /**< array of frame_t structures in this zone */ |
14 | frame_t *frames; /**< array of frame_t structures in this zone */ |
15 | count_t free_count; /**< number of free frame_t structures */ |
15 | count_t free_count; /**< number of free frame_t structures */ |
16 | count_t busy_count; /**< number of busy frame_t structures */ |
16 | count_t busy_count; /**< number of busy frame_t structures */ |
17 | 17 | ||
18 | u32_t max_order; |
18 | u32_t max_order; |
19 | link_t order[21]; |
19 | link_t order[21]; |
20 | 20 | ||
21 | int flags; |
21 | int flags; |
22 | } zone_t; |
22 | } zone_t; |
23 | 23 | ||
- | 24 | ||
24 | typedef struct |
25 | typedef struct |
25 | { |
26 | { |
26 | count_t count; |
27 | link_t link; |
- | 28 | link_t adj; |
|
27 | addr_t frames[18]; |
29 | addr_t base; |
- | 30 | size_t size; |
|
- | 31 | void *parent; |
|
- | 32 | u32_t state; |
|
28 | }phismem_t; |
33 | }md_t; |
29 | 34 | ||
30 | 35 | ||
31 | #define PG_MAP 1 |
36 | #define PG_MAP 1 |
32 | 37 | #define PG_WRITE 2 |
|
- | 38 | #define PG_USER 4 |
|
- | 39 | ||
- | 40 | #define PG_SW 3 |
|
- | 41 | #define PG_UW 7 |
|
- | 42 | ||
- | 43 | ||
33 | 44 | ||
34 | #define PAGE_SIZE 4096 |
45 | #define PAGE_SIZE 4096 |
35 | #define FRAME_WIDTH 12 |
46 | #define FRAME_WIDTH 12 |
36 | 47 | ||
37 | #define BUDDY_SYSTEM_INNER_BLOCK 0xff |
48 | #define BUDDY_SYSTEM_INNER_BLOCK 0xff |
38 | 49 | ||
39 | 50 | ||
40 | # define PA2KA(x) (((addr_t) (x)) + OS_BASE) |
51 | # define PA2KA(x) (((addr_t) (x)) + OS_BASE) |
41 | # define KA2PA(x) (((addr_t) (x)) - OS_BASE) |
52 | # define KA2PA(x) (((addr_t) (x)) - OS_BASE) |
42 | 53 | ||
43 | static inline count_t SIZE2FRAMES(size_t size) |
54 | static inline count_t SIZE2FRAMES(size_t size) |
44 | { |
55 | { |
45 | if (!size) |
56 | if (!size) |
46 | return 0; |
57 | return 0; |
47 | return (count_t) ((size - 1) >> FRAME_WIDTH) + 1; |
58 | return (count_t) ((size - 1) >> FRAME_WIDTH) + 1; |
48 | } |
59 | } |
49 | 60 | ||
50 | static inline addr_t PFN2ADDR(pfn_t frame) |
61 | static inline addr_t PFN2ADDR(pfn_t frame) |
51 | { |
62 | { |
52 | return (addr_t) (frame << FRAME_WIDTH); |
63 | return (addr_t) (frame << FRAME_WIDTH); |
53 | } |
64 | } |
54 | 65 | ||
55 | static inline pfn_t ADDR2PFN(addr_t addr) |
66 | static inline pfn_t ADDR2PFN(addr_t addr) |
56 | { |
67 | { |
57 | return (pfn_t) (addr >> FRAME_WIDTH); |
68 | return (pfn_t) (addr >> FRAME_WIDTH); |
58 | }; |
69 | }; |
59 | 70 | ||
60 | void init_mm(); |
71 | void init_mm(); |
61 | 72 | ||
- | 73 | void* __fastcall frame_get_parent(pfn_t pfn); |
|
- | 74 | void __fastcall frame_set_parent(pfn_t pfn, void *data); |
|
- | 75 | ||
- | 76 | void frame_free(pfn_t frame); |
|
- | 77 | ||
- | 78 | ||
62 | addr_t __fastcall core_alloc(u32_t order); |
79 | addr_t __fastcall core_alloc(u32_t order); |
63 | void __fastcall core_free(addr_t frame); |
80 | void __fastcall core_free(addr_t frame); |
64 | 81 | ||
65 | pfn_t alloc_page() __attribute__ ((deprecated)); |
82 | pfn_t alloc_page() __attribute__ ((deprecated)); |
66 | pfn_t __stdcall alloc_pages(count_t count) __asm__ ("_alloc_pages") __attribute__ ((deprecated)); |
83 | |
67 | - | ||
68 | void frame_free(pfn_t frame); |
- | |
69 | - | ||
70 | void __fastcall frame_set_parent(pfn_t pfn, void *data); |
- | |
71 | void* __fastcall frame_get_parent(pfn_t pfn); |
- | |
- | 84 | ||
72 | 85 | md_t* __fastcall md_alloc(size_t size, u32_t flags); |
|
- | 86 | void* __fastcall mem_alloc(size_t size, u32_t flags); |
|
- | 87 | void __fastcall mem_free(void *mem);><>>>>>>>>>>> |
|
73 | void* __fastcall mem_alloc(size_t size, u32_t flags) ;><>>>>>>>>>>> |
- |