93,7 → 93,7 |
|
typedef struct { |
SPINLOCK_DECLARE(lock); |
unsigned int count; |
int count; |
zone_t *info[ZONES_MAX]; |
} zones_t; |
|
144,7 → 144,7 |
*/ |
static int zones_add_zone(zone_t *newzone) |
{ |
unsigned int i, j; |
int i,j; |
ipl_t ipl; |
zone_t *z; |
|
185,10 → 185,10 |
* is filled into the variable on success. |
* @return Pointer to locked zone containing frame |
*/ |
static zone_t * find_zone_and_lock(pfn_t frame, unsigned int *pzone) |
static zone_t * find_zone_and_lock(pfn_t frame, int *pzone) |
{ |
unsigned int i; |
unsigned int hint = pzone ? *pzone : 0; |
int i; |
int hint = pzone ? *pzone : 0; |
zone_t *z; |
|
spinlock_lock(&zones.lock); |
232,9 → 232,9 |
*/ |
static zone_t * find_free_zone_and_lock(uint8_t order, int *pzone) |
{ |
unsigned int i; |
int i; |
zone_t *z; |
unsigned int hint = pzone ? *pzone : 0; |
int hint = pzone ? *pzone : 0; |
|
spinlock_lock(&zones.lock); |
if (hint >= zones.count) |
539,8 → 539,7 |
static void _zone_merge(zone_t *z, zone_t *z1, zone_t *z2) |
{ |
uint8_t max_order; |
unsigned int i; |
int z2idx; |
int i, z2idx; |
pfn_t frame_idx; |
frame_t *frame; |
|
562,7 → 561,7 |
&zone_buddy_system_operations, |
(void *) z); |
|
z->frames = (frame_t *)((uint8_t *) z->buddy_system + buddy_conf_size(max_order)); |
z->frames = (frame_t *)((void *)z->buddy_system+buddy_conf_size(max_order)); |
for (i = 0; i < z->count; i++) { |
/* This marks all frames busy */ |
frame_initialize(&z->frames[i]); |
574,9 → 573,9 |
* will not be reallocated during merge and it would make later |
* problems with allocation/free. |
*/ |
for (i = 0; i < z1->count; i++) |
for (i=0; i<z1->count; i++) |
z->frames[i] = z1->frames[i]; |
for (i = 0; i < z2->count; i++) { |
for (i=0; i < z2->count; i++) { |
z2idx = i + (z2->base - z1->base); |
z->frames[z2idx] = z2->frames[i]; |
} |
624,7 → 623,7 |
pfn_t pfn; |
frame_t *frame; |
count_t cframes; |
unsigned int i; |
int i; |
|
pfn = ADDR2PFN((uintptr_t)KA2PA(oldzone)); |
cframes = SIZE2FRAMES(zone_conf_size(oldzone->count)); |
635,7 → 634,7 |
frame = &newzone->frames[pfn - newzone->base]; |
ASSERT(!frame->buddy_order); |
|
for (i = 0; i < cframes; i++) { |
for (i=0; i < cframes; i++) { |
newzone->busy_count++; |
zone_frame_free(newzone, pfn+i-newzone->base); |
} |
658,13 → 657,13 |
uint8_t order; |
frame_t *frame; |
|
ASSERT(frame_idx + count < zone->count); |
ASSERT(frame_idx+count < zone->count); |
|
order = zone->frames[frame_idx].buddy_order; |
ASSERT((count_t) (1 << order) >= count); |
ASSERT((1 << order) >= count); |
|
/* Reduce all blocks to order 0 */ |
for (i = 0; i < (count_t) (1 << order); i++) { |
for (i=0; i < (1 << order); i++) { |
frame = &zone->frames[i + frame_idx]; |
frame->buddy_order = 0; |
if (! frame->refcount) |
672,7 → 671,7 |
ASSERT(frame->refcount == 1); |
} |
/* Free unneeded frames */ |
for (i = count; i < (count_t) (1 << order); i++) { |
for (i=count; i < (1 << order); i++) { |
zone_frame_free(zone, i + frame_idx); |
} |
} |
686,13 → 685,13 |
* not to be 2^order size. Once the allocator is running it is no longer |
* possible, merged configuration data occupies more space :-/ |
*/ |
void zone_merge(unsigned int z1, unsigned int z2) |
void zone_merge(int z1, int z2) |
{ |
ipl_t ipl; |
zone_t *zone1, *zone2, *newzone; |
unsigned int cframes; |
int cframes; |
uint8_t order; |
unsigned int i; |
int i; |
pfn_t pfn; |
|
ipl = interrupts_disable(); |
723,7 → 722,7 |
else |
goto errout2; |
|
newzone = (zone_t *) PA2KA(PFN2ADDR(pfn)); |
newzone = (zone_t *)PA2KA(PFN2ADDR(pfn)); |
|
_zone_merge(newzone, zone1, zone2); |
|
780,7 → 779,7 |
*/ |
static void zone_construct(pfn_t start, count_t count, zone_t *z, int flags) |
{ |
unsigned int i; |
int i; |
uint8_t max_order; |
|
spinlock_initialize(&z->lock, "zone_lock"); |
802,8 → 801,8 |
|
/* Allocate frames _after_ the conframe */ |
/* Check sizes */ |
z->frames = (frame_t *)((uint8_t *) z->buddy_system + buddy_conf_size(max_order)); |
for (i = 0; i < count; i++) { |
z->frames = (frame_t *)((void *)z->buddy_system+buddy_conf_size(max_order)); |
for (i = 0; i<count; i++) { |
frame_initialize(&z->frames[i]); |
} |
|
849,7 → 848,7 |
zone_t *z; |
uintptr_t addr; |
count_t confcount; |
unsigned int i; |
int i; |
int znum; |
|
/* Theoretically we could have here 0, practically make sure |
893,8 → 892,8 |
return -1; |
|
/* If confdata in zone, mark as unavailable */ |
if (confframe >= start && confframe < start + count) |
for (i = confframe; i < confframe + confcount; i++) { |
if (confframe >= start && confframe < start+count) |
for (i=confframe; i<confframe+confcount; i++) { |
zone_mark_unavailable(z, i - z->base); |
} |
return znum; |
904,7 → 903,7 |
/* Frame functions */ |
|
/** Set parent of frame */ |
void frame_set_parent(pfn_t pfn, void *data, unsigned int hint) |
void frame_set_parent(pfn_t pfn, void *data, int hint) |
{ |
zone_t *zone = find_zone_and_lock(pfn, &hint); |
|
914,7 → 913,7 |
spinlock_unlock(&zone->lock); |
} |
|
void * frame_get_parent(pfn_t pfn, unsigned int hint) |
void * frame_get_parent(pfn_t pfn, int hint) |
{ |
zone_t *zone = find_zone_and_lock(pfn, &hint); |
void *res; |
1045,11 → 1044,11 |
/** Mark given range unavailable in frame zones */ |
void frame_mark_unavailable(pfn_t start, count_t count) |
{ |
unsigned int i; |
int i; |
zone_t *zone; |
unsigned int prefzone = 0; |
int prefzone = 0; |
|
for (i = 0; i < count; i++) { |
for (i=0; i < count; i++) { |
zone = find_zone_and_lock(start + i, &prefzone); |
if (!zone) /* PFN not found */ |
continue; |
1095,7 → 1094,7 |
*/ |
void zone_print_list(void) { |
zone_t *zone = NULL; |
unsigned int i; |
int i; |
ipl_t ipl; |
|
ipl = interrupts_disable(); |
1116,10 → 1115,10 |
* |
* @param num Zone base address or zone number. |
*/ |
void zone_print_one(unsigned int num) { |
void zone_print_one(int num) { |
zone_t *zone = NULL; |
ipl_t ipl; |
unsigned int i; |
int i; |
|
ipl = interrupts_disable(); |
spinlock_lock(&zones.lock); |