]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/include/cpu.h
Merge OpenSSL 1.0.1h.
[FreeBSD/FreeBSD.git] / sys / arm / include / cpu.h
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/armreg.h>
8 #include <machine/frame.h>
9
10 void    cpu_halt(void);
11 void    swi_vm(void *);
12
13 #ifdef _KERNEL
14 static __inline uint64_t
15 get_cyclecount(void)
16 {
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)
21         uint32_t ccnt;
22         uint64_t ccnt64;
23
24         /*
25          * Read PMCCNTR. Curses! Its only 32 bits.
26          * TODO: Fix this by catching overflow with interrupt?
27          */
28         __asm __volatile("mrc p15, 0, %0, c9, c13, 0": "=r" (ccnt));
29         ccnt64 = (uint64_t)ccnt;
30         return (ccnt64);
31 #else /* No performance counters, so use binuptime(9). This is slooooow */
32         struct bintime bt;
33
34         binuptime(&bt);
35         return ((uint64_t)bt.sec << 56 | bt.frac >> 8);
36 #endif
37 }
38 #endif
39
40 #define TRAPF_USERMODE(frame)   ((frame->tf_spsr & PSR_MODE) == PSR_USR32_MODE)
41
42 #define TRAPF_PC(tfp)           ((tfp)->tf_pc)
43
44 #define cpu_getstack(td)        ((td)->td_frame->tf_usr_sp)
45 #define cpu_setstack(td, sp)    ((td)->td_frame->tf_usr_sp = (sp))
46 #define cpu_spinwait()          /* nothing */
47
48 #define ARM_NVEC                8
49 #define ARM_VEC_ALL             0xffffffff
50
51 extern vm_offset_t vector_page;
52
53 /*
54  * Params passed into initarm. If you change the size of this you will
55  * need to update locore.S to allocate more memory on the stack before
56  * it calls initarm.
57  */
58 struct arm_boot_params {
59         register_t      abp_size;       /* Size of this structure */
60         register_t      abp_r0;         /* r0 from the boot loader */
61         register_t      abp_r1;         /* r1 from the boot loader */
62         register_t      abp_r2;         /* r2 from the boot loader */
63         register_t      abp_r3;         /* r3 from the boot loader */
64         vm_offset_t     abp_physaddr;   /* The kernel physical address */
65         vm_offset_t     abp_pagetable;  /* The early page table */
66 };
67
68 void    arm_vector_init(vm_offset_t, int);
69 void    fork_trampoline(void);
70 void    identify_arm_cpu(void);
71 void    *initarm(struct arm_boot_params *);
72
73 extern char btext[];
74 extern char etext[];
75 int badaddr_read(void *, size_t, void *);
76 #endif /* !MACHINE_CPU_H */