Changeset c1982e45 in mainline


Ignore:
Timestamp:
2006-05-20T21:11:08Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
125e944
Parents:
1068f6a
Message:

make hardware memory mapping more generic

Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/src/mm/page.c

    r1068f6a rc1982e45  
    7272        SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \
    7373    }
     74
     75
    7476void page_arch_init(void)
    7577{
     
    108110        }
    109111}
     112
    110113
    111114/** Identity page mapper
     
    162165}
    163166
     167
    164168void page_fault(int n, istate_t *istate)
    165169{
     
    173177        }
    174178}
     179
     180
     181__address hw_map(__address physaddr, size_t size)
     182{
     183        if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
     184                panic("Unable to map physical memory %p (%d bytes)", physaddr, size)
     185       
     186        __address virtaddr = PA2KA(last_frame);
     187        pfn_t i;
     188        for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
     189                page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE);
     190       
     191        last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
     192       
     193        return virtaddr;
     194}
  • arch/ia32/src/mm/page.c

    r1068f6a rc1982e45  
    3434#include <mm/as.h>
    3535#include <arch/types.h>
     36#include <align.h>
    3637#include <config.h>
    3738#include <func.h>
     
    4243#include <print.h>
    4344#include <interrupt.h>
     45
    4446
    4547void page_arch_init(void)
     
    7072        paging_on();
    7173}
     74
     75
     76__address hw_map(__address physaddr, size_t size)
     77{
     78        if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
     79                panic("Unable to map physical memory %p (%d bytes)", physaddr, size)
     80       
     81        __address virtaddr = PA2KA(last_frame);
     82        pfn_t i;
     83        for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
     84                page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE);
     85       
     86        last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
     87       
     88        return virtaddr;
     89}
  • arch/sparc64/Makefile.inc

    r1068f6a rc1982e45  
    6666
    6767CONFIG_FB = y
    68 CONFIG_FB_MAP_ARCH = y
    6968
    7069## Compile with support for i8042 controller.
  • arch/sparc64/src/console.c

    r1068f6a rc1982e45  
    7070        mutex_initialize(&canwork);
    7171        ofw_console_active = 1;
    72 }
    73 
    74 void fb_map_arch(__address virtaddr, __address physaddr, size_t size)
    75 {
    76         dtlb_insert_mapping(virtaddr, physaddr, PAGESIZE_512K, true, false);
    77         dtlb_insert_mapping(virtaddr + 512*1024, physaddr + 512*1024, PAGESIZE_512K, true, false);
    7872}
    7973
  • arch/sparc64/src/mm/page.c

    r1068f6a rc1982e45  
    2828
    2929#include <arch/mm/page.h>
     30#include <arch/mm/tlb.h>
    3031#include <genarch/mm/page_ht.h>
     32#include <mm/frame.h>
     33#include <bitops.h>
    3134
    3235void page_arch_init(void)
     
    3437        page_mapping_operations = &ht_mapping_operations;
    3538}
     39
     40__address hw_map(__address physaddr, size_t size)
     41{
     42        unsigned int order;
     43       
     44        if (size <= FRAME_SIZE)
     45                order = 0;
     46        else
     47                order = (fnzb32(size - 1) + 1) - FRAME_WIDTH;
     48       
     49        __address virtaddr = PA2KA(PFN2ADDR(frame_alloc(order, FRAME_KA)));
     50       
     51        dtlb_insert_mapping(virtaddr, physaddr, PAGESIZE_512K, true, false);
     52        dtlb_insert_mapping(virtaddr + 512 * 1024, physaddr + 512 * 1024, PAGESIZE_512K, true, false);
     53       
     54        return virtaddr;
     55}
  • genarch/Makefile.inc

    r1068f6a rc1982e45  
    6868                genarch/src/fb/fb.c
    6969        DEFS += -DCONFIG_FB
    70         ifneq ($(CONFIG_FB_MAP_ARCH),y)
    71                 GENARCH_SOURCES += \
    72                         genarch/src/fb/fb_map.c
    73         endif
    7470endif
    7571
  • genarch/include/fb/fb.h

    r1068f6a rc1982e45  
    3636void fb_init(__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan);
    3737
    38 /* To be implemented by architecture. */
    39 void fb_map_arch(__address virtaddr, __address physaddr, size_t size);
    40 
    4138#endif
  • genarch/src/fb/fb.c

    r1068f6a rc1982e45  
    3333#include <sysinfo/sysinfo.h>
    3434#include <mm/slab.h>
    35 #include <bitops.h>
    3635#include <align.h>
    3736#include <panic.h>
     
    350349       
    351350        unsigned int fbsize = scan * y;
    352         unsigned int fborder;
    353        
    354         if (fbsize <= FRAME_SIZE)
    355                 fborder = 0;
    356         else
    357                 fborder = (fnzb32(fbsize - 1) + 1) - FRAME_WIDTH;
    358351       
    359352        /* Map the framebuffer */
    360         fbaddress = (__u8 *) PA2KA(PFN2ADDR(frame_alloc(fborder, FRAME_KA)));
    361        
    362         fb_map_arch((__address) fbaddress, (__address) addr, fbsize);
     353        fbaddress = (__u8 *) hw_map((__address) addr, fbsize);
    363354       
    364355        xres = x;
  • generic/include/mm/page.h

    r1068f6a rc1982e45  
    7979extern pte_t *page_table_create(int flags);
    8080extern void map_structure(__address s, size_t size);
     81extern __address hw_map(__address physaddr, size_t size);
    8182
    8283#endif
Note: See TracChangeset for help on using the changeset viewer.