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>
14 static __inline uint64_t
17 /* This '#if' asks the question 'Does CP15/SCC include performance counters?' */
18 #if defined(CPU_ARM1136) || defined(CPU_ARM1176) \
19 || defined(CPU_MV_PJ4B) \
20 || defined(CPU_CORTEXA) || defined(CPU_KRAIT)
25 * Read PMCCNTR. Curses! Its only 32 bits.
26 * TODO: Fix this by catching overflow with interrupt?
28 /* The ARMv6 vs ARMv7 divide is going to need a better way of
29 * distinguishing between them.
31 #if defined(CPU_ARM1136) || defined(CPU_ARM1176)
32 /* ARMv6 - Earlier model SCCs */
33 __asm __volatile("mrc p15, 0, %0, c15, c12, 1": "=r" (ccnt));
35 /* ARMv7 - Later model SCCs */
36 __asm __volatile("mrc p15, 0, %0, c9, c13, 0": "=r" (ccnt));
38 ccnt64 = (uint64_t)ccnt;
40 #else /* No performance counters, so use binuptime(9). This is slooooow */
44 return ((uint64_t)bt.sec << 56 | bt.frac >> 8);
49 #define TRAPF_USERMODE(frame) ((frame->tf_spsr & PSR_MODE) == PSR_USR32_MODE)
51 #define TRAPF_PC(tfp) ((tfp)->tf_pc)
53 #define cpu_getstack(td) ((td)->td_frame->tf_usr_sp)
54 #define cpu_setstack(td, sp) ((td)->td_frame->tf_usr_sp = (sp))
55 #define cpu_spinwait() /* nothing */
58 #define ARM_VEC_ALL 0xffffffff
60 extern vm_offset_t vector_page;
63 * Params passed into initarm. If you change the size of this you will
64 * need to update locore.S to allocate more memory on the stack before
67 struct arm_boot_params {
68 register_t abp_size; /* Size of this structure */
69 register_t abp_r0; /* r0 from the boot loader */
70 register_t abp_r1; /* r1 from the boot loader */
71 register_t abp_r2; /* r2 from the boot loader */
72 register_t abp_r3; /* r3 from the boot loader */
73 vm_offset_t abp_physaddr; /* The kernel physical address */
74 vm_offset_t abp_pagetable; /* The early page table */
77 void arm_vector_init(vm_offset_t, int);
78 void fork_trampoline(void);
79 void identify_arm_cpu(void);
80 void *initarm(struct arm_boot_params *);
84 int badaddr_read(void *, size_t, void *);
85 #endif /* !MACHINE_CPU_H */