2 * Copyright (C) 2010 Piotr JaroszyĆski <p.jaroszynski@gmail.com>
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 FILE_LICENCE(GPL2_OR_LATER);
26 * Linux devices, drivers and device requests.
29 #include <ipxe/list.h>
30 #include <ipxe/device.h>
31 #include <ipxe/settings.h>
34 * Convert a Linux error number to an iPXE status code
36 * @v errno Linux error number
37 * @ret rc iPXE status code (before negation)
39 #define ELINUX( errno ) EPLATFORM ( EINFO_EPLATFORM, errno )
45 /** Driver that's handling the device */
46 struct linux_driver *driver;
47 /** Private data used by drivers */
51 struct linux_device_request;
58 int (*probe)(struct linux_device *device, struct linux_device_request *request);
59 /** Remove function */
60 void (*remove)(struct linux_device *device);
61 /** Can the driver probe any more devices? */
65 /** Linux driver table */
66 #define LINUX_DRIVERS __table(struct linux_driver, "linux_drivers")
68 /** Declare a Linux driver */
69 #define __linux_driver __table_entry(LINUX_DRIVERS, 01)
72 * Set linux device driver-private data
74 * @v device Linux device
75 * @v priv Private data
77 static inline void linux_set_drvdata(struct linux_device * device, void *priv)
83 * Get linux device driver-private data
85 * @v device Linux device
86 * @ret priv Private data
88 static inline void *linux_get_drvdata(struct linux_device *device)
96 * To be created and filled by the UI code.
98 struct linux_device_request {
99 /** Driver name. Compared to the linux drivers' names */
102 struct list_head list;
103 /** List of settings */
104 struct list_head settings;
107 /** A device request setting */
108 struct linux_setting {
113 /** Was the setting already applied? */
116 struct list_head list;
120 * List of requested devices.
122 * Filled by the UI code. Linux root_driver walks over this list looking for an
123 * appropriate driver to handle each request by matching the driver's name.
125 extern struct list_head linux_device_requests;
128 * List of global settings to apply.
130 * Filled by the UI code. Linux root_driver applies these settings.
132 extern struct list_head linux_global_settings;
135 * Look for the last occurrence of a setting with the specified name
137 * @v name Name of the setting to look for
138 * @v settings List of the settings to look through
140 struct linux_setting *linux_find_setting(char *name, struct list_head *settings);
143 * Apply a list of linux settings to a settings block
145 * @v new_settings List of linux_setting's to apply
146 * @v settings_block Settings block to apply the settings to
147 * @ret rc 0 on success
149 extern void linux_apply_settings(struct list_head *new_settings, struct settings *settings_block);
152 #endif /* _IPXE_LINUX_H */