|
@@ -0,0 +1,58 @@
|
|
1
|
+#ifndef _GPXE_HOTPLUG_H
|
|
2
|
+#define _GPXE_HOTPLUG_H
|
|
3
|
+
|
|
4
|
+/** @file
|
|
5
|
+ *
|
|
6
|
+ * Hotplug support
|
|
7
|
+ *
|
|
8
|
+ */
|
|
9
|
+
|
|
10
|
+#include <gpxe/list.h>
|
|
11
|
+
|
|
12
|
+/**
|
|
13
|
+ * A persistent reference to another data structure
|
|
14
|
+ *
|
|
15
|
+ * This data structure should be embedded within any data structure
|
|
16
|
+ * (the referrer) which holds a persistent reference to a separate,
|
|
17
|
+ * volatile data structure (the referee).
|
|
18
|
+ */
|
|
19
|
+struct reference {
|
|
20
|
+ /** List of persistent references */
|
|
21
|
+ struct list_head list;
|
|
22
|
+ /** Forget persistent reference
|
|
23
|
+ *
|
|
24
|
+ * @v ref Persistent reference
|
|
25
|
+ *
|
|
26
|
+ * This method is called immediately before the referred-to
|
|
27
|
+ * data structure is destroyed. The reference holder must
|
|
28
|
+ * forget all references to the referee before returning from
|
|
29
|
+ * this method.
|
|
30
|
+ *
|
|
31
|
+ * This method must also call ref_del() to remove the
|
|
32
|
+ * reference.
|
|
33
|
+ */
|
|
34
|
+ void ( * forget ) ( struct reference *ref );
|
|
35
|
+};
|
|
36
|
+
|
|
37
|
+/**
|
|
38
|
+ * Add persistent reference
|
|
39
|
+ *
|
|
40
|
+ * @v ref Persistent reference
|
|
41
|
+ * @v list List of persistent references
|
|
42
|
+ */
|
|
43
|
+static inline void ref_add ( struct reference *ref, struct list_head *list ) {
|
|
44
|
+ list_add ( &ref->list, list );
|
|
45
|
+}
|
|
46
|
+
|
|
47
|
+/**
|
|
48
|
+ * Remove persistent reference
|
|
49
|
+ *
|
|
50
|
+ * @v ref Persistent reference
|
|
51
|
+ */
|
|
52
|
+static inline void ref_del ( struct reference *ref ) {
|
|
53
|
+ list_del ( &ref->list );
|
|
54
|
+}
|
|
55
|
+
|
|
56
|
+extern void forget_references ( struct list_head *list );
|
|
57
|
+
|
|
58
|
+#endif /* _GPXE_HOTPLUG_H */
|