@@ -45,161 +45,14 @@ int hpi_debug_level_get(void)
4545 return hpi_debug_level ;
4646}
4747
48- #ifdef HPIOS_DEBUG_PRINT
49- /* implies OS has no printf-like function */
50- #include <stdarg.h>
51-
52- void hpi_debug_printf (char * fmt , ...)
53- {
54- va_list arglist ;
55- char buffer [128 ];
56-
57- va_start (arglist , fmt );
58-
59- if (buffer [0 ])
60- HPIOS_DEBUG_PRINT (buffer );
61- va_end (arglist );
62- }
63- #endif
64-
65- struct treenode {
66- void * array ;
67- unsigned int num_elements ;
68- };
69-
70- #define make_treenode_from_array (nodename , array ) \
71- static void *tmp_strarray_##nodename[] = array; \
72- static struct treenode nodename = { \
73- &tmp_strarray_##nodename, \
74- ARRAY_SIZE(tmp_strarray_##nodename) \
75- };
76-
77- #define get_treenode_elem (node_ptr , idx , type ) \
78- (&(*((type *)(node_ptr)->array)[idx]))
79-
80- make_treenode_from_array (hpi_control_type_strings , HPI_CONTROL_TYPE_STRINGS )
81-
82- make_treenode_from_array (hpi_subsys_strings , HPI_SUBSYS_STRINGS )
83- make_treenode_from_array (hpi_adapter_strings , HPI_ADAPTER_STRINGS )
84- make_treenode_from_array (hpi_istream_strings , HPI_ISTREAM_STRINGS )
85- make_treenode_from_array (hpi_ostream_strings , HPI_OSTREAM_STRINGS )
86- make_treenode_from_array (hpi_mixer_strings , HPI_MIXER_STRINGS )
87- make_treenode_from_array (hpi_node_strings ,
88- {
89- "NODE is invalid object" })
90-
91- make_treenode_from_array (hpi_control_strings , HPI_CONTROL_STRINGS )
92- make_treenode_from_array (hpi_nvmemory_strings , HPI_OBJ_STRINGS )
93- make_treenode_from_array (hpi_digitalio_strings , HPI_DIGITALIO_STRINGS )
94- make_treenode_from_array (hpi_watchdog_strings , HPI_WATCHDOG_STRINGS )
95- make_treenode_from_array (hpi_clock_strings , HPI_CLOCK_STRINGS )
96- make_treenode_from_array (hpi_profile_strings , HPI_PROFILE_STRINGS )
97- make_treenode_from_array (hpi_asyncevent_strings , HPI_ASYNCEVENT_STRINGS )
98- #define HPI_FUNCTION_STRINGS \
99- { \
100- &hpi_subsys_strings,\
101- &hpi_adapter_strings,\
102- &hpi_ostream_strings,\
103- &hpi_istream_strings,\
104- &hpi_mixer_strings,\
105- &hpi_node_strings,\
106- &hpi_control_strings,\
107- &hpi_nvmemory_strings,\
108- &hpi_digitalio_strings,\
109- &hpi_watchdog_strings,\
110- &hpi_clock_strings,\
111- &hpi_profile_strings,\
112- &hpi_control_strings, \
113- &hpi_asyncevent_strings \
114- }
115- make_treenode_from_array (hpi_function_strings , HPI_FUNCTION_STRINGS )
116-
117- compile_time_assert (HPI_OBJ_MAXINDEX == 14 , obj_list_doesnt_match );
118-
119- static char * hpi_function_string (unsigned int function )
120- {
121- unsigned int object ;
122- struct treenode * tmp ;
123-
124- object = function / HPI_OBJ_FUNCTION_SPACING ;
125- function = function - object * HPI_OBJ_FUNCTION_SPACING ;
126-
127- if (object == 0 || object == HPI_OBJ_NODE
128- || object > hpi_function_strings .num_elements )
129- return "invalid object" ;
130-
131- tmp = get_treenode_elem (& hpi_function_strings , object - 1 ,
132- struct treenode * );
133-
134- if (function == 0 || function > tmp -> num_elements )
135- return "invalid function" ;
136-
137- return get_treenode_elem (tmp , function - 1 , char * );
138- }
139-
14048void hpi_debug_message (struct hpi_message * phm , char * sz_fileline )
14149{
14250 if (phm ) {
143- if ((phm -> object <= HPI_OBJ_MAXINDEX ) && phm -> object ) {
144- u16 index = 0 ;
145- u16 attrib = 0 ;
146- int is_control = 0 ;
147-
148- index = phm -> obj_index ;
149- switch (phm -> object ) {
150- case HPI_OBJ_ADAPTER :
151- case HPI_OBJ_PROFILE :
152- break ;
153- case HPI_OBJ_MIXER :
154- if (phm -> function ==
155- HPI_MIXER_GET_CONTROL_BY_INDEX )
156- index = phm -> u .m .control_index ;
157- break ;
158- case HPI_OBJ_OSTREAM :
159- case HPI_OBJ_ISTREAM :
160- break ;
161-
162- case HPI_OBJ_CONTROLEX :
163- case HPI_OBJ_CONTROL :
164- if (phm -> version == 1 )
165- attrib = HPI_CTL_ATTR (UNIVERSAL , 1 );
166- else
167- attrib = phm -> u .c .attribute ;
168- is_control = 1 ;
169- break ;
170- default :
171- break ;
172- }
173-
174- if (is_control && (attrib & 0xFF00 )) {
175- int control_type = (attrib & 0xFF00 ) >> 8 ;
176- int attr_index = HPI_CTL_ATTR_INDEX (attrib );
177- /* note the KERN facility level
178- is in szFileline already */
179- printk ("%s adapter %d %s "
180- "ctrl_index x%04x %s %d\n" ,
181- sz_fileline , phm -> adapter_index ,
182- hpi_function_string (phm -> function ),
183- index ,
184- get_treenode_elem
185- (& hpi_control_type_strings ,
186- control_type , char * ),
187- attr_index );
188-
189- } else
190- printk ("%s adapter %d %s "
191- "idx x%04x attr x%04x \n" ,
192- sz_fileline , phm -> adapter_index ,
193- hpi_function_string (phm -> function ),
194- index , attrib );
195- } else {
196- printk ("adap=%d, invalid obj=%d, func=0x%x\n" ,
197- phm -> adapter_index , phm -> object ,
198- phm -> function );
199- }
200- } else
201- printk (KERN_ERR
202- "NULL message pointer to hpi_debug_message!\n" );
51+ printk ("HPI_MSG%d,%d,%d,%d,%d\n" , phm -> version ,
52+ phm -> adapter_index , phm -> obj_index , phm -> function ,
53+ phm -> u .c .attribute );
54+ }
55+
20356}
20457
20558void hpi_debug_data (u16 * pdata , u32 len )
0 commit comments