Hi,
saw something like this missing: diff --git a/sys/arch/arm/include/sysreg.h b/sys/arch/arm/include/sysreg.h index c2aab7d6667..f41a3b362ec 100644 --- a/sys/arch/arm/include/sysreg.h +++ b/sys/arch/arm/include/sysreg.h @@ -269,4 +269,20 @@ */ #define CP15_CBAR(rr) p15, 4, rr, c15, c0, 0 /* Configuration Base Address Register */ +/* + * SysRegSTRing-Macro to be used within asm(), to allow using macros above. + * like: + * + * u_int + * cpu_mpidr(void) + * { + * u_int mpidr; + * asm volatile("mrc " SR_STR(CP15_MPIDR(%0)) "\n" : "=r"(mpidr)); + * return mpidr; + * } + * + */ +#define __SRSTR(...) #__VA_ARGS__ +#define SR_STR(x) __SRSTR(x) + #endif /* !MACHINE_SYSREG_H */ now, i'm not certainly suggesting above as is, but just to show it, and to give something to those who like bikeshedding, i don't care about the name, nor suggest it would need the comment above. another _bad_ example of what it would allow: diff --git a/sys/arch/arm/include/cpufunc.h b/sys/arch/arm/include/cpufunc.h index 65da821b49a..c3e4274ceb3 100644 --- a/sys/arch/arm/include/cpufunc.h +++ b/sys/arch/arm/include/cpufunc.h @@ -160,7 +160,22 @@ extern u_int cputype; #define cpu_id() cpufuncs.cf_id() #define cpu_cpwait() cpufuncs.cf_cpwait() -#define cpu_control(c, s) cpufuncs.cf_control(c, s) +#include <arm/sysreg.h> +/*efine cpu_control(c, s) cpufuncs.cf_control(c, s)*/ +static inline u_int +cpu_control(u_int clrb, u_int xorb) +{ + u_int ov, nv; + asm volatile( + "mrc " SR_STR(CP15_SCTLR(%0)) "\n" /* %0 = sctlr; */ + "bic %1, %0, %2\n" /* %1 = %0 & ~clrb; */ + "eor %1, %1, %3\n" /* %1 ^= xorb; */ + "teq %0, %1\n" /* if (%0 != %1) */ + "mcrne " SR_STR(CP15_SCTLR(%1)) "\n" /* sctlr = %1; */ + : "=r"(ov), "=r"(nv) : "r"(clrb), "r"(xorb) : "memory"); + return ov; +} + #define cpu_auxcontrol(c, s) cpufuncs.cf_auxcontrol(c, s) #define cpu_domains(d) cpufuncs.cf_domains(d) #define cpu_setttb(t) cpufuncs.cf_setttb(t) the above is bad, esp. in placement, because whoever goes out to rewrite cpufuncs out of armv7, or anything like that, should imo. do it into arch/armv7/ fwiw. to not carry the various licenses involved any further as remains of unnecessary abstraction. anyway, the first diff would be usable in current as is making the various CP15 uses more readable etc. when applied where possible. -Artturi