2009-07-27 20:23:08 +04:00
|
|
|
/*
|
|
|
|
** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
2019-08-31 01:16:02 +03:00
|
|
|
** Distributed under the terms of the MIT License.
|
2009-07-27 20:23:08 +04:00
|
|
|
*/
|
2011-03-14 16:48:21 +03:00
|
|
|
#ifndef _KERNEL_ARCH_ARM_CPU_H
|
|
|
|
#define _KERNEL_ARCH_ARM_CPU_H
|
2009-07-27 20:23:08 +04:00
|
|
|
|
2014-01-20 00:27:09 +04:00
|
|
|
|
|
|
|
#define CPU_MAX_CACHE_LEVEL 8
|
|
|
|
#define CACHE_LINE_SIZE 64
|
|
|
|
// TODO: Could be 32-bits sometimes?
|
|
|
|
|
|
|
|
|
2019-06-20 20:04:47 +03:00
|
|
|
#if __ARM_ARCH__ <= 5
|
|
|
|
#define isb() __asm__ __volatile__("" : : : "memory")
|
|
|
|
#define dsb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__("" : : : "memory")
|
|
|
|
#elif __ARM_ARCH__ == 6
|
|
|
|
#define isb() __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dsb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 5" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#else /* ARMv7+ */
|
|
|
|
#define isb() __asm__ __volatile__("isb" : : : "memory")
|
|
|
|
#define dsb() __asm__ __volatile__("dsb" : : : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__("dmb" : : : "memory")
|
|
|
|
#endif
|
|
|
|
|
2018-01-31 21:32:46 +03:00
|
|
|
#define set_ac()
|
|
|
|
#define clear_ac()
|
|
|
|
|
|
|
|
|
2009-07-27 20:23:08 +04:00
|
|
|
#ifndef _ASSEMBLER
|
|
|
|
|
|
|
|
#include <arch/arm/arch_thread_types.h>
|
|
|
|
#include <kernel.h>
|
|
|
|
|
2014-01-20 00:27:09 +04:00
|
|
|
|
2009-07-27 20:23:08 +04:00
|
|
|
/* raw exception frames */
|
|
|
|
struct iframe {
|
2012-11-06 14:41:12 +04:00
|
|
|
uint32 spsr;
|
2009-07-27 20:23:08 +04:00
|
|
|
uint32 r0;
|
|
|
|
uint32 r1;
|
|
|
|
uint32 r2;
|
|
|
|
uint32 r3;
|
|
|
|
uint32 r4;
|
|
|
|
uint32 r5;
|
|
|
|
uint32 r6;
|
|
|
|
uint32 r7;
|
|
|
|
uint32 r8;
|
|
|
|
uint32 r9;
|
|
|
|
uint32 r10;
|
|
|
|
uint32 r11;
|
|
|
|
uint32 r12;
|
2012-11-06 14:41:12 +04:00
|
|
|
uint32 usr_sp;
|
|
|
|
uint32 usr_lr;
|
|
|
|
uint32 svc_sp;
|
|
|
|
uint32 svc_lr;
|
2009-07-27 20:23:08 +04:00
|
|
|
uint32 pc;
|
|
|
|
} _PACKED;
|
|
|
|
|
2012-11-13 15:04:35 +04:00
|
|
|
/**! Values for arch_cpu_info.arch */
|
|
|
|
enum {
|
|
|
|
ARCH_ARM_PRE_ARM7,
|
|
|
|
ARCH_ARM_v3,
|
|
|
|
ARCH_ARM_v4,
|
|
|
|
ARCH_ARM_v4T,
|
|
|
|
ARCH_ARM_v5,
|
|
|
|
ARCH_ARM_v5T,
|
|
|
|
ARCH_ARM_v5TE,
|
|
|
|
ARCH_ARM_v5TEJ,
|
2014-06-14 00:15:54 +04:00
|
|
|
ARCH_ARM_v6,
|
|
|
|
ARCH_ARM_v7
|
2012-11-13 15:04:35 +04:00
|
|
|
};
|
|
|
|
|
2009-07-27 20:23:08 +04:00
|
|
|
typedef struct arch_cpu_info {
|
2012-11-13 15:04:35 +04:00
|
|
|
/* For a detailed interpretation of these values,
|
|
|
|
see "The System Control coprocessor",
|
|
|
|
"Main ID register" in your ARM ARM */
|
|
|
|
int implementor;
|
|
|
|
int part_number;
|
|
|
|
int revision;
|
|
|
|
int variant;
|
|
|
|
int arch;
|
2009-07-27 20:23:08 +04:00
|
|
|
} arch_cpu_info;
|
|
|
|
|
2012-11-06 14:41:12 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern addr_t arm_get_far(void);
|
|
|
|
extern int32 arm_get_fsr(void);
|
2013-09-18 01:04:59 +04:00
|
|
|
extern addr_t arm_get_fp(void);
|
2012-11-06 14:41:12 +04:00
|
|
|
|
|
|
|
extern int mmu_read_c1(void);
|
|
|
|
extern int mmu_write_c1(int val);
|
|
|
|
|
2014-02-13 09:37:15 +04:00
|
|
|
|
|
|
|
static inline void
|
|
|
|
arch_cpu_pause(void)
|
|
|
|
{
|
|
|
|
// TODO: ARM Priority pause call
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
arch_cpu_idle(void)
|
|
|
|
{
|
|
|
|
uint32 Rd = 0;
|
|
|
|
asm volatile("mcr p15, 0, %[c7format], c7, c0, 4"
|
|
|
|
: : [c7format] "r" (Rd) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-06 14:41:12 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2009-07-27 20:23:08 +04:00
|
|
|
#endif // !_ASSEMBLER
|
|
|
|
|
|
|
|
#endif /* _KERNEL_ARCH_ARM_CPU_H */
|