Ignore:
Timestamp:
2010-05-24T18:57:31Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/mm/sun4v/as.c

    r666f492 rda1bafb  
    4444
    4545#ifdef CONFIG_TSB
     46
    4647#include <arch/mm/tsb.h>
    4748#include <arch/memstr.h>
     
    5051#include <bitops.h>
    5152#include <macros.h>
     53
    5254#endif /* CONFIG_TSB */
    5355
     
    6163}
    6264
    63 int as_constructor_arch(as_t *as, int flags)
     65int as_constructor_arch(as_t *as, unsigned int flags)
    6466{
    6567#ifdef CONFIG_TSB
    66         int order = fnzb32(
     68        uint8_t order = fnzb32(
    6769                (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH);
    68 
     70       
    6971        uintptr_t tsb = (uintptr_t) frame_alloc(order, flags);
    70 
     72       
    7173        if (!tsb)
    7274                return -1;
    73 
     75       
    7476        as->arch.tsb_description.page_size = PAGESIZE_8K;
    7577        as->arch.tsb_description.associativity = 1;
     
    7981        as->arch.tsb_description.reserved = 0;
    8082        as->arch.tsb_description.context = 0;
    81 
     83       
    8284        memsetb((void *) PA2KA(as->arch.tsb_description.tsb_base),
    8385                TSB_ENTRY_COUNT * sizeof(tsb_entry_t), 0);
    8486#endif
     87       
    8588        return 0;
    8689}
     
    9194        size_t cnt = (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH;
    9295        frame_free((uintptr_t) as->arch.tsb_description.tsb_base);
     96       
    9397        return cnt;
    9498#else
     
    97101}
    98102
    99 int as_create_arch(as_t *as, int flags)
     103int as_create_arch(as_t *as, unsigned int flags)
    100104{
    101105#ifdef CONFIG_TSB
    102106        tsb_invalidate(as, 0, (size_t) -1);
    103107#endif
     108       
    104109        return 0;
    105110}
     
    111116 *
    112117 * @param as Address space.
     118 *
    113119 */
    114120void as_install_arch(as_t *as)
    115121{
    116122        mmu_secondary_context_write(as->asid);
    117 #ifdef CONFIG_TSB       
     123       
     124#ifdef CONFIG_TSB
    118125        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    119 
     126       
    120127        ASSERT(as->arch.tsb_description.tsb_base);
    121128        uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base);
    122                
     129       
    123130        if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    124131                /*
     
    126133                 * by the locked 4M kernel DTLB entry. We need
    127134                 * to map both TSBs explicitly.
     135                 *
    128136                 */
    129137                mmu_demap_page(tsb, 0, MMU_FLAG_DTLB);
    130138                dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true);
    131139        }
    132 
     140       
    133141        __hypercall_fast2(MMU_TSB_CTXNON0, 1, KA2PA(&(as->arch.tsb_description)));
    134        
    135142#endif
    136143}
     
    142149 *
    143150 * @param as Address space.
     151 *
    144152 */
    145153void as_deinstall_arch(as_t *as)
    146154{
    147 
    148155        /*
    149156         * Note that we don't and may not lock the address space. That's ok
     
    151158         *
    152159         * Moreover, the as->asid is protected by asidlock, which is being held.
     160         *
    153161         */
    154 
     162       
    155163#ifdef CONFIG_TSB
    156164        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    157 
     165       
    158166        ASSERT(as->arch.tsb_description.tsb_base);
    159 
     167       
    160168        uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base);
    161                
     169       
    162170        if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    163171                /*
     
    165173                 * by the locked 4M kernel DTLB entry. We need
    166174                 * to demap the entry installed by as_install_arch().
     175                 *
    167176                 */
    168177                __hypercall_fast3(MMU_UNMAP_PERM_ADDR, tsb, 0, MMU_FLAG_DTLB);
Note: See TracChangeset for help on using the changeset viewer.