FreeCalypso > hg > ueda-linux
annotate ueda/mclutils/bomtally.c @ 96:82d22cdaa74c
SML-510MW.fp: created based on E-Sample and FCDEV3B versions
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 26 Sep 2019 05:30:41 +0000 |
parents | 88cdef7e6b1b |
children |
rev | line source |
---|---|
83
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This code generates a tallied form of the BOM from the MCL, |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * to be used for generation of various BOM output formats. |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <unistd.h> |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "../libueda/mcl.h" |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "bomstruct.h" |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 extern struct component components[]; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 extern int ncomponents; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern char *get_comp_attr(); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern struct component *find_partdef_by_name(); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern int check_completeness, refdes_lists; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern struct bompart *bomhead; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 tally_parts() |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 int c; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 register struct component *comp; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 register char *attr; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 struct component *socket; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 for (comp = components, c = 0; c < ncomponents; comp++, c++) { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 if (!check_component_popopt(comp)) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 continue; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if (comp->partdef == NULL) { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 attr = get_comp_attr(comp, "part"); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (attr && !strcmp(attr, "none")) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 continue; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 if (check_completeness) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 fprintf(stderr, "%s has no part defined\n", |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 comp->name); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 continue; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 add_part_to_bom(comp->partdef, comp->name); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 attr = get_comp_attr(comp, "socket"); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (attr) { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 socket = find_partdef_by_name(attr); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (socket) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 add_part_to_bom(socket, comp->name); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 else |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 fprintf(stderr, |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 "%s: socket part %s not found\n", |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 comp->name, attr); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 add_part_to_bom(part, refdes) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 struct component *part; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 char *refdes; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 register struct bompart *bp, **bpp; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 for (bpp = &bomhead; bp = *bpp; bpp = &bp->next) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 if (bp->part == part) { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 bp->qty++; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 if (refdes_lists) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 add_refdes_to_bompart(bp, refdes); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 return; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 /* new part */ |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 bp = (struct bompart *) malloc(sizeof(struct bompart)); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 if (bp == NULL) { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 perror("malloc"); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 exit(1); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 bp->part = part; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 bp->qty = 1; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 bp->next = NULL; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 bp->refdeslist = NULL; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 *bpp = bp; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 if (refdes_lists) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 add_refdes_to_bompart(bp, refdes); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 add_refdes_to_bompart(bp, refdes) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 struct bompart *bp; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 char *refdes; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 register struct refdeslist *le, **lep; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 if (!bp->refdeslist) { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 lep = &bp->refdeslist; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 goto add_new; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 for (le = bp->refdeslist; le->next; le = le->next) |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 ; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 if (is_refdes_sequential(le->last, refdes)) { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 le->last = refdes; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 return(1); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 lep = &le->next; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 add_new: |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 le = (struct refdeslist *) malloc(sizeof(struct refdeslist)); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 if (!le) { |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 perror("malloc"); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 exit(1); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 le->first = refdes; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 le->last = refdes; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 le->next = NULL; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 *lep = le; |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 return(0); |
88cdef7e6b1b
BOM tallying code factored out of ueda-mkbom
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 } |