Changeset 2e9eae2 in mainline


Ignore:
Timestamp:
2006-06-23T16:03:53Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
757551a3
Parents:
a832dd7
Message:

Changed interface of frame_alloc/free to use address of frame instead of the pfn.
This makes it impossible to use >4GB of memory on 32-bit machines, but who cares…

Files:
20 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/smp/smp.c

    ra832dd7 r2e9eae2  
    7474        }
    7575
    76         l_apic_address = PA2KA(PFN2ADDR(frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status)));
     76        l_apic_address = (__address) frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status);
    7777        if (status != FRAME_OK)
    7878                panic("cannot allocate address for l_apic\n");
    7979
    80         io_apic_address = PA2KA(PFN2ADDR(frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status)));
     80        io_apic_address = (__address) frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status);
    8181        if (status != FRAME_OK)
    8282                panic("cannot allocate address for io_apic\n");
  • arch/ia64/src/mm/vhpt.c

    ra832dd7 r2e9eae2  
    4343__address vhpt_set_up(void)
    4444{
    45         vhpt_base=(vhpt_entry_t*) PA2KA(PFN2ADDR(frame_alloc(VHPT_WIDTH-FRAME_WIDTH,FRAME_KA)));
     45        vhpt_base=(vhpt_entry_t*) frame_alloc(VHPT_WIDTH-FRAME_WIDTH,FRAME_KA);
    4646        if(!vhpt_base) panic("Kernel configured with VHPT but no memory for table.");
    4747        vhpt_invalidate_all();
  • arch/ppc64/src/mm/page.c

    ra832dd7 r2e9eae2  
    275275               
    276276                /* Allocate page hash table */
    277                 phte_t *physical_phte = (phte_t *) PFN2ADDR(frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC));
    278                 phte = (phte_t *) PA2KA((__address) physical_phte);
     277                phte_t *physical_phte = (phte_t *) frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC);
    279278               
    280279                ASSERT((__address) physical_phte % (1 << PHT_BITS) == 0);
  • arch/sparc64/src/mm/page.c

    ra832dd7 r2e9eae2  
    7474                order = (fnzb32(size - 1) + 1) - FRAME_WIDTH;
    7575       
    76         __address virtaddr = PA2KA(PFN2ADDR(frame_alloc(order, FRAME_KA)));
     76        __address virtaddr = frame_alloc(order, FRAME_KA);
    7777
    7878        for (i = 0; i < sizemap[order].count; i++)
  • genarch/src/fb/fb.c

    ra832dd7 r2e9eae2  
    395395                order = fnzb(pages-1)+1;
    396396
    397         pfn_t frame = frame_alloc_rc(order,FRAME_ATOMIC,&rc);
    398         if (!rc)
    399                 dbbuffer = (void *)PA2KA(PFN2ADDR(frame));
    400         else
     397        dbbuffer = frame_alloc_rc(order,FRAME_ATOMIC | FRAME_KA, &rc);
     398        if (!dbbuffer)
    401399                printf("Failed to allocate scroll buffer.\n");
    402400        dboffset = 0;
  • genarch/src/mm/as_pt.c

    ra832dd7 r2e9eae2  
    7474        ipl_t ipl;
    7575
    76         dst_ptl0 = (pte_t *) PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA | FRAME_PANIC)));
     76        dst_ptl0 = (pte_t *) frame_alloc(ONE_FRAME, FRAME_KA | FRAME_PANIC);
    7777
    7878        if (flags & FLAG_AS_KERNEL) {
     
    109109void ptl0_destroy(pte_t *page_table)
    110110{
    111         frame_free(ADDR2PFN((__address) page_table));
     111        frame_free((__address)page_table);
    112112}
    113113
  • genarch/src/mm/page_pt.c

    ra832dd7 r2e9eae2  
    7272{
    7373        pte_t *ptl0, *ptl1, *ptl2, *ptl3;
    74         __address newpt;
     74        pte_t *newpt;
    7575
    7676        ptl0 = (pte_t *) PA2KA((__address) as->page_table);
    7777
    7878        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
    79                 newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));
    80                 memsetb(newpt, PAGE_SIZE, 0);
     79                newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
     80                memsetb((__address)newpt, PAGE_SIZE, 0);
    8181                SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
    8282                SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
     
    8686
    8787        if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) {
    88                 newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));
    89                 memsetb(newpt, PAGE_SIZE, 0);
     88                newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
     89                memsetb((__address)newpt, PAGE_SIZE, 0);
    9090                SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
    9191                SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
     
    9595
    9696        if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) {
    97                 newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));
    98                 memsetb(newpt, PAGE_SIZE, 0);
     97                newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
     98                memsetb((__address)newpt, PAGE_SIZE, 0);
    9999                SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
    100100                SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
     
    166166                 * Release the frame and remove PTL3 pointer from preceding table.
    167167                 */
    168                 frame_free(ADDR2PFN(KA2PA((__address) ptl3)));
     168                frame_free(KA2PA((__address) ptl3));
    169169                if (PTL2_ENTRIES)
    170170                        memsetb((__address) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0);
     
    195195                         * Release the frame and remove PTL2 pointer from preceding table.
    196196                         */
    197                         frame_free(ADDR2PFN(KA2PA((__address) ptl2)));
     197                        frame_free(KA2PA((__address) ptl2));
    198198                        if (PTL1_ENTRIES)
    199199                                memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
     
    224224                         * Release the frame and remove PTL1 pointer from preceding table.
    225225                         */
    226                         frame_free(ADDR2PFN(KA2PA((__address) ptl1)));
     226                        frame_free(KA2PA((__address) ptl1));
    227227                        memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
    228228                }
  • generic/include/mm/frame.h

    ra832dd7 r2e9eae2  
    9595
    9696extern void frame_init(void);
    97 extern pfn_t frame_alloc_generic(__u8 order, int flags, int * status, int *pzone);
    98 extern void frame_free(pfn_t pfn);
     97extern void * frame_alloc_generic(__u8 order, int flags, int * status, int *pzone);
     98extern void frame_free(__address frame);
    9999extern void frame_reference_add(pfn_t pfn);
    100100
  • generic/src/console/klog.c

    ra832dd7 r2e9eae2  
    5959        void *faddr;
    6060
    61         faddr = (void *)PFN2ADDR(frame_alloc(KLOG_ORDER, FRAME_ATOMIC));
     61        faddr = frame_alloc(KLOG_ORDER, FRAME_ATOMIC);
    6262        if (!faddr)
    6363                panic("Cannot allocate page for klog");
  • generic/src/cpu/cpu.c

    ra832dd7 r2e9eae2  
    7272
    7373                for (i=0; i < config.cpu_count; i++) {
    74                         cpus[i].stack = (__u8 *) PA2KA(PFN2ADDR(frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_PANIC)));
     74                        cpus[i].stack = (__u8 *) frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_PANIC);
    7575                       
    7676                        cpus[i].id = i;
  • generic/src/mm/as.c

    ra832dd7 r2e9eae2  
    14971497                        node = list_get_instance(cur, btree_node_t, leaf_link);
    14981498                        for (i = 0; i < node->keys; i++)
    1499                                 frame_free(ADDR2PFN((__address) node->value[i]));
     1499                                frame_free((__address) node->value[i]);
    15001500                }
    15011501               
  • generic/src/mm/backend_anon.c

    ra832dd7 r2e9eae2  
    106106                        }
    107107                        if (allocate) {
    108                                 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));
     108                                frame = (__address) frame_alloc(ONE_FRAME, 0);
    109109                                memsetb(PA2KA(frame), FRAME_SIZE, 0);
    110110                               
     
    133133                 *   the different causes
    134134                 */
    135                 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));
     135                frame = (__address)frame_alloc(ONE_FRAME, 0);
    136136                memsetb(PA2KA(frame), FRAME_SIZE, 0);
    137137        }
     
    159159void anon_frame_free(as_area_t *area, __address page, __address frame)
    160160{
    161         frame_free(ADDR2PFN(frame));
     161        frame_free(frame);
    162162}
    163163
  • generic/src/mm/backend_elf.c

    ra832dd7 r2e9eae2  
    135135                 */
    136136                if (entry->p_flags & PF_W) {
    137                         frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));
     137                        frame = (__address)frame_alloc(ONE_FRAME, 0);
    138138                        memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), FRAME_SIZE);
    139139                       
     
    154154                 * and cleared.
    155155                 */
    156                 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));
     156                frame = (__address)frame_alloc(ONE_FRAME, 0);
    157157                memsetb(PA2KA(frame), FRAME_SIZE, 0);
    158158
     
    171171                 */
    172172                size = entry->p_filesz - (i<<PAGE_WIDTH);
    173                 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));
     173                frame = (__address)frame_alloc(ONE_FRAME, 0);
    174174                memsetb(PA2KA(frame) + size, FRAME_SIZE - size, 0);
    175175                memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), size);
     
    219219                         * Free the frame with the copy of writable segment data.
    220220                         */
    221                         frame_free(ADDR2PFN(frame));
     221                        frame_free(frame);
    222222                }
    223223        } else {
     
    227227                 * In any case, a frame needs to be freed.
    228228                 */
    229                 frame_free(ADDR2PFN(frame));
     229                frame_free(frame);
    230230        }
    231231}
  • generic/src/mm/frame.c

    ra832dd7 r2e9eae2  
    929929 * @param pzone  Preferred zone
    930930 *
    931  * @return Allocated frame.
    932  *
    933  */
    934 pfn_t frame_alloc_generic(__u8 order, int flags, int *status, int *pzone)
     931 * @return Physical address of the allocated frame.
     932 *
     933 */
     934void * frame_alloc_generic(__u8 order, int flags, int *status, int *pzone)
    935935{
    936936        ipl_t ipl;
     
    972972                        if (status)
    973973                                *status = FRAME_NO_MEMORY;
    974                         return NULL;
     974                        return 0;
    975975                }
    976976               
     
    987987        if (status)
    988988                *status = FRAME_OK;
    989         return v;
     989
     990        if (flags & FRAME_KA)
     991                return (void *)PA2KA(PFN2ADDR(v));
     992        return (void *)PFN2ADDR(v);
    990993}
    991994
     
    996999 * If it drops to zero, move the frame structure to free list.
    9971000 *
    998  * @param pfn Frame number of the frame to be freed.
    999  */
    1000 void frame_free(pfn_t pfn)
     1001 * @param Frame Physical Address of of the frame to be freed.
     1002 */
     1003void frame_free(__address frame)
    10011004{
    10021005        ipl_t ipl;
    10031006        zone_t *zone;
     1007        pfn_t pfn = ADDR2PFN(frame);
    10041008
    10051009        ipl = interrupts_disable();
  • generic/src/mm/slab.c

    ra832dd7 r2e9eae2  
    163163        int i;
    164164        int status;
    165         pfn_t pfn;
    166165        int zone=0;
    167166       
    168         pfn = frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone);
    169         data = (void *) PA2KA(PFN2ADDR(pfn));
     167        data = frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone);
    170168        if (status != FRAME_OK) {
    171169                return NULL;
     
    174172                slab = slab_alloc(slab_extern_cache, flags);
    175173                if (!slab) {
    176                         frame_free(ADDR2PFN(KA2PA(data)));
     174                        frame_free(KA2PA(data));
    177175                        return NULL;
    178176                }
     
    184182        /* Fill in slab structures */
    185183        for (i=0; i < (1 << cache->order); i++)
    186                 frame_set_parent(pfn+i, slab, zone);
     184                frame_set_parent(ADDR2PFN(KA2PA(data))+i, slab, zone);
    187185
    188186        slab->start = data;
     
    205203static count_t slab_space_free(slab_cache_t *cache, slab_t *slab)
    206204{
    207         frame_free(ADDR2PFN(KA2PA(slab->start)));
     205        frame_free(KA2PA(slab->start));
    208206        if (! (cache->flags & SLAB_CACHE_SLINSIDE))
    209207                slab_free(slab_extern_cache, slab);
  • generic/src/proc/thread.c

    ra832dd7 r2e9eae2  
    125125{
    126126        thread_t *t = (thread_t *)obj;
    127         pfn_t pfn;
    128127        int status;
    129128
     
    143142#endif 
    144143
    145         pfn = frame_alloc_rc(STACK_FRAMES, FRAME_KA | kmflags,&status);
     144        t->kstack = frame_alloc_rc(STACK_FRAMES, FRAME_KA | kmflags,&status);
    146145        if (status) {
    147146#ifdef ARCH_HAS_FPU
     
    151150                return -1;
    152151        }
    153         t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn));
    154152
    155153        return 0;
     
    161159        thread_t *t = (thread_t *)obj;
    162160
    163         frame_free(ADDR2PFN(KA2PA(t->kstack)));
     161        frame_free(KA2PA(t->kstack));
    164162#ifdef ARCH_HAS_FPU
    165163        if (t->saved_fpu_context)
  • generic/src/time/clock.c

    ra832dd7 r2e9eae2  
    8080        void *faddr;
    8181
    82         faddr = (void *)PFN2ADDR(frame_alloc(0, FRAME_ATOMIC));
     82        faddr = frame_alloc(0, FRAME_ATOMIC);
    8383        if (!faddr)
    8484                panic("Cannot allocate page for clock");
  • test/mm/falloc1/test.c

    ra832dd7 r2e9eae2  
    5656                        allocated = 0;
    5757                        for (i = 0; i < MAX_FRAMES >> order; i++) {
    58                                 frames[allocated] = PA2KA(PFN2ADDR(frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status)));
     58                                frames[allocated] = frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status);
    5959                               
    6060                                if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
     
    8181                        printf("Deallocating ... ");
    8282                        for (i = 0; i < allocated; i++) {
    83                                 frame_free(ADDR2PFN(KA2PA(frames[i])));
     83                                frame_free(KA2PA(frames[i]));
    8484                        }
    8585                        printf("done.\n");
  • test/mm/falloc2/test.c

    ra832dd7 r2e9eae2  
    6666                        allocated = 0;
    6767                        for (i = 0; i < (MAX_FRAMES >> order); i++) {
    68                                 frames[allocated] = PA2KA(PFN2ADDR(frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status)));
     68                                frames[allocated] = frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status);
    6969                                if (status == 0) {
    7070                                        memsetb(frames[allocated], FRAME_SIZE << order, val);
     
    8484                                        }
    8585                                }
    86                                 frame_free(ADDR2PFN(KA2PA(frames[i])));
     86                                frame_free(KA2PA(frames[i]));
    8787                        }
    8888                        printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id);
  • test/mm/mapping1/test.c

    ra832dd7 r2e9eae2  
    4848        printf("Memory management test mapping #1\n");
    4949
    50         frame0 = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));
    51         frame1 = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));
     50        frame0 = frame_alloc(ONE_FRAME, FRAME_KA);
     51        frame1 = frame_alloc(ONE_FRAME, FRAME_KA);
    5252
    5353        printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0));
Note: See TracChangeset for help on using the changeset viewer.