xref: /freebsd/sys/arm/include/cpu.h (revision 8a474d01)
1 /* $NetBSD: cpu.h,v 1.2 2001/02/23 21:23:52 reinoud Exp $ */
2 /* $FreeBSD$ */
3 
4 #ifndef MACHINE_CPU_H
5 #define MACHINE_CPU_H
6 
7 #include <machine/acle-compat.h>
8 #include <machine/armreg.h>
9 #include <machine/frame.h>
10 
11 #if __ARM_ARCH >= 6
12 #include <machine/cpu-v6.h>
13 #endif
14 
15 void	cpu_halt(void);
16 void	swi_vm(void *);
17 
18 #ifdef _KERNEL
19 static __inline uint64_t
20 get_cyclecount(void)
21 {
22 #if __ARM_ARCH >= 6
23 	return cp15_pmccntr_get();
24 #else /* No performance counters, so use binuptime(9). This is slooooow */
25 	struct bintime bt;
26 
27 	binuptime(&bt);
28 	return ((uint64_t)bt.sec << 56 | bt.frac >> 8);
29 #endif
30 }
31 #endif
32 
33 #define TRAPF_USERMODE(frame)	((frame->tf_spsr & PSR_MODE) == PSR_USR32_MODE)
34 
35 #define TRAPF_PC(tfp)		((tfp)->tf_pc)
36 
37 #define cpu_getstack(td)	((td)->td_frame->tf_usr_sp)
38 #define cpu_setstack(td, sp)	((td)->td_frame->tf_usr_sp = (sp))
39 #define cpu_spinwait()		/* nothing */
40 
41 #define ARM_NVEC		8
42 #define ARM_VEC_ALL		0xffffffff
43 
44 extern vm_offset_t vector_page;
45 
46 /*
47  * Params passed into initarm. If you change the size of this you will
48  * need to update locore.S to allocate more memory on the stack before
49  * it calls initarm.
50  */
51 struct arm_boot_params {
52 	register_t	abp_size;	/* Size of this structure */
53 	register_t	abp_r0;		/* r0 from the boot loader */
54 	register_t	abp_r1;		/* r1 from the boot loader */
55 	register_t	abp_r2;		/* r2 from the boot loader */
56 	register_t	abp_r3;		/* r3 from the boot loader */
57 	vm_offset_t	abp_physaddr;	/* The kernel physical address */
58 	vm_offset_t	abp_pagetable;	/* The early page table */
59 };
60 
61 void	arm_vector_init(vm_offset_t, int);
62 void	fork_trampoline(void);
63 void	identify_arm_cpu(void);
64 void	*initarm(struct arm_boot_params *);
65 
66 extern char btext[];
67 extern char etext[];
68 int badaddr_read(void *, size_t, void *);
69 #endif /* !MACHINE_CPU_H */
70