9 type template
func(string, *string, *string, *uint32, *uint32) int
11 // extractPadFuncFromComment
12 // line : string from file with pad config map
13 // return : pad function string
14 func extractPadFuncFromComment(line
string) string {
15 if !strings
.Contains(line
, "/*") && !strings
.Contains(line
, "*/") {
19 fields
:= strings
.Fields(line
)
20 for i
, field
:= range fields
{
21 if field
== "/*" && len(fields
) >= i
+2 {
29 func tokenCheck(c rune
) bool {
30 return c
!= '_' && c
!= '#' && !unicode
.IsLetter(c
) && !unicode
.IsNumber(c
)
34 // line : string from file with pad config map
35 // *function : the string that means the pad function
36 // *id : pad id string
37 // *dw0 : DW0 register value
38 // *dw1 : DW1 register value
41 func useInteltoolLogTemplate(line
string, function
*string,
42 id
*string, dw0
*uint32, dw1
*uint32) int {
45 // 0x0520: 0x0000003c44000600 GPP_B12 SLP_S0#
46 // 0x0438: 0xffffffffffffffff GPP_C7 RESERVED
47 if fields
:= strings
.FieldsFunc(line
, tokenCheck
); len(fields
) >= 4 {
48 fmt
.Sscanf(fields
[1], "0x%x", &val
)
49 *dw0
= uint32(val
& 0xffffffff)
50 *dw1
= uint32(val
>> 32)
53 // Sometimes the configuration file contains compound functions such as
54 // SUSWARN#/SUSPWRDNACK. Since the template does not take this into account,
55 // need to collect all parts of the pad function back into a single word
56 for i
:= 4; i
< len(fields
); i
++ {
57 *function
+= "/" + fields
[i
]
59 // clear RO Interrupt Select (INTSEL)
66 // line : string from file with pad config map
67 // *function : the string that means the pad function
68 // *id : pad id string
69 // *dw0 : DW0 register value
70 // *dw1 : DW1 register value
73 func useGpioHTemplate(line
string, function
*string,
74 id
*string, dw0
*uint32, dw1
*uint32) int {
76 // /* RCIN# */ _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000),
77 // _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000), /* RCIN# */
78 // _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000)
79 fields
:= strings
.FieldsFunc(line
, tokenCheck
)
80 for i
, field
:= range fields
{
81 if field
== "_PAD_CFG_STRUCT" {
83 /* the number of definitions does not match the format */
87 if !strings
.Contains(fields
[i
+2], "0x") ||
!strings
.Contains(fields
[i
+3], "0x") {
88 /* definitions inside the macro do not match the pattern */
92 fmt
.Sscanf(fields
[i
+2], "0x%x", dw0
)
93 fmt
.Sscanf(fields
[i
+3], "0x%x", dw1
)
94 *function
= extractPadFuncFromComment(line
)
102 func useYourTemplate(line
string, function
*string,
103 id
*string, dw0
*uint32, dw1
*uint32) int {
105 // ADD YOUR TEMPLATE HERE
111 fmt
.Printf("ADD YOUR TEMPLATE!\n")
115 // registerInfoTemplate
116 // line : (in) string from file with pad config map
117 // *name : (out) register name
118 // *offset : (out) offset name
119 // *value : (out) register value
122 func registerInfoTemplate(line
string, name
*string, offset
*uint32, value
*uint32) int {
123 // 0x0088: 0x00ffffff (HOSTSW_OWN_GPP_F)
124 // 0x0100: 0x00000000 (GPI_IS_GPP_A)
125 if fields
:= strings
.FieldsFunc(line
, tokenCheck
); len(fields
) == 3 {
127 fmt
.Sscanf(fields
[1], "0x%x", value
)
128 fmt
.Sscanf(fields
[0], "0x%x", offset
)