linux内核规定primary cpu的逻辑id为0,而secondary cpu可通过dts获取其硬件id。 由于启动时的运行cpu即为primary cpu,因此其硬件id可在启动流程中从mpidr寄存器中直接读出。以下为其初始化流程图: 其中smp_setup_processor_id的实现如下: void __init smp_setup_processor_id(void) { u64 mpidr = read_cpuid_mp...
smp_setup_processor_id() 函数是用来设置处理器 ID 的。在 Linux 内核中,处理器 ID 是指每个 CPU 的唯一标识符。在多核系统中,不同的 CPU 需要有不同的处理器 ID,以便内核可以区分不同的 CPU。 初始化内核调试对象 debug_objects_early_init() 函数是用于在内核初始化早期阶段初始化内核对象调试代码的。它...
1、smp_setup_processor_id(); 读取mpdir,获取当前cpu id,填写到cpu_logical_map(0),输出"Booting Linux on physical CPU 0x%lx\n" 2、boot_cpu_init():读取mpdir,填写set_cpu_online(0,true)/set_cpu_active(0, true)/set_cpu_present(0, true)/set_cpu_possible(0, true),记录cpu号到__boot_...
3void__init smp_setup_processor_id(void) 4{ 5inti; 6u32 cpu = is_smp() ? read_cpuid_mpidr() &0xff:0; //判断是否是smp系统,如果是读取当前cpuid,否则为0 7//存在多cpu,判断哪个cpu是当前cpu 8cpu_logical_map(0) = cpu; //当前cpu赋值给cpu第一个表项 ...
intcpu = smp_processor_id; irq_enter(cpu, irq); status =1;/* Force the "do bottom halves" bit */ if(!(action->flags & SA_INTERRUPT))// 如果中断处理能够在打开中断的情况下执行, 那么就打开中断 __sti; do{ status |= action->flags; ...
smp_setup_processor_id(); debug_objects_early_init(); cgroup_init_early(); local_irq_disable(); early_boot_irqs_disabled=true; /* * Interrupts are still disabled. Do necessary setups, then * enable them. */ boot_cpu_init();
asmlinkage unsigned intdo_IRQ(struct pt_regs regs){int irq=regs.orig_eax&0xff;/* 获取IRQ号 */int cpu=smp_processor_id();irq_desc_t*desc=irq_desc+irq;struct irqaction*action;unsigned int status;kstat.irqs[cpu][irq]++;spin_lock(&desc->lock);desc->handler->ack(irq);status=desc->st...
); } /* 如果外部中断控制器需要,则安装一个中断处理例程irq2到中断IRQ2上 */ if (!acpi_ioapic && !of_ioapic && nr_legacy_irqs()) setup_irq(2, &irq2); #ifdef CONFIG_X86_32 /* 在x86_32模式下,会为当前CPU分配一个中断使用的栈空间 */ irq_ctx_init(smp_processor_id()); #endif }...
int cpu = smp_processor_id(); __u32 pending; unsigned long flags; __u32 mask; if (in_interrupt()) return; local_irq_save(flags); pending = softirq_pending(cpu); if (pending) { struct softirq_action *h; mask = ~pending;
smp_init的代码在init/main.c: /* Called by boot processor to activate the rest. */staticvoid__initsmp_init(void){unsigned int cpu;/* FIXME: This should be done in userspace --RR */for_each_present_cpu(cpu){if(num_online_cpus()>=setup_max_cpus)break;if(!cpu_online(cpu))cpu_up...