Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <html> |
2 | <head> | |
3 | <title>SPARC Architectural Model: Device and Utility API</title> | |
4 | </head> | |
5 | <body bgcolor="#FFFFFF" LANG="en-US"> | |
6 | | |
7 | <h2> | |
8 | mmi_register_interface_cb</h2> | |
9 | ||
10 | <h4> | |
11 | NAME</h4> | |
12 | ||
13 | <ul>mmi_register_interface_cb - Register interface callback</ul> | |
14 | ||
15 | <h4> | |
16 | SYNOPSIS</h4> | |
17 | ||
18 | <ul> | |
19 | <font color="#0000FF">#include "mmi.h"</font> | |
20 | <p>typedef void * (*<i>fn_interface_cb</i>) ( | |
21 | void * <i>cb_data</i>, | |
22 | const char *<i>interface_name</i>); | |
23 | <p>bool_t mmi_register_interface_cb (module_t *<i>module</i>, fn_interface_cb <i>fn</i>); | |
24 | </ul> | |
25 | ||
26 | <h4> | |
27 | DESCRIPTION</h4> | |
28 | ||
29 | <ul> | |
30 | Register <i>fn</i> callback for <i>module</i>. | |
31 | This function is called via <b>mmi_get_interface()</b> from a client module. | |
32 | </ul> | |
33 | ||
34 | <ul> | |
35 | The callback function examines <i>interface_name</i>, returning a corresponding interface pointer if it matches. | |
36 | </ul> | |
37 | ||
38 | <h4> | |
39 | RETURN VALUES</h4> | |
40 | ||
41 | <ul>Returns 0 for failure.</ul> | |
42 | ||
43 | <h4> | |
44 | ERRORS</h4> | |
45 | <ul>Will fail if:</ul> | |
46 | <ul><i>module</i> is invalid.</ul> | |
47 | ||
48 | <h4> | |
49 | USAGE</h4> | |
50 | ||
51 | <ul> | |
52 | <pre> | |
53 | <tt> | |
54 | ||
55 | // return pointer to interface | |
56 | void * | |
57 | Schizo::get_interface(const char *name) | |
58 | { | |
59 | if (!strcmp(name, SCHIZO_INTERFACE)) | |
60 | return this; | |
61 | if (!strcmp(name, PCI_BUS_INTERFACE)) | |
62 | return (PciBusIf*)this; | |
63 | if (!strcmp(name, PCI_DEV_INTERFACE)) | |
64 | return (PciDevIf*)this; | |
65 | return NULL; | |
66 | } | |
67 | ||
68 | static void *schizo_get_interface(void *cb_data, const char *name) | |
69 | { | |
70 | Schizo *schizo = (Schizo *) cb_data; | |
71 | return schizo->get_interface(name); | |
72 | } | |
73 | ||
74 | void | |
75 | Schizo::register_interface_callback(module_t *instance) | |
76 | { | |
77 | mmi_register_cb_data(instance, this); | |
78 | mmi_register_interface_cb(instance, schizo_get_interface); | |
79 | } | |
80 | ||
81 | </tt> | |
82 | </pre> | |
83 | </ul> | |
84 | ||
85 | <h4> | |
86 | SEE ALSO</h4> | |
87 | <ul> | |
88 | <a href="mmi_get_interface.html">mmi_get_interface</a> | |
89 | </ul> | |
90 | ||
91 | <h4> | |
92 | WARNINGS</h4> | |
93 | | |
94 | </body> | |
95 | </html> |