1 /*
2  * Header for Microchannel Architecture Bus
3  * Written by Martin Kolinek, February 1996
4  */
5 
6 #ifndef _LINUX_MCA_H
7 #define _LINUX_MCA_H
8 
9 /* The detection of MCA bus is done in the real mode (using BIOS).
10  * The information is exported to the protected code, where this
11  * variable is set to one in case MCA bus was detected.
12  */
13 #ifndef MCA_bus__is_a_macro
14 extern int  MCA_bus;
15 #endif
16 
17 /* Maximal number of MCA slots - actually, some machines have less, but
18  * they all have sufficient number of POS registers to cover 8.
19  */
20 #define MCA_MAX_SLOT_NR  8
21 
22 /* MCA_NOTFOUND is an error condition.  The other two indicate
23  * motherboard POS registers contain the adapter.  They might be
24  * returned by the mca_find_adapter() function, and can be used as
25  * arguments to mca_read_stored_pos().  I'm not going to allow direct
26  * access to the motherboard registers until we run across an adapter
27  * that requires it.  We don't know enough about them to know if it's
28  * safe.
29  *
30  * See Documentation/mca.txt or one of the existing drivers for
31  * more information.
32  */
33 #define MCA_NOTFOUND	(-1)
34 #define MCA_INTEGSCSI	(MCA_MAX_SLOT_NR)
35 #define MCA_INTEGVIDEO	(MCA_MAX_SLOT_NR+1)
36 #define MCA_MOTHERBOARD (MCA_MAX_SLOT_NR+2)
37 
38 /* Max number of adapters, including both slots and various integrated
39  * things.
40  */
41 #define MCA_NUMADAPTERS (MCA_MAX_SLOT_NR+3)
42 
43 /* Returns the slot of the first enabled adapter matching id.  User can
44  * specify a starting slot beyond zero, to deal with detecting multiple
45  * devices.  Returns MCA_NOTFOUND if id not found.  Also checks the
46  * integrated adapters.
47  */
48 extern int mca_find_adapter(int id, int start);
49 extern int mca_find_unused_adapter(int id, int start);
50 
51 /* adapter state info - returns 0 if no */
52 extern int mca_isadapter(int slot);
53 extern int mca_isenabled(int slot);
54 
55 extern int mca_is_adapter_used(int slot);
56 extern int mca_mark_as_used(int slot);
57 extern void mca_mark_as_unused(int slot);
58 
59 /* gets a byte out of POS register (stored in memory) */
60 extern unsigned char mca_read_stored_pos(int slot, int reg);
61 
62 /* This can be expanded later.  Right now, it gives us a way of
63  * getting meaningful information into the MCA_info structure,
64  * so we can have a more interesting /proc/mca.
65  */
66 extern void mca_set_adapter_name(int slot, char* name);
67 extern char* mca_get_adapter_name(int slot);
68 
69 /* This sets up an information callback for /proc/mca/slot?.  The
70  * function is called with the buffer, slot, and device pointer (or
71  * some equally informative context information, or nothing, if you
72  * prefer), and is expected to put useful information into the
73  * buffer.  The adapter name, id, and POS registers get printed
74  * before this is called though, so don't do it again.
75  *
76  * This should be called with a NULL procfn when a module
77  * unregisters, thus preventing kernel crashes and other such
78  * nastiness.
79  */
80 typedef int (*MCA_ProcFn)(char* buf, int slot, void* dev);
81 extern void mca_set_adapter_procfn(int slot, MCA_ProcFn, void* dev);
82 
83 /* These routines actually mess with the hardware POS registers.  They
84  * temporarily disable the device (and interrupts), so make sure you know
85  * what you're doing if you use them.  Furthermore, writing to a POS may
86  * result in two devices trying to share a resource, which in turn can
87  * result in multiple devices sharing memory spaces, IRQs, or even trashing
88  * hardware.  YOU HAVE BEEN WARNED.
89  *
90  * You can only access slots with this.  Motherboard registers are off
91  * limits.
92  */
93 
94 /* read a byte from the specified POS register. */
95 extern unsigned char mca_read_pos(int slot, int reg);
96 
97 /* write a byte to the specified POS register. */
98 extern void mca_write_pos(int slot, int reg, unsigned char byte);
99 
100 /* Should only be called by the NMI interrupt handler, this will do some
101  * fancy stuff to figure out what might have generated a NMI.
102  */
103 extern void mca_handle_nmi(void);
104 
105 #endif /* _LINUX_MCA_H */
106