setup_processor()

来源:互联网 发布:拒绝网络暴力作文高中 编辑:程序博客网 时间:2024/06/09 15:01

Linux version 2.6.35 arch\arm\kernel\setup.c

static void __init setup_processor(void)

{
    struct proc_info_list *list;

    /*
     * locate processor in the list of supported processor
     * types.  The linker builds this table for us from the
     * entries in arch/arm/mm/proc-v6.S

     */

    /*

     * 搜索processpr类型,该类型在之前head.S中已经获取了, 在proc-*.S中,

extern struct processor {
    /* MISC
     * get data abort address/flags
     */
    void (*_data_abort)(unsigned long pc);
    /*
     * Retrieve prefetch fault address
     */
    unsigned long (*_prefetch_abort)(unsigned long lr);
    /*
     * Set up any processor specifics
     */
    void (*_proc_init)(void);
    /*
     * Disable any processor specifics
     */
    void (*_proc_fin)(void);
    /*
     * Special stuff for a reset
     */
    void (*reset)(unsigned long addr) __attribute__((noreturn));
    /*
     * Idle the processor
     */
    int (*_do_idle)(void);
    /*
     * Processor architecture specific
     */
    /*
     * clean a virtual address range from the
     * D-cache without flushing the cache.
     */
    void (*dcache_clean_area)(void *addr, int size);

    /*
     * Set the page table
     */
    void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *mm);
    /*
     * Set a possibly extended PTE.  Non-extended PTEs should
     * ignore 'ext'.
     */
    void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext);
}processor;

ENTRY(v6_processor_functions)
    .word    v6_early_abort
    .word    v6_pabort
    .word    cpu_v6_proc_init
    .word    cpu_v6_proc_fin
    .word    cpu_v6_reset
    .word    cpu_v6_do_idle
    .word    cpu_v6_dcache_clean_area
    .word    cpu_v6_switch_mm
    .word    cpu_v6_set_pte_ext


struct proc_info_list {
    unsigned int        cpu_val;
    unsigned int        cpu_mask;
    unsigned long        __cpu_mm_mmu_flags;    /* used by head.S */
    unsigned long        __cpu_io_mmu_flags;    /* used by head.S */
    unsigned long        __cpu_flush;        /* used by head.S */
    const char        *arch_name;
    const char        *elf_name;
    unsigned int        elf_hwcap;
    const char        *cpu_name;
    struct processor    *proc;
    struct cpu_tlb_fns    *tlb;
    struct cpu_user_fns    *user;
    struct cpu_cache_fns    *cache;
};


__v6_proc_info:
    .long    0x0007b000
    .long    0x0007f000
    .long   PMD_TYPE_SECT | \
        PMD_SECT_AP_WRITE | \
        PMD_SECT_AP_READ | \
        PMD_FLAGS
    .long   PMD_TYPE_SECT | \
        PMD_SECT_XN | \
        PMD_SECT_AP_WRITE | \
        PMD_SECT_AP_READ
    b    __v6_setup
    .long    cpu_arch_name
    .long    cpu_elf_name
    .long    HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
    .long    cpu_v6_name
    .long    v6_processor_functions
    .long    v6wbi_tlb_fns
    .long    v6_user_fns
    .long    v6_cache_fns
    .size    __v6_proc_info, . - __v6_proc_info

     */

    list = lookup_processor_type(read_cpuid_id());
    if (!list) {/* 如果没有获得 则打印错误信息 并进入死循环
        printk("CPU configuration botched (ID %08x), unable "
               "to continue.\n", read_cpuid_id());
        while (1);
    }

    cpu_name = list->cpu_name;        //cpu_arch_name

#ifdef MULTI_CPU
    processor = *list->proc;                   //v6_processor_functions
#endif
#ifdef MULTI_TLB
    cpu_tlb = *list->tlb;                            //v6wbi_tlb_fns
#endif
#ifdef MULTI_USER
    cpu_user = *list->user;                    //v6_user_fns
#endif
#ifdef MULTI_CACHE
    cpu_cache = *list->cache;               //v6_cache_fns
#endif

    printk("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n",
           cpu_name, read_cpuid_id(), read_cpuid_id() & 15,
           proc_arch[cpu_architecture()], cr_alignment);

    sprintf(init_utsname()->machine, "%s%c", list->arch_name, ENDIANNESS);
    sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS);
    elf_hwcap = list->elf_hwcap;
#ifndef CONFIG_ARM_THUMB
    elf_hwcap &= ~HWCAP_THUMB;
#endif

    cacheid_init();
    cpu_proc_init();                                   //#define cpu_proc_init()            processor._proc_init()              
}
原创粉丝点击