• mit 6.828学习笔记不知道几---lab4 parta


    Exercise 1:

    // Where to start the next region.  Initially, this is the
        // beginning of the MMIO region.  Because this is static, its
        // value will be preserved between calls to mmio_map_region
        // (just like nextfree in boot_alloc).
        static uintptr_t base = MMIOBASE;
    
        // Reserve size bytes of virtual memory starting at base and
        // map physical pages [pa,pa+size) to virtual addresses
        // [base,base+size).  Since this is device memory and not
        // regular DRAM, you'll have to tell the CPU that it isn't
        // safe to cache access to this memory.  Luckily, the page
        // tables provide bits for this purpose; simply create the
        // mapping with PTE_PCD|PTE_PWT (cache-disable and
        // write-through) in addition to PTE_W.  (If you're interested
        // in more details on this, see section 10.5 of IA32 volume
        // 3A.)
        //
        // Be sure to round size up to a multiple of PGSIZE and to
        // handle if this reservation would overflow MMIOLIM (it's
        // okay to simply panic if this happens).
        //
        // Hint: The staff solution uses boot_map_region.
        //
        // Your code here:
    
        void* ret = (void*)base;
    
        size = ROUNDUP(size, PGSIZE);
        if (base + size > MMIOLIM || base + size < base)
            panic("mmio_map_region: reservation overflow
    ");
    
        boot_map_region(kern_pgdir, base, size, pa,  PTE_PCD | PTE_PWT |PTE_W );
        base += size;
    
        return ret;
        //panic("mmio_map_region not implemented");

    exercise2:

    size_t i;
        //Mark physical page 0 as in use.
        pages[0].pp_ref = 1;
        pages[0].pp_link = NULL;
        
        size_t lowio= IOPHYSMEM / PGSIZE;
        size_t  highio = EXTPHYSMEM / PGSIZE;
        
        for (i = 1; i < npages; i++)
        {
            if ( (i == MPENTRY_PADDR / PGSIZE)||(i >= lowio && i < highio) || (i >= EXTPHYSMEM / PGSIZE && i < PADDR(boot_alloc(0)) / PGSIZE))
            {
                pages[i].pp_ref = 1;
                pages[i].pp_link = NULL;
            }
                    
            else {
                pages[i].pp_ref = 0;
                pages[i].pp_link = page_free_list;
                page_free_list = &pages[i];
            }
    
        }
        
  • 相关阅读:
    前端分页功能的实现以及原理
    Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结
    Jquery实现的几款漂亮的时间轴
    jQuery点击弹出层,弹出模态框,点击模态框消失
    如何用CSS快速布局(一)—— 布局元素详细
    验证控件jQuery Validation Engine调用外部函数验证
    Javascript实现页面跳转的几种方式
    最详细win7下手动搭建PHP环境:apache2.4.23+php7.0.11
    spark调优——JVM调优
    spark调优——Shuffle调优
  • 原文地址:https://www.cnblogs.com/luo-he/p/13991550.html
Copyright © 2020-2023  润新知