Thu Feb 20 17:27:46 2014 UTC ()
Refactor and cleanup a bit.  Prepare for ASIDs.


(matt)
diff -r1.10 -r1.11 src/sys/arch/arm/arm/cpufunc_asm_arm11.S

cvs diff -r1.10 -r1.11 src/sys/arch/arm/arm/cpufunc_asm_arm11.S (expand / switch to unified diff)

--- src/sys/arch/arm/arm/cpufunc_asm_arm11.S 2013/08/18 06:28:18 1.10
+++ src/sys/arch/arm/arm/cpufunc_asm_arm11.S 2014/02/20 17:27:46 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpufunc_asm_arm11.S,v 1.10 2013/08/18 06:28:18 matt Exp $ */ 1/* $NetBSD: cpufunc_asm_arm11.S,v 1.11 2014/02/20 17:27:46 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2002, 2005 ARM Limited 4 * Copyright (c) 2002, 2005 ARM Limited
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -47,92 +47,113 @@ @@ -47,92 +47,113 @@
47ENTRY(arm11_setttb) 47ENTRY(arm11_setttb)
48#ifdef PMAP_CACHE_VIVT 48#ifdef PMAP_CACHE_VIVT
49#error arm11 does not have a VIVT cache. 49#error arm11 does not have a VIVT cache.
50#endif 50#endif
51 51
52 mcr p15, 0, r0, c2, c0, 0 /* load new TTB */ 52 mcr p15, 0, r0, c2, c0, 0 /* load new TTB */
53 53
54 cmp r1, #0 54 cmp r1, #0
55 mcrne p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */ 55 mcrne p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
56 mcrne p15, 0, r0, c7, c10, 4 /* drain write buffer */ 56 mcrne p15, 0, r0, c7, c10, 4 /* drain write buffer */
57 RET 57 RET
58END(arm11_setttb) 58END(arm11_setttb)
59 59
60/* 
61 * TLB functions 
62 */ 
63ENTRY(arm11_tlb_flushID_SE) 
64 mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */ 
65 mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */ 
66 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ 
67 RET 
68END(arm11_tlb_flushID_SE) 
69 
70ENTRY(arm11_tlb_flushI_SE) 
71 mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */ 
72 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ 
73 RET 
74END(arm11_tlb_flushI_SE) 
75 
76 60
77/* 61/*
78 * Context switch. 62 * Context switch.
79 * 63 *
80 * These are the CPU-specific parts of the context switcher cpu_switchto() 64 * These are the CPU-specific parts of the context switcher cpu_switchto()
81 * These functions actually perform the TTB reload. 65 * These functions actually perform the TTB reload.
82 */ 66 */
83ENTRY(arm11_context_switch) 67ENTRY(arm11_context_switch)
84 /* 68 /*
85 * We can assume that the caches will only contain kernel addresses 69 * We can assume that the caches will only contain kernel addresses
86 * at this point. So no need to flush them again. 70 * at this point. So no need to flush them again.
87 */ 71 */
88 mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ 72 mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
89 mcr p15, 0, r0, c2, c0, 0 /* set the new TTB */ 73 mcr p15, 0, r0, c2, c0, 0 /* set the new TTB */
90 mcr p15, 0, r0, c8, c7, 0 /* and flush the I+D tlbs */ 74 mcr p15, 0, r0, c8, c7, 0 /* and flush the I+D tlbs */
91 75
92 /* Paranoia -- make sure the pipeline is empty. */ 76 /* Paranoia -- make sure the pipeline is empty. */
93 nop 77 nop
94 nop 78 nop
95 nop 79 nop
96 RET 80 RET
97END(arm11_context_switch) 81END(arm11_context_switch)
98 82
99/* 83/*
100 * TLB functions 84 * TLB functions
101 */ 85 */
102ENTRY(arm11_tlb_flushID) 
103 mcr p15, 0, r0, c8, c7, 0 /* flush I+D tlb */ 
104 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ 
105 RET 
106END(arm11_tlb_flushID) 
107 86
108ENTRY(arm11_tlb_flushI) 87ENTRY(arm11_tlb_flushI)
 88 mov r0, #0
109 mcr p15, 0, r0, c8, c5, 0 /* flush I tlb */ 89 mcr p15, 0, r0, c8, c5, 0 /* flush I tlb */
110 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ 90 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
111 RET 91 RET
112END(arm11_tlb_flushI) 92END(arm11_tlb_flushI)
113 93
 94ENTRY(arm11_tlb_flushI_SE)
 95#ifdef ARM_MMU_EXTENDED
 96 orr r0, r0, r1 /* insert ASID into MVA */
 97#endif
 98 mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */
 99 mov r0, #0
 100 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
 101 RET
 102END(arm11_tlb_flushI_SE)
 103
114ENTRY(arm11_tlb_flushD) 104ENTRY(arm11_tlb_flushD)
 105 mov r0, #0
115 mcr p15, 0, r0, c8, c6, 0 /* flush D tlb */ 106 mcr p15, 0, r0, c8, c6, 0 /* flush D tlb */
116 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ 107 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
117 RET 108 RET
118END(arm11_tlb_flushD) 109END(arm11_tlb_flushD)
119 110
120ENTRY(arm11_tlb_flushD_SE) 111ENTRY(arm11_tlb_flushD_SE)
 112#ifdef ARM_MMU_EXTENDED
 113 orr r0, r0, r1 /* insert ASID into MVA */
 114#endif
121 mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */ 115 mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */
 116 mov r0, #0
122 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ 117 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
123 RET 118 RET
124END(arm11_tlb_flushD_SE) 119END(arm11_tlb_flushD_SE)
125 120
 121ENTRY(arm11_tlb_flushID)
 122 mov r0, #0
 123 mcr p15, 0, r0, c8, c7, 0 /* flush I+D tlb */
 124 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
 125 RET
 126END(arm11_tlb_flushID)
 127
 128ENTRY(arm11_tlb_flushID_SE)
 129#ifdef ARM_MMU_EXTENDED
 130 orr r0, r0, r1 /* insert ASID into MVA */
 131#endif
 132 mcr p15, 0, r0, c8, c7, 1 /* flush I+D tlb single entry */
 133 mov r0, #0
 134 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
 135 RET
 136END(arm11_tlb_flushID_SE)
 137
 138#ifdef ARM_MMU_EXTENDED
 139ENTRY(arm11_tlb_flushID_ASID)
 140 mcr p15, 0, r0, c8, c7, 2 /* flush I+D tlb */
 141 mov r0, #0
 142 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
 143 RET
 144END(arm11_tlb_flushID_ASID)
 145#endif
 146
126/* 147/*
127 * Other functions 148 * Other functions
128 */ 149 */
129ENTRY(arm11_drain_writebuf) 150ENTRY(arm11_drain_writebuf)
130 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ 151 mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
131 RET 152 RET
132END(arm11_drain_writebuf) 153END(arm11_drain_writebuf)
133 154
134ENTRY_NP(arm11_sleep) 155ENTRY_NP(arm11_sleep)
135 mov r0, #0 156 mov r0, #0
136 mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */ 157 mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */
137 RET 158 RET
138END(arm11_sleep) 159END(arm11_sleep)