Ejemplo n.º 1
0
static ssize_t sn_check_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	char SN[32] = {0};
	char *pbuf = (char *)kzalloc(512, GFP_KERNEL);

	GetSNSectorInfo(pbuf);
	unsigned short snlen = *(unsigned short *)pbuf;
	memcpy(buf,pbuf+2,snlen);
	kfree(pbuf);
	return snlen;
}
Ejemplo n.º 2
0
int rk29sdk_wifi_mac_addr(unsigned char *buf)
{
       char mac_buf[20] = {0};
    printk("rk29sdk_wifi_mac_addr.\n");

    // from vflash
    if(is_zero_ether_addr(wifi_custom_mac_addr)) {
       int i;
       char *tempBuf = kmalloc(512, GFP_KERNEL);
       if(tempBuf) {
           GetSNSectorInfo(tempBuf);
           for (i = 506; i <= 511; i++)
               wifi_custom_mac_addr[i-506] = tempBuf[i];
           kfree(tempBuf);
       } else {
           return -1;
       }
    }

	sprintf(mac_buf,"%02x:%02x:%02x:%02x:%02x:%02x",wifi_custom_mac_addr[0],wifi_custom_mac_addr[1],
	wifi_custom_mac_addr[2],wifi_custom_mac_addr[3],wifi_custom_mac_addr[4],wifi_custom_mac_addr[5]);
	printk("falsh wifi_custom_mac_addr=[%s]\n", mac_buf);

	if (is_valid_ether_addr(wifi_custom_mac_addr)) {
		if (2 == (wifi_custom_mac_addr[0] & 0x0F)) {
			printk("This mac address come into conflict with the address of direct, ignored...\n");
			return -1;
		}
	} else {
		printk("This mac address is not valid, ignored...\n");
		return -1;
	}

#if defined(CONFIG_RKWIFI)
	memcpy(buf, wifi_custom_mac_addr, 6);
#else 
	memcpy(buf, mac_buf, strlen(mac_buf));//realtek's wifi use this branch
#endif
    return 0;
}
int rockchip_wifi_mac_addr(unsigned char *buf)
{
    char mac_buf[20] = {0};
    LOG("%s: enter.\n", __func__);

    // from vflash
    if(is_zero_ether_addr(wifi_custom_mac_addr)) {
        int i;
        char *tempBuf = kmalloc(512, GFP_KERNEL);
        if(tempBuf) {
            GetSNSectorInfo(tempBuf);
            for (i = 445; i <= 450; i++)
                wifi_custom_mac_addr[i-445] = tempBuf[i];
            kfree(tempBuf);
        } else {
            return -1;
        }
    }

    sprintf(mac_buf,"%02x:%02x:%02x:%02x:%02x:%02x",wifi_custom_mac_addr[0],wifi_custom_mac_addr[1],
    wifi_custom_mac_addr[2],wifi_custom_mac_addr[3],wifi_custom_mac_addr[4],wifi_custom_mac_addr[5]);
    LOG("falsh wifi_custom_mac_addr=[%s]\n", mac_buf);

    if (is_valid_ether_addr(wifi_custom_mac_addr)) {
        if (2 == (wifi_custom_mac_addr[0] & 0x0F)) {
            LOG("This mac address come into conflict with the address of direct, ignored...\n");
            return -1;
        }
    } else {
        LOG("This mac address is not valid, ignored...\n");
        return -1;
    }

    memcpy(buf, wifi_custom_mac_addr, 6);

    return 0;
}
Ejemplo n.º 4
0
static long mtk23d_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	struct rk2818_23d_data *pdata = gpdata;
	int ret;
	void __user *argp = (void __user *)arg;
	
	char SectorBuffer[512];
	
	printk("mtk23d_ioctl\n");
	ret = down_interruptible(&pdata->power_sem);
	if (ret < 0) {
		printk("%s: down power_sem error ret = %d\n", __func__, ret);
		return ret;
	}
	
	switch(cmd)
	{

		case MTK23D_POWEROFF:
			printk("MTK23D_POWEROFF\n");
			rk29_uart_to_gpio(0);
			gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_LOW:GPIO_HIGH);
			msleep(2500);
			gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_HIGH:GPIO_LOW);
			msleep(500);
			gpio_set_value(pdata->bp_reset, pdata->bp_reset_active_low? GPIO_LOW:GPIO_HIGH);
			break;

		case MTK23D_RESET:		
			printk("MTK23D_RESET\n");
			/****power off 23d and uart to gpio***/
			rk29_uart_to_gpio(0);
			gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_LOW:GPIO_HIGH);
			msleep(2500);
			gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_HIGH:GPIO_LOW);
			msleep(500);
			gpio_set_value(pdata->bp_reset, pdata->bp_reset_active_low? GPIO_LOW:GPIO_HIGH);
			
			/****power on 23d***/
			msleep(100);
			gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_LOW:GPIO_HIGH);
			rk29_gpio_to_uart(0);
			msleep(300);
			gpio_set_value(pdata->bp_reset, pdata->bp_reset_active_low? GPIO_HIGH:GPIO_LOW);
			msleep(2500);
			gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_HIGH:GPIO_LOW);
			break;

		case MTK23D_POWERON:		
			/****power on 23d***/
			printk("MTK23D_POWERON\n");
			gpio_set_value(pdata->bp_reset, pdata->bp_reset_active_low? GPIO_LOW:GPIO_HIGH);
			msleep(100);
			gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_LOW:GPIO_HIGH);
			rk29_gpio_to_uart(0);
			msleep(300);
			gpio_set_value(pdata->bp_reset, pdata->bp_reset_active_low? GPIO_HIGH:GPIO_LOW);
			msleep(2500);
			gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_HIGH:GPIO_LOW);
			break;
			
		case MTK23D_IMEI_READ:
			printk("MTK23D_IMEI_READ\n");
			
			GetSNSectorInfo(SectorBuffer); // phc,20110624
			
			if(copy_to_user(argp, &(SectorBuffer[451]), 16))  // IMEI后从451偏移开始的16bytes,第一个byte为长度固定为15
			{
				printk("ERROR: copy_to_user---%s\n", __FUNCTION__);
				up(&pdata->power_sem);
				return -EFAULT;
			}
			//printk("IMEI:%d %d %d %d\n", SectorBuffer[451], SectorBuffer[452], SectorBuffer[453], SectorBuffer[454]);
			break;
		default:
			break;
	}

	up(&pdata->power_sem);
	
	return 0;
}
Ejemplo n.º 5
0
static void SN_get(struct work_struct *work)
{

	char *pbuf = (char *)kzalloc(512, GFP_KERNEL);;
	char SN[31] = {0};
	char  bd_addr[6] = {0};
	int  i = 0;

//	unsigned short *pSnLen = NULL;
	long fd = 0;
	char buf_tmp[15] = {0};
	char mac_tmp[30] = {0};

	DBG(1,"%s........enter\n",__FUNCTION__);
	GetSNSectorInfo(pbuf);
	unsigned short *pSnLen = (unsigned short *)pbuf; 
	memcpy(SN,pbuf+2,*pSnLen);	
	//memcpy(sn_buf,pbuf+2,*pSnLen);	
	//printk("%s..psnlen=%d...SN=%s\n",__FUNCTION__,*pSnLen,SN);

    	fd = sys_open(SN_FILE,O_CREAT | O_RDWR,S_IRWXU|S_IRGRP|S_IROTH);
    
	if(fd < 0)
    	{
		printk("%s SN_get: open file /data/sn failed\n",__FILE__);
		return;
	}
	sys_write(fd, (const char __user *)SN, *pSnLen);
	
    sys_close(fd);
		fd = sys_open(BLUE_MAC,O_CREAT | O_RDWR,S_IRWXU|S_IRGRP|S_IROTH);
    

	if(fd < 0)
    	{
		printk("%s SN_get: open file /data/blue_mac failed\n",__FILE__);
		return;
	}
            for(i=499; i<=504; i++)
			 {
				//printk("%s....*(pbuf+%d)=%x\n",__FUNCTION__,i,*(pbuf+i));
				bd_addr[504-i] = *(pbuf+i);
			//sprintf(mac_tmp+i-499+4,"%02x:",*(pbuf+i));
			//	printk("%s.....bd_addr[504-i] =%x\n",__FUNCTION__,bd_addr[504-i]);
			}
		sprintf(mac_tmp,"%02x:%02x:%02x:%02x:%02x:%02x",bd_addr[5],bd_addr[4],bd_addr[3],bd_addr[2],bd_addr[1],bd_addr[0]);
		//printk("%s....msc_tmp=%s\n",__FUNCTION__,mac_tmp);
	sys_write(fd, (const char __user *)mac_tmp,strlen(mac_tmp)); 
	
    sys_close(fd);
	kfree(pbuf);
	/*
		fd = sys_open(BLUE_MAC,O_CREAT | O_RDWR,S_IRWXU|S_IRGRP|S_IROTH);
		sys_read(fd,buf_tmp,15);
		for (i=0;i<15;i++)
				printk("buf_tmp[i]=%4x",buf_tmp[i]);
				printk("mac over\n");
		sys_close(fd);
	*/
	DBG(1,"%s.......blue over.\n",__FUNCTION__);	
}
Ejemplo n.º 6
0
static long bp_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	struct bp_private_data *bp = g_bp;
	void __user *argp = (void __user *)arg;
	char SectorBuffer[512];
	int result = 0;
	printk("<---%s:bp_id=%d,cmd=%d--->\n",__FUNCTION__,bp->ops->bp_id,cmd);
	switch(cmd)
	{
		case BP_IOCTL_RESET:	
			if(bp->ops->reset)
			{
				bp->ops->reset(bp);
			}
			break;
			
		case BP_IOCTL_POWON:
			if(bp->ops->active)
			bp->ops->active(bp, 1);
			bp->status = BP_ON;
			break;
			
		case BP_IOCTL_POWOFF:
			if(bp->ops->active)
			bp->ops->active(bp, 0);
			bp->status = BP_OFF;
			break;
	
		case BP_IOCTL_WRITE_STATUS:
			
			break;
	
		case BP_IOCTL_GET_STATUS:
			
			break;

		case BP_IOCTL_SET_PVID:
			
			break;
	
		case BP_IOCTL_GET_BPID:
			if (copy_to_user(argp, &bp->ops->bp_id, sizeof(bp->ops->bp_id)))
			{
	            		printk("%s:failed to copy status to user space.\n",__FUNCTION__);
				return -EFAULT;
			}
			
			break;
		case BP_IOCTL_GET_IMEI:
			printk("BP_IMEI_READ\n");
			GetSNSectorInfo(SectorBuffer); 
			if(copy_to_user(argp, &(SectorBuffer[451]), 16))  // IMEIo¨®¡ä¨®451??¨°??a¨º?¦Ì?16bytes¡ê?¦Ì¨²¨°???byte?a3¡è?¨¨1¨¬?¡§?a15
			{
				printk("ERROR: copy_to_user---%s\n", __FUNCTION__);
				return -EFAULT;
			}
			break;
			
		default:
			break;
	}
	
	return 0;
}