2 * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gpxe/interface.h>
24 * Object communication interfaces
29 * Obtain reference to interface
34 * Increases the reference count on the interface.
36 static struct interface * intf_get ( struct interface *intf ) {
37 intf->refcnt ( intf, +1 );
42 * Drop reference to interface
46 * Decreases the reference count on the interface.
48 static void intf_put ( struct interface *intf ) {
49 intf->refcnt ( intf, -1 );
53 * Plug an interface into a new destination interface
56 * @v dest New destination interface
58 * The reference to the existing destination interface is dropped, a
59 * reference to the new destination interface is obtained, and the
60 * interface is updated to point to the new destination interface.
62 * Note that there is no "unplug" call; instead you must plug the
63 * interface into a null interface.
65 void plug ( struct interface *intf, struct interface *dest ) {
66 intf_put ( intf->dest );
67 intf->dest = intf_get ( dest );
71 * Null update reference count
74 * @v delta Change to apply to reference count
76 * Use this as the refcnt() method for an interface that does not need
77 * to support reference counting.
79 void null_refcnt ( struct interface *intf __unused, int delta __unused ) {