|
@@ -9,9 +9,12 @@
|
9
|
9
|
|
10
|
10
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
11
|
11
|
|
|
12
|
+#include <stdint.h>
|
12
|
13
|
#include <config/fault.h>
|
13
|
14
|
|
14
|
15
|
extern int inject_fault_nonzero ( unsigned int rate );
|
|
16
|
+extern void inject_corruption_nonzero ( unsigned int rate, const void *data,
|
|
17
|
+ size_t len );
|
15
|
18
|
|
16
|
19
|
/**
|
17
|
20
|
* Inject fault with a specified probability
|
|
@@ -29,4 +32,22 @@ inject_fault ( unsigned int rate ) {
|
29
|
32
|
return inject_fault_nonzero ( rate );
|
30
|
33
|
}
|
31
|
34
|
|
|
35
|
+/**
|
|
36
|
+ * Corrupt data with a specified probability
|
|
37
|
+ *
|
|
38
|
+ * @v rate Reciprocal of fault probability (zero for no faults)
|
|
39
|
+ * @v data Data
|
|
40
|
+ * @v len Length of data
|
|
41
|
+ * @ret rc Return status code
|
|
42
|
+ */
|
|
43
|
+static inline __attribute__ (( always_inline )) void
|
|
44
|
+inject_corruption ( unsigned int rate, const void *data, size_t len ) {
|
|
45
|
+
|
|
46
|
+ /* Force dead code elimination in non-fault-injecting builds */
|
|
47
|
+ if ( rate == 0 )
|
|
48
|
+ return;
|
|
49
|
+
|
|
50
|
+ return inject_corruption_nonzero ( rate, data, len );
|
|
51
|
+}
|
|
52
|
+
|
32
|
53
|
#endif /* _IPXE_FAULT_H */
|