summaryrefslogtreecommitdiffstats
path: root/src/core/dev.c
blob: 0f9936a0fdcc3989b4bf2c4b6373e0234437daef (plain) (blame)
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
#include "etherboot.h"
#include "stddef.h"
#include "dev.h"

/* Defined by linker */
extern struct boot_driver boot_drivers[];
extern struct boot_driver boot_drivers_end[];

/* Current attempted boot driver */
static struct boot_driver *boot_driver = boot_drivers;

/* Print all drivers */
void print_drivers ( void ) {
	struct boot_driver *driver;

	for ( driver = boot_drivers ; driver < boot_drivers_end ; driver++ ) {
		printf ( "%s ", driver->name );
	}
}

/* Get the next available boot device */
int probe ( struct dev *dev ) {
	
	for ( ; boot_driver < boot_drivers_end ; boot_driver++ ) {
		dev->name = "unknown";
		if ( boot_driver->probe ( dev ) )
			return 1;
	}
	
	/* No more boot devices found */
	boot_driver = boot_drivers;
	return 0;
}

/* Disable a device */
void disable ( struct dev *dev ) {
	if ( dev->dev_op ) {
		dev->dev_op->disable ( dev );
		dev->dev_op = NULL;
	}
}