Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1065 → Rev 1066

/kernel/branches/kolibri_pe/include/mm.h
1,13 → 1,24
 
typedef struct
{
link_t link;
addr_t base;
size_t size;
addr_t pte[0];
 
}mmap_t;
 
 
typedef struct
{
link_t buddy_link; /**< link to the next free block inside one order */
count_t refcount; /**< tracking of shared frames */
u32_t buddy_order; /**< buddy system block order */
u16_t refcount; /**< tracking of shared frames */
u16_t buddy_order; /**< buddy system block order */
void *parent; /**< If allocated by slab, this points there */
} frame_t;
 
typedef struct {
typedef struct
{
SPINLOCK_DECLARE(lock); /**< this lock protects everything below */
pfn_t base; /**< frame_no of the first frame in the frames array */
count_t count; /**< Size of zone */
44,11 → 55,9
 
 
#define PAGE_SIZE 4096
#define FRAME_WIDTH 12
#define PAGE_WIDTH 12
 
#define BUDDY_SYSTEM_INNER_BLOCK 0xff
 
 
# define PA2KA(x) (((addr_t) (x)) + OS_BASE)
# define KA2PA(x) (((addr_t) (x)) - OS_BASE)
 
56,39 → 65,39
{
if (!size)
return 0;
return (count_t) ((size - 1) >> FRAME_WIDTH) + 1;
return (count_t) ((size - 1) >> PAGE_WIDTH) + 1;
}
 
static inline addr_t PFN2ADDR(pfn_t frame)
{
return (addr_t) (frame << FRAME_WIDTH);
return (addr_t) (frame << PAGE_WIDTH);
}
 
static inline pfn_t ADDR2PFN(addr_t addr)
{
return (pfn_t) (addr >> FRAME_WIDTH);
return (pfn_t) (addr >> PAGE_WIDTH);
};
 
void init_mm();
void init_pg_slab();
 
void* __fastcall frame_get_parent(pfn_t pfn);
void __fastcall frame_set_parent(pfn_t pfn, void *data);
 
void frame_free(pfn_t frame);
 
 
addr_t __fastcall core_alloc(u32_t order);
void __fastcall core_free(addr_t frame);
 
pfn_t alloc_page() __attribute__ ((deprecated));
 
addr_t alloc_page(void);
 
#define __export __attribute__ ((dllexport))
 
 
md_t* __fastcall md_alloc(size_t size, u32_t flags) ;
void __fastcall md_free(md_t *md);
 
void* __fastcall __export mem_alloc(size_t size, u32_t flags) asm ("MemAlloc");
void __fastcall __export mem_free(void *mem) asm ("MemFree");
addr_t __fastcall __export mem_alloc(size_t size, u32_t flags) asm ("MemAlloc");
void __fastcall __export mem_free(addr_t mem) asm ("MemFree");
 
addr_t __fastcall frame_alloc(size_t size);
size_t __fastcall frame_free(addr_t addr);