]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/include/cpu.h
ident(1): Normalizing date format
[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 #include <machine/cpu-v6.h>
15
16 static __inline uint64_t
17 get_cyclecount(void)
18 {
19 #if __ARM_ARCH > 6 || (__ARM_ARCH == 6 && defined(CPU_ARM1176))
20 #if (__ARM_ARCH > 6) && defined(DEV_PMU)
21         if (pmu_attched) {
22                 u_int cpu;
23                 uint64_t h, h2;
24                 uint32_t l, r;
25
26                 cpu = PCPU_GET(cpuid);
27                 h = (uint64_t)atomic_load_acq_32(&ccnt_hi[cpu]);
28                 l = cp15_pmccntr_get();
29                 /* In case interrupts are disabled we need to check for overflow. */
30                 r = cp15_pmovsr_get();
31                 if (r & PMU_OVSR_C) {
32                         atomic_add_32(&ccnt_hi[cpu], 1);
33                         /* Clear the event. */
34                         cp15_pmovsr_set(PMU_OVSR_C);
35                 }
36                 /* Make sure there was no wrap-around while we read the lo half. */
37                 h2 = (uint64_t)atomic_load_acq_32(&ccnt_hi[cpu]);
38                 if (h != h2)
39                         l = cp15_pmccntr_get();
40                 return (h2 << 32 | l);
41         } else
42 #endif
43                 return cp15_pmccntr_get();
44 #else /* No performance counters, so use binuptime(9). This is slooooow */
45         struct bintime bt;
46
47         binuptime(&bt);
48         return ((uint64_t)bt.sec << 56 | bt.frac >> 8);
49 #endif
50 }
51 #endif
52
53 #define TRAPF_USERMODE(frame)   ((frame->tf_spsr & PSR_MODE) == PSR_USR32_MODE)
54
55 #define TRAPF_PC(tfp)           ((tfp)->tf_pc)
56
57 #define cpu_getstack(td)        ((td)->td_frame->tf_usr_sp)
58 #define cpu_setstack(td, sp)    ((td)->td_frame->tf_usr_sp = (sp))
59 #define cpu_spinwait()          /* nothing */
60 #define cpu_lock_delay()        DELAY(1)
61
62 #define ARM_NVEC                8
63 #define ARM_VEC_ALL             0xffffffff
64
65 extern vm_offset_t vector_page;
66
67 /*
68  * Params passed into initarm. If you change the size of this you will
69  * need to update locore.S to allocate more memory on the stack before
70  * it calls initarm.
71  */
72 struct arm_boot_params {
73         register_t      abp_size;       /* Size of this structure */
74         register_t      abp_r0;         /* r0 from the boot loader */
75         register_t      abp_r1;         /* r1 from the boot loader */
76         register_t      abp_r2;         /* r2 from the boot loader */
77         register_t      abp_r3;         /* r3 from the boot loader */
78         vm_offset_t     abp_physaddr;   /* The kernel physical address */
79         vm_offset_t     abp_pagetable;  /* The early page table */
80 };
81
82 void    arm_vector_init(vm_offset_t, int);
83 void    fork_trampoline(void);
84 void    identify_arm_cpu(void);
85 void    *initarm(struct arm_boot_params *);
86
87 extern char btext[];
88 extern char etext[];
89 int badaddr_read(void *, size_t, void *);
90 #endif /* !MACHINE_CPU_H */