1 /* $NetBSD: cpu.h,v 1.2 2001/02/23 21:23:52 reinoud Exp $ */
7 #include <machine/armreg.h>
8 #include <machine/frame.h>
15 #include <machine/cpu-v6.h>
17 #include <machine/cpu-v4.h>
18 #endif /* __ARM_ARCH >= 6 */
20 static __inline uint64_t
24 #if (__ARM_ARCH > 6) && defined(DEV_PMU)
30 cpu = PCPU_GET(cpuid);
31 h = (uint64_t)atomic_load_acq_32(&ccnt_hi[cpu]);
32 l = cp15_pmccntr_get();
33 /* In case interrupts are disabled we need to check for overflow. */
34 r = cp15_pmovsr_get();
36 atomic_add_32(&ccnt_hi[cpu], 1);
37 /* Clear the event. */
38 cp15_pmovsr_set(PMU_OVSR_C);
40 /* Make sure there was no wrap-around while we read the lo half. */
41 h2 = (uint64_t)atomic_load_acq_32(&ccnt_hi[cpu]);
43 l = cp15_pmccntr_get();
44 return (h2 << 32 | l);
47 return cp15_pmccntr_get();
48 #else /* No performance counters, so use binuptime(9). This is slooooow */
52 return ((uint64_t)bt.sec << 56 | bt.frac >> 8);
57 #define TRAPF_USERMODE(frame) ((frame->tf_spsr & PSR_MODE) == PSR_USR32_MODE)
59 #define TRAPF_PC(tfp) ((tfp)->tf_pc)
61 #define cpu_getstack(td) ((td)->td_frame->tf_usr_sp)
62 #define cpu_setstack(td, sp) ((td)->td_frame->tf_usr_sp = (sp))
63 #define cpu_spinwait() /* nothing */
66 #define ARM_VEC_ALL 0xffffffff
68 extern vm_offset_t vector_page;
71 * Params passed into initarm. If you change the size of this you will
72 * need to update locore.S to allocate more memory on the stack before
75 struct arm_boot_params {
76 register_t abp_size; /* Size of this structure */
77 register_t abp_r0; /* r0 from the boot loader */
78 register_t abp_r1; /* r1 from the boot loader */
79 register_t abp_r2; /* r2 from the boot loader */
80 register_t abp_r3; /* r3 from the boot loader */
81 vm_offset_t abp_physaddr; /* The kernel physical address */
82 vm_offset_t abp_pagetable; /* The early page table */
85 void arm_vector_init(vm_offset_t, int);
86 void fork_trampoline(void);
87 void identify_arm_cpu(void);
88 void *initarm(struct arm_boot_params *);
92 int badaddr_read(void *, size_t, void *);
93 #endif /* !MACHINE_CPU_H */