blob: 7428f62db4d28d1ac74a58f4297598cc4b5df904 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * rsparser.c - parses and encodes pnpbios resource data streams
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 */
4
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/ctype.h>
6#include <linux/pnp.h>
7#include <linux/pnpbios.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -08008#include <linux/string.h>
9#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11#ifdef CONFIG_PCI
12#include <linux/pci.h>
13#else
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070014inline void pcibios_penalize_isa_irq(int irq, int active)
15{
16}
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -070017#endif /* CONFIG_PCI */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Bjorn Helgaas772defc2008-04-28 16:33:52 -060019#include "../base.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include "pnpbios.h"
21
22/* standard resource tags */
23#define SMALL_TAG_PNPVERNO 0x01
24#define SMALL_TAG_LOGDEVID 0x02
25#define SMALL_TAG_COMPATDEVID 0x03
26#define SMALL_TAG_IRQ 0x04
27#define SMALL_TAG_DMA 0x05
28#define SMALL_TAG_STARTDEP 0x06
29#define SMALL_TAG_ENDDEP 0x07
30#define SMALL_TAG_PORT 0x08
31#define SMALL_TAG_FIXEDPORT 0x09
32#define SMALL_TAG_VENDOR 0x0e
33#define SMALL_TAG_END 0x0f
34#define LARGE_TAG 0x80
35#define LARGE_TAG_MEM 0x81
36#define LARGE_TAG_ANSISTR 0x82
37#define LARGE_TAG_UNICODESTR 0x83
38#define LARGE_TAG_VENDOR 0x84
39#define LARGE_TAG_MEM32 0x85
40#define LARGE_TAG_FIXEDMEM32 0x86
41
42/*
43 * Resource Data Stream Format:
44 *
45 * Allocated Resources (required)
46 * end tag ->
47 * Resource Configuration Options (optional)
48 * end tag ->
49 * Compitable Device IDs (optional)
50 * final end tag ->
51 */
52
53/*
54 * Allocated Resources
55 */
56
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -060057static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058{
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -060059 struct pnp_resource_table *res = &dev->res;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 int i = 0;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -070061
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070062 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
63 && i < PNP_MAX_IRQ)
64 i++;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 if (i < PNP_MAX_IRQ) {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070066 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 if (irq == -1) {
68 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
69 return;
70 }
71 res->irq_resource[i].start =
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070072 res->irq_resource[i].end = (unsigned long)irq;
David Shaohua Lic9c3e452005-04-01 00:07:31 -050073 pcibios_penalize_isa_irq(irq, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 }
75}
76
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -060077static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -060079 struct pnp_resource_table *res = &dev->res;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 int i = 0;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -070081
Adrian Bunk6e3e98d2005-05-01 08:59:29 -070082 while (i < PNP_MAX_DMA &&
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070083 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
Adrian Bunk6e3e98d2005-05-01 08:59:29 -070084 i++;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 if (i < PNP_MAX_DMA) {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070086 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 if (dma == -1) {
88 res->dma_resource[i].flags |= IORESOURCE_DISABLED;
89 return;
90 }
91 res->dma_resource[i].start =
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070092 res->dma_resource[i].end = (unsigned long)dma;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 }
94}
95
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -060096static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -070097 int io, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -060099 struct pnp_resource_table *res = &dev->res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 int i = 0;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700101
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700102 while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
103 && i < PNP_MAX_PORT)
104 i++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 if (i < PNP_MAX_PORT) {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700106 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
107 if (len <= 0 || (io + len - 1) >= 0x10003) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 res->port_resource[i].flags |= IORESOURCE_DISABLED;
109 return;
110 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700111 res->port_resource[i].start = (unsigned long)io;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 res->port_resource[i].end = (unsigned long)(io + len - 1);
113 }
114}
115
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600116static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700117 int mem, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118{
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600119 struct pnp_resource_table *res = &dev->res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 int i = 0;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700121
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700122 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
123 && i < PNP_MAX_MEM)
124 i++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 if (i < PNP_MAX_MEM) {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700126 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 if (len <= 0) {
128 res->mem_resource[i].flags |= IORESOURCE_DISABLED;
129 return;
130 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700131 res->mem_resource[i].start = (unsigned long)mem;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 res->mem_resource[i].end = (unsigned long)(mem + len - 1);
133 }
134}
135
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600136static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev,
137 unsigned char *p,
138 unsigned char *end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139{
140 unsigned int len, tag;
141 int io, size, mask, i;
142
143 if (!p)
144 return NULL;
145
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600146 dev_dbg(&dev->dev, "parse allocated resources\n");
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 /* Blank the resource table values */
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600149 pnp_init_resource_table(&dev->res);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
151 while ((char *)p < (char *)end) {
152
153 /* determine the type of tag */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700154 if (p[0] & LARGE_TAG) { /* large tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 len = (p[2] << 8) | p[1];
156 tag = p[0];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700157 } else { /* small tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 len = p[0] & 0x07;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700159 tag = ((p[0] >> 3) & 0x0f);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 }
161
162 switch (tag) {
163
164 case LARGE_TAG_MEM:
165 if (len != 9)
166 goto len_err;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700167 io = *(short *)&p[4];
168 size = *(short *)&p[10];
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600169 pnpbios_parse_allocated_memresource(dev, io, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 break;
171
172 case LARGE_TAG_ANSISTR:
173 /* ignore this for now */
174 break;
175
176 case LARGE_TAG_VENDOR:
177 /* do nothing */
178 break;
179
180 case LARGE_TAG_MEM32:
181 if (len != 17)
182 goto len_err;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700183 io = *(int *)&p[4];
184 size = *(int *)&p[16];
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600185 pnpbios_parse_allocated_memresource(dev, io, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 break;
187
188 case LARGE_TAG_FIXEDMEM32:
189 if (len != 9)
190 goto len_err;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700191 io = *(int *)&p[4];
192 size = *(int *)&p[8];
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600193 pnpbios_parse_allocated_memresource(dev, io, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 break;
195
196 case SMALL_TAG_IRQ:
197 if (len < 2 || len > 3)
198 goto len_err;
199 io = -1;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700200 mask = p[1] + p[2] * 256;
201 for (i = 0; i < 16; i++, mask = mask >> 1)
202 if (mask & 0x01)
203 io = i;
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600204 pnpbios_parse_allocated_irqresource(dev, io);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 break;
206
207 case SMALL_TAG_DMA:
208 if (len != 2)
209 goto len_err;
210 io = -1;
211 mask = p[1];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700212 for (i = 0; i < 8; i++, mask = mask >> 1)
213 if (mask & 0x01)
214 io = i;
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600215 pnpbios_parse_allocated_dmaresource(dev, io);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 break;
217
218 case SMALL_TAG_PORT:
219 if (len != 7)
220 goto len_err;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700221 io = p[2] + p[3] * 256;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 size = p[7];
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600223 pnpbios_parse_allocated_ioresource(dev, io, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 break;
225
226 case SMALL_TAG_VENDOR:
227 /* do nothing */
228 break;
229
230 case SMALL_TAG_FIXEDPORT:
231 if (len != 3)
232 goto len_err;
233 io = p[1] + p[2] * 256;
234 size = p[3];
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600235 pnpbios_parse_allocated_ioresource(dev, io, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 break;
237
238 case SMALL_TAG_END:
239 p = p + 2;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700240 return (unsigned char *)p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 break;
242
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700243 default: /* an unkown tag */
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600244len_err:
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700245 printk(KERN_ERR
246 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
247 tag, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 break;
249 }
250
251 /* continue to the next tag */
252 if (p[0] & LARGE_TAG)
253 p += len + 3;
254 else
255 p += len + 1;
256 }
257
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700258 printk(KERN_ERR
259 "PnPBIOS: Resource structure does not contain an end tag.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 return NULL;
262}
263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264/*
265 * Resource Configuration Options
266 */
267
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600268static __init void pnpbios_parse_mem_option(struct pnp_dev *dev,
269 unsigned char *p, int size,
Thomas Renninger2bb9a6b2008-02-06 01:40:03 -0800270 struct pnp_option *option)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700272 struct pnp_mem *mem;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700273
Robert P. J. Daycd861282006-12-13 00:34:52 -0800274 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 if (!mem)
276 return;
277 mem->min = ((p[5] << 8) | p[4]) << 8;
278 mem->max = ((p[7] << 8) | p[6]) << 8;
279 mem->align = (p[9] << 8) | p[8];
280 mem->size = ((p[11] << 8) | p[10]) << 8;
281 mem->flags = p[3];
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600282 pnp_register_mem_resource(dev, option, mem);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283}
284
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600285static __init void pnpbios_parse_mem32_option(struct pnp_dev *dev,
286 unsigned char *p, int size,
Thomas Renninger2bb9a6b2008-02-06 01:40:03 -0800287 struct pnp_option *option)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700289 struct pnp_mem *mem;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700290
Robert P. J. Daycd861282006-12-13 00:34:52 -0800291 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 if (!mem)
293 return;
294 mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
295 mem->max = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
296 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12];
297 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16];
298 mem->flags = p[3];
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600299 pnp_register_mem_resource(dev, option, mem);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300}
301
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600302static __init void pnpbios_parse_fixed_mem32_option(struct pnp_dev *dev,
303 unsigned char *p, int size,
Thomas Renninger2bb9a6b2008-02-06 01:40:03 -0800304 struct pnp_option *option)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700306 struct pnp_mem *mem;
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600307
Robert P. J. Daycd861282006-12-13 00:34:52 -0800308 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 if (!mem)
310 return;
311 mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
312 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
313 mem->align = 0;
314 mem->flags = p[3];
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600315 pnp_register_mem_resource(dev, option, mem);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316}
317
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600318static __init void pnpbios_parse_irq_option(struct pnp_dev *dev,
319 unsigned char *p, int size,
320 struct pnp_option *option)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700322 struct pnp_irq *irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 unsigned long bits;
324
Robert P. J. Daycd861282006-12-13 00:34:52 -0800325 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 if (!irq)
327 return;
328 bits = (p[2] << 8) | p[1];
329 bitmap_copy(irq->map, &bits, 16);
330 if (size > 2)
331 irq->flags = p[3];
332 else
333 irq->flags = IORESOURCE_IRQ_HIGHEDGE;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600334 pnp_register_irq_resource(dev, option, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335}
336
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600337static __init void pnpbios_parse_dma_option(struct pnp_dev *dev,
338 unsigned char *p, int size,
339 struct pnp_option *option)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700341 struct pnp_dma *dma;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700342
Robert P. J. Daycd861282006-12-13 00:34:52 -0800343 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 if (!dma)
345 return;
346 dma->map = p[1];
347 dma->flags = p[2];
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600348 pnp_register_dma_resource(dev, option, dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349}
350
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600351static __init void pnpbios_parse_port_option(struct pnp_dev *dev,
352 unsigned char *p, int size,
Thomas Renninger2bb9a6b2008-02-06 01:40:03 -0800353 struct pnp_option *option)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700355 struct pnp_port *port;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700356
Robert P. J. Daycd861282006-12-13 00:34:52 -0800357 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 if (!port)
359 return;
360 port->min = (p[3] << 8) | p[2];
361 port->max = (p[5] << 8) | p[4];
362 port->align = p[6];
363 port->size = p[7];
364 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600365 pnp_register_port_resource(dev, option, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366}
367
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600368static __init void pnpbios_parse_fixed_port_option(struct pnp_dev *dev,
369 unsigned char *p, int size,
Thomas Renninger2bb9a6b2008-02-06 01:40:03 -0800370 struct pnp_option *option)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700372 struct pnp_port *port;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700373
Robert P. J. Daycd861282006-12-13 00:34:52 -0800374 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 if (!port)
376 return;
377 port->min = port->max = (p[2] << 8) | p[1];
378 port->size = p[3];
379 port->align = 0;
380 port->flags = PNP_PORT_FLAG_FIXED;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600381 pnp_register_port_resource(dev, option, port);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382}
383
Thomas Renninger2bb9a6b2008-02-06 01:40:03 -0800384static __init unsigned char *
385pnpbios_parse_resource_option_data(unsigned char *p, unsigned char *end,
386 struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387{
388 unsigned int len, tag;
389 int priority = 0;
390 struct pnp_option *option, *option_independent;
391
392 if (!p)
393 return NULL;
394
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600395 dev_dbg(&dev->dev, "parse resource options\n");
396
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 option_independent = option = pnp_register_independent_option(dev);
398 if (!option)
399 return NULL;
400
401 while ((char *)p < (char *)end) {
402
403 /* determine the type of tag */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700404 if (p[0] & LARGE_TAG) { /* large tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 len = (p[2] << 8) | p[1];
406 tag = p[0];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700407 } else { /* small tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 len = p[0] & 0x07;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700409 tag = ((p[0] >> 3) & 0x0f);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 }
411
412 switch (tag) {
413
414 case LARGE_TAG_MEM:
415 if (len != 9)
416 goto len_err;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600417 pnpbios_parse_mem_option(dev, p, len, option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 break;
419
420 case LARGE_TAG_MEM32:
421 if (len != 17)
422 goto len_err;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600423 pnpbios_parse_mem32_option(dev, p, len, option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 break;
425
426 case LARGE_TAG_FIXEDMEM32:
427 if (len != 9)
428 goto len_err;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600429 pnpbios_parse_fixed_mem32_option(dev, p, len, option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 break;
431
432 case SMALL_TAG_IRQ:
433 if (len < 2 || len > 3)
434 goto len_err;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600435 pnpbios_parse_irq_option(dev, p, len, option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 break;
437
438 case SMALL_TAG_DMA:
439 if (len != 2)
440 goto len_err;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600441 pnpbios_parse_dma_option(dev, p, len, option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 break;
443
444 case SMALL_TAG_PORT:
445 if (len != 7)
446 goto len_err;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600447 pnpbios_parse_port_option(dev, p, len, option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 break;
449
450 case SMALL_TAG_VENDOR:
451 /* do nothing */
452 break;
453
454 case SMALL_TAG_FIXEDPORT:
455 if (len != 3)
456 goto len_err;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600457 pnpbios_parse_fixed_port_option(dev, p, len, option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 break;
459
460 case SMALL_TAG_STARTDEP:
461 if (len > 1)
462 goto len_err;
463 priority = 0x100 | PNP_RES_PRIORITY_ACCEPTABLE;
464 if (len > 0)
465 priority = 0x100 | p[1];
466 option = pnp_register_dependent_option(dev, priority);
467 if (!option)
468 return NULL;
469 break;
470
471 case SMALL_TAG_ENDDEP:
472 if (len != 0)
473 goto len_err;
474 if (option_independent == option)
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700475 printk(KERN_WARNING
476 "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 option = option_independent;
Bjorn Helgaasc1caf062008-04-28 16:34:04 -0600478 dev_dbg(&dev->dev, "end dependent options\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 break;
480
481 case SMALL_TAG_END:
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700482 return p + 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700484 default: /* an unkown tag */
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600485len_err:
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700486 printk(KERN_ERR
487 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
488 tag, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 break;
490 }
491
492 /* continue to the next tag */
493 if (p[0] & LARGE_TAG)
494 p += len + 3;
495 else
496 p += len + 1;
497 }
498
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700499 printk(KERN_ERR
500 "PnPBIOS: Resource structure does not contain an end tag.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
502 return NULL;
503}
504
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505/*
506 * Compatible Device IDs
507 */
508
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700509static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
510 unsigned char *end,
511 struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512{
513 int len, tag;
Bjorn Helgaas25eb8462008-04-28 16:33:53 -0600514 u32 eisa_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 char id[8];
516 struct pnp_id *dev_id;
517
518 if (!p)
519 return NULL;
520
521 while ((char *)p < (char *)end) {
522
523 /* determine the type of tag */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700524 if (p[0] & LARGE_TAG) { /* large tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 len = (p[2] << 8) | p[1];
526 tag = p[0];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700527 } else { /* small tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 len = p[0] & 0x07;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700529 tag = ((p[0] >> 3) & 0x0f);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 }
531
532 switch (tag) {
533
534 case LARGE_TAG_ANSISTR:
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700535 strncpy(dev->name, p + 3,
536 len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len);
537 dev->name[len >=
538 PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0';
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 break;
540
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700541 case SMALL_TAG_COMPATDEVID: /* compatible ID */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 if (len != 4)
543 goto len_err;
Bjorn Helgaas25eb8462008-04-28 16:33:53 -0600544 eisa_id = p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24;
545 pnp_eisa_id_to_string(eisa_id & PNP_EISA_ID_MASK, id);
Bjorn Helgaas772defc2008-04-28 16:33:52 -0600546 dev_id = pnp_add_id(dev, id);
547 if (!dev_id)
548 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 break;
550
551 case SMALL_TAG_END:
552 p = p + 2;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700553 return (unsigned char *)p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 break;
555
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700556 default: /* an unkown tag */
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600557len_err:
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700558 printk(KERN_ERR
559 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
560 tag, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 break;
562 }
563
564 /* continue to the next tag */
565 if (p[0] & LARGE_TAG)
566 p += len + 3;
567 else
568 p += len + 1;
569 }
570
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700571 printk(KERN_ERR
572 "PnPBIOS: Resource structure does not contain an end tag.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573
574 return NULL;
575}
576
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577/*
578 * Allocated Resource Encoding
579 */
580
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600581static void pnpbios_encode_mem(struct pnp_dev *dev, unsigned char *p,
582 struct resource *res)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583{
584 unsigned long base = res->start;
585 unsigned long len = res->end - res->start + 1;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700586
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 p[4] = (base >> 8) & 0xff;
588 p[5] = ((base >> 8) >> 8) & 0xff;
589 p[6] = (base >> 8) & 0xff;
590 p[7] = ((base >> 8) >> 8) & 0xff;
591 p[10] = (len >> 8) & 0xff;
592 p[11] = ((len >> 8) >> 8) & 0xff;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600593
594 dev_dbg(&dev->dev, " encode mem %#llx-%#llx\n",
595 (unsigned long long) res->start, (unsigned long long) res->end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596}
597
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600598static void pnpbios_encode_mem32(struct pnp_dev *dev, unsigned char *p,
599 struct resource *res)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600{
601 unsigned long base = res->start;
602 unsigned long len = res->end - res->start + 1;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700603
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 p[4] = base & 0xff;
605 p[5] = (base >> 8) & 0xff;
606 p[6] = (base >> 16) & 0xff;
607 p[7] = (base >> 24) & 0xff;
608 p[8] = base & 0xff;
609 p[9] = (base >> 8) & 0xff;
610 p[10] = (base >> 16) & 0xff;
611 p[11] = (base >> 24) & 0xff;
612 p[16] = len & 0xff;
613 p[17] = (len >> 8) & 0xff;
614 p[18] = (len >> 16) & 0xff;
615 p[19] = (len >> 24) & 0xff;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600616
617 dev_dbg(&dev->dev, " encode mem32 %#llx-%#llx\n",
618 (unsigned long long) res->start, (unsigned long long) res->end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619}
620
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600621static void pnpbios_encode_fixed_mem32(struct pnp_dev *dev, unsigned char *p,
622 struct resource *res)
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700623{
624 unsigned long base = res->start;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 unsigned long len = res->end - res->start + 1;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700626
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 p[4] = base & 0xff;
628 p[5] = (base >> 8) & 0xff;
629 p[6] = (base >> 16) & 0xff;
630 p[7] = (base >> 24) & 0xff;
631 p[8] = len & 0xff;
632 p[9] = (len >> 8) & 0xff;
633 p[10] = (len >> 16) & 0xff;
634 p[11] = (len >> 24) & 0xff;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600635
636 dev_dbg(&dev->dev, " encode fixed_mem32 %#llx-%#llx\n",
637 (unsigned long long) res->start, (unsigned long long) res->end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638}
639
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600640static void pnpbios_encode_irq(struct pnp_dev *dev, unsigned char *p,
641 struct resource *res)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642{
643 unsigned long map = 0;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700644
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 map = 1 << res->start;
646 p[1] = map & 0xff;
647 p[2] = (map >> 8) & 0xff;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600648
649 dev_dbg(&dev->dev, " encode irq %d\n", res->start);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650}
651
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600652static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p,
653 struct resource *res)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654{
655 unsigned long map = 0;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700656
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 map = 1 << res->start;
658 p[1] = map & 0xff;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600659
660 dev_dbg(&dev->dev, " encode dma %d\n", res->start);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661}
662
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600663static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p,
664 struct resource *res)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665{
666 unsigned long base = res->start;
667 unsigned long len = res->end - res->start + 1;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700668
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 p[2] = base & 0xff;
670 p[3] = (base >> 8) & 0xff;
671 p[4] = base & 0xff;
672 p[5] = (base >> 8) & 0xff;
673 p[7] = len & 0xff;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600674
675 dev_dbg(&dev->dev, " encode io %#llx-%#llx\n",
676 (unsigned long long) res->start, (unsigned long long) res->end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677}
678
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600679static void pnpbios_encode_fixed_port(struct pnp_dev *dev, unsigned char *p,
680 struct resource *res)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681{
682 unsigned long base = res->start;
683 unsigned long len = res->end - res->start + 1;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700684
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 p[1] = base & 0xff;
686 p[2] = (base >> 8) & 0xff;
687 p[3] = len & 0xff;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600688
689 dev_dbg(&dev->dev, " encode fixed_io %#llx-%#llx\n",
690 (unsigned long long) res->start, (unsigned long long) res->end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691}
692
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600693static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev
694 *dev,
695 unsigned char *p,
696 unsigned char *end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697{
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600698 struct pnp_resource_table *res = &dev->res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 unsigned int len, tag;
700 int port = 0, irq = 0, dma = 0, mem = 0;
701
702 if (!p)
703 return NULL;
704
705 while ((char *)p < (char *)end) {
706
707 /* determine the type of tag */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700708 if (p[0] & LARGE_TAG) { /* large tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 len = (p[2] << 8) | p[1];
710 tag = p[0];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700711 } else { /* small tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 len = p[0] & 0x07;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700713 tag = ((p[0] >> 3) & 0x0f);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 }
715
716 switch (tag) {
717
718 case LARGE_TAG_MEM:
719 if (len != 9)
720 goto len_err;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600721 pnpbios_encode_mem(dev, p, &res->mem_resource[mem]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 mem++;
723 break;
724
725 case LARGE_TAG_MEM32:
726 if (len != 17)
727 goto len_err;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600728 pnpbios_encode_mem32(dev, p, &res->mem_resource[mem]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 mem++;
730 break;
731
732 case LARGE_TAG_FIXEDMEM32:
733 if (len != 9)
734 goto len_err;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600735 pnpbios_encode_fixed_mem32(dev, p, &res->mem_resource[mem]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 mem++;
737 break;
738
739 case SMALL_TAG_IRQ:
740 if (len < 2 || len > 3)
741 goto len_err;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600742 pnpbios_encode_irq(dev, p, &res->irq_resource[irq]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 irq++;
744 break;
745
746 case SMALL_TAG_DMA:
747 if (len != 2)
748 goto len_err;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600749 pnpbios_encode_dma(dev, p, &res->dma_resource[dma]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 dma++;
751 break;
752
753 case SMALL_TAG_PORT:
754 if (len != 7)
755 goto len_err;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600756 pnpbios_encode_port(dev, p, &res->port_resource[port]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 port++;
758 break;
759
760 case SMALL_TAG_VENDOR:
761 /* do nothing */
762 break;
763
764 case SMALL_TAG_FIXEDPORT:
765 if (len != 3)
766 goto len_err;
Bjorn Helgaas72dcc882008-04-28 16:34:07 -0600767 pnpbios_encode_fixed_port(dev, p, &res->port_resource[port]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 port++;
769 break;
770
771 case SMALL_TAG_END:
772 p = p + 2;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700773 return (unsigned char *)p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 break;
775
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700776 default: /* an unkown tag */
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600777len_err:
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700778 printk(KERN_ERR
779 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
780 tag, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 break;
782 }
783
784 /* continue to the next tag */
785 if (p[0] & LARGE_TAG)
786 p += len + 3;
787 else
788 p += len + 1;
789 }
790
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700791 printk(KERN_ERR
792 "PnPBIOS: Resource structure does not contain an end tag.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793
794 return NULL;
795}
796
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797/*
798 * Core Parsing Functions
799 */
800
Thomas Renninger2bb9a6b2008-02-06 01:40:03 -0800801int __init pnpbios_parse_data_stream(struct pnp_dev *dev,
802 struct pnp_bios_node *node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700804 unsigned char *p = (char *)node->data;
805 unsigned char *end = (char *)(node->data + node->size);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700806
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600807 p = pnpbios_parse_allocated_resource_data(dev, p, end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 if (!p)
809 return -EIO;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700810 p = pnpbios_parse_resource_option_data(p, end, dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 if (!p)
812 return -EIO;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700813 p = pnpbios_parse_compatible_ids(p, end, dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 if (!p)
815 return -EIO;
816 return 0;
817}
818
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600819int pnpbios_read_resources_from_node(struct pnp_dev *dev,
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700820 struct pnp_bios_node *node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700822 unsigned char *p = (char *)node->data;
823 unsigned char *end = (char *)(node->data + node->size);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700824
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600825 p = pnpbios_parse_allocated_resource_data(dev, p, end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 if (!p)
827 return -EIO;
828 return 0;
829}
830
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600831int pnpbios_write_resources_to_node(struct pnp_dev *dev,
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700832 struct pnp_bios_node *node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700834 unsigned char *p = (char *)node->data;
835 unsigned char *end = (char *)(node->data + node->size);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700836
Bjorn Helgaas4ab55d82008-04-28 16:34:06 -0600837 p = pnpbios_encode_allocated_resource_data(dev, p, end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 if (!p)
839 return -EIO;
840 return 0;
841}