@@ -37,18 +37,6 @@ static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
3737
3838static int acpi_apic_instance __initdata_or_acpilib ;
3939
40- enum acpi_subtable_type {
41- ACPI_SUBTABLE_COMMON ,
42- ACPI_SUBTABLE_HMAT ,
43- ACPI_SUBTABLE_PRMT ,
44- ACPI_SUBTABLE_CEDT ,
45- };
46-
47- struct acpi_subtable_entry {
48- union acpi_subtable_headers * hdr ;
49- enum acpi_subtable_type type ;
50- };
51-
5240/*
5341 * Disable table checksum verification for the early stage due to the size
5442 * limitation of the current x86 early mapping implementation.
@@ -237,167 +225,6 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
237225 }
238226}
239227
240- static unsigned long __init_or_acpilib
241- acpi_get_entry_type (struct acpi_subtable_entry * entry )
242- {
243- switch (entry -> type ) {
244- case ACPI_SUBTABLE_COMMON :
245- return entry -> hdr -> common .type ;
246- case ACPI_SUBTABLE_HMAT :
247- return entry -> hdr -> hmat .type ;
248- case ACPI_SUBTABLE_PRMT :
249- return 0 ;
250- case ACPI_SUBTABLE_CEDT :
251- return entry -> hdr -> cedt .type ;
252- }
253- return 0 ;
254- }
255-
256- static unsigned long __init_or_acpilib
257- acpi_get_entry_length (struct acpi_subtable_entry * entry )
258- {
259- switch (entry -> type ) {
260- case ACPI_SUBTABLE_COMMON :
261- return entry -> hdr -> common .length ;
262- case ACPI_SUBTABLE_HMAT :
263- return entry -> hdr -> hmat .length ;
264- case ACPI_SUBTABLE_PRMT :
265- return entry -> hdr -> prmt .length ;
266- case ACPI_SUBTABLE_CEDT :
267- return entry -> hdr -> cedt .length ;
268- }
269- return 0 ;
270- }
271-
272- static unsigned long __init_or_acpilib
273- acpi_get_subtable_header_length (struct acpi_subtable_entry * entry )
274- {
275- switch (entry -> type ) {
276- case ACPI_SUBTABLE_COMMON :
277- return sizeof (entry -> hdr -> common );
278- case ACPI_SUBTABLE_HMAT :
279- return sizeof (entry -> hdr -> hmat );
280- case ACPI_SUBTABLE_PRMT :
281- return sizeof (entry -> hdr -> prmt );
282- case ACPI_SUBTABLE_CEDT :
283- return sizeof (entry -> hdr -> cedt );
284- }
285- return 0 ;
286- }
287-
288- static enum acpi_subtable_type __init_or_acpilib
289- acpi_get_subtable_type (char * id )
290- {
291- if (strncmp (id , ACPI_SIG_HMAT , 4 ) == 0 )
292- return ACPI_SUBTABLE_HMAT ;
293- if (strncmp (id , ACPI_SIG_PRMT , 4 ) == 0 )
294- return ACPI_SUBTABLE_PRMT ;
295- if (strncmp (id , ACPI_SIG_CEDT , 4 ) == 0 )
296- return ACPI_SUBTABLE_CEDT ;
297- return ACPI_SUBTABLE_COMMON ;
298- }
299-
300- static __init_or_acpilib bool has_handler (struct acpi_subtable_proc * proc )
301- {
302- return proc -> handler || proc -> handler_arg ;
303- }
304-
305- static __init_or_acpilib int call_handler (struct acpi_subtable_proc * proc ,
306- union acpi_subtable_headers * hdr ,
307- unsigned long end )
308- {
309- if (proc -> handler )
310- return proc -> handler (hdr , end );
311- if (proc -> handler_arg )
312- return proc -> handler_arg (hdr , proc -> arg , end );
313- return - EINVAL ;
314- }
315-
316- /**
317- * acpi_parse_entries_array - for each proc_num find a suitable subtable
318- *
319- * @id: table id (for debugging purposes)
320- * @table_size: size of the root table
321- * @table_header: where does the table start?
322- * @proc: array of acpi_subtable_proc struct containing entry id
323- * and associated handler with it
324- * @proc_num: how big proc is?
325- * @max_entries: how many entries can we process?
326- *
327- * For each proc_num find a subtable with proc->id and run proc->handler
328- * on it. Assumption is that there's only single handler for particular
329- * entry id.
330- *
331- * The table_size is not the size of the complete ACPI table (the length
332- * field in the header struct), but only the size of the root table; i.e.,
333- * the offset from the very first byte of the complete ACPI table, to the
334- * first byte of the very first subtable.
335- *
336- * On success returns sum of all matching entries for all proc handlers.
337- * Otherwise, -ENODEV or -EINVAL is returned.
338- */
339- static int __init_or_acpilib acpi_parse_entries_array (
340- char * id , unsigned long table_size ,
341- struct acpi_table_header * table_header , struct acpi_subtable_proc * proc ,
342- int proc_num , unsigned int max_entries )
343- {
344- struct acpi_subtable_entry entry ;
345- unsigned long table_end , subtable_len , entry_len ;
346- int count = 0 ;
347- int errs = 0 ;
348- int i ;
349-
350- table_end = (unsigned long )table_header + table_header -> length ;
351-
352- /* Parse all entries looking for a match. */
353-
354- entry .type = acpi_get_subtable_type (id );
355- entry .hdr = (union acpi_subtable_headers * )
356- ((unsigned long )table_header + table_size );
357- subtable_len = acpi_get_subtable_header_length (& entry );
358-
359- while (((unsigned long )entry .hdr ) + subtable_len < table_end ) {
360- if (max_entries && count >= max_entries )
361- break ;
362-
363- for (i = 0 ; i < proc_num ; i ++ ) {
364- if (acpi_get_entry_type (& entry ) != proc [i ].id )
365- continue ;
366- if (!has_handler (& proc [i ]) ||
367- (!errs &&
368- call_handler (& proc [i ], entry .hdr , table_end ))) {
369- errs ++ ;
370- continue ;
371- }
372-
373- proc [i ].count ++ ;
374- break ;
375- }
376- if (i != proc_num )
377- count ++ ;
378-
379- /*
380- * If entry->length is 0, break from this loop to avoid
381- * infinite loop.
382- */
383- entry_len = acpi_get_entry_length (& entry );
384- if (entry_len == 0 ) {
385- pr_err ("[%4.4s:0x%02x] Invalid zero length\n" , id , proc -> id );
386- return - EINVAL ;
387- }
388-
389- entry .hdr = (union acpi_subtable_headers * )
390- ((unsigned long )entry .hdr + entry_len );
391- }
392-
393- if (max_entries && count > max_entries ) {
394- pr_warn ("[%4.4s:0x%02x] found the maximum %i entries\n" ,
395- id , proc -> id , count );
396- }
397-
398- return errs ? - EINVAL : count ;
399- }
400-
401228int __init_or_acpilib acpi_table_parse_entries_array (
402229 char * id , unsigned long table_size , struct acpi_subtable_proc * proc ,
403230 int proc_num , unsigned int max_entries )
0 commit comments