summaryrefslogtreecommitdiff
path: root/lib/vbexport/boot_device.h
blob: 1a0a69480a17db935a7f9a82bf1d686910875ba1 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 */

/*
 * This is an interface that we can boot from. It provides a function to start
 * up the peripheral and also one to scan for available devices attached to
 * this peripheral.
 */
struct boot_interface {
	const char *name;
	int type;		/* IF_TYPE... from part.h */

	/**
	 * Start the peripheral interface, so we are ready to scan for
	 * devices. This function can return 0 if it knows that there is
	 * no need to scan. If it returns 1 or more, then a scan will
	 * started.
	 *
	 * @param flags		Flags for this disk: VB_DISK_FLAG_...
	 * @return 0 if no devices, >=1 if we have devices, -1 on error
	 */
	int (*start)(uint32_t flags);

	/**
	 * Scan this peripheral for available devices
	 *
	 * @param desc		Array to put available devices into
	 * @param max_devs	Maximum number of devices to return
	 * @param flags		Flags for this disk: VB_DISK_FLAG_...
	 * @return number of devices found, or -1 on error
	 */
	int (*scan)(block_dev_desc_t **desc, int max_devs, uint32_t flags);
};

/**
 * Register a new boot interface.
 *
 * @param iface		The interface to register
 * @return 0 if ok, -1 on error
 */
int boot_device_register_interface(struct boot_interface *iface);

/**
 * Checks if a given device matches the provided disk_flags.
 *
 * @param dev		Device to check
 * @param disk_flags	Disk flags which must be present for this device
 * @param flags		Returns calculated flags for this device
 * @return 1 if the device matches, 0 if not
 */
int boot_device_matches(const block_dev_desc_t *dev, uint32_t disk_flags,
			uint32_t *flags);

/**
 * Probe functions for available interfaces
 *
 * @return 0 if ok, -1 on error
 */
int boot_device_usb_probe(void);
int boot_device_mmc_probe(void);
int boot_device_ide_probe(void);
int boot_device_scsi_probe(void);

/**
 * Register all the available boot devices.
 *
 * @return 0 if ok, -1 on error
 */
int boot_device_init(void);