Linux 4.4.6 中断向量分析

来源:互联网 发布:golang占位符 编辑:程序博客网 时间:2024/06/10 12:15

在linux4.4.6中的中断向量的设置过程分析:

File Function init/mian.c start_kernel() arch/arm/kernel/setup.c setup_arch() arch/arm/mm/mmu.c paging_init() arch/arm/mm/mmu.c devicemaps_init() arch/arm/kernel/traps.c early_trap_init()
//arch/arm/kernel/traps.cvoid __init early_trap_init(void *vectors_base){    unsigned long vectors = (unsigned long)vectors_base;    extern char __stubs_start[], __stubs_end[];    extern char __vectors_start[], __vectors_end[];    unsigned i;    vectors_page = vectors_base;    /*     * Poison the vectors page with an undefined instruction.  This     * instruction is chosen to be undefined for both ARM and Thumb     * ISAs.  The Thumb version is an undefined instruction with a     * branch back to the undefined instruction.     */    for (i = 0; i < PAGE_SIZE / sizeof(u32); i++)        ((u32 *)vectors_base)[i] = 0xe7fddef1;    /*     * Copy the vectors, stubs and kuser helpers (in entry-armv.S)     * into the vector page, mapped at 0xffff0000, and ensure these     * are visible to the instruction stream.     */    memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);    memcpy((void *)vectors + 0x1000, __stubs_start, __stubs_end - __stubs_start);    kuser_init(vectors_base);    flush_icache_range(vectors, vectors + PAGE_SIZE * 2);}
/* * arch/arm/kernel/entry-armv.S * vector_rst,vector_und,vector_pabt等都为宏定义 */    .section .vectors, "ax", %progbits__vectors_start:    W(b)    vector_rst    W(b)    vector_und    W(ldr)  pc, __vectors_start + 0x1000    W(b)    vector_pabt    W(b)    vector_dabt    W(b)    vector_addrexcptn    W(b)    vector_irq    W(b)    vector_fiq/* * arch/arm/kernel/vmlinux.lds.S * The vectors and stubs are relocatable code, and the * only thing that matters is their relative offsets */    __vectors_start = .;    .vectors 0 : AT(__vectors_start) {        *(.vectors)    }    . = __vectors_start + SIZEOF(.vectors);    __vectors_end = .;    __stubs_start = .;    .stubs 0x1000 : AT(__stubs_start) {        *(.stubs)    }    . = __stubs_start + SIZEOF(.stubs);    __stubs_end = .;

vector_stub und, UND_MODE

0 0