Changeset b1011dae in mainline for kernel/arch/arm32/include
- Timestamp:
- 2013-01-24T21:18:18Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 077b9172
- Parents:
- 5e761f3 (diff), c124dce3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- kernel/arch/arm32/include
- Files:
-
- 3 added
- 8 edited
-
asm.h (modified) (1 diff)
-
barrier.h (modified) (2 diffs)
-
cache.h (added)
-
cp15.h (added)
-
cpu.h (modified) (2 diffs)
-
cycle.h (modified) (2 diffs)
-
mm/frame.h (modified) (1 diff)
-
mm/page.h (modified) (1 diff)
-
mm/page_fault.h (modified) (1 diff)
-
regutils.h (modified) (1 diff)
-
security_ext.h (added)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/include/asm.h
r5e761f3 rb1011dae 43 43 #include <trace.h> 44 44 45 /** No such instruction on old ARM to sleep CPU.45 /** CPU specific way to sleep cpu. 46 46 * 47 47 * ARMv7 introduced wait for event and wait for interrupt (wfe/wfi). 48 48 * ARM920T has custom coprocessor action to do the same. See ARM920T Technical 49 49 * Reference Manual ch 4.9 p. 4-23 (103 in the PDF) 50 * ARM926EJ-S uses the same coprocessor instruction as ARM920T. See ARM926EJ-S 51 * chapter 2.3.8 p.2-22 (52 in the PDF) 52 * 53 * @note Although mcr p15, 0, R0, c7, c0, 4 is defined in ARM Architecture 54 * reference manual for armv4/5 CP15 implementation is mandatory only for 55 * armv6+. 50 56 */ 51 57 NO_TRACE static inline void cpu_sleep(void) 52 58 { 53 #ifdef PROCESSOR_ armv7_a54 asm volatile ( "wfe" ::);55 #elif defined( MACHINE_gta02)56 asm volatile ( "mcr p15, 0,R0,c7,c0,4" ::);59 #ifdef PROCESSOR_ARCH_armv7_a 60 asm volatile ( "wfe" ); 61 #elif defined(PROCESSOR_ARCH_armv6) | defined(PROCESSOR_arm926ej_s) | defined(PROCESSOR_arm920t) 62 asm volatile ( "mcr p15, 0, R0, c7, c0, 4" ); 57 63 #endif 58 64 } -
kernel/arch/arm32/include/barrier.h
r5e761f3 rb1011dae 37 37 #define KERN_arm32_BARRIER_H_ 38 38 39 /* 40 * TODO: implement true ARM memory barriers for macros below. 41 */ 39 #ifdef KERNEL 40 #include <arch/cp15.h> 41 #else 42 #include <libarch/cp15.h> 43 #endif 44 42 45 #define CS_ENTER_BARRIER() asm volatile ("" ::: "memory") 43 46 #define CS_LEAVE_BARRIER() asm volatile ("" ::: "memory") 44 47 48 #if defined PROCESSOR_ARCH_armv7_a 49 /* ARMv7 uses instructions for memory barriers see ARM Architecture reference 50 * manual for details: 51 * DMB: ch. A8.8.43 page A8-376 52 * DSB: ch. A8.8.44 page A8-378 53 * See ch. A3.8.3 page A3-148 for details about memory barrier implementation 54 * and functionality on armv7 architecture. 55 */ 56 #define memory_barrier() asm volatile ("dmb" ::: "memory") 57 #define read_barrier() asm volatile ("dsb" ::: "memory") 58 #define write_barrier() asm volatile ("dsb st" ::: "memory") 59 #define inst_barrier() asm volatile ("isb" ::: "memory") 60 #elif defined PROCESSOR_ARCH_armv6 | defined KERNEL 61 /* 62 * ARMv6 introduced user access of the following commands: 63 * - Prefetch flush 64 * - Data synchronization barrier 65 * - Data memory barrier 66 * - Clean and prefetch range operations. 67 * ARM Architecture Reference Manual version I ch. B.3.2.1 p. B3-4 68 */ 69 /* ARMv6- use system control coprocessor (CP15) for memory barrier instructions. 70 * Although at least mcr p15, 0, r0, c7, c10, 4 is mentioned in earlier archs, 71 * CP15 implementation is mandatory only for armv6+. 72 */ 73 #define memory_barrier() CP15DMB_write(0) 74 #define read_barrier() CP15DSB_write(0) 75 #define write_barrier() read_barrier() 76 #define inst_barrier() CP15ISB_write(0) 77 #else 78 /* Older manuals mention syscalls as a way to implement cache coherency and 79 * barriers. See for example ARM Architecture Reference Manual Version D 80 * chapter 2.7.4 Prefetching and self-modifying code (p. A2-28) 81 */ 82 // TODO implement on per PROCESSOR basis or via syscalls 45 83 #define memory_barrier() asm volatile ("" ::: "memory") 46 84 #define read_barrier() asm volatile ("" ::: "memory") 47 85 #define write_barrier() asm volatile ("" ::: "memory") 86 #define inst_barrier() asm volatile ("" ::: "memory") 87 #endif 48 88 49 89 /* … … 62 102 */ 63 103 64 /* Available on both all supported arms, 104 #if defined PROCESSOR_ARCH_armv7_a | defined PROCESSOR_ARCH_armv6 | defined KERNEL 105 /* Available on all supported arms, 65 106 * invalidates entire ICache so the written value does not matter. */ 66 #define smc_coherence(a) asm volatile ( "mcr p15, 0, r0, c7, c5, 0") 67 #define smc_coherence_block(a, l) smc_coherence(a) 107 //TODO might be PL1 only on armv5- 108 #define smc_coherence(a) \ 109 do { \ 110 DCCMVAU_write((uint32_t)(a)); /* Flush changed memory */\ 111 write_barrier(); /* Wait for completion */\ 112 ICIALLU_write(0); /* Flush ICache */\ 113 inst_barrier(); /* Wait for Inst refetch */\ 114 } while (0) 115 /* @note: Cache type register is not available in uspace. We would need 116 * to export the cache line value, or use syscall for uspace smc_coherence */ 117 #define smc_coherence_block(a, l) \ 118 do { \ 119 for (uintptr_t addr = (uintptr_t)a; addr < (uintptr_t)a + l; addr += 4)\ 120 smc_coherence(addr); \ 121 } while (0) 122 #else 123 #define smc_coherence(a) 124 #define smc_coherence_block(a, l) 125 #endif 68 126 69 127 -
kernel/arch/arm32/include/cpu.h
r5e761f3 rb1011dae 40 40 #include <arch/asm.h> 41 41 42 enum { 43 ARM_MAX_CACHE_LEVELS = 7, 44 }; 42 45 43 46 /** Struct representing ARM CPU identification. */ … … 57 60 /** Revision number. */ 58 61 uint32_t rev_num; 62 63 struct { 64 unsigned ways; 65 unsigned sets; 66 unsigned line_size; 67 unsigned way_shift; 68 unsigned set_shift; 69 } dcache[ARM_MAX_CACHE_LEVELS]; 70 unsigned dcache_levels; 59 71 } cpu_arch_t; 60 72 -
kernel/arch/arm32/include/cycle.h
r5e761f3 rb1011dae 38 38 39 39 #include <trace.h> 40 #include <arch/cp15.h> 40 41 41 42 /** Return count of CPU cycles. … … 48 49 NO_TRACE static inline uint64_t get_cycle(void) 49 50 { 51 #ifdef PROCESSOR_ARCH_armv7_a 52 if ((ID_PFR1_read() & ID_PFR1_GEN_TIMER_EXT_MASK) == 53 ID_PFR1_GEN_TIMER_EXT) { 54 uint32_t low = 0, high = 0; 55 asm volatile( "MRRC p15, 0, %[low], %[high], c14": [low]"=r"(low), [high]"=r"(high)); 56 return ((uint64_t)high << 32) | low; 57 } else { 58 return (uint64_t)PMCCNTR_read() * 64; 59 } 60 #endif 50 61 return 0; 51 62 } -
kernel/arch/arm32/include/mm/frame.h
r5e761f3 rb1011dae 47 47 48 48 #ifdef MACHINE_gta02 49 50 #define PHYSMEM_START_ADDR 0x30008000 49 51 #define BOOT_PAGE_TABLE_ADDRESS 0x30010000 52 50 53 #elif defined MACHINE_beagleboardxm 54 55 #define PHYSMEM_START_ADDR 0x80000000 51 56 #define BOOT_PAGE_TABLE_ADDRESS 0x80008000 57 52 58 #elif defined MACHINE_beaglebone 59 60 #define PHYSMEM_START_ADDR 0x80000000 53 61 #define BOOT_PAGE_TABLE_ADDRESS 0x80008000 62 54 63 #else 64 65 #define PHYSMEM_START_ADDR 0x00000000 55 66 #define BOOT_PAGE_TABLE_ADDRESS 0x00008000 67 56 68 #endif 57 69 58 70 #define BOOT_PAGE_TABLE_START_FRAME (BOOT_PAGE_TABLE_ADDRESS >> FRAME_WIDTH) 59 71 #define BOOT_PAGE_TABLE_SIZE_IN_FRAMES (BOOT_PAGE_TABLE_SIZE >> FRAME_WIDTH) 60 61 #ifdef MACHINE_gta0262 #define PHYSMEM_START_ADDR 0x3000800063 #elif defined MACHINE_beagleboardxm64 #define PHYSMEM_START_ADDR 0x8000000065 #elif defined MACHINE_beaglebone66 #define PHYSMEM_START_ADDR 0x8000000067 #else68 #define PHYSMEM_START_ADDR 0x0000000069 #endif70 72 71 73 extern void frame_low_arch_init(void); -
kernel/arch/arm32/include/mm/page.h
r5e761f3 rb1011dae 129 129 set_pt_level1_present((pte_t *) (ptl3), (size_t) (i)) 130 130 131 #if defined(PROCESSOR_ armv6) | defined(PROCESSOR_armv7_a)131 #if defined(PROCESSOR_ARCH_armv6) | defined(PROCESSOR_ARCH_armv7_a) 132 132 #include "page_armv6.h" 133 #elif defined(PROCESSOR_ armv4) | defined(PROCESSOR_armv5)133 #elif defined(PROCESSOR_ARCH_armv4) | defined(PROCESSOR_ARCH_armv5) 134 134 #include "page_armv4.h" 135 135 #else -
kernel/arch/arm32/include/mm/page_fault.h
r5e761f3 rb1011dae 42 42 /** Decribes CP15 "fault status register" (FSR). 43 43 * 44 * See ARM Architecture Reference Manual ch. B4.9.6 (pdf p.743). 44 * "VMSAv6 added a fifth fault status bit (bit[10]) to both the IFSR and DFSR. 45 * It is IMPLEMENTATION DEFINED how this bit is encoded in earlier versions of 46 * the architecture. A write flag (bit[11] of the DFSR) has also been 47 * introduced." 48 * ARM Architecture Reference Manual version i ch. B4.6 (PDF p. 719) 49 * 50 * See ARM Architecture Reference Manual ch. B4.9.6 (pdf p.743). for FSR info 45 51 */ 46 52 typedef union { -
kernel/arch/arm32/include/regutils.h
r5e761f3 rb1011dae 41 41 #define STATUS_REG_MODE_MASK 0x1f 42 42 43 /* COntrol register bit values see ch. B4.1.130 of ARM Architecture Reference44 * Manual ARMv7-A and ARMv7-R edition, page 1687 */45 #define CP15_R1_MMU_EN (1 << 0)46 #define CP15_R1_ALIGN_CHECK_EN (1 << 1) /* Allow alignemnt check */47 #define CP15_R1_CACHE_EN (1 << 2)48 #define CP15_R1_CP15_BARRIER_EN (1 << 5)49 #define CP15_R1_B_EN (1 << 7) /* ARMv6- only big endian switch */50 #define CP15_R1_SWAP_EN (1 << 10)51 #define CP15_R1_BRANCH_PREDICT_EN (1 << 11)52 #define CP15_R1_INST_CACHE_EN (1 << 12)53 #define CP15_R1_HIGH_VECTORS_EN (1 << 13)54 #define CP15_R1_ROUND_ROBIN_EN (1 << 14)55 #define CP15_R1_HW_ACCESS_FLAG_EN (1 << 17)56 #define CP15_R1_WRITE_XN_EN (1 << 19) /* Only if virt. supported */57 #define CP15_R1_USPCE_WRITE_XN_EN (1 << 20) /* Only if virt. supported */58 #define CP15_R1_FAST_IRQ_EN (1 << 21) /* Disbale impl.specific features */59 #define CP15_R1_UNALIGNED_EN (1 << 22) /* Must be 1 on armv7 */60 #define CP15_R1_IRQ_VECTORS_EN (1 << 24)61 #define CP15_R1_BIG_ENDIAN_EXC (1 << 25)62 #define CP15_R1_NMFI_EN (1 << 27)63 #define CP15_R1_TEX_REMAP_EN (1 << 28)64 #define CP15_R1_ACCESS_FLAG_EN (1 << 29)65 #define CP15_R1_THUMB_EXC_EN (1 << 30)66 67 43 /* ARM Processor Operation Modes */ 68 #define USER_MODE 0x10 69 #define FIQ_MODE 0x11 70 #define IRQ_MODE 0x12 71 #define SUPERVISOR_MODE 0x13 72 #define ABORT_MODE 0x17 73 #define UNDEFINED_MODE 0x1b 74 #define SYSTEM_MODE 0x1f 75 44 enum { 45 USER_MODE = 0x10, 46 FIQ_MODE = 0x11, 47 IRQ_MODE = 0x12, 48 SUPERVISOR_MODE = 0x13, 49 MONITOR_MODE = 0x16, 50 ABORT_MODE = 0x17, 51 HYPERVISOR_MODE = 0x1a, 52 UNDEFINED_MODE = 0x1b, 53 SYSTEM_MODE = 0x1f, 54 MODE_MASK = 0x1f, 55 }; 76 56 /* [CS]PRS manipulation macros */ 77 57 #define GEN_STATUS_READ(nm, reg) \
Note:
See TracChangeset
for help on using the changeset viewer.
