iPXE
linux.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Piotr JaroszyƄski <p.jaroszynski@gmail.com>
3  *
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.
8  *
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.
13  *
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.
17  */
18 
19 #ifndef _IPXE_LINUX_H
20 #define _IPXE_LINUX_H
21 
22 FILE_LICENCE(GPL2_OR_LATER);
23 
24 /** @file
25  *
26  * Linux devices, drivers and device requests.
27  */
28 
29 #include <ipxe/list.h>
30 #include <ipxe/device.h>
31 #include <ipxe/settings.h>
32 
33 /**
34  * Convert a Linux error number to an iPXE status code
35  *
36  * @v errno Linux error number
37  * @ret rc iPXE status code (before negation)
38  */
39 #define ELINUX( errno ) EPLATFORM ( EINFO_EPLATFORM, errno )
40 
41 /** A linux device */
42 struct linux_device {
43  /** Generic device */
44  struct device dev;
45  /** Driver that's handling the device */
47  /** Private data used by drivers */
48  void *priv;
49 };
50 
52 
53 /** A linux driver */
54 struct linux_driver {
55  /** Name */
56  char *name;
57  /** Probe function */
59  /** Remove function */
60  void (*remove)(struct linux_device *device);
61  /** Can the driver probe any more devices? */
62  int can_probe;
63 };
64 
65 /** Linux driver table */
66 #define LINUX_DRIVERS __table(struct linux_driver, "linux_drivers")
67 
68 /** Declare a Linux driver */
69 #define __linux_driver __table_entry(LINUX_DRIVERS, 01)
70 
71 /**
72  * Set linux device driver-private data
73  *
74  * @v device Linux device
75  * @v priv Private data
76  */
77 static inline void linux_set_drvdata(struct linux_device * device, void *priv)
78 {
79  device->priv = priv;
80 }
81 
82 /**
83  * Get linux device driver-private data
84  *
85  * @v device Linux device
86  * @ret priv Private data
87  */
88 static inline void *linux_get_drvdata(struct linux_device *device)
89 {
90  return device->priv;
91 }
92 
93 /**
94  * A device request.
95  *
96  * To be created and filled by the UI code.
97  */
99  /** Driver name. Compared to the linux drivers' names */
100  char *driver;
101  /** List node */
102  struct list_head list;
103  /** List of settings */
105 };
106 
107 /** A device request setting */
109  /** Name */
110  char *name;
111  /** Value */
112  char *value;
113  /** Was the setting already applied? */
114  int applied;
115  /** List node */
116  struct list_head list;
117 };
118 
119 /**
120  * List of requested devices.
121  *
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.
124  */
125 extern struct list_head linux_device_requests;
126 
127 /**
128  * List of global settings to apply.
129  *
130  * Filled by the UI code. Linux root_driver applies these settings.
131  */
132 extern struct list_head linux_global_settings;
133 
134 /**
135  * Look for the last occurrence of a setting with the specified name
136  *
137  * @v name Name of the setting to look for
138  * @v settings List of the settings to look through
139  */
140 struct linux_setting *linux_find_setting(char *name, struct list_head *settings);
141 
142 /**
143  * Apply a list of linux settings to a settings block
144  *
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
148  */
149 extern void linux_apply_settings(struct list_head *new_settings, struct settings *settings_block);
150 
151 
152 #endif /* _IPXE_LINUX_H */
struct linux_driver * driver
Driver that's handling the device.
Definition: linux.h:46
const char * name
Definition: ath9k_hw.c:1984
struct list_head list
List node.
Definition: linux.h:116
char * name
Name.
Definition: linux.h:56
A linux device.
Definition: linux.h:42
struct linux_setting * linux_find_setting(char *name, struct list_head *settings)
Look for the last occurrence of a setting with the specified name.
A device request.
Definition: linux.h:98
int can_probe
Can the driver probe any more devices?
Definition: linux.h:62
uint16_t device
Device ID.
Definition: ena.h:24
void * priv
Private data used by drivers.
Definition: linux.h:48
A doubly-linked list entry (or list head)
Definition: list.h:18
int(* probe)(struct linux_device *device, struct linux_device_request *request)
Probe function.
Definition: linux.h:58
char * value
Value.
Definition: linux.h:112
struct device dev
Generic device.
Definition: linux.h:44
A hardware device.
Definition: device.h:73
int applied
Was the setting already applied?
Definition: linux.h:114
FILE_LICENCE(GPL2_OR_LATER)
char * name
Name.
Definition: linux.h:110
A device request setting.
Definition: linux.h:108
Linked lists.
Configuration settings.
static void linux_set_drvdata(struct linux_device *device, void *priv)
Set linux device driver-private data.
Definition: linux.h:77
A settings block.
Definition: settings.h:132
static void * linux_get_drvdata(struct linux_device *device)
Get linux device driver-private data.
Definition: linux.h:88
char * driver
Driver name.
Definition: linux.h:100
struct list_head linux_global_settings
List of global settings to apply.
struct list_head list
List node.
Definition: linux.h:102
static struct tlan_private * priv
Definition: tlan.c:224
void(* remove)(struct linux_device *device)
Remove function.
Definition: linux.h:60
u8 request[0]
List of IEs requested.
Definition: ieee80211.h:16
Device model.
void linux_apply_settings(struct list_head *new_settings, struct settings *settings_block)
Apply a list of linux settings to a settings block.
A linux driver.
Definition: linux.h:54
struct list_head linux_device_requests
List of requested devices.