Changeset 89c57b6 in mainline for kernel/generic/src/mm


Ignore:
Timestamp:
2011-04-13T14:45:41Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
88634420
Parents:
cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/generic/src/mm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/as.c

    rcefb126 r89c57b6  
    7171#include <memstr.h>
    7272#include <macros.h>
     73#include <bitops.h>
    7374#include <arch.h>
    7475#include <errno.h>
     
    8687 * Each architecture decides what functions will be used to carry out
    8788 * address space operations such as creating or locking page tables.
    88  *
    8989 */
    9090as_operations_t *as_operations = NULL;
    9191
    92 /**
    93  * Slab for as_t objects.
     92/** Slab for as_t objects.
    9493 *
    9594 */
    9695static slab_cache_t *as_slab;
    9796
    98 /**
    99  * This lock serializes access to the ASID subsystem.
    100  * It protects:
     97/** ASID subsystem lock.
     98 *
     99 * This lock protects:
    101100 * - inactive_as_with_asid_head list
    102101 * - as->asid for each as of the as_t type
     
    107106
    108107/**
    109  * This list contains address spaces that are not active on any
    110  * processor and that have valid ASID.
    111  *
     108 * Inactive address spaces (on all processors)
     109 * that have valid ASID.
    112110 */
    113111LIST_INITIALIZE(inactive_as_with_asid_head);
     
    116114as_t *AS_KERNEL = NULL;
    117115
    118 static int as_constructor(void *obj, unsigned int flags)
     116NO_TRACE static int as_constructor(void *obj, unsigned int flags)
    119117{
    120118        as_t *as = (as_t *) obj;
     
    123121        mutex_initialize(&as->lock, MUTEX_PASSIVE);
    124122       
    125         int rc = as_constructor_arch(as, flags);
    126        
    127         return rc;
    128 }
    129 
    130 static size_t as_destructor(void *obj)
    131 {
    132         as_t *as = (as_t *) obj;
    133         return as_destructor_arch(as);
     123        return as_constructor_arch(as, flags);
     124}
     125
     126NO_TRACE static size_t as_destructor(void *obj)
     127{
     128        return as_destructor_arch((as_t *) obj);
    134129}
    135130
     
    146141                panic("Cannot create kernel address space.");
    147142       
    148         /* Make sure the kernel address space
     143        /*
     144         * Make sure the kernel address space
    149145         * reference count never drops to zero.
    150146         */
     
    195191{
    196192        DEADLOCK_PROBE_INIT(p_asidlock);
    197 
     193       
    198194        ASSERT(as != AS);
    199195        ASSERT(atomic_get(&as->refcount) == 0);
     
    203199         * lock its mutex.
    204200         */
    205 
     201       
    206202        /*
    207203         * We need to avoid deadlock between TLB shootdown and asidlock.
     
    210206         * disabled to prevent nested context switches. We also depend on the
    211207         * fact that so far no spinlocks are held.
    212          *
    213208         */
    214209        preemption_disable();
     
    235230        spinlock_unlock(&asidlock);
    236231        interrupts_restore(ipl);
    237 
     232       
    238233       
    239234        /*
     
    241236         * The B+tree must be walked carefully because it is
    242237         * also being destroyed.
    243          *
    244238         */
    245239        bool cond = true;
     
    268262/** Hold a reference to an address space.
    269263 *
    270  * Holding a reference to an address space prevents destruction of that address
    271  * space.
     264 * Holding a reference to an address space prevents destruction
     265 * of that address space.
    272266 *
    273267 * @param as Address space to be held.
    274268 *
    275269 */
    276 void as_hold(as_t *as)
     270NO_TRACE void as_hold(as_t *as)
    277271{
    278272        atomic_inc(&as->refcount);
     
    281275/** Release a reference to an address space.
    282276 *
    283  * The last one to release a reference to an address space destroys the address
    284  * space.
     277 * The last one to release a reference to an address space
     278 * destroys the address space.
    285279 *
    286280 * @param asAddress space to be released.
    287281 *
    288282 */
    289 void as_release(as_t *as)
     283NO_TRACE void as_release(as_t *as)
    290284{
    291285        if (atomic_predec(&as->refcount) == 0)
     
    295289/** Check area conflicts with other areas.
    296290 *
    297  * @param as         Address space.
    298  * @param va         Starting virtual address of the area being tested.
    299  * @param size       Size of the area being tested.
    300  * @param avoid_area Do not touch this area.
     291 * @param as    Address space.
     292 * @param addr  Starting virtual address of the area being tested.
     293 * @param count Number of pages in the area being tested.
     294 * @param avoid Do not touch this area.
    301295 *
    302296 * @return True if there is no conflict, false otherwise.
    303297 *
    304298 */
    305 static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
    306     as_area_t *avoid_area)
    307 {
     299NO_TRACE static bool check_area_conflicts(as_t *as, uintptr_t addr,
     300    size_t count, as_area_t *avoid)
     301{
     302        ASSERT((addr % PAGE_SIZE) == 0);
    308303        ASSERT(mutex_locked(&as->lock));
    309304       
    310305        /*
    311306         * We don't want any area to have conflicts with NULL page.
    312          *
    313          */
    314         if (overlaps(va, size, NULL, PAGE_SIZE))
     307         */
     308        if (overlaps(addr, count << PAGE_WIDTH, (uintptr_t) NULL, PAGE_SIZE))
    315309                return false;
    316310       
     
    321315         * record in the left neighbour, the leftmost record in the right
    322316         * neighbour and all records in the leaf node itself.
    323          *
    324317         */
    325318        btree_node_t *leaf;
    326319        as_area_t *area =
    327             (as_area_t *) btree_search(&as->as_area_btree, va, &leaf);
     320            (as_area_t *) btree_search(&as->as_area_btree, addr, &leaf);
    328321        if (area) {
    329                 if (area != avoid_area)
     322                if (area != avoid)
    330323                        return false;
    331324        }
     
    337330                area = (as_area_t *) node->value[node->keys - 1];
    338331               
    339                 mutex_lock(&area->lock);
    340                
    341                 if (overlaps(va, size, area->base, area->pages * PAGE_SIZE)) {
     332                if (area != avoid) {
     333                        mutex_lock(&area->lock);
     334                       
     335                        if (overlaps(addr, count << PAGE_WIDTH,
     336                            area->base, area->pages << PAGE_WIDTH)) {
     337                                mutex_unlock(&area->lock);
     338                                return false;
     339                        }
     340                       
    342341                        mutex_unlock(&area->lock);
    343                         return false;
    344                 }
    345                
    346                 mutex_unlock(&area->lock);
     342                }
    347343        }
    348344       
     
    351347                area = (as_area_t *) node->value[0];
    352348               
    353                 mutex_lock(&area->lock);
    354                
    355                 if (overlaps(va, size, area->base, area->pages * PAGE_SIZE)) {
     349                if (area != avoid) {
     350                        mutex_lock(&area->lock);
     351                       
     352                        if (overlaps(addr, count << PAGE_WIDTH,
     353                            area->base, area->pages << PAGE_WIDTH)) {
     354                                mutex_unlock(&area->lock);
     355                                return false;
     356                        }
     357                       
    356358                        mutex_unlock(&area->lock);
    357                         return false;
    358                 }
    359                
    360                 mutex_unlock(&area->lock);
     359                }
    361360        }
    362361       
     
    366365                area = (as_area_t *) leaf->value[i];
    367366               
    368                 if (area == avoid_area)
     367                if (area == avoid)
    369368                        continue;
    370369               
    371370                mutex_lock(&area->lock);
    372371               
    373                 if (overlaps(va, size, area->base, area->pages * PAGE_SIZE)) {
     372                if (overlaps(addr, count << PAGE_WIDTH,
     373                    area->base, area->pages << PAGE_WIDTH)) {
    374374                        mutex_unlock(&area->lock);
    375375                        return false;
     
    382382         * So far, the area does not conflict with other areas.
    383383         * Check if it doesn't conflict with kernel address space.
    384          *
    385384         */
    386385        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    387                 return !overlaps(va, size,
     386                return !overlaps(addr, count << PAGE_WIDTH,
    388387                    KERNEL_ADDRESS_SPACE_START,
    389388                    KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
     
    412411    mem_backend_data_t *backend_data)
    413412{
    414         if (base % PAGE_SIZE)
     413        if ((base % PAGE_SIZE) != 0)
    415414                return NULL;
    416415       
    417         if (!size)
     416        if (size == 0)
    418417                return NULL;
     418       
     419        size_t pages = SIZE2FRAMES(size);
    419420       
    420421        /* Writeable executable areas are not supported. */
     
    424425        mutex_lock(&as->lock);
    425426       
    426         if (!check_area_conflicts(as, base, size, NULL)) {
     427        if (!check_area_conflicts(as, base, pages, NULL)) {
    427428                mutex_unlock(&as->lock);
    428429                return NULL;
     
    436437        area->flags = flags;
    437438        area->attributes = attrs;
    438         area->pages = SIZE2FRAMES(size);
     439        area->pages = pages;
     440        area->resident = 0;
    439441        area->base = base;
    440442        area->sh_info = NULL;
     
    463465 *
    464466 */
    465 static as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
     467NO_TRACE static as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
    466468{
    467469        ASSERT(mutex_locked(&as->lock));
     
    479481         * to find out whether this is a miss or va belongs to an address
    480482         * space area found there.
    481          *
    482483         */
    483484       
     
    490491                mutex_lock(&area->lock);
    491492               
    492                 if ((area->base <= va) && (va < area->base + area->pages * PAGE_SIZE))
     493                if ((area->base <= va) &&
     494                    (va < area->base + (area->pages << PAGE_WIDTH)))
    493495                        return area;
    494496               
     
    499501         * Second, locate the left neighbour and test its last record.
    500502         * Because of its position in the B+tree, it must have base < va.
    501          *
    502503         */
    503504        btree_node_t *lnode = btree_leaf_node_left_neighbour(&as->as_area_btree, leaf);
     
    507508                mutex_lock(&area->lock);
    508509               
    509                 if (va < area->base + area->pages * PAGE_SIZE)
     510                if (va < area->base + (area->pages << PAGE_WIDTH))
    510511                        return area;
    511512               
     
    534535        /*
    535536         * Locate the area.
    536          *
    537537         */
    538538        as_area_t *area = find_area_and_lock(as, address);
     
    546546                 * Remapping of address space areas associated
    547547                 * with memory mapped devices is not supported.
    548                  *
    549548                 */
    550549                mutex_unlock(&area->lock);
     
    557556                 * Remapping of shared address space areas
    558557                 * is not supported.
    559                  *
    560558                 */
    561559                mutex_unlock(&area->lock);
     
    568566                /*
    569567                 * Zero size address space areas are not allowed.
    570                  *
    571568                 */
    572569                mutex_unlock(&area->lock);
     
    576573       
    577574        if (pages < area->pages) {
    578                 uintptr_t start_free = area->base + pages * PAGE_SIZE;
     575                uintptr_t start_free = area->base + (pages << PAGE_WIDTH);
    579576               
    580577                /*
    581578                 * Shrinking the area.
    582579                 * No need to check for overlaps.
    583                  *
    584580                 */
    585581               
     
    588584                /*
    589585                 * Start TLB shootdown sequence.
    590                  *
    591586                 */
    592587                ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid,
    593                     area->base + pages * PAGE_SIZE, area->pages - pages);
     588                    area->base + (pages << PAGE_WIDTH), area->pages - pages);
    594589               
    595590                /*
     
    599594                 * is also the right way to remove part of the used_space
    600595                 * B+tree leaf list.
    601                  *
    602596                 */
    603597                bool cond = true;
     
    615609                                size_t i = 0;
    616610                               
    617                                 if (overlaps(ptr, size * PAGE_SIZE, area->base,
    618                                     pages * PAGE_SIZE)) {
     611                                if (overlaps(ptr, size << PAGE_WIDTH, area->base,
     612                                    pages << PAGE_WIDTH)) {
    619613                                       
    620                                         if (ptr + size * PAGE_SIZE <= start_free) {
     614                                        if (ptr + (size << PAGE_WIDTH) <= start_free) {
    621615                                                /*
    622616                                                 * The whole interval fits
    623617                                                 * completely in the resized
    624618                                                 * address space area.
    625                                                  *
    626619                                                 */
    627620                                                break;
     
    632625                                         * to b and c overlaps with the resized
    633626                                         * address space area.
    634                                          *
    635627                                         */
    636628                                       
     
    652644                                for (; i < size; i++) {
    653645                                        pte_t *pte = page_mapping_find(as, ptr +
    654                                             i * PAGE_SIZE);
     646                                            (i << PAGE_WIDTH));
    655647                                       
    656648                                        ASSERT(pte);
     
    661653                                            (area->backend->frame_free)) {
    662654                                                area->backend->frame_free(area,
    663                                                     ptr + i * PAGE_SIZE,
     655                                                    ptr + (i << PAGE_WIDTH),
    664656                                                    PTE_GET_FRAME(pte));
    665657                                        }
    666658                                       
    667659                                        page_mapping_remove(as, ptr +
    668                                             i * PAGE_SIZE);
     660                                            (i << PAGE_WIDTH));
    669661                                }
    670662                        }
     
    673665                /*
    674666                 * Finish TLB shootdown sequence.
    675                  *
    676                  */
    677                
    678                 tlb_invalidate_pages(as->asid, area->base + pages * PAGE_SIZE,
     667                 */
     668               
     669                tlb_invalidate_pages(as->asid, area->base + (pages << PAGE_WIDTH),
    679670                    area->pages - pages);
    680671               
    681672                /*
    682673                 * Invalidate software translation caches (e.g. TSB on sparc64).
    683                  *
    684674                 */
    685675                as_invalidate_translation_cache(as, area->base +
    686                     pages * PAGE_SIZE, area->pages - pages);
     676                    (pages << PAGE_WIDTH), area->pages - pages);
    687677                tlb_shootdown_finalize(ipl);
    688678               
     
    692682                 * Growing the area.
    693683                 * Check for overlaps with other address space areas.
    694                  *
    695                  */
    696                 if (!check_area_conflicts(as, address, pages * PAGE_SIZE,
    697                     area)) {
     684                 */
     685                if (!check_area_conflicts(as, address, pages, area)) {
    698686                        mutex_unlock(&area->lock);
    699687                        mutex_unlock(&as->lock);
     
    717705 *
    718706 */
    719 static void sh_info_remove_reference(share_info_t *sh_info)
     707NO_TRACE static void sh_info_remove_reference(share_info_t *sh_info)
    720708{
    721709        bool dealloc = false;
     
    794782                       
    795783                        for (size = 0; size < (size_t) node->value[i]; size++) {
    796                                 pte_t *pte = page_mapping_find(as, ptr + size * PAGE_SIZE);
     784                                pte_t *pte =
     785                                    page_mapping_find(as, ptr + (size << PAGE_WIDTH));
    797786                               
    798787                                ASSERT(pte);
     
    803792                                    (area->backend->frame_free)) {
    804793                                        area->backend->frame_free(area,
    805                                             ptr + size * PAGE_SIZE, PTE_GET_FRAME(pte));
     794                                            ptr + (size << PAGE_WIDTH), PTE_GET_FRAME(pte));
    806795                                }
    807796                               
    808                                 page_mapping_remove(as, ptr + size * PAGE_SIZE);
     797                                page_mapping_remove(as, ptr + (size << PAGE_WIDTH));
    809798                        }
    810799                }
     
    813802        /*
    814803         * Finish TLB shootdown sequence.
    815          *
    816804         */
    817805       
     
    821809         * Invalidate potential software translation caches (e.g. TSB on
    822810         * sparc64).
    823          *
    824811         */
    825812        as_invalidate_translation_cache(as, area->base, area->pages);
     
    839826        /*
    840827         * Remove the empty area from address space.
    841          *
    842828         */
    843829        btree_remove(&as->as_area_btree, base, NULL);
     
    881867                /*
    882868                 * Could not find the source address space area.
    883                  *
    884869                 */
    885870                mutex_unlock(&src_as->lock);
     
    891876                 * There is no backend or the backend does not
    892877                 * know how to share the area.
    893                  *
    894878                 */
    895879                mutex_unlock(&src_area->lock);
     
    898882        }
    899883       
    900         size_t src_size = src_area->pages * PAGE_SIZE;
     884        size_t src_size = src_area->pages << PAGE_WIDTH;
    901885        unsigned int src_flags = src_area->flags;
    902886        mem_backend_t *src_backend = src_area->backend;
     
    918902         * First, prepare the area for sharing.
    919903         * Then it will be safe to unlock it.
    920          *
    921904         */
    922905        share_info_t *sh_info = src_area->sh_info;
     
    930913                /*
    931914                 * Call the backend to setup sharing.
    932                  *
    933915                 */
    934916                src_area->backend->share(src_area);
     
    949931         * The flags of the source area are masked against dst_flags_mask
    950932         * to support sharing in less privileged mode.
    951          *
    952933         */
    953934        as_area_t *dst_area = as_area_create(dst_as, dst_flags_mask, src_size,
     
    966947         * fully initialized. Clear the AS_AREA_ATTR_PARTIAL
    967948         * attribute and set the sh_info.
    968          *
    969949         */
    970950        mutex_lock(&dst_as->lock);
     
    987967 *
    988968 */
    989 bool as_area_check_access(as_area_t *area, pf_access_t access)
    990 {
     969NO_TRACE bool as_area_check_access(as_area_t *area, pf_access_t access)
     970{
     971        ASSERT(mutex_locked(&area->lock));
     972       
    991973        int flagmap[] = {
    992974                [PF_ACCESS_READ] = AS_AREA_READ,
     
    994976                [PF_ACCESS_EXEC] = AS_AREA_EXEC
    995977        };
    996 
    997         ASSERT(mutex_locked(&area->lock));
    998978       
    999979        if (!(area->flags & flagmap[access]))
     
    1010990 *
    1011991 */
    1012 static unsigned int area_flags_to_page_flags(unsigned int aflags)
     992NO_TRACE static unsigned int area_flags_to_page_flags(unsigned int aflags)
    1013993{
    1014994        unsigned int flags = PAGE_USER | PAGE_PRESENT;
     
    10661046        /*
    10671047         * Compute total number of used pages in the used_space B+tree
    1068          *
    10691048         */
    10701049        size_t used_pages = 0;
     
    10881067        /*
    10891068         * Start TLB shootdown sequence.
    1090          *
    10911069         */
    10921070        ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid, area->base,
     
    10961074         * Remove used pages from page tables and remember their frame
    10971075         * numbers.
    1098          *
    10991076         */
    11001077        size_t frame_idx = 0;
     
    11111088                       
    11121089                        for (size = 0; size < (size_t) node->value[i]; size++) {
    1113                                 pte_t *pte = page_mapping_find(as, ptr + size * PAGE_SIZE);
     1090                                pte_t *pte =
     1091                                    page_mapping_find(as, ptr + (size << PAGE_WIDTH));
    11141092                               
    11151093                                ASSERT(pte);
     
    11201098                               
    11211099                                /* Remove old mapping */
    1122                                 page_mapping_remove(as, ptr + size * PAGE_SIZE);
     1100                                page_mapping_remove(as, ptr + (size << PAGE_WIDTH));
    11231101                        }
    11241102                }
     
    11271105        /*
    11281106         * Finish TLB shootdown sequence.
    1129          *
    11301107         */
    11311108       
     
    11351112         * Invalidate potential software translation caches (e.g. TSB on
    11361113         * sparc64).
    1137          *
    11381114         */
    11391115        as_invalidate_translation_cache(as, area->base, area->pages);
     
    11681144                               
    11691145                                /* Insert the new mapping */
    1170                                 page_mapping_insert(as, ptr + size * PAGE_SIZE,
     1146                                page_mapping_insert(as, ptr + (size << PAGE_WIDTH),
    11711147                                    old_frame[frame_idx++], page_flags);
    11721148                               
     
    12171193                 * No area contained mapping for 'page'.
    12181194                 * Signal page fault to low-level handler.
    1219                  *
    12201195                 */
    12211196                mutex_unlock(&AS->lock);
     
    12371212                 * The address space area is not backed by any backend
    12381213                 * or the backend cannot handle page faults.
    1239                  *
    12401214                 */
    12411215                mutex_unlock(&area->lock);
     
    12491223         * To avoid race condition between two page faults on the same address,
    12501224         * we need to make sure the mapping has not been already inserted.
    1251          *
    12521225         */
    12531226        pte_t *pte;
     
    12671240        /*
    12681241         * Resort to the backend page fault handler.
    1269          *
    12701242         */
    12711243        if (area->backend->page_fault(area, page, access) != AS_PF_OK) {
     
    13221294                 * preemption is disabled. We should not be
    13231295                 * holding any other lock.
    1324                  *
    13251296                 */
    13261297                (void) interrupts_enable();
     
    13421313                         * list of inactive address spaces with assigned
    13431314                         * ASID.
    1344                          *
    13451315                         */
    13461316                        ASSERT(old_as->asid != ASID_INVALID);
     
    13531323                 * Perform architecture-specific tasks when the address space
    13541324                 * is being removed from the CPU.
    1355                  *
    13561325                 */
    13571326                as_deinstall_arch(old_as);
     
    13601329        /*
    13611330         * Second, prepare the new address space.
    1362          *
    13631331         */
    13641332        if ((new_as->cpu_refcount++ == 0) && (new_as != AS_KERNEL)) {
     
    13761344         * Perform architecture-specific steps.
    13771345         * (e.g. write ASID to hardware register etc.)
    1378          *
    13791346         */
    13801347        as_install_arch(new_as);
     
    13851352}
    13861353
    1387 
    1388 
    13891354/** Compute flags for virtual address translation subsytem.
    13901355 *
     
    13941359 *
    13951360 */
    1396 unsigned int as_area_get_flags(as_area_t *area)
     1361NO_TRACE unsigned int as_area_get_flags(as_area_t *area)
    13971362{
    13981363        ASSERT(mutex_locked(&area->lock));
    1399 
     1364       
    14001365        return area_flags_to_page_flags(area->flags);
    14011366}
     
    14121377 *
    14131378 */
    1414 pte_t *page_table_create(unsigned int flags)
     1379NO_TRACE pte_t *page_table_create(unsigned int flags)
    14151380{
    14161381        ASSERT(as_operations);
     
    14271392 *
    14281393 */
    1429 void page_table_destroy(pte_t *page_table)
     1394NO_TRACE void page_table_destroy(pte_t *page_table)
    14301395{
    14311396        ASSERT(as_operations);
     
    14481413 *
    14491414 */
    1450 void page_table_lock(as_t *as, bool lock)
     1415NO_TRACE void page_table_lock(as_t *as, bool lock)
    14511416{
    14521417        ASSERT(as_operations);
     
    14621427 *
    14631428 */
    1464 void page_table_unlock(as_t *as, bool unlock)
     1429NO_TRACE void page_table_unlock(as_t *as, bool unlock)
    14651430{
    14661431        ASSERT(as_operations);
     
    14771442 *         are locked, otherwise false.
    14781443 */
    1479 bool page_table_locked(as_t *as)
     1444NO_TRACE bool page_table_locked(as_t *as)
    14801445{
    14811446        ASSERT(as_operations);
     
    15011466       
    15021467        if (src_area) {
    1503                 size = src_area->pages * PAGE_SIZE;
     1468                size = src_area->pages << PAGE_WIDTH;
    15041469                mutex_unlock(&src_area->lock);
    15051470        } else
     
    15181483 * @param count Number of page to be marked.
    15191484 *
    1520  * @return Zero on failure and non-zero on success.
    1521  *
    1522  */
    1523 int used_space_insert(as_area_t *area, uintptr_t page, size_t count)
     1485 * @return False on failure or true on success.
     1486 *
     1487 */
     1488bool used_space_insert(as_area_t *area, uintptr_t page, size_t count)
    15241489{
    15251490        ASSERT(mutex_locked(&area->lock));
     
    15321497                /*
    15331498                 * We hit the beginning of some used space.
    1534                  *
    1535                  */
    1536                 return 0;
     1499                 */
     1500                return false;
    15371501        }
    15381502       
    15391503        if (!leaf->keys) {
    15401504                btree_insert(&area->used_space, page, (void *) count, leaf);
    1541                 return 1;
     1505                goto success;
    15421506        }
    15431507       
     
    15531517                 * somewhere between the rightmost interval of
    15541518                 * the left neigbour and the first interval of the leaf.
    1555                  *
    15561519                 */
    15571520               
    15581521                if (page >= right_pg) {
    15591522                        /* Do nothing. */
    1560                 } else if (overlaps(page, count * PAGE_SIZE, left_pg,
    1561                     left_cnt * PAGE_SIZE)) {
     1523                } else if (overlaps(page, count << PAGE_WIDTH, left_pg,
     1524                    left_cnt << PAGE_WIDTH)) {
    15621525                        /* The interval intersects with the left interval. */
    1563                         return 0;
    1564                 } else if (overlaps(page, count * PAGE_SIZE, right_pg,
    1565                     right_cnt * PAGE_SIZE)) {
     1526                        return false;
     1527                } else if (overlaps(page, count << PAGE_WIDTH, right_pg,
     1528                    right_cnt << PAGE_WIDTH)) {
    15661529                        /* The interval intersects with the right interval. */
    1567                         return 0;
    1568                 } else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
    1569                     (page + count * PAGE_SIZE == right_pg)) {
     1530                        return false;
     1531                } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
     1532                    (page + (count << PAGE_WIDTH) == right_pg)) {
    15701533                        /*
    15711534                         * The interval can be added by merging the two already
    15721535                         * present intervals.
    1573                          *
    15741536                         */
    15751537                        node->value[node->keys - 1] += count + right_cnt;
    15761538                        btree_remove(&area->used_space, right_pg, leaf);
    1577                         return 1;
    1578                 } else if (page == left_pg + left_cnt * PAGE_SIZE) {
     1539                        goto success;
     1540                } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
    15791541                        /*
    15801542                         * The interval can be added by simply growing the left
    15811543                         * interval.
    1582                          *
    15831544                         */
    15841545                        node->value[node->keys - 1] += count;
    1585                         return 1;
    1586                 } else if (page + count * PAGE_SIZE == right_pg) {
     1546                        goto success;
     1547                } else if (page + (count << PAGE_WIDTH) == right_pg) {
    15871548                        /*
    15881549                         * The interval can be addded by simply moving base of
    15891550                         * the right interval down and increasing its size
    15901551                         * accordingly.
    1591                          *
    15921552                         */
    15931553                        leaf->value[0] += count;
    15941554                        leaf->key[0] = page;
    1595                         return 1;
     1555                        goto success;
    15961556                } else {
    15971557                        /*
    15981558                         * The interval is between both neigbouring intervals,
    15991559                         * but cannot be merged with any of them.
    1600                          *
    16011560                         */
    16021561                        btree_insert(&area->used_space, page, (void *) count,
    16031562                            leaf);
    1604                         return 1;
     1563                        goto success;
    16051564                }
    16061565        } else if (page < leaf->key[0]) {
     
    16111570                 * Investigate the border case in which the left neighbour does
    16121571                 * not exist but the interval fits from the left.
    1613                  *
    1614                  */
    1615                
    1616                 if (overlaps(page, count * PAGE_SIZE, right_pg,
    1617                     right_cnt * PAGE_SIZE)) {
     1572                 */
     1573               
     1574                if (overlaps(page, count << PAGE_WIDTH, right_pg,
     1575                    right_cnt << PAGE_WIDTH)) {
    16181576                        /* The interval intersects with the right interval. */
    1619                         return 0;
    1620                 } else if (page + count * PAGE_SIZE == right_pg) {
     1577                        return false;
     1578                } else if (page + (count << PAGE_WIDTH) == right_pg) {
    16211579                        /*
    16221580                         * The interval can be added by moving the base of the
    16231581                         * right interval down and increasing its size
    16241582                         * accordingly.
    1625                          *
    16261583                         */
    16271584                        leaf->key[0] = page;
    16281585                        leaf->value[0] += count;
    1629                         return 1;
     1586                        goto success;
    16301587                } else {
    16311588                        /*
    16321589                         * The interval doesn't adjoin with the right interval.
    16331590                         * It must be added individually.
    1634                          *
    16351591                         */
    16361592                        btree_insert(&area->used_space, page, (void *) count,
    16371593                            leaf);
    1638                         return 1;
     1594                        goto success;
    16391595                }
    16401596        }
     
    16511607                 * somewhere between the leftmost interval of
    16521608                 * the right neigbour and the last interval of the leaf.
    1653                  *
    16541609                 */
    16551610               
    16561611                if (page < left_pg) {
    16571612                        /* Do nothing. */
    1658                 } else if (overlaps(page, count * PAGE_SIZE, left_pg,
    1659                     left_cnt * PAGE_SIZE)) {
     1613                } else if (overlaps(page, count << PAGE_WIDTH, left_pg,
     1614                    left_cnt << PAGE_WIDTH)) {
    16601615                        /* The interval intersects with the left interval. */
    1661                         return 0;
    1662                 } else if (overlaps(page, count * PAGE_SIZE, right_pg,
    1663                     right_cnt * PAGE_SIZE)) {
     1616                        return false;
     1617                } else if (overlaps(page, count << PAGE_WIDTH, right_pg,
     1618                    right_cnt << PAGE_WIDTH)) {
    16641619                        /* The interval intersects with the right interval. */
    1665                         return 0;
    1666                 } else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
    1667                     (page + count * PAGE_SIZE == right_pg)) {
     1620                        return false;
     1621                } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
     1622                    (page + (count << PAGE_WIDTH) == right_pg)) {
    16681623                        /*
    16691624                         * The interval can be added by merging the two already
    16701625                         * present intervals.
    1671                          *
    16721626                         */
    16731627                        leaf->value[leaf->keys - 1] += count + right_cnt;
    16741628                        btree_remove(&area->used_space, right_pg, node);
    1675                         return 1;
    1676                 } else if (page == left_pg + left_cnt * PAGE_SIZE) {
     1629                        goto success;
     1630                } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
    16771631                        /*
    16781632                         * The interval can be added by simply growing the left
    16791633                         * interval.
    1680                          *
    16811634                         */
    1682                         leaf->value[leaf->keys - 1] +=  count;
    1683                         return 1;
    1684                 } else if (page + count * PAGE_SIZE == right_pg) {
     1635                        leaf->value[leaf->keys - 1] += count;
     1636                        goto success;
     1637                } else if (page + (count << PAGE_WIDTH) == right_pg) {
    16851638                        /*
    16861639                         * The interval can be addded by simply moving base of
    16871640                         * the right interval down and increasing its size
    16881641                         * accordingly.
    1689                          *
    16901642                         */
    16911643                        node->value[0] += count;
    16921644                        node->key[0] = page;
    1693                         return 1;
     1645                        goto success;
    16941646                } else {
    16951647                        /*
    16961648                         * The interval is between both neigbouring intervals,
    16971649                         * but cannot be merged with any of them.
    1698                          *
    16991650                         */
    17001651                        btree_insert(&area->used_space, page, (void *) count,
    17011652                            leaf);
    1702                         return 1;
     1653                        goto success;
    17031654                }
    17041655        } else if (page >= leaf->key[leaf->keys - 1]) {
     
    17091660                 * Investigate the border case in which the right neighbour
    17101661                 * does not exist but the interval fits from the right.
    1711                  *
    1712                  */
    1713                
    1714                 if (overlaps(page, count * PAGE_SIZE, left_pg,
    1715                     left_cnt * PAGE_SIZE)) {
     1662                 */
     1663               
     1664                if (overlaps(page, count << PAGE_WIDTH, left_pg,
     1665                    left_cnt << PAGE_WIDTH)) {
    17161666                        /* The interval intersects with the left interval. */
    1717                         return 0;
    1718                 } else if (left_pg + left_cnt * PAGE_SIZE == page) {
     1667                        return false;
     1668                } else if (left_pg + (left_cnt << PAGE_WIDTH) == page) {
    17191669                        /*
    17201670                         * The interval can be added by growing the left
    17211671                         * interval.
    1722                          *
    17231672                         */
    17241673                        leaf->value[leaf->keys - 1] += count;
    1725                         return 1;
     1674                        goto success;
    17261675                } else {
    17271676                        /*
    17281677                         * The interval doesn't adjoin with the left interval.
    17291678                         * It must be added individually.
    1730                          *
    17311679                         */
    17321680                        btree_insert(&area->used_space, page, (void *) count,
    17331681                            leaf);
    1734                         return 1;
     1682                        goto success;
    17351683                }
    17361684        }
     
    17401688         * only between two other intervals of the leaf. The two border cases
    17411689         * were already resolved.
    1742          *
    17431690         */
    17441691        btree_key_t i;
     
    17521699                        /*
    17531700                         * The interval fits between left_pg and right_pg.
    1754                          *
    17551701                         */
    17561702                       
    1757                         if (overlaps(page, count * PAGE_SIZE, left_pg,
    1758                             left_cnt * PAGE_SIZE)) {
     1703                        if (overlaps(page, count << PAGE_WIDTH, left_pg,
     1704                            left_cnt << PAGE_WIDTH)) {
    17591705                                /*
    17601706                                 * The interval intersects with the left
    17611707                                 * interval.
    1762                                  *
    17631708                                 */
    1764                                 return 0;
    1765                         } else if (overlaps(page, count * PAGE_SIZE, right_pg,
    1766                             right_cnt * PAGE_SIZE)) {
     1709                                return false;
     1710                        } else if (overlaps(page, count << PAGE_WIDTH, right_pg,
     1711                            right_cnt << PAGE_WIDTH)) {
    17671712                                /*
    17681713                                 * The interval intersects with the right
    17691714                                 * interval.
    1770                                  *
    17711715                                 */
    1772                                 return 0;
    1773                         } else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
    1774                             (page + count * PAGE_SIZE == right_pg)) {
     1716                                return false;
     1717                        } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
     1718                            (page + (count << PAGE_WIDTH) == right_pg)) {
    17751719                                /*
    17761720                                 * The interval can be added by merging the two
    17771721                                 * already present intervals.
    1778                                  *
    17791722                                 */
    17801723                                leaf->value[i - 1] += count + right_cnt;
    17811724                                btree_remove(&area->used_space, right_pg, leaf);
    1782                                 return 1;
    1783                         } else if (page == left_pg + left_cnt * PAGE_SIZE) {
     1725                                goto success;
     1726                        } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
    17841727                                /*
    17851728                                 * The interval can be added by simply growing
    17861729                                 * the left interval.
    1787                                  *
    17881730                                 */
    17891731                                leaf->value[i - 1] += count;
    1790                                 return 1;
    1791                         } else if (page + count * PAGE_SIZE == right_pg) {
     1732                                goto success;
     1733                        } else if (page + (count << PAGE_WIDTH) == right_pg) {
    17921734                                /*
    17931735                                 * The interval can be addded by simply moving
    17941736                                 * base of the right interval down and
    17951737                                 * increasing its size accordingly.
    1796                                  *
    17971738                                 */
    17981739                                leaf->value[i] += count;
    17991740                                leaf->key[i] = page;
    1800                                 return 1;
     1741                                goto success;
    18011742                        } else {
    18021743                                /*
     
    18041745                                 * intervals, but cannot be merged with any of
    18051746                                 * them.
    1806                                  *
    18071747                                 */
    18081748                                btree_insert(&area->used_space, page,
    18091749                                    (void *) count, leaf);
    1810                                 return 1;
     1750                                goto success;
    18111751                        }
    18121752                }
    18131753        }
    18141754       
    1815         panic("Inconsistency detected while adding %" PRIs " pages of used "
    1816             "space at %p.", count, page);
     1755        panic("Inconsistency detected while adding %zu pages of used "
     1756            "space at %p.", count, (void *) page);
     1757       
     1758success:
     1759        area->resident += count;
     1760        return true;
    18171761}
    18181762
     
    18251769 * @param count Number of page to be marked.
    18261770 *
    1827  * @return Zero on failure and non-zero on success.
    1828  *
    1829  */
    1830 int used_space_remove(as_area_t *area, uintptr_t page, size_t count)
     1771 * @return False on failure or true on success.
     1772 *
     1773 */
     1774bool used_space_remove(as_area_t *area, uintptr_t page, size_t count)
    18311775{
    18321776        ASSERT(mutex_locked(&area->lock));
     
    18391783                /*
    18401784                 * We are lucky, page is the beginning of some interval.
    1841                  *
    18421785                 */
    18431786                if (count > pages) {
    1844                         return 0;
     1787                        return false;
    18451788                } else if (count == pages) {
    18461789                        btree_remove(&area->used_space, page, leaf);
    1847                         return 1;
     1790                        goto success;
    18481791                } else {
    18491792                        /*
    18501793                         * Find the respective interval.
    18511794                         * Decrease its size and relocate its start address.
    1852                          *
    18531795                         */
    18541796                        btree_key_t i;
    18551797                        for (i = 0; i < leaf->keys; i++) {
    18561798                                if (leaf->key[i] == page) {
    1857                                         leaf->key[i] += count * PAGE_SIZE;
     1799                                        leaf->key[i] += count << PAGE_WIDTH;
    18581800                                        leaf->value[i] -= count;
    1859                                         return 1;
     1801                                        goto success;
    18601802                                }
    18611803                        }
     1804                       
    18621805                        goto error;
    18631806                }
     
    18691812                size_t left_cnt = (size_t) node->value[node->keys - 1];
    18701813               
    1871                 if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
    1872                     count * PAGE_SIZE)) {
    1873                         if (page + count * PAGE_SIZE ==
    1874                             left_pg + left_cnt * PAGE_SIZE) {
     1814                if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
     1815                    count << PAGE_WIDTH)) {
     1816                        if (page + (count << PAGE_WIDTH) ==
     1817                            left_pg + (left_cnt << PAGE_WIDTH)) {
    18751818                                /*
    18761819                                 * The interval is contained in the rightmost
     
    18781821                                 * removed by updating the size of the bigger
    18791822                                 * interval.
    1880                                  *
    18811823                                 */
    18821824                                node->value[node->keys - 1] -= count;
    1883                                 return 1;
    1884                         } else if (page + count * PAGE_SIZE <
    1885                             left_pg + left_cnt*PAGE_SIZE) {
     1825                                goto success;
     1826                        } else if (page + (count << PAGE_WIDTH) <
     1827                            left_pg + (left_cnt << PAGE_WIDTH)) {
    18861828                                /*
    18871829                                 * The interval is contained in the rightmost
     
    18901832                                 * the original interval and also inserting a
    18911833                                 * new interval.
    1892                                  *
    18931834                                 */
    1894                                 size_t new_cnt = ((left_pg + left_cnt * PAGE_SIZE) -
    1895                                     (page + count*PAGE_SIZE)) >> PAGE_WIDTH;
     1835                                size_t new_cnt = ((left_pg + (left_cnt << PAGE_WIDTH)) -
     1836                                    (page + (count << PAGE_WIDTH))) >> PAGE_WIDTH;
    18961837                                node->value[node->keys - 1] -= count + new_cnt;
    18971838                                btree_insert(&area->used_space, page +
    1898                                     count * PAGE_SIZE, (void *) new_cnt, leaf);
    1899                                 return 1;
     1839                                    (count << PAGE_WIDTH), (void *) new_cnt, leaf);
     1840                                goto success;
    19001841                        }
    19011842                }
    1902                 return 0;
     1843               
     1844                return false;
    19031845        } else if (page < leaf->key[0])
    1904                 return 0;
     1846                return false;
    19051847       
    19061848        if (page > leaf->key[leaf->keys - 1]) {
     
    19081850                size_t left_cnt = (size_t) leaf->value[leaf->keys - 1];
    19091851               
    1910                 if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
    1911                     count * PAGE_SIZE)) {
    1912                         if (page + count * PAGE_SIZE ==
    1913                             left_pg + left_cnt * PAGE_SIZE) {
     1852                if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
     1853                    count << PAGE_WIDTH)) {
     1854                        if (page + (count << PAGE_WIDTH) ==
     1855                            left_pg + (left_cnt << PAGE_WIDTH)) {
    19141856                                /*
    19151857                                 * The interval is contained in the rightmost
    19161858                                 * interval of the leaf and can be removed by
    19171859                                 * updating the size of the bigger interval.
    1918                                  *
    19191860                                 */
    19201861                                leaf->value[leaf->keys - 1] -= count;
    1921                                 return 1;
    1922                         } else if (page + count * PAGE_SIZE < left_pg +
    1923                             left_cnt * PAGE_SIZE) {
     1862                                goto success;
     1863                        } else if (page + (count << PAGE_WIDTH) < left_pg +
     1864                            (left_cnt << PAGE_WIDTH)) {
    19241865                                /*
    19251866                                 * The interval is contained in the rightmost
     
    19281869                                 * original interval and also inserting a new
    19291870                                 * interval.
    1930                                  *
    19311871                                 */
    1932                                 size_t new_cnt = ((left_pg + left_cnt * PAGE_SIZE) -
    1933                                     (page + count * PAGE_SIZE)) >> PAGE_WIDTH;
     1872                                size_t new_cnt = ((left_pg + (left_cnt << PAGE_WIDTH)) -
     1873                                    (page + (count << PAGE_WIDTH))) >> PAGE_WIDTH;
    19341874                                leaf->value[leaf->keys - 1] -= count + new_cnt;
    19351875                                btree_insert(&area->used_space, page +
    1936                                     count * PAGE_SIZE, (void *) new_cnt, leaf);
    1937                                 return 1;
     1876                                    (count << PAGE_WIDTH), (void *) new_cnt, leaf);
     1877                                goto success;
    19381878                        }
    19391879                }
    1940                 return 0;
     1880               
     1881                return false;
    19411882        }
    19421883       
    19431884        /*
    19441885         * The border cases have been already resolved.
    1945          * Now the interval can be only between intervals of the leaf. 
     1886         * Now the interval can be only between intervals of the leaf.
    19461887         */
    19471888        btree_key_t i;
     
    19551896                         * to (i - 1) and i.
    19561897                         */
    1957                         if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
    1958                             count * PAGE_SIZE)) {
    1959                                 if (page + count * PAGE_SIZE ==
    1960                                     left_pg + left_cnt*PAGE_SIZE) {
     1898                        if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
     1899                            count << PAGE_WIDTH)) {
     1900                                if (page + (count << PAGE_WIDTH) ==
     1901                                    left_pg + (left_cnt << PAGE_WIDTH)) {
    19611902                                        /*
    19621903                                         * The interval is contained in the
     
    19641905                                         * be removed by updating the size of
    19651906                                         * the bigger interval.
    1966                                          *
    19671907                                         */
    19681908                                        leaf->value[i - 1] -= count;
    1969                                         return 1;
    1970                                 } else if (page + count * PAGE_SIZE <
    1971                                     left_pg + left_cnt * PAGE_SIZE) {
     1909                                        goto success;
     1910                                } else if (page + (count << PAGE_WIDTH) <
     1911                                    left_pg + (left_cnt << PAGE_WIDTH)) {
    19721912                                        /*
    19731913                                         * The interval is contained in the
     
    19781918                                         */
    19791919                                        size_t new_cnt = ((left_pg +
    1980                                             left_cnt * PAGE_SIZE) -
    1981                                             (page + count * PAGE_SIZE)) >>
     1920                                            (left_cnt << PAGE_WIDTH)) -
     1921                                            (page + (count << PAGE_WIDTH))) >>
    19821922                                            PAGE_WIDTH;
    19831923                                        leaf->value[i - 1] -= count + new_cnt;
    19841924                                        btree_insert(&area->used_space, page +
    1985                                             count * PAGE_SIZE, (void *) new_cnt,
     1925                                            (count << PAGE_WIDTH), (void *) new_cnt,
    19861926                                            leaf);
    1987                                         return 1;
     1927                                        goto success;
    19881928                                }
    19891929                        }
    1990                         return 0;
     1930                       
     1931                        return false;
    19911932                }
    19921933        }
    19931934       
    19941935error:
    1995         panic("Inconsistency detected while removing %" PRIs " pages of used "
    1996             "space from %p.", count, page);
     1936        panic("Inconsistency detected while removing %zu pages of used "
     1937            "space from %p.", count, (void *) page);
     1938       
     1939success:
     1940        area->resident -= count;
     1941        return true;
    19971942}
    19981943
     
    20021947
    20031948/** Wrapper for as_area_create(). */
    2004 unative_t sys_as_area_create(uintptr_t address, size_t size, unsigned int flags)
     1949sysarg_t sys_as_area_create(uintptr_t address, size_t size, unsigned int flags)
    20051950{
    20061951        if (as_area_create(AS, flags | AS_AREA_CACHEABLE, size, address,
    20071952            AS_AREA_ATTR_NONE, &anon_backend, NULL))
    2008                 return (unative_t) address;
     1953                return (sysarg_t) address;
    20091954        else
    2010                 return (unative_t) -1;
     1955                return (sysarg_t) -1;
    20111956}
    20121957
    20131958/** Wrapper for as_area_resize(). */
    2014 unative_t sys_as_area_resize(uintptr_t address, size_t size, unsigned int flags)
    2015 {
    2016         return (unative_t) as_area_resize(AS, address, size, 0);
     1959sysarg_t sys_as_area_resize(uintptr_t address, size_t size, unsigned int flags)
     1960{
     1961        return (sysarg_t) as_area_resize(AS, address, size, 0);
    20171962}
    20181963
    20191964/** Wrapper for as_area_change_flags(). */
    2020 unative_t sys_as_area_change_flags(uintptr_t address, unsigned int flags)
    2021 {
    2022         return (unative_t) as_area_change_flags(AS, flags, address);
     1965sysarg_t sys_as_area_change_flags(uintptr_t address, unsigned int flags)
     1966{
     1967        return (sysarg_t) as_area_change_flags(AS, flags, address);
    20231968}
    20241969
    20251970/** Wrapper for as_area_destroy(). */
    2026 unative_t sys_as_area_destroy(uintptr_t address)
    2027 {
    2028         return (unative_t) as_area_destroy(AS, address);
     1971sysarg_t sys_as_area_destroy(uintptr_t address)
     1972{
     1973        return (sysarg_t) as_area_destroy(AS, address);
     1974}
     1975
     1976/** Return pointer to unmapped address space area
     1977 *
     1978 * @param base Lowest address bound.
     1979 * @param size Requested size of the allocation.
     1980 *
     1981 * @return Pointer to the beginning of unmapped address space area.
     1982 *
     1983 */
     1984sysarg_t sys_as_get_unmapped_area(uintptr_t base, size_t size)
     1985{
     1986        if (size == 0)
     1987                return 0;
     1988       
     1989        /*
     1990         * Make sure we allocate from page-aligned
     1991         * address. Check for possible overflow in
     1992         * each step.
     1993         */
     1994       
     1995        size_t pages = SIZE2FRAMES(size);
     1996        uintptr_t ret = 0;
     1997       
     1998        /*
     1999         * Find the lowest unmapped address aligned on the sz
     2000         * boundary, not smaller than base and of the required size.
     2001         */
     2002       
     2003        mutex_lock(&AS->lock);
     2004       
     2005        /* First check the base address itself */
     2006        uintptr_t addr = ALIGN_UP(base, PAGE_SIZE);
     2007        if ((addr >= base) &&
     2008            (check_area_conflicts(AS, addr, pages, NULL)))
     2009                ret = addr;
     2010       
     2011        /* Eventually check the addresses behind each area */
     2012        link_t *cur;
     2013        for (cur = AS->as_area_btree.leaf_head.next;
     2014            (ret == 0) && (cur != &AS->as_area_btree.leaf_head);
     2015            cur = cur->next) {
     2016                btree_node_t *node =
     2017                    list_get_instance(cur, btree_node_t, leaf_link);
     2018               
     2019                btree_key_t i;
     2020                for (i = 0; (ret == 0) && (i < node->keys); i++) {
     2021                        as_area_t *area = (as_area_t *) node->value[i];
     2022                       
     2023                        mutex_lock(&area->lock);
     2024                       
     2025                        uintptr_t addr =
     2026                            ALIGN_UP(area->base + (area->pages << PAGE_WIDTH),
     2027                            PAGE_SIZE);
     2028                       
     2029                        if ((addr >= base) && (addr >= area->base) &&
     2030                            (check_area_conflicts(AS, addr, pages, area)))
     2031                                ret = addr;
     2032                       
     2033                        mutex_unlock(&area->lock);
     2034                }
     2035        }
     2036       
     2037        mutex_unlock(&AS->lock);
     2038       
     2039        return (sysarg_t) ret;
    20292040}
    20302041
     
    20952106        mutex_lock(&as->lock);
    20962107       
    2097         /* print out info about address space areas */
     2108        /* Print out info about address space areas */
    20982109        link_t *cur;
    20992110        for (cur = as->as_area_btree.leaf_head.next;
     
    21072118                       
    21082119                        mutex_lock(&area->lock);
    2109                         printf("as_area: %p, base=%p, pages=%" PRIs
    2110                             " (%p - %p)\n", area, area->base, area->pages,
    2111                             area->base, area->base + FRAMES2SIZE(area->pages));
     2120                        printf("as_area: %p, base=%p, pages=%zu"
     2121                            " (%p - %p)\n", area, (void *) area->base,
     2122                            area->pages, (void *) area->base,
     2123                            (void *) (area->base + FRAMES2SIZE(area->pages)));
    21122124                        mutex_unlock(&area->lock);
    21132125                }
  • kernel/generic/src/mm/backend_elf.c

    rcefb126 r89c57b6  
    9191        if (!as_area_check_access(area, access))
    9292                return AS_PF_FAULT;
    93 
    94         ASSERT((addr >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) &&
    95             (addr < entry->p_vaddr + entry->p_memsz));
     93       
     94        if (addr < ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE))
     95                return AS_PF_FAULT;
     96       
     97        if (addr >= entry->p_vaddr + entry->p_memsz)
     98                return AS_PF_FAULT;
     99       
    96100        i = (addr - ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) >> PAGE_WIDTH;
    97101        base = (uintptr_t)
  • kernel/generic/src/mm/backend_phys.c

    rcefb126 r89c57b6  
    8181        page_mapping_insert(AS, addr, base + (addr - area->base),
    8282            as_area_get_flags(area));
    83         if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1))
    84                 panic("Cannot insert used space.");
     83       
     84        if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1))
     85                panic("Cannot insert used space.");
    8586
    8687        return AS_PF_OK;
  • kernel/generic/src/mm/frame.c

    rcefb126 r89c57b6  
    7575/********************/
    7676
    77 static inline size_t frame_index(zone_t *zone, frame_t *frame)
     77NO_TRACE static inline size_t frame_index(zone_t *zone, frame_t *frame)
    7878{
    7979        return (size_t) (frame - zone->frames);
    8080}
    8181
    82 static inline size_t frame_index_abs(zone_t *zone, frame_t *frame)
     82NO_TRACE static inline size_t frame_index_abs(zone_t *zone, frame_t *frame)
    8383{
    8484        return (size_t) (frame - zone->frames) + zone->base;
    8585}
    8686
    87 static inline bool frame_index_valid(zone_t *zone, size_t index)
     87NO_TRACE static inline bool frame_index_valid(zone_t *zone, size_t index)
    8888{
    8989        return (index < zone->count);
    9090}
    9191
    92 static inline size_t make_frame_index(zone_t *zone, frame_t *frame)
     92NO_TRACE static inline size_t make_frame_index(zone_t *zone, frame_t *frame)
    9393{
    9494        return (frame - zone->frames);
     
    100100 *
    101101 */
    102 static void frame_initialize(frame_t *frame)
     102NO_TRACE static void frame_initialize(frame_t *frame)
    103103{
    104104        frame->refcount = 1;
     
    121121 *
    122122 */
    123 static size_t zones_insert_zone(pfn_t base, size_t count)
     123NO_TRACE static size_t zones_insert_zone(pfn_t base, size_t count,
     124    zone_flags_t flags)
    124125{
    125126        if (zones.count + 1 == ZONES_MAX) {
     
    131132        for (i = 0; i < zones.count; i++) {
    132133                /* Check for overlap */
    133                 if (overlaps(base, count,
    134                     zones.info[i].base, zones.info[i].count)) {
    135                         printf("Zones overlap!\n");
     134                if (overlaps(zones.info[i].base, zones.info[i].count,
     135                    base, count)) {
     136                       
     137                        /*
     138                         * If the overlaping zones are of the same type
     139                         * and the new zone is completely within the previous
     140                         * one, then quietly ignore the new zone.
     141                         *
     142                         */
     143                       
     144                        if ((zones.info[i].flags != flags) ||
     145                            (!iswithin(zones.info[i].base, zones.info[i].count,
     146                            base, count))) {
     147                                printf("Zone (%p, %p) overlaps "
     148                                    "with previous zone (%p %p)!\n",
     149                                    (void *) PFN2ADDR(base), (void *) PFN2ADDR(count),
     150                                    (void *) PFN2ADDR(zones.info[i].base),
     151                                    (void *) PFN2ADDR(zones.info[i].count));
     152                        }
     153                       
    136154                        return (size_t) -1;
    137155                }
     
    144162        for (j = zones.count; j > i; j--) {
    145163                zones.info[j] = zones.info[j - 1];
    146                 zones.info[j].buddy_system->data =
    147                     (void *) &zones.info[j - 1];
     164                if (zones.info[j].buddy_system != NULL)
     165                        zones.info[j].buddy_system->data =
     166                            (void *) &zones.info[j];
    148167        }
    149168       
     
    162181 */
    163182#ifdef CONFIG_DEBUG
    164 static size_t total_frames_free(void)
     183NO_TRACE static size_t total_frames_free(void)
    165184{
    166185        size_t total = 0;
     
    185204 *
    186205 */
    187 size_t find_zone(pfn_t frame, size_t count, size_t hint)
     206NO_TRACE size_t find_zone(pfn_t frame, size_t count, size_t hint)
    188207{
    189208        if (hint >= zones.count)
     
    206225
    207226/** @return True if zone can allocate specified order */
    208 static bool zone_can_alloc(zone_t *zone, uint8_t order)
     227NO_TRACE static bool zone_can_alloc(zone_t *zone, uint8_t order)
    209228{
    210229        return (zone_flags_available(zone->flags)
     
    222241 *
    223242 */
    224 static size_t find_free_zone(uint8_t order, zone_flags_t flags, size_t hint)
     243NO_TRACE static size_t find_free_zone(uint8_t order, zone_flags_t flags,
     244    size_t hint)
    225245{
    226246        if (hint >= zones.count)
     
    262282 *
    263283 */
    264 static link_t *zone_buddy_find_block(buddy_system_t *buddy, link_t *child,
    265     uint8_t order)
     284NO_TRACE static link_t *zone_buddy_find_block(buddy_system_t *buddy,
     285    link_t *child, uint8_t order)
    266286{
    267287        frame_t *frame = list_get_instance(child, frame_t, buddy_link);
     
    285305 *
    286306 */
    287 static link_t *zone_buddy_find_buddy(buddy_system_t *buddy, link_t *block)
     307NO_TRACE static link_t *zone_buddy_find_buddy(buddy_system_t *buddy,
     308    link_t *block)
    288309{
    289310        frame_t *frame = list_get_instance(block, frame_t, buddy_link);
     
    321342 *
    322343 */
    323 static link_t *zone_buddy_bisect(buddy_system_t *buddy, link_t *block)
     344NO_TRACE static link_t *zone_buddy_bisect(buddy_system_t *buddy, link_t *block)
    324345{
    325346        frame_t *frame_l = list_get_instance(block, frame_t, buddy_link);
     
    339360 *
    340361 */
    341 static link_t *zone_buddy_coalesce(buddy_system_t *buddy, link_t *block_1,
    342     link_t *block_2)
     362NO_TRACE static link_t *zone_buddy_coalesce(buddy_system_t *buddy,
     363    link_t *block_1, link_t *block_2)
    343364{
    344365        frame_t *frame1 = list_get_instance(block_1, frame_t, buddy_link);
     
    355376 *
    356377 */
    357 static void zone_buddy_set_order(buddy_system_t *buddy, link_t *block,
     378NO_TRACE static void zone_buddy_set_order(buddy_system_t *buddy, link_t *block,
    358379    uint8_t order)
    359380{
     
    369390 *
    370391 */
    371 static uint8_t zone_buddy_get_order(buddy_system_t *buddy, link_t *block)
     392NO_TRACE static uint8_t zone_buddy_get_order(buddy_system_t *buddy,
     393    link_t *block)
    372394{
    373395        return list_get_instance(block, frame_t, buddy_link)->buddy_order;
     
    380402 *
    381403 */
    382 static void zone_buddy_mark_busy(buddy_system_t *buddy, link_t * block)
     404NO_TRACE static void zone_buddy_mark_busy(buddy_system_t *buddy, link_t *block)
    383405{
    384406        list_get_instance(block, frame_t, buddy_link)->refcount = 1;
     
    389411 * @param buddy Buddy system.
    390412 * @param block Buddy system block.
    391  */
    392 static void zone_buddy_mark_available(buddy_system_t *buddy, link_t *block)
     413 *
     414 */
     415NO_TRACE static void zone_buddy_mark_available(buddy_system_t *buddy,
     416    link_t *block)
    393417{
    394418        list_get_instance(block, frame_t, buddy_link)->refcount = 0;
     
    421445 *
    422446 */
    423 static pfn_t zone_frame_alloc(zone_t *zone, uint8_t order)
     447NO_TRACE static pfn_t zone_frame_alloc(zone_t *zone, uint8_t order)
    424448{
    425449        ASSERT(zone_flags_available(zone->flags));
     
    449473 *
    450474 */
    451 static void zone_frame_free(zone_t *zone, size_t frame_idx)
     475NO_TRACE static void zone_frame_free(zone_t *zone, size_t frame_idx)
    452476{
    453477        ASSERT(zone_flags_available(zone->flags));
     
    470494
    471495/** Return frame from zone. */
    472 static frame_t *zone_get_frame(zone_t *zone, size_t frame_idx)
     496NO_TRACE static frame_t *zone_get_frame(zone_t *zone, size_t frame_idx)
    473497{
    474498        ASSERT(frame_idx < zone->count);
     
    477501
    478502/** Mark frame in zone unavailable to allocation. */
    479 static void zone_mark_unavailable(zone_t *zone, size_t frame_idx)
     503NO_TRACE static void zone_mark_unavailable(zone_t *zone, size_t frame_idx)
    480504{
    481505        ASSERT(zone_flags_available(zone->flags));
     
    506530 *
    507531 */
    508 static void zone_merge_internal(size_t z1, size_t z2, zone_t *old_z1, buddy_system_t *buddy)
     532NO_TRACE static void zone_merge_internal(size_t z1, size_t z2, zone_t *old_z1,
     533    buddy_system_t *buddy)
    509534{
    510535        ASSERT(zone_flags_available(zones.info[z1].flags));
     
    602627 *
    603628 */
    604 static void return_config_frames(size_t znum, pfn_t pfn, size_t count)
     629NO_TRACE static void return_config_frames(size_t znum, pfn_t pfn, size_t count)
    605630{
    606631        ASSERT(zone_flags_available(zones.info[znum].flags));
     
    637662 *
    638663 */
    639 static void zone_reduce_region(size_t znum, pfn_t frame_idx, size_t count)
     664NO_TRACE static void zone_reduce_region(size_t znum, pfn_t frame_idx,
     665    size_t count)
    640666{
    641667        ASSERT(zone_flags_available(zones.info[znum].flags));
     
    738764        for (i = z2 + 1; i < zones.count; i++) {
    739765                zones.info[i - 1] = zones.info[i];
    740                 zones.info[i - 1].buddy_system->data =
    741                     (void *) &zones.info[i - 1];
     766                if (zones.info[i - 1].buddy_system != NULL)
     767                        zones.info[i - 1].buddy_system->data =
     768                            (void *) &zones.info[i - 1];
    742769        }
    743770       
     
    777804 *
    778805 */
    779 static void zone_construct(zone_t *zone, buddy_system_t *buddy, pfn_t start,
    780     size_t count, zone_flags_t flags)
     806NO_TRACE static void zone_construct(zone_t *zone, buddy_system_t *buddy,
     807    pfn_t start, size_t count, zone_flags_t flags)
    781808{
    782809        zone->base = start;
     
    821848 *
    822849 */
    823 uintptr_t zone_conf_size(size_t count)
     850size_t zone_conf_size(size_t count)
    824851{
    825852        return (count * sizeof(frame_t) + buddy_conf_size(fnzb(count)));
     
    852879                 * the assert
    853880                 */
    854                 ASSERT(confframe != NULL);
     881                ASSERT(confframe != ADDR2PFN((uintptr_t ) NULL));
    855882               
    856883                /* If confframe is supposed to be inside our zone, then make sure
     
    888915                }
    889916               
    890                 size_t znum = zones_insert_zone(start, count);
     917                size_t znum = zones_insert_zone(start, count, flags);
    891918                if (znum == (size_t) -1) {
    892919                        irq_spinlock_unlock(&zones.lock, true);
     
    911938       
    912939        /* Non-available zone */
    913         size_t znum = zones_insert_zone(start, count);
     940        size_t znum = zones_insert_zone(start, count, flags);
    914941        if (znum == (size_t) -1) {
    915942                irq_spinlock_unlock(&zones.lock, true);
     
    10231050               
    10241051#ifdef CONFIG_DEBUG
    1025                 printf("Thread %" PRIu64 " waiting for %" PRIs " frames, "
    1026                     "%" PRIs " available.\n", THREAD->tid, size, avail);
     1052                printf("Thread %" PRIu64 " waiting for %zu frames, "
     1053                    "%zu available.\n", THREAD->tid, size, avail);
    10271054#endif
    10281055               
     
    10781105         */
    10791106        pfn_t pfn = ADDR2PFN(frame);
    1080         size_t znum = find_zone(pfn, 1, NULL);
     1107        size_t znum = find_zone(pfn, 1, 0);
    10811108       
    10821109        ASSERT(znum != (size_t) -1);
     
    11081135 *
    11091136 */
    1110 void frame_reference_add(pfn_t pfn)
     1137NO_TRACE void frame_reference_add(pfn_t pfn)
    11111138{
    11121139        irq_spinlock_lock(&zones.lock, true);
     
    11151142         * First, find host frame zone for addr.
    11161143         */
    1117         size_t znum = find_zone(pfn, 1, NULL);
     1144        size_t znum = find_zone(pfn, 1, 0);
    11181145       
    11191146        ASSERT(znum != (size_t) -1);
     
    11271154 *
    11281155 */
    1129 void frame_mark_unavailable(pfn_t start, size_t count)
     1156NO_TRACE void frame_mark_unavailable(pfn_t start, size_t count)
    11301157{
    11311158        irq_spinlock_lock(&zones.lock, true);
     
    12711298                bool available = zone_flags_available(flags);
    12721299               
    1273                 printf("%-4" PRIs, i);
     1300                printf("%-4zu", i);
    12741301               
    12751302#ifdef __32_BITS__
    1276                 printf("  %10p", base);
     1303                printf("  %p", (void *) base);
    12771304#endif
    12781305               
    12791306#ifdef __64_BITS__
    1280                 printf(" %18p", base);
     1307                printf(" %p", (void *) base);
    12811308#endif
    12821309               
    1283                 printf(" %12" PRIs " %c%c%c      ", count,
     1310                printf(" %12zu %c%c%c      ", count,
    12841311                    available ? 'A' : ' ',
    12851312                    (flags & ZONE_RESERVED) ? 'R' : ' ',
     
    12871314               
    12881315                if (available)
    1289                         printf("%14" PRIs " %14" PRIs,
     1316                        printf("%14zu %14zu",
    12901317                            free_count, busy_count);
    12911318               
     
    13281355        bool available = zone_flags_available(flags);
    13291356       
    1330         printf("Zone number:       %" PRIs "\n", znum);
    1331         printf("Zone base address: %p\n", base);
    1332         printf("Zone size:         %" PRIs " frames (%" PRIs " KiB)\n", count,
     1357        printf("Zone number:       %zu\n", znum);
     1358        printf("Zone base address: %p\n", (void *) base);
     1359        printf("Zone size:         %zu frames (%zu KiB)\n", count,
    13331360            SIZE2KB(FRAMES2SIZE(count)));
    13341361        printf("Zone flags:        %c%c%c\n",
     
    13381365       
    13391366        if (available) {
    1340                 printf("Allocated space:   %" PRIs " frames (%" PRIs " KiB)\n",
     1367                printf("Allocated space:   %zu frames (%zu KiB)\n",
    13411368                    busy_count, SIZE2KB(FRAMES2SIZE(busy_count)));
    1342                 printf("Available space:   %" PRIs " frames (%" PRIs " KiB)\n",
     1369                printf("Available space:   %zu frames (%zu KiB)\n",
    13431370                    free_count, SIZE2KB(FRAMES2SIZE(free_count)));
    13441371        }
  • kernel/generic/src/mm/page.c

    rcefb126 r89c57b6  
    115115 *
    116116 */
    117 void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
     117NO_TRACE void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
    118118    unsigned int flags)
    119119{
     
    139139 *
    140140 */
    141 void page_mapping_remove(as_t *as, uintptr_t page)
     141NO_TRACE void page_mapping_remove(as_t *as, uintptr_t page)
    142142{
    143143        ASSERT(page_table_locked(as));
     
    163163 *
    164164 */
    165 pte_t *page_mapping_find(as_t *as, uintptr_t page)
     165NO_TRACE pte_t *page_mapping_find(as_t *as, uintptr_t page)
    166166{
    167167        ASSERT(page_table_locked(as));
  • kernel/generic/src/mm/slab.c

    rcefb126 r89c57b6  
    177177 *
    178178 */
    179 static slab_t *slab_space_alloc(slab_cache_t *cache, unsigned int flags)
     179NO_TRACE static slab_t *slab_space_alloc(slab_cache_t *cache,
     180    unsigned int flags)
    180181{
    181182       
     
    224225 *
    225226 */
    226 static size_t slab_space_free(slab_cache_t *cache, slab_t *slab)
     227NO_TRACE static size_t slab_space_free(slab_cache_t *cache, slab_t *slab)
    227228{
    228229        frame_free(KA2PA(slab->start));
     
    236237
    237238/** Map object to slab structure */
    238 static slab_t *obj2slab(void *obj)
     239NO_TRACE static slab_t *obj2slab(void *obj)
    239240{
    240241        return (slab_t *) frame_get_parent(ADDR2PFN(KA2PA(obj)), 0);
     
    252253 *
    253254 */
    254 static size_t slab_obj_destroy(slab_cache_t *cache, void *obj, slab_t *slab)
     255NO_TRACE static size_t slab_obj_destroy(slab_cache_t *cache, void *obj,
     256    slab_t *slab)
    255257{
    256258        if (!slab)
     
    293295 *
    294296 */
    295 static void *slab_obj_create(slab_cache_t *cache, int flags)
     297NO_TRACE static void *slab_obj_create(slab_cache_t *cache, unsigned int flags)
    296298{
    297299        spinlock_lock(&cache->slablock);
     
    349351 *
    350352 */
    351 static slab_magazine_t *get_mag_from_cache(slab_cache_t *cache, bool first)
     353NO_TRACE static slab_magazine_t *get_mag_from_cache(slab_cache_t *cache,
     354    bool first)
    352355{
    353356        slab_magazine_t *mag = NULL;
     
    373376 *
    374377 */
    375 static void put_mag_to_cache(slab_cache_t *cache, slab_magazine_t *mag)
     378NO_TRACE static void put_mag_to_cache(slab_cache_t *cache,
     379    slab_magazine_t *mag)
    376380{
    377381        spinlock_lock(&cache->maglock);
     
    388392 *
    389393 */
    390 static size_t magazine_destroy(slab_cache_t *cache, slab_magazine_t *mag)
     394NO_TRACE static size_t magazine_destroy(slab_cache_t *cache,
     395    slab_magazine_t *mag)
    391396{
    392397        size_t i;
     
    406411 *
    407412 */
    408 static slab_magazine_t *get_full_current_mag(slab_cache_t *cache)
     413NO_TRACE static slab_magazine_t *get_full_current_mag(slab_cache_t *cache)
    409414{
    410415        slab_magazine_t *cmag = cache->mag_cache[CPU->id].current;
    411416        slab_magazine_t *lastmag = cache->mag_cache[CPU->id].last;
    412 
     417       
    413418        ASSERT(spinlock_locked(&cache->mag_cache[CPU->id].lock));
    414419       
     
    443448 *
    444449 */
    445 static void *magazine_obj_get(slab_cache_t *cache)
     450NO_TRACE static void *magazine_obj_get(slab_cache_t *cache)
    446451{
    447452        if (!CPU)
     
    473478 *
    474479 */
    475 static slab_magazine_t *make_empty_current_mag(slab_cache_t *cache)
     480NO_TRACE static slab_magazine_t *make_empty_current_mag(slab_cache_t *cache)
    476481{
    477482        slab_magazine_t *cmag = cache->mag_cache[CPU->id].current;
     
    479484       
    480485        ASSERT(spinlock_locked(&cache->mag_cache[CPU->id].lock));
    481 
     486       
    482487        if (cmag) {
    483488                if (cmag->busy < cmag->size)
     
    523528 *
    524529 */
    525 static int magazine_obj_put(slab_cache_t *cache, void *obj)
     530NO_TRACE static int magazine_obj_put(slab_cache_t *cache, void *obj)
    526531{
    527532        if (!CPU)
     
    552557 *
    553558 */
    554 static size_t comp_objects(slab_cache_t *cache)
     559NO_TRACE static size_t comp_objects(slab_cache_t *cache)
    555560{
    556561        if (cache->flags & SLAB_CACHE_SLINSIDE)
     
    564569 *
    565570 */
    566 static size_t badness(slab_cache_t *cache)
     571NO_TRACE static size_t badness(slab_cache_t *cache)
    567572{
    568573        size_t objects = comp_objects(cache);
     
    578583 *
    579584 */
    580 static bool make_magcache(slab_cache_t *cache)
     585NO_TRACE static bool make_magcache(slab_cache_t *cache)
    581586{
    582587        ASSERT(_slab_initialized >= 2);
     
    600605 *
    601606 */
    602 static void _slab_cache_create(slab_cache_t *cache, const char *name,
     607NO_TRACE static void _slab_cache_create(slab_cache_t *cache, const char *name,
    603608    size_t size, size_t align, int (*constructor)(void *obj,
    604609    unsigned int kmflag), size_t (*destructor)(void *obj), unsigned int flags)
     
    607612        cache->name = name;
    608613       
    609         if (align < sizeof(unative_t))
    610                 align = sizeof(unative_t);
     614        if (align < sizeof(sysarg_t))
     615                align = sizeof(sysarg_t);
    611616       
    612617        size = ALIGN_UP(size, align);
     
    676681 *
    677682 */
    678 static size_t _slab_reclaim(slab_cache_t *cache, unsigned int flags)
     683NO_TRACE static size_t _slab_reclaim(slab_cache_t *cache, unsigned int flags)
    679684{
    680685        if (cache->flags & SLAB_CACHE_NOMAGAZINE)
     
    781786 *
    782787 */
    783 static void _slab_free(slab_cache_t *cache, void *obj, slab_t *slab)
     788NO_TRACE static void _slab_free(slab_cache_t *cache, void *obj, slab_t *slab)
    784789{
    785790        ipl_t ipl = interrupts_disable();
     
    801806}
    802807
    803 /** Go through all caches and reclaim what is possible
    804  *
    805  * Interrupts must be disabled before calling this function,
    806  * otherwise  memory allocation from interrupts can deadlock.
    807  *
    808  */
     808/** Go through all caches and reclaim what is possible */
    809809size_t slab_reclaim(unsigned int flags)
    810810{
    811         irq_spinlock_lock(&slab_cache_lock, false);
     811        irq_spinlock_lock(&slab_cache_lock, true);
    812812       
    813813        size_t frames = 0;
     
    819819        }
    820820       
    821         irq_spinlock_unlock(&slab_cache_lock, false);
     821        irq_spinlock_unlock(&slab_cache_lock, true);
    822822       
    823823        return frames;
     
    885885                irq_spinlock_unlock(&slab_cache_lock, true);
    886886               
    887                 printf("%-18s %8" PRIs " %8u %8" PRIs " %8ld %8ld %8ld %-5s\n",
     887                printf("%-18s %8zu %8u %8zu %8ld %8ld %8ld %-5s\n",
    888888                    name, size, (1 << order), objects, allocated_slabs,
    889889                    cached_objs, allocated_objs,
Note: See TracChangeset for help on using the changeset viewer.