diff --git a/sys/sys/ras.h b/sys/sys/ras.h index 60b3f5a4879c..838a19fd8443 100644 --- a/sys/sys/ras.h +++ b/sys/sys/ras.h @@ -1,4 +1,4 @@ -/* $NetBSD: ras.h,v 1.11 2008/04/28 20:24:11 martin Exp $ */ +/* $NetBSD: ras.h,v 1.12 2008/04/29 20:50:42 scw Exp $ */ /*- * Copyright (c) 2002, 2004, 2007 The NetBSD Foundation, Inc. @@ -32,6 +32,7 @@ #ifndef _SYS_RAS_H_ #define _SYS_RAS_H_ +#ifndef __ASSEMBLER__ #include #include @@ -44,16 +45,21 @@ struct ras { #define RAS_INSTALL 0 #define RAS_PURGE 1 #define RAS_PURGE_ALL 2 +#else +#include +#endif /* __ASSEMBLER__ */ #ifdef _KERNEL +#ifndef __ASSEMBLER__ struct proc; void *ras_lookup(struct proc *, void *); int ras_fork(struct proc *, struct proc *); int ras_purgeall(void); +#endif /* __ASSEMBLER__ */ -#else +#else /* !_KERNEL */ #ifndef RAS_DECL @@ -65,6 +71,9 @@ extern void __CONCAT(name,_ras_start(void)), __CONCAT(name,_ras_end(void)) /* * RAS_START and RAS_END contain implicit instruction reordering * barriers. See __insn_barrier() in . + * + * Note: You are strongly advised to avoid coding RASs in C. There is a + * good chance the compiler will generate code which cannot be restarted. */ #define RAS_START(name) \ __asm volatile(".globl " ___STRING(name) "_ras_start\n" \ @@ -80,10 +89,42 @@ extern void __CONCAT(name,_ras_start(void)), __CONCAT(name,_ras_end(void)) #define RAS_SIZE(name) ((size_t)((uintptr_t) __CONCAT(name,_ras_end) - \ (uintptr_t) __CONCAT(name,_ras_start))) +#ifndef __ASSEMBLER__ __BEGIN_DECLS int rasctl(void *, size_t, int); __END_DECLS +#else /* __ASSEMBLER__ */ + +/* + * RAS_START_ASM and RAS_END_ASM are for use within assembly code. + * This is the prefered method of coding a RAS. + */ +#define RAS_START_ASM(name) \ + .globl _C_LABEL(__CONCAT(name,_ras_start)); \ + _C_LABEL(__CONCAT(name,_ras_start)): + +#define RAS_END_ASM(name) \ + .globl _C_LABEL(__CONCAT(name,_ras_end)); \ + _C_LABEL(__CONCAT(name,_ras_end)): + +/* + * RAS_START_ASM_HIDDEN and RAS_END_ASM_HIDDEN are similar to the above, + * except that they limit the scope of the symbol such that it will not + * be placed into the dynamic symbol table. Thus no other module (executable + * or shared library) can reference it directly. + */ +#define RAS_START_ASM_HIDDEN(name) \ + .globl _C_LABEL(__CONCAT(name,_ras_start)); \ + .hidden _C_LABEL(__CONCAT(name,_ras_start)); \ + _C_LABEL(__CONCAT(name,_ras_start)): + +#define RAS_END_ASM_HIDDEN(name) \ + .globl _C_LABEL(__CONCAT(name,_ras_end)); \ + .hidden _C_LABEL(__CONCAT(name,_ras_start)); \ + _C_LABEL(__CONCAT(name,_ras_end)): +#endif /* __ASSEMBLER__ */ + #endif /* _KERNEL */ #endif /* !_SYS_RAS_H_ */