Esempio n. 1
0
int fb_find_mode(struct fb_var_screeninfo *var,
		 struct fb_info *info, const char *mode_option,
		 const struct fb_videomode *db, unsigned int dbsize,
		 const struct fb_videomode *default_mode,
		 unsigned int default_bpp)
{
    int i;

    /* Set up defaults */
    if (!db) {
	db = modedb;
	dbsize = ARRAY_SIZE(modedb);
    }

    if (!default_mode)
	default_mode = &db[0];

    if (!default_bpp)
	default_bpp = 8;

    /* Did the user specify a video mode? */
    if (!mode_option)
	mode_option = fb_mode_option;
    if (mode_option) {
	const char *name = mode_option;
	unsigned int namelen = strlen(name);
	int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
	unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0;
	int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0;
	u32 best, diff, tdiff;

	for (i = namelen-1; i >= 0; i--) {
	    switch (name[i]) {
		case '@':
		    namelen = i;
		    if (!refresh_specified && !bpp_specified &&
			!yres_specified) {
			refresh = simple_strtol(&name[i+1], NULL, 10);
			refresh_specified = 1;
			if (cvt || rb)
			    cvt = 0;
		    } else
			goto done;
		    break;
		case '-':
		    namelen = i;
		    if (!bpp_specified && !yres_specified) {
			bpp = simple_strtol(&name[i+1], NULL, 10);
			bpp_specified = 1;
			if (cvt || rb)
			    cvt = 0;
		    } else
			goto done;
		    break;
		case 'x':
		    if (!yres_specified) {
			yres = simple_strtol(&name[i+1], NULL, 10);
			yres_specified = 1;
		    } else
			goto done;
		    break;
		case '0' ... '9':
		    break;
		case 'M':
		    if (!yres_specified)
			cvt = 1;
		    break;
		case 'R':
		    if (!cvt)
			rb = 1;
		    break;
		case 'm':
		    if (!cvt)
			margins = 1;
		    break;
		case 'i':
		    if (!cvt)
			interlace = 1;
		    break;
		default:
		    goto done;
	    }
	}
	if (i < 0 && yres_specified) {
	    xres = simple_strtol(name, NULL, 10);
	    res_specified = 1;
	}
done:
	if (cvt) {
	    struct fb_videomode cvt_mode;
	    int ret;

	    DPRINTK("CVT mode %dx%d@%dHz%s%s%s\n", xres, yres,
		    (refresh) ? refresh : 60, (rb) ? " reduced blanking" :
		    "", (margins) ? " with margins" : "", (interlace) ?
		    " interlaced" : "");

	    memset(&cvt_mode, 0, sizeof(cvt_mode));
	    cvt_mode.xres = xres;
	    cvt_mode.yres = yres;
	    cvt_mode.refresh = (refresh) ? refresh : 60;

	    if (interlace)
		cvt_mode.vmode |= FB_VMODE_INTERLACED;
	    else
		cvt_mode.vmode &= ~FB_VMODE_INTERLACED;

	    ret = fb_find_mode_cvt(&cvt_mode, margins, rb);

	    if (!ret && !fb_try_mode(var, info, &cvt_mode, bpp)) {
		DPRINTK("modedb CVT: CVT mode ok\n");
		return 1;
	    }

	    DPRINTK("CVT mode invalid, getting mode from database\n");
	}

	DPRINTK("Trying specified video mode%s %ix%i\n",
	    refresh_specified ? "" : " (ignoring refresh rate)", xres, yres);

	if (!refresh_specified) {
		/*
		 * If the caller has provided a custom mode database and a
		 * valid monspecs structure, we look for the mode with the
		 * highest refresh rate.  Otherwise we play it safe it and
		 * try to find a mode with a refresh rate closest to the
		 * standard 60 Hz.
		 */
		if (db != modedb &&
		    info->monspecs.vfmin && info->monspecs.vfmax &&
		    info->monspecs.hfmin && info->monspecs.hfmax &&
		    info->monspecs.dclkmax) {
			refresh = 1000;
		} else {
			refresh = 60;
		}
	}

	diff = -1;
	best = -1;
	for (i = 0; i < dbsize; i++) {
		if ((name_matches(db[i], name, namelen) ||
		    (res_specified && res_matches(db[i], xres, yres))) &&
		    !fb_try_mode(var, info, &db[i], bpp)) {
			if (refresh_specified && db[i].refresh == refresh) {
				return 1;
			} else {
				if (abs(db[i].refresh - refresh) < diff) {
					diff = abs(db[i].refresh - refresh);
					best = i;
				}
			}
		}
	}
	if (best != -1) {
		fb_try_mode(var, info, &db[best], bpp);
		return (refresh_specified) ? 2 : 1;
	}

	diff = 2 * (xres + yres);
	best = -1;
	DPRINTK("Trying best-fit modes\n");
	for (i = 0; i < dbsize; i++) {
		DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres);
		if (!fb_try_mode(var, info, &db[i], bpp)) {
			tdiff = abs(db[i].xres - xres) +
				abs(db[i].yres - yres);

			/*
			 * Penalize modes with resolutions smaller
			 * than requested.
			 */
			if (xres > db[i].xres || yres > db[i].yres)
				tdiff += xres + yres;

			if (diff > tdiff) {
				diff = tdiff;
				best = i;
			}
		}
	}
	if (best != -1) {
	    fb_try_mode(var, info, &db[best], bpp);
	    return 5;
	}
    }

    DPRINTK("Trying default video mode\n");
    if (!fb_try_mode(var, info, default_mode, default_bpp))
	return 3;

    DPRINTK("Trying all modes\n");
    for (i = 0; i < dbsize; i++)
	if (!fb_try_mode(var, info, &db[i], default_bpp))
	    return 4;

    DPRINTK("No valid mode found\n");
    return 0;
}
static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	u8 *buf, b_nand;
	int x, y, nbytes, selcfg;
	extern char console_buffer[];

	if (argc < 2) {
		printf("Usage:\n%s\n", cmdtp->usage);
		return 1;
	}

	if ((strcmp(argv[1], "nor") != 0) &&
	    (strcmp(argv[1], "nand") != 0)) {
		printf("Unsupported boot-device - only nor|nand support\n");
		return 1;
	}

	/* set the nand flag based on provided input */
	if ((strcmp(argv[1], "nand") == 0))
		b_nand = 1;
	else
		b_nand = 0;

	printf("Available configurations: \n\n");

	if (b_nand) {
		for(x = 0, y = 0; boot_configs[x][0] != 0; x++) {
			/* filter on nand compatible */
			if (boot_configs[x][0] & NAND_COMPATIBLE) {
				printf(" %d - %s\n", (y+1), config_labels[x]);
				y++;
			}
		}
	} else {
		for(x = 0, y = 0; boot_configs[x][0] != 0; x++) {
			/* filter on nor compatible */
			if (boot_configs[x][0] & NOR_COMPATIBLE) {
				printf(" %d - %s\n", (y+1), config_labels[x]);
				y++;
			}
		}
	}

	do {
		nbytes = readline(" Selection [1-x / quit]: ");

		if (nbytes) {
			if (strcmp(console_buffer, "quit") == 0)
				return 0;
			selcfg = simple_strtol(console_buffer, NULL, 10);
			if ((selcfg < 1) || (selcfg > y))
				nbytes = 0;
		}
	} while (nbytes == 0);


	y = (selcfg - 1);

	for (x = 0; boot_configs[x][0] != 0; x++) {
		if (b_nand) {
			if (boot_configs[x][0] & NAND_COMPATIBLE) {
				if (y > 0)
					y--;
				else if (y < 1)
					break;
			}
		} else {
			if (boot_configs[x][0] & NOR_COMPATIBLE) {
				if (y > 0)
					y--;
				else if (y < 1)
					break;
			}
		}
	}

	buf = &boot_configs[x][1];

	if (b_nand) {
		buf[5] = nand_boot[0];
		buf[6] = nand_boot[1];
		buf[8] = nand_boot[2];
		buf[9] = nand_boot[3];
		buf[11] = nand_boot[4];
	}

	if (i2c_write(I2C_EEPROM_ADDR, 0, 1, buf, 16) != 0)
		printf("Error writing to EEPROM at address 0x%x\n", I2C_EEPROM_ADDR);
	udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);

	printf("Done\n");
	printf("Please power-cycle the board for the changes to take effect\n");

	return 0;
}
Esempio n. 3
0
static int
wls_parse_batching_cmd(struct net_device *dev, char *command, int total_len)
{
	int err = BCME_OK;
	uint i, tokens;
	char *pos, *pos2, *token, *token2, *delim;
	char param[PNO_PARAM_SIZE], value[VALUE_SIZE];
	struct dhd_pno_batch_params batch_params;
	DHD_PNO(("%s: command=%s, len=%d\n", __FUNCTION__, command, total_len));
	if (total_len < strlen(CMD_WLS_BATCHING)) {
		DHD_ERROR(("%s argument=%d less min size\n", __FUNCTION__, total_len));
		err = BCME_ERROR;
		goto exit;
	}
	pos = command + strlen(CMD_WLS_BATCHING) + 1;
	memset(&batch_params, 0, sizeof(struct dhd_pno_batch_params));

	if (!strncmp(pos, PNO_BATCHING_SET, strlen(PNO_BATCHING_SET))) {
		pos += strlen(PNO_BATCHING_SET) + 1;
		while ((token = strsep(&pos, PNO_PARAMS_DELIMETER)) != NULL) {
			memset(param, 0, sizeof(param));
			memset(value, 0, sizeof(value));
			if (token == NULL || !*token)
				break;
			if (*token == '\0')
				continue;
			delim = strchr(token, PNO_PARAM_VALUE_DELLIMETER);
			if (delim != NULL)
				*delim = ' ';

			tokens = sscanf(token, "%s %s", param, value);
			if (!strncmp(param, PNO_PARAM_SCANFREQ, strlen(PNO_PARAM_MSCAN))) {
				batch_params.scan_fr = simple_strtol(value, NULL, 0);
				DHD_PNO(("scan_freq : %d\n", batch_params.scan_fr));
			} else if (!strncmp(param, PNO_PARAM_BESTN, strlen(PNO_PARAM_MSCAN))) {
				batch_params.bestn = simple_strtol(value, NULL, 0);
				DHD_PNO(("bestn : %d\n", batch_params.bestn));
			} else if (!strncmp(param, PNO_PARAM_MSCAN, strlen(PNO_PARAM_MSCAN))) {
				batch_params.mscan = simple_strtol(value, NULL, 0);
				DHD_PNO(("mscan : %d\n", batch_params.mscan));
			} else if (!strncmp(param, PNO_PARAM_CHANNEL, strlen(PNO_PARAM_MSCAN))) {
				i = 0;
				pos2 = value;
				tokens = sscanf(value, "<%s>", value);
				if (tokens != 1) {
					err = BCME_ERROR;
					DHD_ERROR(("%s : invalid format for channel"
					" <> params\n", __FUNCTION__));
					goto exit;
				}
					while ((token2 = strsep(&pos2,
					PNO_PARAM_CHANNEL_DELIMETER)) != NULL) {
					if (token2 == NULL || !*token2)
						break;
					if (*token2 == '\0')
						continue;
					if (*token2 == 'A' || *token2 == 'B') {
						batch_params.band = (*token2 == 'A')?
							WLC_BAND_5G : WLC_BAND_2G;
						DHD_PNO(("band : %s\n",
							(*token2 == 'A')? "A" : "B"));
					} else {
						batch_params.chan_list[i++] =
						simple_strtol(token2, NULL, 0);
						batch_params.nchan++;
						DHD_PNO(("channel :%d\n",
						batch_params.chan_list[i-1]));
					}
				 }
			} else if (!strncmp(param, PNO_PARAM_RTT, strlen(PNO_PARAM_MSCAN))) {
				batch_params.rtt = simple_strtol(value, NULL, 0);
				DHD_PNO(("rtt : %d\n", batch_params.rtt));
			} else {
				DHD_ERROR(("%s : unknown param: %s\n", __FUNCTION__, param));
				err = BCME_ERROR;
				goto exit;
			}
		}
		err = dhd_dev_pno_set_for_batch(dev, &batch_params);
		if (err < 0) {
			DHD_ERROR(("failed to configure batch scan\n"));
		} else {
			memset(command, 0, total_len);
			err = sprintf(command, "%d", err);
		}
	} else if (!strncmp(pos, PNO_BATCHING_GET, strlen(PNO_BATCHING_GET))) {
		err = dhd_dev_pno_get_for_batch(dev, command, total_len);
		if (err < 0) {
			DHD_ERROR(("failed to getting batching results\n"));
		}
	} else if (!strncmp(pos, PNO_BATCHING_STOP, strlen(PNO_BATCHING_STOP))) {
		err = dhd_dev_pno_stop_for_batch(dev);
		if (err < 0) {
			DHD_ERROR(("failed to stop batching scan\n"));
		} else {
			memset(command, 0, total_len);
			err = sprintf(command, "OK");
		}
	} else {
		DHD_ERROR(("%s : unknown command\n", __FUNCTION__));
		err = BCME_ERROR;
		goto exit;
	}
exit:
	return err;
}
Esempio n. 4
0
void dynamic_parse(void *data, pattern_t *pattern, size_t offset)
{
    if(unlikely(!get_flags_dynamic_enable()))
        return;
    struct ssn_skb_values * ssv = ( struct ssn_skb_values *)data;
    //struct l2ct_var_dpi * lvd =  &(ssv->ssn->vars_dpi);
#if 0 
    if (unlikely(pattern->pattern_key.dynamic_current_phase - 1 & lvd->ac_state_tbl != pattern->pattern_key.dynamic_current_phase - 1)) {
        if (i != 4) {
        D("current_phase[%u], ldv[%p], ac_state_tbl[%u]\n", pattern->pattern_key.dynamic_current_phase,lvd, lvd->ac_state_tbl);
            aaa =4;
        }
        lvd->ac_state_tbl = 0;
        return;
    }
    lvd->ac_state_tbl |= pattern->pattern_key.dynamic_current_phase;

    if (lvd->ac_state_tbl < pattern->pattern_key.dynamic_need_phase)
        return;
    	lvd->ac_state_tbl = 0;
#endif
//get dns or ip + port list
    //char *sp = ssv->payload + offset + pattern->pattern_len;
    char *sp = ssv->payload + offset;
    char *ep = ssv->payload + ssv->payload_len;
    int pos = 0;
    uint32_t ip;
    uint32_t proto_mark;
    uint16_t port = 0;

    switch(pattern->pattern_key.dynamic_type) {
            case 1:
                    {
                            if (pattern->pattern_key.dynamic_port && pattern->pattern_key.dynamic_port != (uint16_t)-1)
                            {
                                    if(pattern->pattern_key.dynamic_dir && pattern->pattern_key.dynamic_port != ssv->ssn->sess_key.port_dst)
                                    {
                                            return;
                                    }

                                    if(0 == pattern->pattern_key.dynamic_dir && pattern->pattern_key.dynamic_port != ssv->ssn->sess_key.port_src)
                                    {
                                            return;
                                    }

                            } 
                           
                            if (pattern->pattern_key.dynamic_dir) 
                            {    
                                    if (pattern->pattern_key.dynamic_port == (uint16_t)-1) {

                                        study_cache_try_get(ssv->ssn->sess_key.ip_dst, ssv->dport, ssv->ssn->proto_mark, 0, DYNAMIC_TIMEO); 	
 #ifdef DYNAMIC_DEBUG
                                    LOG("pattern[%s]add ip [%u]and port [%u.%u.%u.%u:%u] proto[%u] dynamic_indirect[%d]to study cache, common type, \n",
                                                    pattern->pattern_name, ssv->ssn->sess_key.ip_dst, IPQUADS(ssv->ssn->sess_key.ip_dst), ntohs(ssv->dport),  ssv->ssn->proto_mark,pattern->pattern_key.dynamic_indirect); 
#endif
                                   } else {
                                    study_cache_try_get(ssv->ssn->sess_key.ip_dst, pattern->pattern_key.dynamic_port, ssv->ssn->proto_mark, 0, DYNAMIC_TIMEO); 	
#ifdef DYNAMIC_DEBUG
                                    LOG("pattern[%s]add ip [%u]and port [%u.%u.%u.%u:%u] proto[%u] dynamic_indirect[%d]to study cache, common type, \n",
                                                    pattern->pattern_name, ssv->ssn->sess_key.ip_dst, IPQUADS(ssv->ssn->sess_key.ip_dst), ntohs(pattern->pattern_key.dynamic_port),  ssv->ssn->proto_mark,pattern->pattern_key.dynamic_indirect); 
#endif
                                }
                            } 
                            else 
                            {
                                    if (pattern->pattern_key.dynamic_port == (uint16_t)-1) {

                                        study_cache_try_get(ssv->ssn->sess_key.ip_src, ssv->sport, ssv->ssn->proto_mark, 0, 0); 	
 #ifdef DYNAMIC_DEBUG
                                    LOG("pattern[%s]add ip [%u]and port [%u.%u.%u.%u:%u] proto[%u] dynamic_indirect[%d]to study cache, common type, \n",
                                                    pattern->pattern_name, ssv->ssn->sess_key.ip_src, IPQUADS(ssv->ssn->sess_key.ip_src), ntohs(ssv->sport),  ssv->ssn->proto_mark,pattern->pattern_key.dynamic_indirect); 
#endif
                                    } else {
                                    study_cache_try_get(ssv->ssn->sess_key.ip_src, pattern->pattern_key.dynamic_port, ssv->ssn->proto_mark, 0, 0); 
#ifdef DYNAMIC_DEBUG
                                    LOG("pattern[%s]add ip and port [%u.%u.%u.%u:%u] proto[%u] dynamic_indirect[%d]to study cache, common type\n",
                                                    pattern->pattern_name, IPQUADS(ssv->ssn->sess_key.ip_src), ntohs(pattern->pattern_key.dynamic_port),  ssv->ssn->proto_mark,pattern->pattern_key.dynamic_indirect); 
#endif
                                    }
                            }

                            break;
                    }
            case 2:
                    {
                            //printf("dns type\n");
                            parse_dns(data, pattern, offset); 
                            break;
                    }
            case 3:// ip:port[10.211.55.88:88]
                    {
                            do{
                                    pos = subhex_in_mainhex(sp, ep - sp, pattern->pattern_key.ip_key, pattern->pattern_key.ip_key_len, 0);
                                    if (pos <= 0)
                                            return;
                                    sp += pos;
                                    for(; __isspace(*sp)||*sp == '"'||*sp == ':'; sp++) {
                                            if (sp >= ep)
                                                    return;
                                    }
                                    ip = ipv4_stonl(sp);
                                    if (unlikely(ip == 0xFFFFFFFF))
                                            return;
                                    sp += 6;
                                    if (pattern->pattern_key.dynamic_port) {
                                            port = pattern->pattern_key.dynamic_port;
                                    } else { 
                                            pos = substr_in_mainstr_nocase(sp, 16, ":", 0);
                                            if (pos > 0) {
                                                    sp += pos;
                                                    port = port_stons(sp);
                                                    if (port == 65535) {
                                                            port = 0;
                                                    }
                                            } 
                                    }
                                    if (likely(pattern->pattern_key.dynamic_indirect == 0) ) {
                                            if (pattern->pattern_key.dynamic_dir) {    
                                                    study_cache_try_get(ip, port, ssv->ssn->proto_mark, 0, 0); 
                                            } else {
                                                    dynamic_cache_try_get(ip, port, ssv->ssn->proto_mark, 0); 
                                            }

#ifdef DYNAMIC_DEBUG
                                            LOG("[%s]add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache isinner[%d]\n",pattern->pattern_name, IPQUADS(ip), ntohs(port), ssv->ssn->proto_mark, ssv->isinner);
#endif
                                    } else {
                                            if ((proto_mark = dns_study_lookup_behavior(ssv->dip, ssv->dport)) > 0) {

                                                    if (pattern->pattern_key.dynamic_dir) {    
                                                            study_cache_try_get(ip, port, proto_mark, 0, DNS_STUDY_TIMEO); 
                                                    } else {
                                                            dynamic_cache_try_get(ip, port, proto_mark, 0); 
                                                    }

#ifdef DYNAMIC_DEBUG
                                                    LOG("[%s] dynamic indirect add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache isinner[%d]\n", pattern->pattern_name, IPQUADS(ip), ntohs(port), proto_mark, ssv->isinner);
#endif
                                            }  else if ((proto_mark = dns_study_lookup_behavior(ssv->sip, ssv->sport)) > 0) {
                                                    if (pattern->pattern_key.dynamic_dir) {    
                                                            study_cache_try_get(ip, port, proto_mark, 0, DNS_STUDY_TIMEO); 
                                                    } else {
                                                            dynamic_cache_try_get(ip, port, proto_mark, 0); 
                                                    }

#ifdef DYNAMIC_DEBUG
                                                    LOG("[%s] dynamic indirect add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache isinner[%d]\n",pattern->pattern_name, IPQUADS(ip), ntohs(port), proto_mark, ssv->isinner);
#endif
                                            }
                                    }
                            } while (pattern->pattern_key.mult_iplist && sp < ep);
                            //   lvd->is_dynamic = 1;
                            break;
                    }
            case 4://such as: "ip":"111.161.80.157","port":1935,
                    {
                            do{
                                    pos = subhex_in_mainhex(sp, ep - sp, pattern->pattern_key.ip_key, pattern->pattern_key.ip_key_len, 0);
                                    if (pos <= 0)
                                            return;
                                    sp += pos;
                                    for(; __isspace(*sp)||*sp == '"'||*sp == ':'; sp++) {
                                            if (sp >= ep)
                                                    return;
                                    }

                                    ip = ipv4_stonl(sp);
                                    if (unlikely(ip == 0xFFFFFFFF))
                                            return;
                                    sp += 6; 
                                    pos = subhex_in_mainhex(sp, ep - sp, pattern->pattern_key.port_key, pattern->pattern_key.port_key_len, 0);
                                    if (pos <= 0)
                                            return;
                                    sp += pos;
                                    for(; __isspace(*sp)||*sp == '"'||*sp == ':'; sp++) {
                                            if (sp >= ep)
                                                    return;
                                    }
                                    port = port_stons(sp);
                                    if (likely(pattern->pattern_key.dynamic_indirect == 0) ) {
                                            if (pattern->pattern_key.dynamic_dir) {    
                                                    study_cache_try_get(ip, port, ssv->ssn->proto_mark, 0, 0); 
                                            } else {
                                                    dynamic_cache_try_get(ip, port, ssv->ssn->proto_mark, 0); 
                                            }
#ifdef DYNAMIC_DEBUG
                                            LOG("[%s]add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache isinner[%d]\n", pattern->pattern_name, IPQUADS(ip), ntohs(port), ssv->ssn->proto_mark, ssv->isinner);
#endif 
                                    } else {
                                            if ((proto_mark = dns_study_lookup_behavior(ssv->dip, ssv->dport)) > 0) {

                                                    if (pattern->pattern_key.dynamic_dir) {    
                                                            study_cache_try_get(ip, port, proto_mark, 0, DNS_STUDY_TIMEO); 
                                                    } else {
                                                            dynamic_cache_try_get(ip, port, proto_mark, 0); 
                                                    }

#ifdef DYNAMIC_DEBUG
                                                    LOG("[%s] dynamic indirect add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache  isinner[%d]\n", pattern->pattern_name, IPQUADS(ip), ntohs(port), proto_mark, ssv->isinner);
#endif
                                            } else if ((proto_mark = dns_study_lookup_behavior(ssv->sip, ssv->sport)) > 0) {


                                                    if (pattern->pattern_key.dynamic_dir) {    
                                                            study_cache_try_get(ip, port, proto_mark, 0, DNS_STUDY_TIMEO); 
                                                    } else {
                                                            dynamic_cache_try_get(ip, port, proto_mark, 0); 
                                                    }

#ifdef DYNAMIC_DEBUG
                                                    LOG("[%s] dynamic indirect add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache  isinner[%d]\n", pattern->pattern_name, IPQUADS(ip), ntohs(port), proto_mark, ssv->isinner);
#endif
                                            }

                                    }
                            } while (pattern->pattern_key.mult_iplist && sp < ep);
                            //                lvd->is_dynamic = 1;
                            break;

                    }

            case 5:
                    {
                            do{
                                    for(; __isspace(*sp)||*sp == '"'||*sp == ':'; sp++) {
                                            if (sp >= ep)
                                                    return;
                                    }

                                    ip = ipv4_stonl(sp);
                                    if (unlikely(ip == 0xFFFFFFFF))
                                            return;
                                    sp += 6;

                                    if (pattern->pattern_key.dynamic_port) {
                                            port = pattern->pattern_key.dynamic_port;
                                    } else { 
                                            pos = subhex_in_mainhex(sp, 16, pattern->pattern_key.port_key,pattern->pattern_key.port_key_len, 0);
                                            if (pos > 0) {
                                                    sp += pos;
                                                    port = port_stons(sp);
                                                    if (port == 65535) {
                                                            port = 0;
                                                    }
                                            } 
                                    }

                                    if (likely(pattern->pattern_key.dynamic_indirect == 0) ) {
                                            if (pattern->pattern_key.dynamic_dir) {    
                                                    study_cache_try_get(ip, port, ssv->ssn->proto_mark, 0, 0); 
                                            } else {
                                                    dynamic_cache_try_get(ip, port, ssv->ssn->proto_mark, 0); 
                                            }
#ifdef DYNAMIC_DEBUG
                                            LOG("[%s]add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache isinner[%d]\n", pattern->pattern_name, IPQUADS(ip), ntohs(port), ssv->ssn->proto_mark, ssv->isinner);
#endif 
                                    } else {
                                            if ((proto_mark = dns_study_lookup_behavior(ssv->dip, ssv->dport)) > 0) {

                                                    if (pattern->pattern_key.dynamic_dir) {    
                                                            study_cache_try_get(ip, port, proto_mark, 0, DNS_STUDY_TIMEO); 
                                                    } else {
                                                            dynamic_cache_try_get(ip, port, proto_mark, 0); 
                                                    }

#ifdef DYNAMIC_DEBUG
                                                    LOG("[%s] dynamic indirect add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache  isinner[%d]\n", pattern->pattern_name, IPQUADS(ip), ntohs(port), proto_mark, ssv->isinner);
#endif
                                            } else if ((proto_mark = dns_study_lookup_behavior(ssv->sip, ssv->sport)) > 0) {


                                                    if (pattern->pattern_key.dynamic_dir) {    
                                                            study_cache_try_get(ip, port, proto_mark, 0, DNS_STUDY_TIMEO); 
                                                    } else {
                                                            dynamic_cache_try_get(ip, port, proto_mark, 0); 
                                                    }

#ifdef DYNAMIC_DEBUG
                                                    LOG("[%s] dynamic indirect add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache  isinner[%d]\n", pattern->pattern_name, IPQUADS(ip), ntohs(port), proto_mark, ssv->isinner);
#endif
                                            }

                                    }
                            } while (pattern->pattern_key.mult_iplist && sp < ep);
                            //                lvd->is_dynamic = 1;
                            break;

                    }


#if 0
            case 5://such as: ch1.dnf.qq.com,
                    {
                            do{
                                    for(; __isspace(*sp); sp++) {
                                            if (sp >= ep)
                                                    return;
                                    }
                                    pos = substr_in_mainstr_nocase(sp, ep - sp, pattern->port_key, 0);
                                    //pos = substr_in_mainstr_nocase(sp, 16, ":", 0);
                                    if (pos > 0) {
                                            strncopy(domain, sp, pos - strlen(pattern->port_key));
                                            sp += pos;
                                            port = simple_strtol(sp, NULL, 0);
                                            domain_cache_try_get(domain, ssv->ssn->proto_mark); 
                                            printk("---port=%u\n", port);
                                    }
                                    // else {
                                    //     port = pattern->dynamic_port;
                                    // }
                                    DEG("add ip and port [%u.%u.%u.%u:%u]proto[%u]to dynamic cache\n", IPQUADS(ip), ntohs(port), ssv->ssn->proto_mark); 
                            } while (pattern->mult_iplist && sp < ep);
                            lvd->is_dynamic = 1;
                            break;
                    }
#endif
            default: 
                    break;

    }

}
Esempio n. 5
0
int do_fastboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	int ret = 1;
	char fbparts[4096], *env;
	int check_timeout = 0;
	uint64_t timeout_endtime = 0;
	uint64_t timeout_ticks = 0;
	long timeout_seconds = -1;
	int continue_from_disconnect = 0;

	/*
	 * Place the runtime partitions at the end of the
	 * static paritions.  First save the start off so
	 * it can be saved from run to run.
	 */
	if (static_pcount >= 0) {
		/* Reset */
		pcount = static_pcount;
	} else {
		/* Save */
		static_pcount = pcount;
	}
	env = getenv("fbparts");
	if (env) {
		unsigned int len;
		len = strlen(env);
		if (len && len < 4096) {
			char *s, *e;

			memcpy(&fbparts[0], env, len + 1);
			printf("Fastboot: Adding partitions from environment\n");
			s = &fbparts[0];
			e = s + len;
			while (s < e) {
				if (add_partition_from_environment(s, &s)) {
					printf("Error:Fastboot: Abort adding partitions\n");
					/* reset back to static */
					pcount = static_pcount;
					break;
				}
				/* Skip a bunch of delimiters */
				while (s < e) {
					if ((' ' == *s) ||
					    ('\t' == *s) ||
					    ('\n' == *s) ||
					    ('\r' == *s) ||
					    (',' == *s)) {
						s++;
					} else {
						break;
					}
				}
			}
		}
	}

	/* Time out */
	if (2 == argc) {
		long try_seconds;
		char *try_seconds_end;
		/* Check for timeout */
		try_seconds = simple_strtol(argv[1],
					    &try_seconds_end, 10);
		if ((try_seconds_end != argv[1]) &&
		    (try_seconds >= 0)) {
			check_timeout = 1;
			timeout_seconds = try_seconds;
			printf("Fastboot inactivity timeout %ld seconds\n", timeout_seconds);
		}
	}

	if (1 == check_timeout) {
		timeout_ticks = (uint64_t)
			(timeout_seconds * get_tbclk());
	}


	do {
		continue_from_disconnect = 0;

		/* Initialize the board specific support */
		if (0 == fastboot_init(&interface)) {

			int poll_status;

			/* If we got this far, we are a success */
			ret = 0;
			printf("fastboot initialized\n");

			timeout_endtime = get_ticks();
			timeout_endtime += timeout_ticks;

			while (1) {
				uint64_t current_time = 0;
				poll_status = fastboot_poll();

				if (1 == check_timeout)
					current_time = get_ticks();

				if (FASTBOOT_ERROR == poll_status) {
					/* Error */
					break;
				} else if (FASTBOOT_DISCONNECT == poll_status) {
					/* beak, cleanup and re-init */
					printf("Fastboot disconnect detected\n");
					continue_from_disconnect = 1;
					break;
				} else if ((1 == check_timeout) &&
					   (FASTBOOT_INACTIVE == poll_status)) {

					/* No activity */
					if (current_time >= timeout_endtime) {
						printf("Fastboot inactivity detected\n");
						break;
					}
				} else {
					/* Something happened */
					if (1 == check_timeout) {
						/* Update the timeout endtime */
						timeout_endtime = current_time;
						timeout_endtime += timeout_ticks;
					}
				}

				/* Check if the user wanted to terminate with ^C */
				if ((FASTBOOT_INACTIVE == poll_status) &&
				    (ctrlc())) {
					printf("Fastboot ended by user\n");
					break;
				}

				/*
				 * Check if the fastboot client wanted to
				 * continue booting
				 */
				if (continue_booting) {
					printf("Fastboot ended by client\n");
					break;
				}

				/* Check if there is something to upload */
				tx_handler();
			}
		}

		/* Reset the board specific support */
		fastboot_shutdown();

		/* restart the loop if a disconnect was detected */
	} while (continue_from_disconnect);

	return ret;
}
INT	Set_Antenna_Proc(
	IN	PRTMP_ADAPTER	pAd, 
	IN	PSTRING			arg)
{
	ANT_DIVERSITY_TYPE UsedAnt;
	DBGPRINT(RT_DEBUG_OFF, ("==> Set_Antenna_Proc *******************\n"));

	UsedAnt = simple_strtol(arg, 0, 10);
#ifdef ANT_DIVERSITY_SUPPORT
	pAd->CommonCfg.bRxAntDiversity = UsedAnt;
#endif /* ANT_DIVERSITY_SUPPORT */

	switch (UsedAnt)
	{
#ifdef ANT_DIVERSITY_SUPPORT
		/* 0: Disabe --> set Antenna CON1*/
		case ANT_DIVERSITY_DISABLE:
#endif /* ANT_DIVERSITY_SUPPORT */
		/* 2: Fix in the PHY Antenna CON1*/
		case ANT_FIX_ANT0:
			AsicSetRxAnt(pAd, 0);
			DBGPRINT(RT_DEBUG_OFF, ("<== Set_Antenna_Proc(Fix in Ant CON1), (%d,%d)\n", 
					pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
			break;
#ifdef ANT_DIVERSITY_SUPPORT
		/* 1: Enable --> HW/SW Antenna diversity*/
		case ANT_DIVERSITY_ENABLE:
			if ((pAd->chipCap.FlgIsHwAntennaDiversitySup) && (pAd->chipOps.HwAntEnable)) /* HW_ANT_DIV (PPAD) */
			{
				pAd->chipOps.HwAntEnable(pAd);
				pAd->CommonCfg.bRxAntDiversity = ANT_HW_DIVERSITY_ENABLE;
			}	
			else /* SW_ANT_DIV */
			{
				pAd->RxAnt.EvaluateStableCnt = 0;
				pAd->CommonCfg.bRxAntDiversity = ANT_SW_DIVERSITY_ENABLE;
			}

			DBGPRINT(RT_DEBUG_OFF, ("<== Set_Antenna_Proc(Auto Switch Mode), (%d,%d)\n", 
					pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
			break;
#endif /* ANT_DIVERSITY_SUPPORT */
    	/* 3: Fix in the PHY Antenna CON2*/
		case ANT_FIX_ANT1:
			AsicSetRxAnt(pAd, 1);
			DBGPRINT(RT_DEBUG_OFF, ("<== Set_Antenna_Proc(Fix in Ant CON2), (%d,%d)\n", 
					pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
			break;
#ifdef ANT_DIVERSITY_SUPPORT
		/* 4: Enable SW Antenna Diversity */
		case ANT_SW_DIVERSITY_ENABLE:
			pAd->RxAnt.EvaluateStableCnt = 0;
			DBGPRINT(RT_DEBUG_OFF, ("<== Set_Antenna_Proc(Auto Switch Mode --> SW), (%d,%d)\n", 
					pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
			break;
		/* 5: Enable HW Antenna Diversity - PPAD */
		case ANT_HW_DIVERSITY_ENABLE:
			if ((pAd->chipCap.FlgIsHwAntennaDiversitySup) && (pAd->chipOps.HwAntEnable)) /* HW_ANT_DIV (PPAD) */
				pAd->chipOps.HwAntEnable(pAd);
			DBGPRINT(RT_DEBUG_OFF, ("<== Set_Antenna_Proc(Auto Switch Mode --> HW), (%d,%d)\n", 
					pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
			break;
#endif /* ANT_DIVERSITY_SUPPORT */
		default:
			DBGPRINT(RT_DEBUG_ERROR, ("<== Set_Antenna_Proc(N/A cmd: %d), (%d,%d)\n", UsedAnt,
					pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
			break;
	}
	
	return TRUE;
}
Esempio n. 7
0
VOID rtmp_read_wds_from_file(
			IN  PRTMP_ADAPTER pAd,
			PSTRING tmpbuf,
			PSTRING buffer)
{
	PSTRING		macptr;
	INT			i=0, j;
	STRING		tok_str[16];
	BOOLEAN		bUsePrevFormat = FALSE;
	UCHAR		macAddress[MAC_ADDR_LEN];
	UCHAR	    keyMaterial[40];	
	UCHAR		KeyLen, CipherAlg = CIPHER_NONE, KeyIdx;
	PRT_802_11_WDS_ENTRY pWdsEntry;
		
	/*WdsPhyMode */
	if (RTMPGetKeyParameter("WdsPhyMode", tmpbuf, MAX_PARAM_BUFFER_SIZE, buffer, TRUE))
	{	
		for (i=0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) 
		{
	        if ((strncmp(macptr, "CCK", 3) == 0) || (strncmp(macptr, "cck", 3) == 0))
	            pAd->WdsTab.WdsEntry[i].PhyMode = MODE_CCK;
	        else if ((strncmp(macptr, "OFDM", 4) == 0) || (strncmp(macptr, "ofdm", 4) == 0))
	            pAd->WdsTab.WdsEntry[i].PhyMode = MODE_OFDM;
#ifdef DOT11_N_SUPPORT
	        else if ((strncmp(macptr, "HTMIX", 5) == 0) || (strncmp(macptr, "htmix", 5) == 0))
	            pAd->WdsTab.WdsEntry[i].PhyMode = MODE_HTMIX;
	        else if ((strncmp(macptr, "GREENFIELD", 10) == 0) || (strncmp(macptr, "greenfield", 10) == 0))
	            pAd->WdsTab.WdsEntry[i].PhyMode = MODE_HTGREENFIELD;
#endif /* DOT11_N_SUPPORT */
	        else
	            pAd->WdsTab.WdsEntry[i].PhyMode = 0xff;
		
	        DBGPRINT(RT_DEBUG_TRACE, ("If/wds%d - WdsPhyMode=%d\n", i, pAd->WdsTab.WdsEntry[i].PhyMode));	    
		}
	}
	
	/*WdsList */
	if (RTMPGetKeyParameter("WdsList", tmpbuf, MAX_PARAM_BUFFER_SIZE, buffer, TRUE))
	{
		if (pAd->WdsTab.Mode != WDS_LAZY_MODE)
		{
			for (i=0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) 
			{				
				if(strlen(macptr) != 17)  /*Mac address acceptable format 01:02:03:04:05:06 length 17 */
					continue; 
				if(strcmp(macptr,"00:00:00:00:00:00") == 0)
					continue; 
				if(i >= MAX_WDS_ENTRY)
					break; 

				for (j=0; j<ETH_LENGTH_OF_ADDRESS; j++)
				{
					AtoH(macptr, &macAddress[j], 1);
					macptr=macptr+3;
				}	

				WdsEntryAlloc(pAd, macAddress);				
			}
		}
	}
	/*WdsEncrypType */
	if (RTMPGetKeyParameter("WdsEncrypType", tmpbuf, 128, buffer, TRUE))
	{				
	    for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++)
	    {
	        if ((strncmp(macptr, "NONE", 4) == 0) || (strncmp(macptr, "none", 4) == 0))
	            pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11WEPDisabled;
	        else if ((strncmp(macptr, "WEP", 3) == 0) || (strncmp(macptr, "wep", 3) == 0))
	            pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11WEPEnabled;
	        else if ((strncmp(macptr, "TKIP", 4) == 0) || (strncmp(macptr, "tkip", 4) == 0))
	            pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11Encryption2Enabled;
	        else if ((strncmp(macptr, "AES", 3) == 0) || (strncmp(macptr, "aes", 3) == 0))
	            pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11Encryption3Enabled;
	        else
	            pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11WEPDisabled;

	        DBGPRINT(RT_DEBUG_TRACE, ("WdsEncrypType[%d]=%d(%s)\n", i, pAd->WdsTab.WdsEntry[i].WepStatus, GetEncryptType(pAd->WdsTab.WdsEntry[i].WepStatus)));
	    }
		
		/* Previous WDS only supports single encryption type. */
		/* For backward compatible, other wds link encryption type shall be the same with the first. */
		if (i == 1)
		{
			for (j = 1; j < MAX_WDS_ENTRY; j++)
			{
				pAd->WdsTab.WdsEntry[j].WepStatus = pAd->WdsTab.WdsEntry[0].WepStatus;	
				DBGPRINT(RT_DEBUG_TRACE, ("@WdsEncrypType[%d]=%d(%s)\n", j, pAd->WdsTab.WdsEntry[i].WepStatus, GetEncryptType(pAd->WdsTab.WdsEntry[i].WepStatus)));	
			}
		}
			
	}
	/* WdsKey */
	/* This is a previous parameter and it only stores WPA key material, not WEP key */
	if (RTMPGetKeyParameter("WdsKey", tmpbuf, 255, buffer, FALSE))
	{			
		for (i = 0; i < MAX_WDS_ENTRY; i++)
			NdisZeroMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, sizeof(CIPHER_KEY));

		if (strlen(tmpbuf) > 0)
			bUsePrevFormat = TRUE;

		/* check if the wds-0 link key material is valid */
		if (((pAd->WdsTab.WdsEntry[0].WepStatus == Ndis802_11Encryption2Enabled)
				|| (pAd->WdsTab.WdsEntry[0].WepStatus == Ndis802_11Encryption3Enabled))
			&& (strlen(tmpbuf) >= 8) && (strlen(tmpbuf) <= 64))
		{
			RT_CfgSetWPAPSKKey(pAd, tmpbuf, strlen(tmpbuf), (PUCHAR)RALINK_PASSPHRASE, sizeof(RALINK_PASSPHRASE), keyMaterial);
			if (pAd->WdsTab.WdsEntry[0].WepStatus == Ndis802_11Encryption3Enabled)
				pAd->WdsTab.WdsEntry[0].WdsKey.CipherAlg = CIPHER_AES;
			else
				pAd->WdsTab.WdsEntry[0].WdsKey.CipherAlg = CIPHER_TKIP;
			
			NdisMoveMemory(&pAd->WdsTab.WdsEntry[0].WdsKey.Key, keyMaterial, 16);
			pAd->WdsTab.WdsEntry[0].WdsKey.KeyLen = 16;
			NdisMoveMemory(&pAd->WdsTab.WdsEntry[0].WdsKey.RxMic, keyMaterial+16, 8);
			NdisMoveMemory(&pAd->WdsTab.WdsEntry[0].WdsKey.TxMic, keyMaterial+16, 8);
		}

		/* Previous WDS only supports single key-material. */
		/* For backward compatible, other wds link key-material shall be the same with the first. */
		if (pAd->WdsTab.WdsEntry[0].WdsKey.KeyLen == 16)
		{
			for (j = 1; j < MAX_WDS_ENTRY; j++)
			{
				NdisMoveMemory(&pAd->WdsTab.WdsEntry[j].WdsKey, &pAd->WdsTab.WdsEntry[0].WdsKey, sizeof(CIPHER_KEY));								
			}
		}
	
	}

	/* The parameters can provide different key information for each WDS-Link */
	/* no matter WEP or WPA */
	if (!bUsePrevFormat)
	{
		for (i = 0; i < MAX_WDS_ENTRY; i++)
		{
			AP_WDS_KeyNameMakeUp(tok_str, sizeof(tok_str), i);

			/* WdsXKey (X=0~MAX_WDS_ENTRY-1) */
			if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, FALSE))
			{			
				if (pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption1Enabled)
				{
					/* Ascii type */
					if (strlen(tmpbuf) == 5 || strlen(tmpbuf) == 13)
					{		
						KeyLen = strlen(tmpbuf);
						pAd->WdsTab.WdsEntry[i].WdsKey.KeyLen = KeyLen;
						NdisMoveMemory(pAd->WdsTab.WdsEntry[i].WdsKey.Key, tmpbuf, KeyLen);
						if (KeyLen == 5)
							CipherAlg = CIPHER_WEP64;
						else
							CipherAlg = CIPHER_WEP128;	

						pAd->WdsTab.WdsEntry[i].WdsKey.CipherAlg = CipherAlg;
						DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d Key=%s ,type=Ascii, CipherAlg(%s)\n", i, tmpbuf, (CipherAlg == CIPHER_WEP64 ? "wep64" : "wep128")));
					}
					/* Hex type */
					else if (strlen(tmpbuf) == 10 || strlen(tmpbuf) == 26)
					{		
						KeyLen = strlen(tmpbuf);
						pAd->WdsTab.WdsEntry[i].WdsKey.KeyLen = KeyLen / 2;
						AtoH(tmpbuf, pAd->WdsTab.WdsEntry[i].WdsKey.Key, KeyLen / 2);						
						if (KeyLen == 10)
							CipherAlg = CIPHER_WEP64;
						else
							CipherAlg = CIPHER_WEP128;	

						pAd->WdsTab.WdsEntry[i].WdsKey.CipherAlg = CipherAlg;
						DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d Key=%s ,type=Hex, CipherAlg(%s)\n", i, tmpbuf, (CipherAlg == CIPHER_WEP64 ? "wep64" : "wep128")));
					}
					/* Invalid type */
					else
					{
						pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11EncryptionDisabled;
						NdisZeroMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, sizeof(CIPHER_KEY));
						DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d has invalid key for WEP, reset encryption to OPEN\n", i));
					}
				}
				else if ((pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption2Enabled)
					|| (pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption3Enabled))					
				{
					if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) <= 64))
					{
						RT_CfgSetWPAPSKKey(pAd, tmpbuf, strlen(tmpbuf), (PUCHAR) RALINK_PASSPHRASE, sizeof(RALINK_PASSPHRASE), keyMaterial);
						if (pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption3Enabled)
							pAd->WdsTab.WdsEntry[i].WdsKey.CipherAlg = CIPHER_AES;
						else
							pAd->WdsTab.WdsEntry[i].WdsKey.CipherAlg = CIPHER_TKIP;
						
						NdisMoveMemory(&pAd->WdsTab.WdsEntry[i].WdsKey.Key, keyMaterial, 16);
						pAd->WdsTab.WdsEntry[i].WdsKey.KeyLen = 16;
						NdisMoveMemory(&pAd->WdsTab.WdsEntry[i].WdsKey.RxMic, keyMaterial+16, 8);
						NdisMoveMemory(&pAd->WdsTab.WdsEntry[i].WdsKey.TxMic, keyMaterial+16, 8);
						DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d Key=%s, CipherAlg(%s)\n", i, tmpbuf, (CipherAlg == CIPHER_AES ? "AES" : "TKIP")));
					}
					else
					{
						DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d has invalid key for WPA, reset encryption to OPEN\n", i));
						pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11EncryptionDisabled;
						NdisZeroMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, sizeof(CIPHER_KEY));
					}

				}
				else
				{									
					pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11EncryptionDisabled;
					NdisZeroMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, sizeof(CIPHER_KEY));
				}								
			}
		}
	}

	/* WdsDefaultKeyID */
	if(RTMPGetKeyParameter("WdsDefaultKeyID", tmpbuf, 10, buffer, TRUE))
	{
		for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++)
		{
			KeyIdx = (UCHAR) simple_strtol(macptr, 0, 10);
			if((KeyIdx >= 1 ) && (KeyIdx <= 4))
				pAd->WdsTab.WdsEntry[i].KeyIdx = (UCHAR) (KeyIdx - 1);
			else
				pAd->WdsTab.WdsEntry[i].KeyIdx = 0;

			if ((pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption2Enabled)
					|| (pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption3Enabled))
				pAd->WdsTab.WdsEntry[i].KeyIdx = 0;	

			DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d - WdsDefaultKeyID(0~3)=%d\n", i, pAd->WdsTab.WdsEntry[i].KeyIdx));	
		}				
	}
	
	/* WdsTxMode */
	if (RTMPGetKeyParameter("WdsTxMode", tmpbuf, 25, buffer, TRUE))
	{
		for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++)
		{
			pWdsEntry = &pAd->WdsTab.WdsEntry[i];

			pWdsEntry->DesiredTransmitSetting.field.FixedTxMode = 
										RT_CfgSetFixedTxPhyMode(macptr);
			DBGPRINT(RT_DEBUG_TRACE, ("I/F(wds%d) Tx Mode = %d\n", i,
											pWdsEntry->DesiredTransmitSetting.field.FixedTxMode));					
		}	
	}

	/* WdsTxMcs */
	if (RTMPGetKeyParameter("WdsTxMcs", tmpbuf, 50, buffer, TRUE))
	{
		for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++)
		{
			pWdsEntry = &pAd->WdsTab.WdsEntry[i];

			pWdsEntry->DesiredTransmitSetting.field.MCS = 
					RT_CfgSetTxMCSProc(macptr, &pWdsEntry->bAutoTxRateSwitch);

			if (pWdsEntry->DesiredTransmitSetting.field.MCS == MCS_AUTO)
			{
				DBGPRINT(RT_DEBUG_TRACE, ("I/F(wds%d) Tx MCS = AUTO\n", i));
			}
			else
			{
				DBGPRINT(RT_DEBUG_TRACE, ("I/F(wds%d) Tx MCS = %d\n", i, 
									pWdsEntry->DesiredTransmitSetting.field.MCS));
			}
		}	
	}
	
	/*WdsEnable */
	if(RTMPGetKeyParameter("WdsEnable", tmpbuf, 10, buffer, TRUE))
	{						
		RT_802_11_WDS_ENTRY *pWdsEntry;
		switch(simple_strtol(tmpbuf, 0, 10))
		{
			case 2: /* Bridge mode, DisAllow association(stop Beacon generation and Probe Req. */
				pAd->WdsTab.Mode = WDS_BRIDGE_MODE;
				break;
			case 1:	
		    case 3: /* Repeater mode */
				pAd->WdsTab.Mode = WDS_REPEATER_MODE;
				break;
			case 4: /* Lazy mode, Auto learn wds entry by same SSID, channel, security policy */
				for(i = 0; i < MAX_WDS_ENTRY; i++)
				{
					pWdsEntry = &pAd->WdsTab.WdsEntry[i];
					if (pWdsEntry->Valid)
						WdsEntryDel(pAd, pWdsEntry->PeerWdsAddr);
				
					/* When Lazy mode is enabled, the all wds-link shall share the same encryption type and key material */
					if (i > 0)
					{
						pAd->WdsTab.WdsEntry[i].WepStatus = pAd->WdsTab.WdsEntry[0].WepStatus;
						pAd->WdsTab.WdsEntry[i].KeyIdx = pAd->WdsTab.WdsEntry[0].KeyIdx;
						NdisMoveMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, &pAd->WdsTab.WdsEntry[0].WdsKey, sizeof(CIPHER_KEY));
					}
				}
				pAd->WdsTab.Mode = WDS_LAZY_MODE;
				break;
		    case 0: /* Disable mode */
		    default:
				APWdsInitialize(pAd);
			    pAd->WdsTab.Mode = WDS_DISABLE_MODE;
			   	break;
		}

		DBGPRINT(RT_DEBUG_TRACE, ("WDS-Enable mode=%d\n", pAd->WdsTab.Mode));

	}
	
#ifdef WDS_VLAN_SUPPORT
	/* WdsVlan */
	if (RTMPGetKeyParameter("WDS_VLANID", tmpbuf, MAX_PARAM_BUFFER_SIZE, buffer, TRUE))
	{	
		for (i=0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) 
		{
            pAd->WdsTab.WdsEntry[i].VLAN_VID = simple_strtol(macptr, 0, 10);
            pAd->WdsTab.WdsEntry[i].VLAN_Priority = 0;
		
	        DBGPRINT(RT_DEBUG_TRACE, ("If/wds%d - WdsVlanId=%d\n", i, pAd->WdsTab.WdsEntry[i].VLAN_VID));	    
		}
	}
#endif /* WDS_VLAN_SUPPORT */
}
Esempio n. 8
0
static ssize_t store_addr(struct device *dev, struct device_attribute *attr,
                const char *buf, size_t n)
{
    dbg_addr = simple_strtol(buf, NULL, 16);
    return n;
}
Esempio n. 9
0
static ssize_t i2c_store_property(struct device *dev,
		struct device_attribute * attr,
		const char *buf, size_t size)
{
	int i, ret = 0, bytes;
	char *data, *after, *poiter;
	size_t count = 0;
	const ptrdiff_t off = attr - i2c_attrs;

	data = kzalloc((size + 1) / 2, GFP_KERNEL);
	if (!data)
		return -ENOMEM;
	poiter = data;

	while (count < size) {
		(*poiter) = (char)simple_strtol(buf, &after, 16);
		if (after == buf)
			return -EINVAL;
		poiter++;
		count += after - buf;
		if (*after && isspace(*after))
			count++;
		buf = after + 1;
	}
	bytes = poiter - data;
	printk("Data:");
	for (i=0; i<bytes; i++) {
		printk("0x%02x ", data[i]);
	}
	printk("\n");

	switch (off) {
	case I2C_ID:
	{
		struct i2c_adapter *adap;
		if (bytes != 1) {
			printk("ID not supported.\n");
			return -EINVAL;
		}
		adap = i2c_get_adapter(data[0]);
		if (!adap) {
			printk("I2C bus not exist.\n");
			return -EINVAL;
		}
		i2c_put_adapter(adap);
		i2c_id = data[0];
		break;
	}
	case I2C_ADDR:
		if (bytes != 1) {
			printk("Only 7-bits address supported.\n");
			return -EINVAL;
		}
		i2c_addr = data[0];
		break;
	case I2C_WRITE:
		if (bytes == 1)
			read_regaddr = data[0];
		else
        {
            ret = i2c_writes(i2c_id, i2c_addr, data, bytes);
            if (ret < 0) return -ENXIO;
        }
		break;
	default:
		return -EINVAL;
	}

	kfree(data);
	return count;
}
Esempio n. 10
0
INT Set_TxStreamMeasureReq_Proc(
	IN PRTMP_ADAPTER pAd,
	IN	PSTRING arg)
{
	POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
	UCHAR ifIndex = pObj->ioctl_if;
	UINT Aid = 1;
	UINT ArgIdx;
	PSTRING thisChar;

	RRM_MLME_TRANSMIT_REQ_INFO TransmitReq;
	PMAC_TABLE_ENTRY pMacEntry;

	ArgIdx = 0;
	NdisZeroMemory(&TransmitReq, sizeof(RRM_MLME_TRANSMIT_REQ_INFO));

	while ((thisChar = strsep((char **)&arg, "-")) != NULL)
	{
		switch(ArgIdx)
		{
			case 0:	/* Aid. */
				Aid = (UINT8) simple_strtol(thisChar, 0, 10);
				if (!VALID_WCID(Aid))
				{
					DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid));
					return TRUE;
				}
				break;

			case 1: /* DurationMandotory. */
				TransmitReq.bDurationMandatory =
					((UINT16)simple_strtol(thisChar, 0, 10) > 0 ? TRUE : FALSE);
				break;

			case 2: /* Measure Duration */
				TransmitReq.MeasureDuration = (UINT16)simple_strtol(thisChar, 0, 10);
				break;

			case 3: /* TID */
				TransmitReq.Tid = (UINT8) simple_strtol(thisChar, 0, 10);
				break;

			case 4: /* Bin 0 Range */
				TransmitReq.BinRange = (UINT8) simple_strtol(thisChar, 0, 10);
				break;

			case 5: /* Averange Condition */
				TransmitReq.ArvCondition =
					((UINT8) simple_strtol(thisChar, 0, 10)) > 0 ? 1 : 0;
				break;

			case 6: /* Consecutive Condition */
				TransmitReq.ConsecutiveCondition =
					((UINT8) simple_strtol(thisChar, 0, 10)) > 0 ? 1 : 0;
				break;

			case 7: /* Delay Condition */
				TransmitReq.DelayCondition =
					((UINT8) simple_strtol(thisChar, 0, 10)) > 0 ? 1 : 0;
				break;

			case 8: /* Averange Error Threshold */
				TransmitReq.AvrErrorThreshold =
					(UINT8) simple_strtol(thisChar, 0, 10);
				break;

			case 9: /* Consecutive Error Threshold */
				TransmitReq.ConsecutiveErrorThreshold =
					(UINT8) simple_strtol(thisChar, 0, 10);
				break;

			case 10: /* Delay Threshold */
				TransmitReq.DelayThreshold =
					(UINT8) simple_strtol(thisChar, 0, 10);
				break;

			case 11: /* Measure counter  */
				TransmitReq.MeasureCnt =
					(UINT8) simple_strtol(thisChar, 0, 10);

				break;

			case 12: /* Trigger time out */
				TransmitReq.TriggerTimeout =
					(UINT8) simple_strtol(thisChar, 0, 10);
				break;
			
		}
		ArgIdx++;
	}	

	if ((ArgIdx != 13) && (ArgIdx != 5))
	{
		DBGPRINT(RT_DEBUG_ERROR,
			("%s: invalid args (%d).\n", __FUNCTION__, ArgIdx));
		DBGPRINT(RT_DEBUG_ERROR,
			("eg: iwpriv ra0 set txreq=<Aid>-<DurationMandortory>-<Duration>-<TID>-<BinRange>[-<AvrCond>-<ConsecutiveCond>-<DealyCond>-<AvrErrorThreshold>-<ConsecutiveErrorThreshold>-<DelayThreshold>-<MeasureCnt>-<TriggerTimeout>]\n"));
		return TRUE;
	}

	if (ArgIdx == 5)
		TransmitReq.bTriggerReport = 0;
	else
		TransmitReq.bTriggerReport = 1;

	pMacEntry = &pAd->MacTab.Content[Aid];
	DBGPRINT(RT_DEBUG_ERROR, ("%s::Aid=%d, PeerMac=%02x:%02x:%02x:%02x:%02x:%02x\n",
		__FUNCTION__, Aid,	pMacEntry->Addr[0], pMacEntry->Addr[1],
		pMacEntry->Addr[2], pMacEntry->Addr[3], pMacEntry->Addr[4], pMacEntry->Addr[5]));

	DBGPRINT(RT_DEBUG_ERROR, ("Duration=%d, Tid=%d, Bin 0 Range=%d\n",
		TransmitReq.MeasureDuration, TransmitReq.Tid, TransmitReq.BinRange));

	DBGPRINT(RT_DEBUG_ERROR, ("ArvCondition=%d, ConsecutiveCondition=%d, DelayCondition=%d\n",
		TransmitReq.ArvCondition, TransmitReq.ConsecutiveCondition, TransmitReq.DelayCondition));

	DBGPRINT(RT_DEBUG_ERROR, ("AvrErrorThreshold=%d, ConsecutiveErrorThreshold=%d\n",
		TransmitReq.AvrErrorThreshold, TransmitReq.ConsecutiveErrorThreshold));

	DBGPRINT(RT_DEBUG_ERROR, ("DelayThreshold=%d\n", TransmitReq.DelayThreshold));

	DBGPRINT(RT_DEBUG_ERROR, ("MeasureCnt=%d, TriggerTimeout=%d\n",
		TransmitReq.MeasureCnt, TransmitReq.TriggerTimeout));

	RRM_EnqueueTxStreamMeasureReq(pAd, Aid, ifIndex, &TransmitReq);

	return TRUE;
}
Esempio n. 11
0
static ssize_t __write_versions(struct file *file, char *buf, size_t size)
{
	char *mesg = buf;
	char *vers, *minorp, sign;
	int len, num, remaining;
	unsigned minor;
	ssize_t tlen = 0;
	char *sep;

	if (size>0) {
		if (nfsd_serv)
			/* Cannot change versions without updating
			 * nfsd_serv->sv_xdrsize, and reallocing
			 * rq_argp and rq_resp
			 */
			return -EBUSY;
		if (buf[size-1] != '\n')
			return -EINVAL;
		buf[size-1] = 0;

		vers = mesg;
		len = qword_get(&mesg, vers, size);
		if (len <= 0) return -EINVAL;
		do {
			sign = *vers;
			if (sign == '+' || sign == '-')
				num = simple_strtol((vers+1), &minorp, 0);
			else
				num = simple_strtol(vers, &minorp, 0);
			if (*minorp == '.') {
				if (num < 4)
					return -EINVAL;
				minor = simple_strtoul(minorp+1, NULL, 0);
				if (minor == 0)
					return -EINVAL;
				if (nfsd_minorversion(minor, sign == '-' ?
						     NFSD_CLEAR : NFSD_SET) < 0)
					return -EINVAL;
				goto next;
			}
			switch(num) {
			case 2:
			case 3:
			case 4:
				nfsd_vers(num, sign == '-' ? NFSD_CLEAR : NFSD_SET);
				break;
			default:
				return -EINVAL;
			}
		next:
			vers += len + 1;
		} while ((len = qword_get(&mesg, vers, size)) > 0);
		/* If all get turned off, turn them back on, as
		 * having no versions is BAD
		 */
		nfsd_reset_versions();
	}

	/* Now write current state into reply buffer */
	len = 0;
	sep = "";
	remaining = SIMPLE_TRANSACTION_LIMIT;
	for (num=2 ; num <= 4 ; num++)
		if (nfsd_vers(num, NFSD_AVAIL)) {
			len = snprintf(buf, remaining, "%s%c%d", sep,
				       nfsd_vers(num, NFSD_TEST)?'+':'-',
				       num);
			sep = " ";

			if (len > remaining)
				break;
			remaining -= len;
			buf += len;
			tlen += len;
		}
	if (nfsd_vers(4, NFSD_AVAIL))
		for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION;
		     minor++) {
			len = snprintf(buf, remaining, " %c4.%u",
					(nfsd_vers(4, NFSD_TEST) &&
					 nfsd_minorversion(minor, NFSD_TEST)) ?
						'+' : '-',
					minor);

			if (len > remaining)
				break;
			remaining -= len;
			buf += len;
			tlen += len;
		}

	len = snprintf(buf, remaining, "\n");
	if (len > remaining)
		return -EINVAL;
	return tlen + len;
}
Esempio n. 12
0
INT Set_BeaconReq_Proc(
	IN PRTMP_ADAPTER pAd,
	IN PSTRING arg)
{
	INT Loop;
	POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
	UCHAR ifIndex = pObj->ioctl_if;
	UINT Aid = 1;
	UINT ArgIdx;
	PSTRING thisChar;

	RRM_MLME_BCN_REQ_INFO BcnReq;

	ArgIdx = 0;
	NdisZeroMemory(&BcnReq, sizeof(RRM_MLME_BCN_REQ_INFO));

	while ((thisChar = strsep((char **)&arg, "-")) != NULL)
	{
		switch(ArgIdx)
		{
			case 0:	/* Aid. */
				Aid = (UINT8) simple_strtol(thisChar, 0, 16);
				if (!VALID_WCID(Aid))
				{
					DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid));
					return TRUE;
				}
				break;

			case 1: /* Meausre Duration. */
				BcnReq.MeasureDuration = (UINT8) simple_strtol(thisChar, 0, 10);

			case 2: /* Regulator Class */
				BcnReq.RegulatoryClass = (UINT8) simple_strtol(thisChar, 0, 10);
				break;

			case 3: /* BSSID */
				if(strlen(thisChar) != 17)
				{
					DBGPRINT(RT_DEBUG_ERROR,
						("%s: invalid value BSSID.\n", 	__FUNCTION__));
					return TRUE;
				}

				if(strlen(thisChar) == 17)  /*Mac address acceptable format 01:02:03:04:05:06 length 17 */
				{
					PSTRING value;
					for (Loop=0, value = rstrtok(thisChar,":"); value; value = rstrtok(NULL,":"))
					{
						if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) 
							return FALSE;  /*Invalid */

						AtoH(value, &BcnReq.Bssid[Loop++], 1);
					}

					if(Loop != 6)
						return TRUE;
				}
				break;

			case 4: /* SSID */
				BcnReq.pSsid = (PUINT8)thisChar;
				BcnReq.SsidLen = strlen(thisChar);
				break;

			case 5: /* measure channel */
				BcnReq.MeasureCh = (UINT8) simple_strtol(thisChar, 0, 10);
				break;

			case 6: /* measure mode. */
				BcnReq.MeasureMode = (UINT8) simple_strtol(thisChar, 0, 10);
				if (BcnReq.MeasureMode > RRM_BCN_REQ_MODE_BCNTAB)
				{
					DBGPRINT(RT_DEBUG_ERROR,
						("%s: invalid Measure Mode. %d\n", 	__FUNCTION__, BcnReq.MeasureMode));
					return TRUE;
				}
			case 7: /* regulatory class. */
				{
					PSTRING RegClassString;
					int RegClassIdx;

					RegClassIdx = 0;
					while ((RegClassString = strsep((char **)&thisChar, "+")) != NULL)
					{
						BcnReq.ChRepRegulatoryClass[RegClassIdx] =
							(UINT8) simple_strtol(RegClassString, 0, 10);
						RegClassIdx++;
					}
				}
				break;
			
		}
		ArgIdx++;
	}	

	if (ArgIdx < 7 || ArgIdx > 8)
	{
		DBGPRINT(RT_DEBUG_ERROR,
			("%s: invalid args (%d).\n", __FUNCTION__, ArgIdx));
		DBGPRINT(RT_DEBUG_ERROR,
			("eg: iwpriv ra0 set BcnReq=<Aid>-<Duration>-<RegulatoryClass>-<BSSID>-<SSID>-<MeasureCh>-<MeasureMode>-<ChRegClass>\n"));
		return TRUE;
	}

#ifdef RELEASE_EXCLUDE
	DBGPRINT(RT_DEBUG_ERROR, ("%s::Aid = %d\n", __FUNCTION__, Aid));


	DBGPRINT(RT_DEBUG_ERROR, ("%s::Bssid = %02x:%02x:%02x:%02x:%02x:%02x\n",
		__FUNCTION__, BcnReq.Bssid[0], BcnReq.Bssid[1],
		BcnReq.Bssid[2], BcnReq.Bssid[3],
		BcnReq.Bssid[4], BcnReq.Bssid[5]));
	DBGPRINT(RT_DEBUG_ERROR, ("%s::SsidLen = %d\n", __FUNCTION__,
		BcnReq.SsidLen));
	DBGPRINT(RT_DEBUG_ERROR, ("%s::MeasureCh = %d\n", __FUNCTION__,
		BcnReq.MeasureCh));
	DBGPRINT(RT_DEBUG_ERROR, ("%s::RegulatoryDuration=%d\n", __FUNCTION__, BcnReq.MeasureDuration));
	DBGPRINT(RT_DEBUG_ERROR, ("%s::MeasureMode=%d\n", __FUNCTION__, BcnReq.MeasureMode));

	DBGPRINT(RT_DEBUG_ERROR, ("RegulatoryClass="));
	for (ArgIdx=0; ArgIdx<MAX_NUM_OF_REGULATORY_CLASS; ArgIdx++)
	{
		if (BcnReq.ChRepRegulatoryClass[ArgIdx] == 0)
			break;
		DBGPRINT(RT_DEBUG_ERROR, ("%d ", \
		BcnReq.ChRepRegulatoryClass[ArgIdx]));
	}
	DBGPRINT(RT_DEBUG_ERROR, ("\n"));
#endif /* RELEASE_EXCLUDE */

	BcnReq.BcnReqCapFlag.field.ReportCondition = TRUE;
	if (BcnReq.MeasureCh == 255)
		BcnReq.BcnReqCapFlag.field.ChannelRep = TRUE;
	else
		BcnReq.BcnReqCapFlag.field.ChannelRep = FALSE;

	RRM_EnqueueBcnReq(pAd, Aid, ifIndex, &BcnReq);

	return TRUE;
}
static int __init init_pon_batt_volt(char *s)
{
	pon_batt_volt = (int) simple_strtol(s, NULL, 10);

	return 0;
}
/**********************************************************
*  Function:       charge_core_parse_dts
*  Discription:    parse the module dts config value
*  Parameters:   np:device_node
*                      di:charge_core_info
*  return value:  0-sucess or others-fail
**********************************************************/
static int charge_core_parse_dts(struct device_node* np, struct charge_core_info *di)
{
    int ret = 0;
    int i = 0;
    int array_len = 0;
    int idata = 0;
    const char *chrg_data_string = NULL;

    /*ac charge current*/
    ret = of_property_read_u32(np, "iin_ac", &(di->data.iin_ac));
    if(ret)
    {
        hwlog_err("get iin_ac failed\n");
        return -EINVAL;
    }
    hwlog_debug("iin_ac = %d\n",di->data.iin_ac);
    ret = of_property_read_u32(np, "ichg_ac", &(di->data.ichg_ac));
    if(ret)
    {
        hwlog_err("get ichg_ac failed\n");
        return -EINVAL;
    }
    hwlog_debug("ichg_ac = %d\n",di->data.ichg_ac);

    /*fcp charge current */
    ret = of_property_read_u32(np,"iin_fcp",&(di->data.iin_fcp));
    if(ret)
    {
        hwlog_info("get iin_fcp failed ,use iin_ac's value instead \n");
        di->data.iin_fcp = di->data.iin_ac;
    }
    hwlog_debug("iin_fcp = %d\n",di->data.iin_fcp);
    ret = of_property_read_u32(np,"ichg_fcp",&(di->data.ichg_fcp));
    if(ret)
    {
        hwlog_info("get ichg_fcp failed ,use ichg_ac's value instead \n");
        di->data.ichg_fcp = di->data.ichg_ac;
    }
    hwlog_debug("ichg_fcp = %d\n",di->data.ichg_fcp);

    /*usb charge current*/
    ret = of_property_read_u32(np, "iin_usb", &(di->data.iin_usb));
    if(ret)
    {
        hwlog_err("get iin_usb failed\n");
        return -EINVAL;
    }
    hwlog_debug("iin_usb = %d\n",di->data.iin_usb);
    ret = of_property_read_u32(np, "ichg_usb", &(di->data.ichg_usb));
    if(ret)
    {
        hwlog_err("get ichg_usb failed\n");
        return -EINVAL;
    }
    hwlog_debug("ichg_usb = %d\n",di->data.ichg_usb);
    /*nonstandard charge current*/
    ret = of_property_read_u32(np, "iin_nonstd", &(di->data.iin_nonstd));
    if(ret)
    {
        hwlog_err("get iin_nonstd failed\n");
        return -EINVAL;
    }
    hwlog_debug("iin_nonstd = %d\n",di->data.iin_nonstd);
    ret = of_property_read_u32(np, "ichg_nonstd", &(di->data.ichg_nonstd));
    if(ret)
    {
        hwlog_err("get ichg_nonstd failed\n");
        return -EINVAL;
    }
    hwlog_debug("ichg_nonstd = %d\n",di->data.ichg_nonstd);
    /*Charging Downstream Port*/
    ret = of_property_read_u32(np, "iin_bc_usb", &(di->data.iin_bc_usb));
    if(ret)
    {
        hwlog_err("get iin_bc_usb failed\n");
        return -EINVAL;
    }
    hwlog_debug("iin_bc_usb = %d\n",di->data.iin_bc_usb);
    ret = of_property_read_u32(np, "ichg_bc_usb", &(di->data.ichg_bc_usb));
    if(ret)
    {
        hwlog_err("get ichg_bc_usb failed\n");
        return -EINVAL;
    }
    hwlog_debug("ichg_bc_usb = %d\n",di->data.ichg_bc_usb);
    /*VR Charge current*/
    ret = of_property_read_u32(np, "iin_vr", &(di->data.iin_vr));
    if(ret)
    {
        hwlog_err("get iin_vr failed\n");
        return -EINVAL;
    }
    hwlog_debug("iin_vr = %d\n",di->data.iin_vr);
    ret = of_property_read_u32(np, "ichg_vr", &(di->data.ichg_vr));
    if(ret)
    {
        hwlog_err("get ichg_vr failed\n");
        return -EINVAL;
    }
    hwlog_debug("ichg_vr = %d\n",di->data.ichg_vr);
    /*terminal current*/
    ret = of_property_read_u32(np, "iterm", &(di->data.iterm));
    if(ret)
    {
        hwlog_err("get iterm failed\n");
        return -EINVAL;
    }
    hwlog_debug("iterm = %d\n",di->data.iterm);
    /*otg current*/
    ret = of_property_read_u32(np, "otg_curr", &(di->data.otg_curr));
    if(ret)
    {
        hwlog_err("get otg_curr failed\n");
        return -EINVAL;
    }
    hwlog_debug("otg_curr = %d\n",di->data.otg_curr);
    /*segment para type*/
    ret = of_property_read_u32(np, "segment_type", &(di->data.segment_type));
    if(ret)
    {
        hwlog_err("get segment_type failed\n");
        return -EINVAL;
    }
    /*TypeC High mode current*/
    ret = of_property_read_u32(np, "typec_support", &(di->data.typec_support));
    if(ret)
    {
        hwlog_err("get typec support flag!\n");
        return -EINVAL;
    }
    hwlog_info("typec support flag = %d\n",di->data.typec_support);

    ret = of_property_read_u32(np, "iin_typech", &(di->data.iin_typech));
    if(ret)
    {
        hwlog_err("get typec high mode ibus curr failed\n");
        return -EINVAL;
    }
    hwlog_info("typec high mode ibus curr = %d\n",di->data.iin_typech);
    ret = of_property_read_u32(np, "ichg_typech", &(di->data.ichg_typech));
    if(ret)
    {
        hwlog_err("get typec high mode ibat curr failed\n");
        return -EINVAL;
    }
    hwlog_info("typec high mode ibat curr = %d\n",di->data.ichg_typech);
    //vdpm_para
    array_len = of_property_count_strings(np, "vdpm_para");
    if ((array_len <= 0) || (array_len % VDPM_PARA_TOTAL != 0))
    {
        hwlog_err("vdpm_para is invaild,please check vdpm_para number!!\n");
        return -EINVAL;
    }

    if (array_len > VDPM_PARA_LEVEL * VDPM_PARA_TOTAL)
    {
        array_len = VDPM_PARA_LEVEL * VDPM_PARA_TOTAL;
        hwlog_err("vdpm_para is too long,use only front %d paras!!\n", array_len);
        return -EINVAL;
    }

    memset(di->vdpm_para, 0, VDPM_PARA_LEVEL * sizeof(struct charge_vdpm_data)); // data reset to 0

    for (i = 0; i < array_len; i++)
    {
        ret = of_property_read_string_index(np, "vdpm_para", i, &chrg_data_string);
        if (ret)
        {
            hwlog_err("get vdpm_para failed\n");
            return -EINVAL;
        }

        idata = simple_strtol(chrg_data_string, NULL, 10);
        switch (i % VDPM_PARA_TOTAL)
        {
            case VDPM_PARA_CAP_MIN:
                if ((idata < VDPM_CBAT_MIN) || (idata > VDPM_CBAT_MAX))
                {
                    hwlog_err("the vdpm_para cap_min is out of range!!\n");
                    return -EINVAL;
                }
                di->vdpm_para[ i/ (VDPM_PARA_TOTAL)].cap_min = idata;
                break;
            case VDPM_PARA_CAP_MAX:
                if((idata < VDPM_CBAT_MIN) || (idata > VDPM_CBAT_MAX))
                {
                    hwlog_err("the vdpm_para cap_max is out of range!!\n");
                    return -EINVAL;
                }
                di->vdpm_para[i / (VDPM_PARA_TOTAL)].cap_max = idata;
                break;
            case VDPM_PARA_DPM:
                if((idata < VDPM_VOLT_MIN) || (idata > VDPM_VOLT_MAX))
                {
                    hwlog_err("the vdpm_para vin_dpm is out of range!!\n");
                    return -EINVAL;
                }
                di->vdpm_para[i / (VDPM_PARA_TOTAL)].vin_dpm = idata;
                break;
            case VDPM_PARA_CAP_BACK:
                if((idata < 0) || (idata > VDPM_CAP_DETA))
                {
                    hwlog_err("the vdpm_para cap_back is out of range!!\n");
                    return -EINVAL;
                }
                di->vdpm_para[i / (VDPM_PARA_TOTAL)].cap_back = idata;
                break;
            default:
                hwlog_err("get vdpm_para failed\n");
        }
        hwlog_debug("di->vdpm_para[%d][%d] = %d\n", i / (VDPM_PARA_TOTAL),
                   i % (VDPM_PARA_TOTAL), idata);
    }

    /* inductance_para */
    memset(di->inductance_para, 0, INDUCTANCE_PARA_LEVEL * sizeof(struct charge_inductance_data)); // data reset to 0

    array_len = of_property_count_strings(np, "inductance_para");
    if ((array_len <= 0) || (array_len % INDUCTANCE_PARA_TOTAL != 0))
    {
        hwlog_err("inductance_para is invaild,please check inductance_para number!!\n");
        return -EINVAL;
    }
    if (array_len > INDUCTANCE_PARA_LEVEL * INDUCTANCE_PARA_TOTAL)
    {
        array_len = INDUCTANCE_PARA_LEVEL * INDUCTANCE_PARA_TOTAL;
        hwlog_err("inductance_para is too long,use only front %d paras!!\n", array_len);
        return -EINVAL;
    }

    for(i = 0; i < array_len ; i++)
    {
        ret = of_property_read_string_index(np, "inductance_para", i, &chrg_data_string);
        if (ret)
         {
             hwlog_err("get inductance_para failed\n");
             return -EINVAL;
         }

        idata = simple_strtol(chrg_data_string, NULL, 10);
        switch (i % INDUCTANCE_PARA_TOTAL)
        {
            case INDUCTANCE_PARA_CAP_MIN:
                if ((idata < INDUCTANCE_CBAT_MIN) || (idata > INDUCTANCE_CBAT_MAX))
                {
                    hwlog_err("the inductance_para cap_min is out of range!!\n");
                    return -EINVAL;
                }
                di->inductance_para[ i/ (INDUCTANCE_PARA_TOTAL)].cap_min = idata;
                break;
            case INDUCTANCE_PARA_CAP_MAX:
                if ((idata < INDUCTANCE_CBAT_MIN) || (idata > INDUCTANCE_CBAT_MAX))
                {
                    hwlog_err("the inductance_para cap_max is out of range!!\n");
                    return -EINVAL;
                }
                di->inductance_para[i / (INDUCTANCE_PARA_TOTAL)].cap_max = idata;
                break;
            case INDUCTANCE_PARA_IIN:
                if ((idata < INDUCTANCE_IIN_MIN) || (idata > INDUCTANCE_IIN_MAX))
                {
                    hwlog_err("the inductance_para iin is out of range!!\n");
                    return -EINVAL;
                }
                di->inductance_para[i / (INDUCTANCE_PARA_TOTAL)].iin_inductance= idata;
                break;
            case INDUCTANCE_PARA_CAP_BACK:
                if ((idata < 0) || (idata > INDUCTANCE_CAP_DETA))
                {
                    hwlog_err("the inductance_para cap_back is out of range!!\n");
                    return -EINVAL;
                }
                di->inductance_para[i / (INDUCTANCE_PARA_TOTAL)].cap_back = idata;
                break;
            default:
                hwlog_err("get vdpm_para failed\n");
        }
        hwlog_info("di->inductance_para[%d][%d] = %d\n", i / (INDUCTANCE_PARA_TOTAL),
           i % (INDUCTANCE_PARA_TOTAL), idata);
    }

    if(strstr(saved_command_line, "androidboot.swtype=factory") && (!is_hisi_battery_exist()))
    {
        di->data.iin_ac = CHARGE_CURRENT_2000_MA;
        di->data.ichg_ac = CHARGE_CURRENT_1900_MA;
        di->data.iin_bc_usb = CHARGE_CURRENT_2000_MA;
        di->data.ichg_bc_usb = CHARGE_CURRENT_1900_MA;
        hwlog_info("factory version,iin_ac = %d mA,ichg_ac %d mA,iin_bc_usb = %d mA,ichg_bc_usb = %d mA\n",
            di->data.iin_ac,di->data.ichg_ac,di->data.iin_bc_usb,di->data.ichg_bc_usb);
    }
    di->data.iin_max = di->data.iin_ac < di->data.iin_fcp ? di->data.iin_fcp :di->data.iin_ac;
    di->data.ichg_max = di->data.ichg_ac < di->data.ichg_fcp ? di->data.ichg_fcp :di->data.ichg_ac;
    hwlog_info("iin_max = %d mA,ichg_max %d mA\n",di->data.iin_max,di->data.ichg_max);
    return 0;
}
Esempio n. 15
0
/* 2 -- Change ee settings */
int	Set_EECMD_Proc(
	IN	PRTMP_ADAPTER	pAd, 
	IN	PUCHAR			arg)
{
	USHORT i;
	
	i = simple_strtol(arg, 0, 10);
	switch(i)
	{
		case 0:
			{
				USHORT value, k;
				for (k = 0; k < EEPROM_SIZE; k+=2)
				{
					RT28xx_EEPROM_READ16(pAd, k, value);
					DBGPRINT(RT_DEBUG_OFF, ("%4.4x ", value));
					if (((k+2) % 0x20) == 0)
						DBGPRINT(RT_DEBUG_OFF,("\n"));
				}
				
			}
			break;
		case 1:
			if (pAd->infType == RTMP_DEV_INF_RBUS)
			{
				DBGPRINT(RT_DEBUG_OFF, ("EEPROM reset to default......\n"));
				DBGPRINT(RT_DEBUG_OFF, ("The last byte of MAC address will be re-generated...\n"));
				if (rtmp_ee_flash_reset(nv_ee_start) != NDIS_STATUS_SUCCESS)
				{
					DBGPRINT(RT_DEBUG_ERROR, ("Set_EECMD_Proc: rtmp_ee_flash_reset() failed\n"));
					return FALSE;
				}
			
				// Random number for the last bytes of MAC address
				{
					USHORT  Addr45;

					rtmp_ee_flash_read(pAd, 0x08, &Addr45);
					Addr45 = Addr45 & 0xff;
					Addr45 = Addr45 | (RandomByte(pAd)&0xf8) << 8;
					DBGPRINT(RT_DEBUG_OFF, ("Addr45 = %4x\n", Addr45));
					rtmp_ee_flash_write(pAd, 0x08, Addr45);
				}
			
				if ((rtmp_ee_flash_read(pAd, 0, &i) != 0x2880) && (rtmp_ee_flash_read(pAd, 0, &i) != 0x2860))
				{
					DBGPRINT(RT_DEBUG_ERROR, ("Set_EECMD_Proc: invalid eeprom\n"));
					return FALSE;
				}
			}
			break;
		case 2:
			{
				USHORT offset, value = 0;
				PUCHAR p;
				
				p = arg+2;
				offset = simple_strtol(p, 0, 10);
				p+=2;
				while (*p != '\0')
				{
					if (*p >= '0' && *p <= '9')
						value = (value << 4) + (*p - 0x30);
					else if (*p >= 'a' && *p <= 'f')
						value = (value << 4) + (*p - 0x57);
					else if (*p >= 'A' && *p <= 'F')
						value = (value << 4) + (*p - 0x37);
					p++;
				}
				RT28xx_EEPROM_WRITE16(pAd, offset, value);
			}
			break;
		default:
			break;
	}

	return TRUE;
}
Esempio n. 16
0
INT Set_IgmpSn_DelEntry_Proc(
	IN PRTMP_ADAPTER pAd, 
	IN PSTRING arg)
{
	INT i, memberCnt = 0;
	BOOLEAN bGroupId = 1;
	PSTRING value;
	PSTRING thisChar;
	UCHAR IpAddr[4];
	UCHAR Addr[ETH_LENGTH_OF_ADDRESS];
	UCHAR GroupId[ETH_LENGTH_OF_ADDRESS];
	PUCHAR *pAddr = (PUCHAR *)&Addr;
	PNET_DEV pDev;
	POS_COOKIE pObj;
	UCHAR ifIndex;

	pObj = (POS_COOKIE) pAd->OS_Cookie;
	ifIndex = pObj->ioctl_if;

	pDev = (ifIndex == MAIN_MBSSID) ? (pAd->net_dev) : (pAd->ApCfg.MBSSID[ifIndex].MSSIDDev);

	while ((thisChar = strsep((char **)&arg, "-")) != NULL)
	{
		/* refuse the Member if it's not a MAC address. */
		if((bGroupId == 0) && (strlen(thisChar) != 17))
			continue;

		if(strlen(thisChar) == 17)  /*Mac address acceptable format 01:02:03:04:05:06 length 17 */
		{
			for (i=0, value = rstrtok(thisChar,":"); value; value = rstrtok(NULL,":")) 
			{
				if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) 
					return FALSE;  /*Invalid */

				AtoH(value, &Addr[i++], 1);
			}

			if(i != 6)
				return FALSE;  /*Invalid */
		}
		else
		{
			for (i=0, value = rstrtok(thisChar,"."); value; value = rstrtok(NULL,".")) 
			{
				if((strlen(value) > 0) && (strlen(value) <= 3)) 
				{
					int ii;
					for(ii=0; ii<strlen(value); ii++)
						if (!isxdigit(*(value + ii)))
							return FALSE;
				}
				else
					return FALSE;  /*Invalid */

				IpAddr[i] = (UCHAR)simple_strtol(value, NULL, 10);
				i++;
			}

			if(i != 4)
				return FALSE;  /*Invalid */

			ConvertMulticastIP2MAC(IpAddr, (PUCHAR *)&pAddr, ETH_P_IP);
		}

		if(bGroupId == 1)
			COPY_MAC_ADDR(GroupId, Addr);
		else
			memberCnt++;

		if (memberCnt > 0 )
			MulticastFilterTableDeleteEntry(pAd, (PUCHAR)GroupId, Addr, pDev);

		bGroupId = 0;
	}

	if(memberCnt == 0)
		MulticastFilterTableDeleteEntry(pAd, (PUCHAR)GroupId, NULL, pDev);

	DBGPRINT(RT_DEBUG_TRACE, ("%s (%2X:%2X:%2X:%2X:%2X:%2X)\n",
		__FUNCTION__, Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5]));

	return TRUE;
}
Esempio n. 17
0
static ssize_t
vr_var_store(int *var, const char *page, size_t count)
{
*var = simple_strtol(page, NULL, 10);
return count;
}
static int dhd_preinit_proc(dhd_pub_t *dhd, int ifidx, char *name, char *value)
{
	int var_int;
	wl_country_t cspec = {{0}, -1, {0}};
	char *revstr;
	char *endptr = NULL;
	int iolen;
	char smbuf[WLC_IOCTL_SMLEN*2];
	int roam_trigger[2] = {CUSTOM_ROAM_TRIGGER_SETTING, WLC_BAND_ALL};
#ifdef ROAM_AP_ENV_DETECTION
	int roam_env_mode = AP_ENV_INDETERMINATE;
#endif /* ROAM_AP_ENV_DETECTION */

	if (!strcmp(name, "country")) {
		revstr = strchr(value, '/');
		if (revstr) {
			cspec.rev = strtoul(revstr + 1, &endptr, 10);
			memcpy(cspec.country_abbrev, value, WLC_CNTRY_BUF_SZ);
			cspec.country_abbrev[2] = '\0';
			memcpy(cspec.ccode, cspec.country_abbrev, WLC_CNTRY_BUF_SZ);
			memset(smbuf, 0, sizeof(smbuf));
			printf("config country code is country : %s, rev : %d !!\n",
				cspec.country_abbrev, cspec.rev);
			iolen = bcm_mkiovar("country", (char*)&cspec, sizeof(cspec),
				smbuf, sizeof(smbuf));
			return dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR,
				smbuf, iolen, TRUE, 0);
		}
		return dhd_wl_ioctl_cmd(dhd, WLC_SET_COUNTRY,
			value, WLC_CNTRY_BUF_SZ, TRUE, 0);
	} else if (!strcmp(name, "roam_scan_period")) {
		var_int = (int)simple_strtol(value, NULL, 0);
		return dhd_wl_ioctl_cmd(dhd, WLC_SET_ROAM_SCAN_PERIOD,
			&var_int, sizeof(var_int), TRUE, 0);
	} else if (!strcmp(name, "roam_delta")) {
		struct {
			int val;
			int band;
		} x;
		x.val = (int)simple_strtol(value, NULL, 0);
		x.band = WLC_BAND_ALL;
		return dhd_wl_ioctl_cmd(dhd, WLC_SET_ROAM_DELTA, &x, sizeof(x), TRUE, 0);
	} else if (!strcmp(name, "roam_trigger")) {
		int ret = 0;

		roam_trigger[0] = (int)simple_strtol(value, NULL, 0);
		roam_trigger[1] = WLC_BAND_ALL;
		ret = dhd_wl_ioctl_cmd(dhd, WLC_SET_ROAM_TRIGGER,
			&roam_trigger, sizeof(roam_trigger), TRUE, 0);

#ifdef ROAM_AP_ENV_DETECTION
		if (roam_trigger[0] == WL_AUTO_ROAM_TRIGGER) {
			char iovbuf[128];
			bcm_mkiovar("roam_env_detection", (char *)&roam_env_mode,
				4, iovbuf, sizeof(iovbuf));
			if (dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR, iovbuf,
				sizeof(iovbuf), TRUE, 0) == BCME_OK) {
				dhd->roam_env_detection = TRUE;
			} else {
				dhd->roam_env_detection = FALSE;
			}
		}
#endif /* ROAM_AP_ENV_DETECTION */
		return ret;
	} else if (!strcmp(name, "PM")) {
		int ret = 0;
		var_int = (int)simple_strtol(value, NULL, 0);

		ret = dhd_wl_ioctl_cmd(dhd, WLC_SET_PM,
			&var_int, sizeof(var_int), TRUE, 0);

#if defined(CONFIG_PM_LOCK)
		if (var_int == 0) {
			g_pm_control = TRUE;
			printk("%s var_int=%d don't control PM\n", __func__, var_int);
		} else {
			g_pm_control = FALSE;
			printk("%s var_int=%d do control PM\n", __func__, var_int);
		}
#endif /* CONFIG_PM_LOCK */

		return ret;
	}
#ifdef WLBTAMP
	else if (!strcmp(name, "btamp_chan")) {
		int btamp_chan;
		int iov_len = 0;
		char iovbuf[128];
		int ret;

		btamp_chan = (int)simple_strtol(value, NULL, 0);
		iov_len = bcm_mkiovar("btamp_chan", (char *)&btamp_chan, 4, iovbuf, sizeof(iovbuf));
		if ((ret  = dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR, iovbuf, iov_len, TRUE, 0) < 0))
			DHD_ERROR(("%s btamp_chan=%d set failed code %d\n",
				__FUNCTION__, btamp_chan, ret));
		else
			DHD_ERROR(("%s btamp_chan %d set success\n", __FUNCTION__, btamp_chan));
	}
#endif /* WLBTAMP */
	 else if (!strcmp(name, "band")) {
		int ret;
		if (!strcmp(value, "auto"))
			var_int = WLC_BAND_AUTO;
		else if (!strcmp(value, "a"))
			var_int = WLC_BAND_5G;
		else if (!strcmp(value, "b"))
			var_int = WLC_BAND_2G;
		else if (!strcmp(value, "all"))
			var_int = WLC_BAND_ALL;
		else {
			printk("set band value should be one of the a or b or all\n");
			var_int = WLC_BAND_AUTO;
		}
		if ((ret = dhd_wl_ioctl_cmd(dhd, WLC_SET_BAND,
			&var_int, sizeof(var_int), TRUE, 0)) < 0)
			printk(" set band err=%d\n", ret);

		return ret;

	} else if (!strcmp(name, "cur_etheraddr")) {
		struct ether_addr ea;
		char buf[32];
		uint iovlen;
		int ret;

		bcm_ether_atoe(value, &ea);

		ret = memcmp(&ea.octet, dhd->mac.octet, ETHER_ADDR_LEN);
		if (ret == 0) {
			DHD_ERROR(("%s: Same Macaddr\n", __FUNCTION__));
			return 0;
		}

		DHD_ERROR(("%s: Change Macaddr = %02X:%02X:%02X:%02X:%02X:%02X\n", __FUNCTION__,
			ea.octet[0], ea.octet[1], ea.octet[2],
			ea.octet[3], ea.octet[4], ea.octet[5]));

		iovlen = bcm_mkiovar("cur_etheraddr", (char*)&ea, ETHER_ADDR_LEN, buf, 32);

		ret = dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR, buf, iovlen, TRUE, 0);
		if (ret < 0) {
			DHD_ERROR(("%s: can't set MAC address , error=%d\n", __FUNCTION__, ret));
			return ret;
		} else {
			memcpy(dhd->mac.octet, (void *)&ea, ETHER_ADDR_LEN);
			return ret;
		}
	}
	else if (!strcmp(name, "lpc")) {
		int ret = 0;
		char buf[32];
		uint iovlen;
		var_int = (int)simple_strtol(value, NULL, 0);
		if (dhd_wl_ioctl_cmd(dhd, WLC_DOWN, NULL, 0, TRUE, 0) < 0) {
			DHD_ERROR(("%s: wl down failed\n", __FUNCTION__));
		}
		iovlen=bcm_mkiovar("lpc", (char *)&var_int, 4, buf, sizeof(buf));
		if ((ret = dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR, buf, iovlen, TRUE, 0)) < 0) {
			DHD_ERROR(("%s Set lpc failed  %d\n", __FUNCTION__, ret));
		}
		if (dhd_wl_ioctl_cmd(dhd, WLC_UP, NULL, 0, TRUE, 0) < 0) {
			DHD_ERROR(("%s: wl up failed\n", __FUNCTION__));
		}
		return ret;
	}
	else if (!strcmp(name, "vht_features")) {
		int ret = 0;
		char buf[32];
		uint iovlen;
		var_int = (int)simple_strtol(value, NULL, 0);

		if (dhd_wl_ioctl_cmd(dhd, WLC_DOWN, NULL, 0, TRUE, 0) < 0) {
			DHD_ERROR(("%s: wl down failed\n", __FUNCTION__));
		}
		iovlen=bcm_mkiovar("vht_features", (char *)&var_int, 4, buf, sizeof(buf));
		if ((ret = dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR, buf, iovlen, TRUE, 0)) < 0) {
			DHD_ERROR(("%s Set vht_features failed  %d\n", __FUNCTION__, ret));
		}
		if (dhd_wl_ioctl_cmd(dhd, WLC_UP, NULL, 0, TRUE, 0) < 0) {
			DHD_ERROR(("%s: wl up failed\n", __FUNCTION__));
		}
		return ret;
	}
	else {
		uint iovlen;
		char iovbuf[WLC_IOCTL_SMLEN];

		/* wlu_iovar_setint */
		var_int = (int)simple_strtol(value, NULL, 0);

		/* Setup timeout bcn_timeout from dhd driver 4.217.48 */
		if (!strcmp(name, "roam_off")) {
			/* Setup timeout if Beacons are lost to report link down */
			if (var_int) {
				uint bcn_timeout = 2;
				bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4,
					iovbuf, sizeof(iovbuf));
				dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR, iovbuf, sizeof(iovbuf), TRUE, 0);
			}
		}
		/* Setup timeout bcm_timeout from dhd driver 4.217.48 */

		DHD_INFO(("%s:[%s]=[%d]\n", __FUNCTION__, name, var_int));

		iovlen = bcm_mkiovar(name, (char *)&var_int, sizeof(var_int),
			iovbuf, sizeof(iovbuf));
		return dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR,
			iovbuf, iovlen, TRUE, 0);
	}

	return 0;
}
Esempio n. 19
0
int do_anatest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	short val;
	int i;
	int volt;
	struct io *out;
	struct io *in;

	out = (struct io *)0xf0300090;
	in = (struct io *)0xf0300000;

	i = simple_strtol (argv[1], NULL, 10);

	volt = 0;
	printf("Setting Channel %d to %dV...\n", i, volt);
	out_be16((void *)&(out[i].val), (volt * 0x7fff) / 10);
	udelay(10000);
	val = in_be16((void *)&(in[i*2].val));
	printf("-> InChannel %d: 0x%04x=%dV\n", i*2, val, (val * 4000) / 0x7fff);
	if ((val < ((volt * 0x7fff) / 40) - ERROR_DELTA) ||
	    (val > ((volt * 0x7fff) / 40) + ERROR_DELTA)) {
		printf("ERROR! (min=0x%04x max=0x%04x)\n", ((volt * 0x7fff) / 40) - ERROR_DELTA,
		       ((volt * 0x7fff) / 40) + ERROR_DELTA);
		return -1;
	}
	val = in_be16((void *)&(in[i*2+1].val));
	printf("-> InChannel %d: 0x%04x=%dV\n", i*2+1, val, (val * 4000) / 0x7fff);
	if ((val < ((volt * 0x7fff) / 40) - ERROR_DELTA) ||
	    (val > ((volt * 0x7fff) / 40) + ERROR_DELTA)) {
		printf("ERROR! (min=0x%04x max=0x%04x)\n", ((volt * 0x7fff) / 40) - ERROR_DELTA,
		       ((volt * 0x7fff) / 40) + ERROR_DELTA);
		return -1;
	}

	volt = 5;
	printf("Setting Channel %d to %dV...\n", i, volt);
	out_be16((void *)&(out[i].val), (volt * 0x7fff) / 10);
	udelay(10000);
	val = in_be16((void *)&(in[i*2].val));
	printf("-> InChannel %d: 0x%04x=%dV\n", i*2, val, (val * 4000) / 0x7fff);
	if ((val < ((volt * 0x7fff) / 40) - ERROR_DELTA) ||
	    (val > ((volt * 0x7fff) / 40) + ERROR_DELTA)) {
		printf("ERROR! (min=0x%04x max=0x%04x)\n", ((volt * 0x7fff) / 40) - ERROR_DELTA,
		       ((volt * 0x7fff) / 40) + ERROR_DELTA);
		return -1;
	}
	val = in_be16((void *)&(in[i*2+1].val));
	printf("-> InChannel %d: 0x%04x=%dV\n", i*2+1, val, (val * 4000) / 0x7fff);
	if ((val < ((volt * 0x7fff) / 40) - ERROR_DELTA) ||
	    (val > ((volt * 0x7fff) / 40) + ERROR_DELTA)) {
		printf("ERROR! (min=0x%04x max=0x%04x)\n", ((volt * 0x7fff) / 40) - ERROR_DELTA,
		       ((volt * 0x7fff) / 40) + ERROR_DELTA);
		return -1;
	}

	volt = 10;
	printf("Setting Channel %d to %dV...\n", i, volt);
	out_be16((void *)&(out[i].val), (volt * 0x7fff) / 10);
	udelay(10000);
	val = in_be16((void *)&(in[i*2].val));
	printf("-> InChannel %d: 0x%04x=%dV\n", i*2, val, (val * 4000) / 0x7fff);
	if ((val < ((volt * 0x7fff) / 40) - ERROR_DELTA) ||
	    (val > ((volt * 0x7fff) / 40) + ERROR_DELTA)) {
		printf("ERROR! (min=0x%04x max=0x%04x)\n", ((volt * 0x7fff) / 40) - ERROR_DELTA,
		       ((volt * 0x7fff) / 40) + ERROR_DELTA);
		return -1;
	}
	val = in_be16((void *)&(in[i*2+1].val));
	printf("-> InChannel %d: 0x%04x=%dV\n", i*2+1, val, (val * 4000) / 0x7fff);
	if ((val < ((volt * 0x7fff) / 40) - ERROR_DELTA) ||
	    (val > ((volt * 0x7fff) / 40) + ERROR_DELTA)) {
		printf("ERROR! (min=0x%04x max=0x%04x)\n", ((volt * 0x7fff) / 40) - ERROR_DELTA,
		       ((volt * 0x7fff) / 40) + ERROR_DELTA);
		return -1;
	}

	printf("Channel %d OK!\n", i);

	return 0;
}
Esempio n. 20
0
static int __init load_ramdisk(char *str)
{
	rd_doload = simple_strtol(str,NULL,0) & 3;
	return 1;
}
Esempio n. 21
0
static int __init ramdisk_start_setup(char *str)
{
	rd_image_start = simple_strtol(str,NULL,0);
	return 1;
}
Esempio n. 22
0
int _get_mmap(U8 *buffer, char *id, MMapInfo_s *mmapInfo)
{
    char *str=NULL;
    char *ptr=NULL;
    UBOOT_TRACE("IN\n");
    if((buffer==NULL)||(id==NULL)||(mmapInfo==NULL))
    {
        UBOOT_ERROR("One of the input parameters is null pointer\n");
        return -1;
    }
    UBOOT_DEBUG("@@id=%s\n",id);
    str=malloc(CMD_BUF);
    if(str==NULL)
    {
        UBOOT_ERROR("malloc for str fail\n");
        return -1;
    }

    memset(str,0,CMD_BUF);
    snprintf(str,CMD_BUF,"%s_ADR",id);
    UBOOT_DEBUG("str=%s\n",str);
    ptr=pattern_search((char *)mmap_buffer,mmap_buffer_size,str);
    if(ptr!=NULL)
    {
        ptr=pattern_search(ptr,mmap_buffer_size-((unsigned int)ptr-(unsigned int)mmap_buffer+1),"0x");
    }
    if(ptr==NULL)
    {
        UBOOT_ERROR("get addr from mmap fail\n");
        return -1;
    }
    memset(str,0,CMD_BUF);
    snprintf(str,NUM_LEN,"%s\n",ptr);
    UBOOT_DEBUG("str=%s\n",str);
    mmapInfo->u32Addr=(U32)simple_strtol(str,NULL,16);

    memset(str,0,CMD_BUF);
    snprintf(str,CMD_BUF,"%s_LEN",id);
    UBOOT_DEBUG("str=%s\n",str);
    ptr=pattern_search((char *)mmap_buffer,mmap_buffer_size,str);
    if(ptr!=NULL)
    {
        ptr=pattern_search(ptr,mmap_buffer_size-((unsigned int)ptr-(unsigned int)mmap_buffer+1),"0x");
    }
    if(ptr==NULL)
    {
        UBOOT_ERROR("get length from mmap fail\n");
        return -1;
    }
    memset(str,0,CMD_BUF);
    snprintf(str,NUM_LEN,"%s\n",ptr);
    UBOOT_DEBUG("str=%s\n",str);
    mmapInfo->u32Size=(U32)simple_strtol(str,NULL,16);
    
    //For an example
    //#define E_MMAP_ID_PM51_USAGE_MEM_MEMORY_TYPE                   (MIU0 | TYPE_NONE | UNCACHE)
    memset(str,0,CMD_BUF);
    snprintf(str,CMD_BUF,"%s_MEMORY_TYPE",id);
    UBOOT_DEBUG("str=%s",str);
    ptr=pattern_search((char *)mmap_buffer,mmap_buffer_size,str);
    if(ptr!=NULL)
    {
        ptr=pattern_search(ptr,mmap_buffer_size-((unsigned int)ptr-(unsigned int)mmap_buffer+1),"(");
    }
    if(ptr==NULL)
    {
        UBOOT_ERROR("get memory type from mmap fail\n");
        return -1;
    }
    ptr++;
    if(memcmp(ptr, "MIU0", strlen("MIU0"))==0)
    {
        UBOOT_DEBUG("In MIU0\n");
        mmapInfo->b_is_miu0=1;
    }
    else
    {
        UBOOT_DEBUG("In MIU1\n");
        mmapInfo->b_is_miu0=0;    
    }
    
    mmapInfo->u32Align=0;
    mmapInfo->u32gID=0;    
    mmapInfo->u8Layer=0;      

    free(str);
    UBOOT_TRACE("OK\n");
    return 0;
}
Esempio n. 23
0
//you can type "showtb 0" in mboot console to see registered cmd.
void App_Register_ToKernel(void)
{
    // Add_Command_Table ("delay 0" , 0, STAGE_TOKERNEL);

    // check the boot mode.if normal mode, run through this cmd.
    #ifdef CONFIG_DISPLAY_LOGO
    unsigned int  u8IsSkipInitPanel = 0;
    if (MDrv_PM_GetWakeupSource() == E_PM_WAKEUPSRC_RTC2)
    {
        u8IsSkipInitPanel = 1;
	}	
    char* opt_logo = NULL;
    opt_logo = getenv("logo");
    if(opt_logo != NULL)
    {
        int logo_on = 0;
        logo_on = simple_strtol(opt_logo, NULL, 10);
        if(logo_on > 0 && logo_on < 3)
        {
        	if(0 == u8IsSkipInitPanel)
        	{
            	Add_Command_Table ("bootlogo" , 0, STAGE_TOKERNEL);
        	}
#if defined (CONFIG_URSA_6M40)
            Add_Command_Table ("ursa_lvds_on" , 0, STAGE_TOKERNEL);
#endif
#if defined (CONFIG_URSA_6M30)
			//open local diming, only for cmo  65" panel, msd6369+6m30qsc
			Add_Command_Table ("pnl_localdimming_on" , 0, STAGE_TOKERNEL);
#endif

        }
    }
    #endif

    #ifdef CONFIG_POWER_MUSIC
    char* opt_music = NULL;
    opt_music = getenv("music");
    if(opt_music != NULL)
    {
        int music_on = 0;
        music_on = simple_strtol(opt_music, NULL, 10);
        if(music_on > 0 && music_on < 3)
		{        	
			if(0 == u8IsSkipInitPanel)
        	{
            	Add_Command_Table ("bootmusic" , 0, STAGE_TOKERNEL);
        	}
        }
    }
    #endif

    #ifdef CONFIG_GENERIC_MMC
		Add_Command_Table ("mmc slcrelwrchk" , 0, STAGE_TOKERNEL);
    #endif
    #if (CONFIG_WDT)
	    Add_Command_Table ("wdt_enable 20" , 0, STAGE_TOKERNEL);
	#endif

	#if (TEMP_SECURE_BOOT)
	    Add_Command_Table ("bootNuttx 20" , 0, STAGE_TOKERNEL);
	#endif
}
Esempio n. 24
0
/*
    ========================================================================

    Routine Description:
        In kernel mode read parameters from file

    Arguments:
        src                     the location of the file.
        dest                        put the parameters to the destination.
        Length                  size to read.

    Return Value:
        None

    Note:

    ========================================================================
*/
void rtmp_read_wapi_parms_from_file(
		IN  PRTMP_ADAPTER pAd, 
		PSTRING tmpbuf, 
		PSTRING buffer)
{	
	UINT32					ip_addr;
#ifdef CONFIG_AP_SUPPORT	
	INT						apidx = 0;
#endif // CONFIG_AP_SUPPORT //

	PCOMMON_WAPI_INFO pInfo = &pAd->CommonCfg.comm_wapi_info;
	
	// wapi interface name
	if (RTMPGetKeyParameter("Wapiifname", tmpbuf, 32, buffer, TRUE))
	{
		if (strlen(tmpbuf) > 0)
		{
			NdisMoveMemory(pInfo->wapi_ifname, tmpbuf, strlen(tmpbuf));
			pInfo->wapi_ifname_len = strlen(tmpbuf); 
			
			DBGPRINT(RT_DEBUG_TRACE, ("Wapiifname=%s, len=%d\n", 
														pInfo->wapi_ifname, 
														pInfo->wapi_ifname_len));
		}
	}
	

	// WapiAsCertPath
	if (RTMPGetKeyParameter("WapiAsCertPath", tmpbuf, 128, buffer, TRUE))
	{
		if (strlen(tmpbuf) > 0)
		{
			NdisMoveMemory(pInfo->as_cert_path, tmpbuf, strlen(tmpbuf));
			pInfo->as_cert_path_len = strlen(tmpbuf); 
			
			DBGPRINT(RT_DEBUG_TRACE, ("WapiAsCertPath=%s, len=%d\n", 
														pInfo->as_cert_path, 
														pInfo->as_cert_path_len));
		}
	}

	// WapiUserCertPath
	if (RTMPGetKeyParameter("WapiUserCertPath", tmpbuf, 128, buffer, TRUE))
	{
		if (strlen(tmpbuf) > 0)
		{
			NdisMoveMemory(pInfo->user_cert_path, tmpbuf, strlen(tmpbuf));
			pInfo->user_cert_path_len = strlen(tmpbuf); 
			
			DBGPRINT(RT_DEBUG_TRACE, ("WapiUserCertPath=%s, len=%d\n", 
														pInfo->user_cert_path, 
														pInfo->user_cert_path_len));
		}
	}

	// WapiAsIpAddr
	if (RTMPGetKeyParameter("WapiAsIpAddr", tmpbuf, 32, buffer, TRUE))
	{
		if (rtinet_aton(tmpbuf, &ip_addr))
     	{
            pInfo->wapi_as_ip = ip_addr;  
			DBGPRINT(RT_DEBUG_TRACE, ("WapiAsIpAddr=%s(%x)\n", tmpbuf, pInfo->wapi_as_ip));
		}	    
	}

	// WapiAsPort
	if (RTMPGetKeyParameter("WapiAsPort", tmpbuf, 32, buffer, TRUE))
	{
		pInfo->wapi_as_port = simple_strtol(tmpbuf, 0, 10); 
		DBGPRINT(RT_DEBUG_TRACE, ("WapiAsPort=%d\n", pInfo->wapi_as_port));			   
	}

	// WapiUskRekeyMethod
	if (RTMPGetKeyParameter("WapiUskRekeyMethod", tmpbuf, 32, buffer, TRUE))
	{		
		if ((strcmp(tmpbuf, "TIME") == 0) || (strcmp(tmpbuf, "time") == 0))
			pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_TIME;
		else if ((strcmp(tmpbuf, "PKT") == 0) || (strcmp(tmpbuf, "pkt") == 0))
			pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_PKT;
		else
			pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_DISABLE;

		DBGPRINT(RT_DEBUG_TRACE, ("WapiUskRekeyMethod=%d\n", pAd->CommonCfg.wapi_usk_rekey_method));			   
	}

	// WapiUskRekeyThreshold
	if (RTMPGetKeyParameter("WapiUskRekeyThreshold", tmpbuf, 32, buffer, TRUE))
	{			
		pAd->CommonCfg.wapi_usk_rekey_threshold = simple_strtol(tmpbuf, 0, 10); 
		DBGPRINT(RT_DEBUG_TRACE, ("WapiUskRekeyThreshold=%d\n", pAd->CommonCfg.wapi_usk_rekey_threshold));			   
	}

	// WapiMskRekeyMethod
	if (RTMPGetKeyParameter("WapiMskRekeyMethod", tmpbuf, 32, buffer, TRUE))
	{		
		if ((strcmp(tmpbuf, "TIME") == 0) || (strcmp(tmpbuf, "time") == 0))
			pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_TIME;
		else if ((strcmp(tmpbuf, "PKT") == 0) || (strcmp(tmpbuf, "pkt") == 0))
			pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_PKT;
		else
			pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_DISABLE;

		DBGPRINT(RT_DEBUG_TRACE, ("WapiMskRekeyMethod=%d\n", pAd->CommonCfg.wapi_msk_rekey_method));			   
	}

	// WapiMskRekeyThreshold
	if (RTMPGetKeyParameter("WapiMskRekeyThreshold", tmpbuf, 32, buffer, TRUE))
	{
		pAd->CommonCfg.wapi_msk_rekey_threshold = simple_strtol(tmpbuf, 0, 10); 
		DBGPRINT(RT_DEBUG_TRACE, ("WapiMskRekeyThreshold=%d\n", pAd->CommonCfg.wapi_msk_rekey_threshold));			   
	}
	
#ifdef CONFIG_AP_SUPPORT
	IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
	{						
		STRING tok_str[16];

		// WapiPskX		
		for (apidx = 0; apidx < pAd->ApCfg.BssidNum; apidx++)
		{
			sprintf(tok_str, "WapiPsk%d", apidx + 1);
			
			NdisZeroMemory(pAd->ApCfg.MBSSID[apidx].WAPIPassPhrase, 64);
			pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen = 0;
			if(RTMPGetKeyParameter(tok_str, tmpbuf, 65, buffer, FALSE))
			{								    
			    if (strlen(tmpbuf) >= 8 && strlen(tmpbuf) <= 64)
			    {                                    
			        NdisMoveMemory(pAd->ApCfg.MBSSID[apidx].WAPIPassPhrase, tmpbuf, strlen(tmpbuf));
			        pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen = strlen(tmpbuf);
   					DBGPRINT(RT_DEBUG_TRACE, ("IF(ra%d) WapiPsk=(%s), len=%d\n", apidx, tmpbuf, strlen(tmpbuf)));						
			    }
				else
				{
					if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWAIPSK)
					{
						pAd->ApCfg.MBSSID[apidx].AuthMode = Ndis802_11AuthModeOpen;
						pAd->ApCfg.MBSSID[apidx].WepStatus = Ndis802_11EncryptionDisabled;
					}
					DBGPRINT(RT_DEBUG_ERROR, ("IF(ra%d) The length of WAPI PSKPassPhrase is invalid(len=%d). \n", apidx, strlen(tmpbuf)));
				}																			
			}
		}					
	}
#endif // CONFIG_AP_SUPPORT //

	

	// WapiPskType
	if (RTMPGetKeyParameter("WapiPskType", tmpbuf, 32, buffer, TRUE))
	{		
		INT	err;

#ifdef CONFIG_AP_SUPPORT
		IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
		{
			PSTRING macptr;
			
			for (apidx = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), apidx++)
		    {
				err = 0;
			
				if (apidx >= pAd->ApCfg.BssidNum)
					break;

				// HEX
				if(simple_strtol(macptr, 0, 10) == 0)
				{
					pAd->ApCfg.MBSSID[apidx].WapiPskType = HEX_MODE;
		
					if (pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen % 2 != 0)
					{
						err = 1;
						DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) The WAPI-PSK key length MUST be even in Hex mode\n", apidx));						
					}						
				}
				// ASCII
				else	
				{
					pAd->ApCfg.MBSSID[apidx].WapiPskType = ASCII_MODE;
				}
				
				if (err)
				{
					pAd->ApCfg.MBSSID[apidx].AuthMode = Ndis802_11AuthModeOpen;
					pAd->ApCfg.MBSSID[apidx].WepStatus = Ndis802_11EncryptionDisabled;
				}
				else
					DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) WapiPskType=%s\n", apidx, (pAd->ApCfg.MBSSID[apidx].WapiPskType == HEX_MODE) ? "HEX" : "ASCII"));
		    }
		}
#endif // CONFIG_AP_SUPPORT //

				
	}
Esempio n. 25
0
static int __init supersonic_disablesdcard_setup(char *str)
{
	opt_disable_sdcard = (bool)simple_strtol(str, NULL, 0);
	return 1;
}
Esempio n. 26
0
static int __init softlockup_all_cpu_backtrace_setup(char *str)
{
	sysctl_softlockup_all_cpu_backtrace =
		!!simple_strtol(str, NULL, 0);
	return 1;
}
int misc_init_r(void)
{
	char *cmdline, *p1;
	int i, ddr_size = 0, cpu;
	u32 base, size;
	u32 max_preferred_freq = 0, max_freq = 0, maxfreqflg = 0;
#ifdef CONFIG_RAMDUMP
	char *s;
	int ramdump;
#endif

	if (pxa_is_warm_reset())
		setenv("bootdelay", "-1");

#if defined(CONFIG_MMP_DISP)
	if (!fastboot)
		show_logo();
#endif

	cmdline = malloc(COMMAND_LINE_SIZE);
	strncpy(cmdline, getenv("bootargs"), COMMAND_LINE_SIZE);

	remove_cmdline_param(cmdline, "ddr_mode=");
	sprintf(cmdline + strlen(cmdline), " ddr_mode=%d", ddr_mode);

	/* set the cma range, we can change it according to
	 * system configuration */
	remove_cmdline_param(cmdline, "cma=");
	remove_cmdline_param(cmdline, "cgourp_disable=");
	remove_cmdline_param(cmdline, "androidboot.low_ram=");
	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
		if (gd->bd->bi_dram[i].size == 0)
			break;
		ddr_size += gd->bd->bi_dram[i].size;
	}

	/* ION reserved here for uboot running for EMMD protection */
	if (ddr_size > SZ_512M + SZ_256M) {
		sprintf(cmdline + strlen(cmdline), " cma=112M");
		/*
		 * cgroup will only enabled for low_ram case,
		 * for high ram case disable cgroup function
		 */
		sprintf(cmdline + strlen(cmdline), " cgroup_disable=memory");
	} else
		sprintf(cmdline + strlen(cmdline), " cma=64M androidboot.low_ram=true");

	remove_cmdline_param(cmdline, "ioncarv=");
	base = CONFIG_SYS_TEXT_BASE;
	size = SZ_16M;
	if (((base + size) > ddr_size))
		printf("ERROR: wrong ION setting!!");

	sprintf(cmdline + strlen(cmdline), " ioncarv=%dM@0x%08x", size >> 20, base);

#ifdef CONFIG_RAMDUMP
	rd_mems[0].start = CONFIG_TZ_HYPERVISOR_SIZE;
	rd_mems[0].end = base;
	rd_mems[1].start = base + size;
	rd_mems[1].end = ddr_size;
#endif

	/* if there's new maxfreq request, add it to bootargs */
	max_preferred_freq = get_sku_max_freq();
	if (max_preferred_freq) {
		if (max_preferred_freq <= 1183)
			max_preferred_freq = 1183;
		else
			max_preferred_freq = 1248;
		remove_cmdline_param(cmdline, "max_freq=");
		sprintf(cmdline + strlen(cmdline),
			" max_freq=%u", max_preferred_freq);
		max_freq = max_preferred_freq;
		maxfreqflg = 1;
	} else {
		/* check whether there is sku setting for max_freq previously */
		p1 = strstr(cmdline, "max_freq=");
		if (p1) {
			p1 = strchr(p1, '=');
			if (p1) {
				p1++;
				max_freq = simple_strtoul(p1, NULL, 10);
			}
			if (max_freq)
				maxfreqflg = 1;
		}
	}

	setenv("bootargs", cmdline);
	/* if there's new maxfreq request, save env to later boots */
	if (max_preferred_freq)
		saveenv();

	free(cmdline);

	p_recovery_reg_funcs = &helandkb_recovery_reg_funcs;

	/* set op according to setting by selected, unless by default */
	if (maxfreqflg) {
		set_plat_max_corefreq(max_freq);
		printf("max_freq is selected as %u\n", max_freq);
	}
	pxa988_fc_init(ddr_mode);
	if (pwr_chg_enable)
		setop(1);
	else
		setop(3);

#if defined(CONFIG_MMP_DISP)
	calculate_dsi_clk(&mmp_mipi_info_saved);
#endif
	for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++)
		set_idle_count(cpu, 0);

	helandkb_touch_detect();

	/*
	 * bus 2 is used by pmic, set here for debug with
	 * "i2c probe", this should be the called just before exit,
	 * in case the default bus number is changed
	 */
	i2c_set_bus_num(2);

	/* for fastboot */
	setenv("fbenv", "mmc2");

#ifdef CONFIG_RAMDUMP
	if (fastboot) {
		s = getenv("ramdump");
		if (!s) {
			setenv("ramdump", "0");
			s = getenv("ramdump");
		}
		ramdump = (int)simple_strtol(s, NULL, 10);
		if (!ramdump && (0x1 != emmd_page->dump_style)) {
#ifdef CONFIG_RAMDUMP_TFFS
			show_ramdump_logo(RAMDUMP_SD_DUMP);
			if (run_command("ramdump 0 0 0 2", 0)) {
				printf("SD dump fail, enter fastboot mode\n");
				show_ramdump_logo(RAMDUMP_USB_DUMP);
				run_command("fb", 0);
			} else {
				run_command("reset", 0);
			}
#endif
		} else {
			printf("ready to enter fastboot mode\n");
			show_ramdump_logo(RAMDUMP_USB_DUMP);
			run_command("fb", 0);
		}
	}
#endif

	return 0;
}
Esempio n. 28
0
struct prom_pmemblock * __init prom_getmdesc(void)
{
	char *memsize_str;
	unsigned int memsize;

	memsize_str = prom_getenv("memsize");
	if (!memsize_str) {
#ifdef CONFIG_MIPS_AVALANCHE_SOC
		prom_printf("memsize not set in boot prom, set to default (64Mb)\n");
		memsize = 0x04000000;
#else
		prom_printf("memsize not set in boot prom, set to default (32Mb)\n");
		memsize = 0x02000000;
#endif
	} else {
#ifdef DEBUG
		prom_printf("prom_memsize = %s\n", memsize_str);
#endif
		memsize = simple_strtol(memsize_str, NULL, 0);
	}

	memset(mdesc, 0, sizeof(mdesc));

#if defined(CONFIG_MIPS_AVALANCHE_SOC)

#define PREV_MDESC(x)  ((x) - 1)
    {
        struct prom_pmemblock *p_mdesc = &mdesc[0];
	p_mdesc->type = yamon_dontuse;	
	p_mdesc->base = 0x00000000;
	p_mdesc->size = AVALANCHE_SDRAM_BASE;

	p_mdesc++;
	p_mdesc->type = yamon_prom;
	p_mdesc->base = PREV_MDESC(p_mdesc)->base + PREV_MDESC(p_mdesc)->size;
	p_mdesc->size = PAGE_SIZE;

	p_mdesc++;
	p_mdesc->type = yamon_prom;    
	p_mdesc->base = PREV_MDESC(p_mdesc)->base + PREV_MDESC(p_mdesc)->size;
	p_mdesc->size = (CONFIG_MIPS_AVALANCHE_LOAD_ADDRESS - KSEG0ADDR(AVALANCHE_SDRAM_BASE)) - PAGE_SIZE;

	p_mdesc++;
	p_mdesc->type = yamon_dontuse;
	p_mdesc->base = PREV_MDESC(p_mdesc)->base + PREV_MDESC(p_mdesc)->size;
	p_mdesc->size = CPHYSADDR(PFN_ALIGN(&_end)) - p_mdesc->base;
	p_mdesc++;
	p_mdesc->type = yamon_free;
	p_mdesc->base = PREV_MDESC(p_mdesc)->base + PREV_MDESC(p_mdesc)->size;
	p_mdesc->size = memsize - (CPHYSADDR(PFN_ALIGN(&_end)) - AVALANCHE_SDRAM_BASE);
    }
#else 
	mdesc[0].type = yamon_dontuse;
	mdesc[0].base = 0x00000000;
	mdesc[0].size = 0x00001000;

	mdesc[1].type = yamon_prom;
	mdesc[1].base = 0x00001000;
	mdesc[1].size = 0x000ef000;

#ifdef CONFIG_MIPS_MALTA
	/*
	 * The area 0x000f0000-0x000fffff is allocated for BIOS memory by the
	 * south bridge and PCI access always forwarded to the ISA Bus and
	 * BIOSCS# is always generated.
	 * This mean that this area can't be used as DMA memory for PCI
	 * devices.
	 */
	mdesc[2].type = yamon_dontuse;
	mdesc[2].base = 0x000f0000;
	mdesc[2].size = 0x00010000;
#else
	mdesc[2].type = yamon_prom;
	mdesc[2].base = 0x000f0000;
	mdesc[2].size = 0x00010000;
#endif

	mdesc[3].type = yamon_dontuse;
	mdesc[3].base = 0x00100000;
	mdesc[3].size = CPHYSADDR(PFN_ALIGN(&_end)) - mdesc[3].base;

	mdesc[4].type = yamon_free;
	mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end));
	mdesc[4].size = memsize - mdesc[4].base;
#endif /* CONFIG_MIPS_AVALANCHE_SOC */	

	return &mdesc[0];
}
Esempio n. 29
0
static int __init prompt_ramdisk(char *str)
{
	rd_prompt = simple_strtol(str,NULL,0) & 1;
	return 1;
}
Esempio n. 30
0
static void kgdbts_run_tests(void)
{
    char *ptr;
    int fork_test = 0;
    int do_sys_open_test = 0;
    int sstep_test = 1000;
    int nmi_sleep = 0;
    int i;

    ptr = strchr(config, 'F');
    if (ptr)
        fork_test = simple_strtol(ptr + 1, NULL, 10);
    ptr = strchr(config, 'S');
    if (ptr)
        do_sys_open_test = simple_strtol(ptr + 1, NULL, 10);
    ptr = strchr(config, 'N');
    if (ptr)
        nmi_sleep = simple_strtol(ptr+1, NULL, 10);
    ptr = strchr(config, 'I');
    if (ptr)
        sstep_test = simple_strtol(ptr+1, NULL, 10);

    /* All HW break point tests */
    if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
        hwbreaks_ok = 1;
        v1printk("kgdbts:RUN hw breakpoint test\n");
        run_breakpoint_test(1);
        v1printk("kgdbts:RUN hw write breakpoint test\n");
        run_hw_break_test(1);
        v1printk("kgdbts:RUN access write breakpoint test\n");
        run_hw_break_test(0);
    }

    /* required internal KGDB tests */
    v1printk("kgdbts:RUN plant and detach test\n");
    run_plant_and_detach_test(0);
    v1printk("kgdbts:RUN sw breakpoint test\n");
    run_breakpoint_test(0);
    v1printk("kgdbts:RUN bad memory access test\n");
    run_bad_read_test();
    v1printk("kgdbts:RUN singlestep test %i iterations\n", sstep_test);
    for (i = 0; i < sstep_test; i++) {
        run_singlestep_break_test();
        if (i % 100 == 0)
            v1printk("kgdbts:RUN singlestep [%i/%i]\n",
                     i, sstep_test);
    }

    /* ===Optional tests=== */

    if (nmi_sleep) {
        v1printk("kgdbts:RUN NMI sleep %i seconds test\n", nmi_sleep);
        run_nmi_sleep_test(nmi_sleep);
    }

    /* If the do_fork test is run it will be the last test that is
     * executed because a kernel thread will be spawned at the very
     * end to unregister the debug hooks.
     */
    if (fork_test) {
        repeat_test = fork_test;
        printk(KERN_INFO "kgdbts:RUN do_fork for %i breakpoints\n",
               repeat_test);
        kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
        run_do_fork_test();
        return;
    }

    /* If the sys_open test is run it will be the last test that is
     * executed because a kernel thread will be spawned at the very
     * end to unregister the debug hooks.
     */
    if (do_sys_open_test) {
        repeat_test = do_sys_open_test;
        printk(KERN_INFO "kgdbts:RUN sys_open for %i breakpoints\n",
               repeat_test);
        kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
        run_sys_open_test();
        return;
    }
    /* Shutdown and unregister */
    kgdb_unregister_io_module(&kgdbts_io_ops);
    configured = 0;
}