Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 761 → Rev 762

/kernel/trunk/generic/include/mm/frame.h
39,9 → 39,10
 
#define ONE_FRAME 0
 
#define FRAME_KA 1 /* skip frames conflicting with user address space */
#define FRAME_PANIC 2 /* panic on failure */
#define FRAME_ATOMIC 4 /* do not panic and do not sleep on failure */
#define FRAME_KA 0x1 /* skip frames conflicting with user address space */
#define FRAME_PANIC 0x2 /* panic on failure */
#define FRAME_ATOMIC 0x4 /* do not panic and do not sleep on failure */
#define FRAME_NO_RECLAIM 0x8 /* Do not start reclaiming when no free memory */
 
#define FRAME_OK 0 /* frame_alloc return status */
#define FRAME_NO_MEMORY 1 /* frame_alloc return status */
78,7 → 79,7
count_t refcount; /**< tracking of shared frames */
__u8 buddy_order; /**< buddy system block order */
link_t buddy_link; /**< link to the next free block inside one order */
slab_slab_t *slab; /**< If allocated by slab, this points there */
void *parent; /**< If allocated by slab, this points there */
};
 
struct region {
100,7 → 101,7
extern void frame_init(void);
extern void frame_initialize(frame_t *frame, zone_t *zone);
 
__address frame_alloc(int flags, __u8 order, int * status);
__address frame_alloc(int flags, __u8 order, int * status, zone_t **pzone);
extern void frame_free(__address addr);
 
zone_t * get_zone_by_frame(frame_t * frame);
114,6 → 115,7
void zone_buddy_set_order(buddy_system_t *b, link_t * block, __u8 order);
__u8 zone_buddy_get_order(buddy_system_t *b, link_t * block);
void zone_buddy_mark_busy(buddy_system_t *b, link_t * block);
extern frame_t * frame_addr2frame(__address addr);
 
/*
* TODO: Implement the following functions.
/kernel/trunk/generic/include/mm/slab.h
1,5 → 1,5
/*
* Copyright (C) 2005 Ondrej Palkovsky
* Copyright (C) 2006 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
38,11 → 38,8
/** If object size is less, store control structure inside SLAB */
#define SLAB_INSIDE_SIZE (PAGE_SIZE / 6)
 
/* slab_alloc constants */
#define SLAB_ATOMIC 0x1 /**< Do not sleep when no free memory,
may return NULL */
#define SLAB_NO_RECLAIM 0x2 /**< Do not try to call slab_reclaim, if no
free memory is found - avoid deadlock */
/** Maximum wasted space we allow for cache */
#define SLAB_MAX_BADNESS(cache) ((PAGE_SIZE << (cache)->order) / 4)
 
/* slab_reclaim constants */
#define SLAB_RECLAIM_ALL 0x1 /**< Reclaim all possible memory, because
54,9 → 51,9
 
typedef struct {
link_t link;
count_t busy;
count_t size;
void *objs[0];
count_t busy; /**< Count of full slots in magazine */
count_t size; /**< Number of slots in magazine */
void *objs[0]; /**< Slots in magazine */
}slab_magazine_t;
 
typedef struct {
65,24 → 62,24
SPINLOCK_DECLARE(lock);
link_t link;
/* Configuration */
size_t size;
size_t align;
size_t size; /**< Size of SLAB position - align_up(sizeof(obj)) */
int (*constructor)(void *obj, int kmflag);
void (*destructor)(void *obj);
int flags;
int flags; /**< Flags changing behaviour of cache */
 
/* Computed values */
int pages;
int objects;
__u8 order; /**< Order of frames to be allocated */
int objects; /**< Number of objects that fit in */
 
/* Statistics */
 
/* Slabs */
link_t full_slabs;
link_t partial_slabs;
link_t full_slabs; /**< List of full slabs */
link_t partial_slabs; /**< List of partial slabs */
/* Magazines */
link_t magazines;
/* CPU cache */
link_t magazines; /**< List o full magazines */
 
/** CPU cache */
struct {
slab_magazine_t *current;
slab_magazine_t *last;
90,30 → 87,22
}mag_cache[0];
}slab_cache_t;
 
typedef struct {
slab_cache_t *cache; /**< Pointer to parent cache */
void *start; /**< Start address of first available item */
count_t available; /**< Count of available items in this slab */
index_t nextavail; /**< The index of next available item */
}slab_slab_t;
extern slab_cache_t * slab_cache_create(char *name,
size_t size,
size_t align,
int (*constructor)(void *obj, int kmflag),
void (*destructor)(void *obj),
int flags);
extern void slab_cache_destroy(slab_cache_t *cache);
 
extern void * slab_alloc(slab_cache_t *cache, int flags);
extern void slab_free(slab_cache_t *cache, void *obj);
extern count_t slab_reclaim(int flags);
 
slab_cache_t * slab_cache_create(char *name,
size_t size,
size_t align,
int (*constructor)(void *obj, int kmflag),
void (*destructor)(void *obj),
int flags);
void slab_cache_destroy(slab_cache_t *cache);
 
void * slab_alloc(slab_cache_t *cache, int flags);
void slab_free(slab_cache_t *cache, void *obj);
count_t slab_reclaim(int flags);
 
/** Initialize SLAB subsytem */
void slab_cache_init(void);
extern void slab_cache_init(void);
 
/* KConsole debug */
void slab_print_list(void);
extern void slab_print_list(void);
 
#endif