15 #include <linux/kernel.h>
16 #include <linux/slab.h>
18 #include <asm/uaccess.h>
19 #include <asm/byteorder.h>
36 #define SLOT2PORT(x) (x<<12)
42 #define get_8(x) (*(u_int8_t*)(x))
44 static inline u_int16_t get_16(
const unsigned char *
x)
46 return (x[1] << 8) | x[0];
49 static inline u_int32_t get_32(
const unsigned char *
x)
51 return (x[3] << 24) | (x[2] << 16) | (x[1] << 8) | x[0];
54 static inline u_int32_t get_24(
const unsigned char *x)
56 return (x[2] << 24) | (x[1] << 16) | (x[0] << 8);
59 static void print_eisa_id(
char *
s,
u_int32_t id)
70 vendor[2] =
'@' + (
id & 0x1f);
72 vendor[1] =
'@' + (
id & 0x1f);
74 vendor[0] =
'@' + (
id & 0x1f);
77 sprintf(s,
"%s%02X%02X", vendor, device, rev);
80 static int configure_memory(
const unsigned char *
buf,
98 res->
start = mem_parent->
start + get_24(buf+len+2);
99 res->
end = res->
start + get_16(buf+len+5)*1024;
101 printk(
"memory %lx-%lx ", (
unsigned long)res->
start, (
unsigned long)res->
end);
104 printk(
KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n");
120 static int configure_irq(
const unsigned char *buf)
151 static int configure_dma(
const unsigned char *buf)
172 static int configure_port(
const unsigned char *buf,
struct resource *io_parent,
188 res->
start = get_16(buf+len+1);
191 printk(
"ioports %lx-%lx ", (
unsigned long)res->
start, (
unsigned long)res->
end);
194 printk(
KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n");
214 static int configure_port_init(
const unsigned char *buf)
230 get_8(buf+len+4)), get_16(buf+len+1));
233 outb(
get_8(buf+len+3), get_16(buf+len+1));
239 if (c & HPEE_PORT_INIT_MASK) {
251 if (c & HPEE_PORT_INIT_MASK) {
255 get_32(buf+len+7)), get_16(buf+len+1));
266 if (c & HPEE_PORT_INIT_MASK) {
279 static int configure_choise(
const unsigned char *buf,
u_int8_t *
info)
288 *info=
get_8(buf+len+1);
293 static int configure_type_string(
const unsigned char *buf)
300 printk(
KERN_ERR "eisa_enumerator: type info field too long (%d, max is 80)\n", len);
306 static int configure_function(
const unsigned char *buf,
int *more)
317 static int parse_slot_config(
int slot,
318 const unsigned char *buf,
332 int id_string_used=0;
344 pos+=configure_function(buf+pos, &function_len);
351 pos += configure_choise(buf+pos, &flags);
355 pos = p0 + function_len;
360 printk(
"function %d have free-form confgiuration, skipping ",
362 pos = p0 + function_len;
375 pos += configure_type_string(buf+pos);
380 pos += configure_memory(buf+pos, mem_parent, board);
384 pos += configure_irq(buf+pos);
388 pos += configure_dma(buf+pos);
393 pos += configure_port(buf+pos, io_parent, board);
397 pos += configure_port_init(buf+pos);
400 if (p0 + function_len < pos) {
402 "got %d, expected %d\n",
403 num_func, pos-p0, function_len);
407 pos = p0 + function_len;
410 if (!id_string_used) {
415 printk(
KERN_ERR "eisa_enumerator: config data length mis-match got %d, expected %d\n",
421 printk(
KERN_ERR "eisa_enumerator: number of functions mis-match got %d, expected %d\n",
440 if (0xffffffff ==
id) {
448 printk(
KERN_ERR "EISA slot %d a configured board was not detected (",
452 printk(
" expected %s)\n", id_string);
458 print_eisa_id(id_string,
id);
463 printk(
" expected %s\n", id_string);
493 eeprom_buf[
i] = gsc_readb(eeprom_addr+i);
505 if (-1==init_slot(i+1, es)) {
511 es, io_parent, mem_parent)) {