I recently read the allwinner solution. I found some of them have been modified. For example, for configuration files such as initialization, allwinner puts them together. The advantage of this is that it is easy to configure and all initialization is clear at a glance. It is very convenient. Where can I find this configuration file? ALLwinne... SyntaxHighlighter. all (); I recently read the allwinner solution. I found some of them have been modified. For example, for configuration files such as initialization, allwinner puts them together. The advantage of this is that it is easy to configure and all initialization is clear at a glance. It is very convenient. Where can I find this configuration file? ALLwinner adds this function to each driver during initialization: int script_parser_fetch (char * main_name, char * sub_name, int value [], int count) this function is used to read the corresponding initialization function. You can add it to each driver during initialization to read the previous configuration. The following describes the function int script_parser_fetch (char * main_name, char * sub_name, int value [], int count) {char main_bkname [32], sub_bkname [32]; char * main_char, * sub_char; script_main_key_t * main_key = NULL; script_sub_key_t * sub_key = NULL; int I, j; int pattern, word_count; pr_debug ("enter script parse fetch. \ n ");/* check params */if (! Script_mod_buf) {return SCRIPT_PARSER_EMPTY_BUFFER;} if (main_name = NULL) | (sub_name = NULL) {return SCRIPT_PARSER_KEYNAME_NULL;} if (value = NULL) {return SCRIPT_PARSER_DATA_VALUE_NULL;}/* truncate string if size> 31 bytes */main_char = main_name; if (_ test_str_length (main_name)> 31) {memset (main_bkname, 0, 32 ); strncpy (main_bkname, main_name, 31); main_char = main_bkname;} sub_char = sub_name; if (_ test_str_length (sub_name)> 31) {memset (sub_bkname, 0, 32 ); strncpy (sub_bkname, sub_name, 31); sub_char = sub_bkname;} pr_debug ("gpio: main name is: % s, sub_name is: % s", main_char, sub_char ); for (I = 0; I Main_name, main_char) {continue; // if it is not the parameter you want to initialize, skip}/* now find sub key */for (j = 0; j Lenth; j ++) {sub_key = (script_sub_key_t *) (script_mod_buf + (main_key-> offset <2) + (j * sizeof (script_sub_key_t ))); if (strcmp (sub_key-> sub_name, sub_char) {continue; // if it is not the parameter you want to initialize, skip} pattern = (sub_key-> pattern> 16) & 0 xffff;/* get datatype */word_count = (sub_key-> pattern> 0) & 0 xffff;/* get count of word */pr_debug ("pattern is: 0x % x, word_count is: 0x % x, ", pattern, word_count); switch (Pattern) {case SCIRPT_PARSER_VALUE_TYPE_SINGLE_WORD: value [0] = * (int *) (script_mod_buf + (sub_key-> offset <2); break; case SCIRPT_PARSER_VALUE_TYPE_STRING: if (count <word_count) {word_count = count;} memcpy (char *) value, script_mod_buf + (sub_key-> offset <2), word_count <2); break; case SCIRPT_PARSER_VALUE_TYPE_MULTI_WORD: break; case SCIRPT_PARSER_VALUE_TYPE_GPIO_WORD: {script_gpio_set _ T * user_gpio_cfg = (script_gpio_set_t *) value;/* buffer space enough? */If (sizeof (script_gpio_set_t)> (count <2) {return variable;} strcpy (user_gpio_cfg-> gpio_name, sub_char); memcpy (& user_gpio_cfg-> port, script_mod_buf + (sub_key-> offset <2), sizeof (script_gpio_set_t)-32); break;} return SCRIPT_PARSER_ OK;} return SCRIPT_PARSER_KEY_NOT_FIND ;}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.