2 * $Id: proc.c,v 1.1.2.1 1998/06/07 23:21:01 geert Exp $
4 * Procfs interface for the Zorro bus.
6 * Copyright (C) 1998 Geert Uytterhoeven
8 * Heavily based on the procfs interface for the PCI bus, which is
10 * Copyright (C) 1997, 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
13 #include <linux/types.h>
14 #include <linux/zorro.h>
15 #include <linux/proc_fs.h>
16 #include <linux/init.h>
17 #include <asm/uaccess.h>
18 #include <asm/amigahw.h>
19 #include <asm/setup.h>
22 proc_bus_zorro_lseek(struct file
*file
, loff_t off
, int whence
)
31 new = file
->f_pos
+ off
;
34 new = sizeof(struct ConfigDev
) + off
;
39 if (new < 0 || new > sizeof(struct ConfigDev
))
41 return (file
->f_pos
= new);
45 proc_bus_zorro_read(struct file
*file
, char *buf
, size_t nbytes
, loff_t
*ppos
)
47 struct inode
*ino
= file
->f_dentry
->d_inode
;
48 struct proc_dir_entry
*dp
= ino
->u
.generic_ip
;
49 struct ConfigDev
*cd
= dp
->data
;
52 if (pos
>= sizeof(struct ConfigDev
))
54 if (nbytes
>= sizeof(struct ConfigDev
))
55 nbytes
= sizeof(struct ConfigDev
);
56 if (pos
+ nbytes
> sizeof(struct ConfigDev
))
57 nbytes
= sizeof(struct ConfigDev
) - pos
;
58 if (copy_to_user(buf
, cd
, nbytes
))
65 static struct file_operations proc_bus_zorro_operations
= {
73 NULL
, /* no special open code */
75 NULL
, /* no special release code */
76 NULL
/* can't fsync */
79 static struct inode_operations proc_bus_zorro_inode_operations
= {
80 &proc_bus_zorro_operations
, /* default base directory file-ops */
91 NULL
, /* follow_link */
100 get_zorro_dev_info(char *buf
, char **start
, off_t pos
, int count
, int wr
)
106 for (slot
= cnt
= 0; slot
< zorro_num_autocon
&& count
> cnt
; slot
++) {
107 struct ConfigDev
*cd
= &zorro_autocon
[slot
];
108 u16 manuf
= cd
->cd_Rom
.er_Manufacturer
;
109 u8 prod
= cd
->cd_Rom
.er_Product
;
111 if (manuf
== ZORRO_MANUF(ZORRO_PROD_GVP_EPC_BASE
) &&
112 prod
== ZORRO_PROD(ZORRO_PROD_GVP_EPC_BASE
)) {
114 u32 addr
= (u32
)cd
->cd_BoardAddr
;
115 epc
= (*(u16
*)ZTWO_VADDR(addr
+0x8000)) & GVP_PRODMASK
;
118 len
= sprintf(buf
, "%02x\t%04x%02x%02x\t%08x\t%08x\t%02x\n",
119 slot
, manuf
, prod
, epc
, (u32
)cd
->cd_BoardAddr
,
120 cd
->cd_BoardSize
, cd
->cd_Rom
.er_Type
);
124 *start
= buf
+ (pos
- (at
- len
));
131 return (count
> cnt
) ? cnt
: count
;
134 static struct proc_dir_entry proc_zorro_devices
= {
135 PROC_BUS_ZORRO_DEVICES
, 7, "devices",
136 S_IFREG
| S_IRUGO
, 1, 0, 0,
137 0, &proc_array_inode_operations
,
141 static struct proc_dir_entry
*proc_bus_zorro_dir
;
143 __initfunc(static int zorro_proc_attach_device(u_int slot
))
145 struct proc_dir_entry
*entry
;
148 sprintf(name
, "%02x", slot
);
149 entry
= create_proc_entry(name
, S_IFREG
| S_IRUGO
, proc_bus_zorro_dir
);
152 entry
->ops
= &proc_bus_zorro_inode_operations
;
153 entry
->data
= &zorro_autocon
[slot
];
154 entry
->size
= sizeof(struct ConfigDev
);
158 __initfunc(void zorro_proc_init(void))
162 if (!MACH_IS_AMIGA
|| !AMIGAHW_PRESENT(ZORRO
))
164 proc_bus_zorro_dir
= create_proc_entry("zorro", S_IFDIR
, proc_bus
);
165 proc_register(proc_bus_zorro_dir
, &proc_zorro_devices
);
166 for (slot
= 0; slot
< zorro_num_autocon
; slot
++)
167 zorro_proc_attach_device(slot
);