Subversion Repositories HelenOS-historic

Rev

Rev 814 | Rev 1144 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 814 Rev 822
Line 540... Line 540...
540
{
540
{
541
    int i;
541
    int i;
542
   
542
   
543
    ASSERT(_slab_initialized >= 2);
543
    ASSERT(_slab_initialized >= 2);
544
 
544
 
545
    cache->mag_cache = kalloc(sizeof(slab_mag_cache_t)*config.cpu_count,0);
545
    cache->mag_cache = malloc(sizeof(slab_mag_cache_t)*config.cpu_count,0);
546
    for (i=0; i < config.cpu_count; i++) {
546
    for (i=0; i < config.cpu_count; i++) {
547
        memsetb((__address)&cache->mag_cache[i],
547
        memsetb((__address)&cache->mag_cache[i],
548
            sizeof(cache->mag_cache[i]), 0);
548
            sizeof(cache->mag_cache[i]), 0);
549
        spinlock_initialize(&cache->mag_cache[i].lock,
549
        spinlock_initialize(&cache->mag_cache[i].lock,
550
                    "slab_maglock_cpu");
550
                    "slab_maglock_cpu");
Line 703... Line 703...
703
    if (!list_empty(&cache->full_slabs) \
703
    if (!list_empty(&cache->full_slabs) \
704
        || !list_empty(&cache->partial_slabs))
704
        || !list_empty(&cache->partial_slabs))
705
        panic("Destroying cache that is not empty.");
705
        panic("Destroying cache that is not empty.");
706
 
706
 
707
    if (!(cache->flags & SLAB_CACHE_NOMAGAZINE))
707
    if (!(cache->flags & SLAB_CACHE_NOMAGAZINE))
708
        kfree(cache->mag_cache);
708
        free(cache->mag_cache);
709
    slab_free(&slab_cache_cache, cache);
709
    slab_free(&slab_cache_cache, cache);
710
}
710
}
711
 
711
 
712
/** Allocate new object from cache - if no flags given, always returns
712
/** Allocate new object from cache - if no flags given, always returns
713
    memory */
713
    memory */
Line 869... Line 869...
869
    spinlock_unlock(&slab_cache_lock);
869
    spinlock_unlock(&slab_cache_lock);
870
}
870
}
871
 
871
 
872
/**************************************/
872
/**************************************/
873
/* kalloc/kfree functions             */
873
/* kalloc/kfree functions             */
874
void * kalloc(unsigned int size, int flags)
874
void * malloc(unsigned int size, int flags)
875
{
875
{
876
    int idx;
876
    int idx;
877
 
877
 
878
    ASSERT(_slab_initialized);
878
    ASSERT(_slab_initialized);
879
    ASSERT( size && size <= (1 << SLAB_MAX_MALLOC_W));
879
    ASSERT( size && size <= (1 << SLAB_MAX_MALLOC_W));
Line 885... Line 885...
885
 
885
 
886
    return slab_alloc(malloc_caches[idx], flags);
886
    return slab_alloc(malloc_caches[idx], flags);
887
}
887
}
888
 
888
 
889
 
889
 
890
void kfree(void *obj)
890
void free(void *obj)
891
{
891
{
892
    slab_t *slab;
892
    slab_t *slab;
893
 
893
 
894
    if (!obj) return;
894
    if (!obj) return;
895
 
895