2 * Copyright (C) 2006 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/list.h>
21 #include <gpxe/tables.h>
22 #include <gpxe/device.h>
31 static struct root_device root_devices
[0]
32 __table_start ( struct root_device
, root_devices
);
33 static struct root_device root_devices_end
[0]
34 __table_end ( struct root_device
, root_devices
);
36 /** Registered root devices */
37 static LIST_HEAD ( devices
);
42 * @v rootdev Root device
43 * @ret rc Return status code
45 static int rootdev_probe ( struct root_device
*rootdev
) {
48 DBG ( "Adding %s root bus\n", rootdev
->dev
.name
);
49 if ( ( rc
= rootdev
->driver
->probe ( rootdev
) ) != 0 ) {
50 DBG ( "Failed to add %s root bus: %s\n",
51 rootdev
->dev
.name
, strerror ( rc
) );
59 * Remove a root device
61 * @v rootdev Root device
63 static void rootdev_remove ( struct root_device
*rootdev
) {
64 rootdev
->driver
->remove ( rootdev
);
65 DBG ( "Removed %s root bus\n", rootdev
->dev
.name
);
71 * @ret rc Return status code
73 * This initiates probing for all devices in the system. After this
74 * call, the device hierarchy will be populated, and all hardware
75 * should be ready to use.
77 int probe_devices ( void ) {
78 struct root_device
*rootdev
;
81 for ( rootdev
= root_devices
; rootdev
< root_devices_end
; rootdev
++ ) {
82 list_add ( &rootdev
->dev
.siblings
, &devices
);
83 INIT_LIST_HEAD ( &rootdev
->dev
.children
);
84 if ( ( rc
= rootdev_probe ( rootdev
) ) != 0 )
85 list_del ( &rootdev
->dev
.siblings
);
94 void remove_devices ( void ) {
95 struct root_device
*rootdev
;
96 struct root_device
*tmp
;
98 list_for_each_entry_safe ( rootdev
, tmp
, &devices
, dev
.siblings
) {
99 rootdev_remove ( rootdev
);
100 list_del ( &rootdev
->dev
.siblings
);