endif
CPPFLAGS += $(INITRD_FLAGS)
+CFLAGS += -Iinclude/ -I$(ARCH_SRC)/include/
OFILES += $(addprefix $(ARCH_SRC),boot.o stack.o cache.o $(GIC) mmu.o ns.o $(BOOTMETHOD) utils.o)
$(LD) $(OFILES) -o $@ --script=model.lds
%.o: %.S Makefile
- $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
+ $(CC) $(CPPFLAGS) -D__ASSEMBLY__ $(CFLAGS) $(DEFINES) -c -o $@ $<
model.lds: $(LD_SCRIPT) Makefile
$(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -P -C -o $@ $<
.globl _start
_start:
- mrs x0, mpidr_el1
- ldr x1, =MPIDR_ID_BITS
- and x0, x0, x1
+ cpuid x0, x1
bl find_logical_id
cmp x0, #MPIDR_INVALID
beq err_invalid_id
* found in the LICENSE.txt file.
*/
-#define MPIDR_ID_BITS (0xff00ffffff)
-#define MPIDR_INVALID (-1)
+#include <cpu.h>
#define CURRENTEL_EL3 (3 << 2)
msr spsr_el3, \mode
eret
.endm
+
+ /* Put MPIDR into \dest, clobber \tmp and flags */
+ .macro cpuid dest, tmp
+ mrs \dest, mpidr_el1
+ ldr \tmp, =MPIDR_ID_BITS
+ ands \dest, \dest, \tmp
+ .endm
/*
* Only the primary CPU setups the (re)distributors.
*/
- mrs x0, mpidr_el1
- ldr x1, =MPIDR_ID_BITS
- tst x0, x1
+ cpuid x0, x1
b.ne setup_cpu_if // secondary CPU
ldr x1, =GIC_DIST_BASE // GICD_CTLR
* Check for the primary CPU to avoid a race on the distributor
* registers.
*/
- mrs x0, mpidr_el1
- ldr x1, =MPIDR_ID_BITS
- tst x0, x1
+ cpuid x0, x1
b.ne 1f // secondary CPU
ldr x1, =GIC_DIST_BASE // GICD_CTLR
--- /dev/null
+/*
+ * arch/aarch64/include/asm/cpu.h
+ *
+ * Copyright (C) 2015 ARM Limited. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE.txt file.
+ */
+#ifndef __ASM_AARCH64_CPU_H
+#define __ASM_AARCH64_CPU_H
+
+#define MPIDR_ID_BITS 0xff00ffffff
+
+#ifndef __ASSEMBLY__
+
+static inline unsigned long read_mpidr(void)
+{
+ unsigned long mpidr;
+
+ asm volatile ("mrs %0, mpidr_el1\n" : "=r" (mpidr));
+ return mpidr & MPIDR_ID_BITS;
+}
+
+
+#endif /* !__ASSEMBLY__ */
+
+#endif
* x1 - optional power state parameter, ignored here
*/
psci_cpu_off:
- mrs x0, mpidr_el1
- ldr x1, =MPIDR_ID_BITS
- and x0, x0, x1
+ cpuid x0, x1
bl find_logical_id
adr x1, branch_table
mov x2, #ADDR_INVALID
bl switch_to_idmap
/* only boot the primary cpu (entry 0 in the table) */
- mrs x0, mpidr_el1
- ldr x1, =MPIDR_ID_BITS
- and x0, x0, x1
+ cpuid x0, x1
bl find_logical_id
cbnz x0, spin
* When a valid address appears, branch to it.
*/
spin:
- mrs x0, mpidr_el1
- ldr x1, =MPIDR_ID_BITS
- and x0, x0, x1
+ cpuid x0, x1
bl find_logical_id
cmp x0, #-1
b.eq spin_dead
* primary cpu, all others will be trapped in an infinite loop.
*/
start_no_el3:
- mrs x0, mpidr_el1
- ldr x1, =MPIDR_ID_BITS
- and x0, x0, x1
+ cpuid x0, x1
bl find_logical_id
cbz x0, start_cpu0
spin_dead:
mov x2, xzr
mov x3, xzr
- mrs x4, mpidr_el1
- ldr x5, =MPIDR_ID_BITS
- tst x4, x5
+ cpuid x4, x5
b.eq 2f
/*
--- /dev/null
+/*
+ * include/cpu.h - Generic CPU features
+ *
+ * Copyright (C) 2015 ARM Limited. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE.txt file.
+ */
+#ifndef __CPU_H
+#define __CPU_H
+
+#include <asm/cpu.h>
+
+#define MPIDR_INVALID (-1)
+
+#endif