summaryrefslogtreecommitdiffstats
path: root/debian/grub-extras/disabled/gpxe/src/include/gpxe/interface.h
blob: 114ebf32d16fdbf3d0d63bf82868d2e2cd044b22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef _GPXE_INTERFACE_H
#define _GPXE_INTERFACE_H

/** @file
 *
 * Object communication interfaces
 *
 */

FILE_LICENCE ( GPL2_OR_LATER );

#include <gpxe/refcnt.h>

/** An object communication interface */
struct interface {
	/** Destination interface
	 *
	 * When messages are sent via this interface, they will be
	 * delivered to the destination interface.
	 *
	 * This pointer may never be NULL.  When the interface is
	 * unplugged, it should point to a null interface.
	 */
	struct interface *dest;
	/** Reference counter
	 *
	 * If this interface is not part of a reference-counted
	 * object, this field may be NULL.
	 */
	struct refcnt *refcnt;
};

/**
 * Increment reference count on an interface
 *
 * @v intf		Interface
 * @ret intf		Interface
 */
static inline __attribute__ (( always_inline )) struct interface *
intf_get ( struct interface *intf ) {
	ref_get ( intf->refcnt );
	return intf;
}

/**
 * Decrement reference count on an interface
 *
 * @v intf		Interface
 */
static inline __attribute__ (( always_inline )) void
intf_put ( struct interface *intf ) {
	ref_put ( intf->refcnt );
}

extern void plug ( struct interface *intf, struct interface *dest );
extern void plug_plug ( struct interface *a, struct interface *b );

#endif /* _GPXE_INTERFACE_H */