Ignore:
Timestamp:
2013-09-11T11:56:39Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1db5669
Parents:
43dd8028
Message:

due to the removal of FRAME_KA, the return value of frame_alloc*() needs to be checked before converting the physical address to kernel address

File:
1 edited

Legend:

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

    r43dd8028 rcd3b380  
    6363{
    6464#ifdef CONFIG_TSB
     65        uintptr_t tsb_phys =
     66            frame_alloc(SIZE2FRAMES((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
     67            sizeof(tsb_entry_t)), flags, 0);
     68        if (!tsb_phys)
     69                return -1;
     70       
     71        tsb_entry_t *tsb = (tsb_entry_t *) PA2KA(tsb_phys);
     72       
     73        as->arch.itsb = tsb;
     74        as->arch.dtsb = tsb + ITSB_ENTRY_COUNT;
     75       
     76        memsetb(as->arch.itsb, (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
     77            sizeof(tsb_entry_t), 0);
     78#endif
     79       
     80        return 0;
     81}
     82
     83int as_destructor_arch(as_t *as)
     84{
     85#ifdef CONFIG_TSB
    6586        size_t frames = SIZE2FRAMES((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
    6687            sizeof(tsb_entry_t));
    67        
    68         uintptr_t tsb = PA2KA(frame_alloc(frames, flags, 0));
    69         if (!tsb)
    70                 return -1;
    71        
    72         as->arch.itsb = (tsb_entry_t *) tsb;
    73         as->arch.dtsb = (tsb_entry_t *) (tsb +
    74             ITSB_ENTRY_COUNT * sizeof(tsb_entry_t));
    75        
    76         memsetb(as->arch.itsb,
    77             (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * sizeof(tsb_entry_t), 0);
    78 #endif
    79        
    80         return 0;
    81 }
    82 
    83 int as_destructor_arch(as_t *as)
    84 {
    85 #ifdef CONFIG_TSB
    86         /*
    87          * The count must be calculated with respect to the emualted 16K page
    88          * size.
    89          */
    90         size_t cnt = ((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
    91             sizeof(tsb_entry_t)) >> FRAME_WIDTH;
    92         frame_free(KA2PA((uintptr_t) as->arch.itsb));
    93        
    94         return cnt;
     88        frame_free(KA2PA((uintptr_t) as->arch.itsb), frames);
     89       
     90        return frames;
    9591#else
    9692        return 0;
Note: See TracChangeset for help on using the changeset viewer.