You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interface.h 1.2KB

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