1 #ifndef _GPXE_INTERFACE_H 2 #define _GPXE_INTERFACE_H 3 4 /** @file 5 * 6 * Object communication interfaces 7 * 8 */ 9 10 FILE_LICENCE ( GPL2_OR_LATER ); 11 12 #include <gpxe/refcnt.h> 13 14 /** An object communication interface */ 15 struct interface { 16 /** Destination interface 17 * 18 * When messages are sent via this interface, they will be 19 * delivered to the destination interface. 20 * 21 * This pointer may never be NULL. When the interface is 22 * unplugged, it should point to a null interface. 23 */ 24 struct interface *dest; 25 /** Reference counter 26 * 27 * If this interface is not part of a reference-counted 28 * object, this field may be NULL. 29 */ 30 struct refcnt *refcnt; 31 }; 32 33 /** 34 * Increment reference count on an interface 35 * 36 * @v intf Interface 37 * @ret intf Interface 38 */ 39 static inline __attribute__ (( always_inline )) struct interface * intf_get(struct interface * intf)40intf_get ( struct interface *intf ) { 41 ref_get ( intf->refcnt ); 42 return intf; 43 } 44 45 /** 46 * Decrement reference count on an interface 47 * 48 * @v intf Interface 49 */ 50 static inline __attribute__ (( always_inline )) void intf_put(struct interface * intf)51intf_put ( struct interface *intf ) { 52 ref_put ( intf->refcnt ); 53 } 54 55 extern void plug ( struct interface *intf, struct interface *dest ); 56 extern void plug_plug ( struct interface *a, struct interface *b ); 57 58 #endif /* _GPXE_INTERFACE_H */ 59