Linux如何映射實體記憶體到核心空間

來源:互聯網
上載者:User
在setup_arch()中: 1. parse_cmdline(): 根據uboot傳遞的mem資訊,調用early_mem()通過arm_add_memory()把實體記憶體資訊添加到meminfo結構體中。 2. paging_init(): 這個就是關鍵的初始化頁表的函數,在裡面會調用bootmem_init()->bootmem_init_node()->map_memory_bank(),在這裡會根據meminfo的資訊調用create_mapping()來為實體記憶體建立核心空間的映射,一般是從0xc0000000開始。下面是arm linux的虛擬位址映射表: Start       End     Use
--------------------------------------------------------------------------
ffff8000 ffffffff   copy_user_page / clear_user_page use.
ffff1000 ffff7fff   Reserved.
    ffff0000 ffff0fff CPU vector page.
    The CPU vectors are mapped here if the  CPU supports vector relocation (control
    register V bit.) ffc00000 fffeffff DMA memory mapping region.  Memory returned by the dma_alloc_xxx functions will be dynamically mapped here. ff000000 ffbfffff Reserved for future expansion of DMA mapping region. VMALLOC_END feffffff Free for platform use, recommended.
    VMALLOC_END must be aligned to a 2MB
    boundary. VMALLOC_START VMALLOC_END-1 vmalloc() / ioremap() space.
    Memory returned by vmalloc/ioremap will
    be dynamically placed in this region.
    VMALLOC_START may be based upon the value
    of the high_memory variable. PAGE_OFFSET high_memory-1 Kernel direct-mapped RAM region.
    This maps the platforms RAM, and typically
    maps all platform RAM in a 1:1 relationship. TASK_SIZE PAGE_OFFSET-1 Kernel module space
    Kernel modules inserted via insmod are
    placed here using dynamic mappings. 00001000 TASK_SIZE-1 User space mappings
    Per-thread mappings are placed here via
    the mmap() system call. 00000000 00000fff CPU vector page / null pointer trap
    CPUs which do not support vector remapping
    place their vector page here.  NULL pointer
    dereferences by both the kernel and user
    space are also caught via this mapping.雖然後面這個表我不知道什麼意思,但是上面的對我還是蠻有用的,至少我知道了,實體記憶體是如何映射到核心空間的。
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.