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
22FILE_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 */
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 */
55 /** Name */
56 char *name;
57 /** Probe function */
59 /** Remove function */
60 void (*remove)(struct linux_device *device);
61};
62
63/** Linux driver table */
64#define LINUX_DRIVERS __table(struct linux_driver, "linux_drivers")
65
66/** Declare a Linux driver */
67#define __linux_driver __table_entry(LINUX_DRIVERS, 01)
68
69/** Define build rules for a Linux driver */
70#define LINUX_ROM( _name, _desc )
71
72/**
73 * Set linux device driver-private data
74 *
75 * @v device Linux device
76 * @v priv Private data
77 */
78static inline void linux_set_drvdata(struct linux_device * device, void *priv)
79{
80 device->priv = priv;
81}
82
83/**
84 * Get linux device driver-private data
85 *
86 * @v device Linux device
87 * @ret priv Private data
88 */
89static inline void *linux_get_drvdata(struct linux_device *device)
90{
91 return device->priv;
92}
93
94/**
95 * A device request.
96 *
97 * To be created and filled by the UI code.
98 */
100 /** Driver name. Compared to the linux drivers' names */
101 char *driver;
102 /** List node */
104 /** List of settings */
106};
107
108/** A device request setting */
110 /** Name */
111 char *name;
112 /** Value */
113 char *value;
114 /** Was the setting already applied? */
116 /** List node */
118};
119
120/**
121 * List of requested devices.
122 *
123 * Filled by the UI code. Linux root_driver walks over this list looking for an
124 * appropriate driver to handle each request by matching the driver's name.
125 */
126extern struct list_head linux_device_requests;
127
128/**
129 * List of global settings to apply.
130 *
131 * Filled by the UI code. Linux root_driver applies these settings.
132 */
133extern struct list_head linux_global_settings;
134
135/**
136 * Look for the last occurrence of a setting with the specified name
137 *
138 * @v name Name of the setting to look for
139 * @v settings List of the settings to look through
140 */
142
143/**
144 * Apply a list of linux settings to a settings block
145 *
146 * @v new_settings List of linux_setting's to apply
147 * @v settings_block Settings block to apply the settings to
148 * @ret rc 0 on success
149 */
150extern void linux_apply_settings(struct list_head *new_settings, struct settings *settings_block);
151
152
153#endif /* _IPXE_LINUX_H */
const char * name
Definition ath9k_hw.c:1986
Device model.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
u8 request[0]
List of IEs requested.
Definition ieee80211.h:2
static void linux_set_drvdata(struct linux_device *device, void *priv)
Set linux device driver-private data.
Definition linux.h:78
struct list_head linux_global_settings
List of global settings to apply.
void linux_apply_settings(struct list_head *new_settings, struct settings *settings_block)
Apply a list of linux settings to a settings block.
static void * linux_get_drvdata(struct linux_device *device)
Get linux device driver-private data.
Definition linux.h:89
struct list_head linux_device_requests
List of requested devices.
struct linux_setting * linux_find_setting(char *name, struct list_head *settings)
Look for the last occurrence of a setting with the specified name.
Configuration settings.
Linked lists.
A hardware device.
Definition device.h:77
A device request.
Definition linux.h:99
struct list_head settings
List of settings.
Definition linux.h:105
struct list_head list
List node.
Definition linux.h:103
char * driver
Driver name.
Definition linux.h:101
A linux device.
Definition linux.h:42
void * priv
Private data used by drivers.
Definition linux.h:48
struct device dev
Generic device.
Definition linux.h:44
struct linux_driver * driver
Driver that's handling the device.
Definition linux.h:46
A linux driver.
Definition linux.h:54
int(* probe)(struct linux_device *device, struct linux_device_request *request)
Probe function.
Definition linux.h:58
void(* remove)(struct linux_device *device)
Remove function.
Definition linux.h:60
char * name
Name.
Definition linux.h:56
A device request setting.
Definition linux.h:109
struct list_head list
List node.
Definition linux.h:117
int applied
Was the setting already applied?
Definition linux.h:115
char * value
Value.
Definition linux.h:113
char * name
Name.
Definition linux.h:111
A doubly-linked list entry (or list head)
Definition list.h:19
A settings block.
Definition settings.h:133
static struct tlan_private * priv
Definition tlan.c:225