📄 dm642.c
字号:
*(volatile unsigned long *)(iomap+8) = tpoint.LINE1_STARTX; osdparam[tpoint.channel].LINE1_STARTX = tpoint.LINE1_STARTX; *(volatile unsigned long *)(iomap+8) = tpoint.LINE1_STARTY; osdparam[tpoint.channel].LINE1_STARTY = tpoint.LINE1_STARTY; *(volatile unsigned long *)(iomap+8) = tpoint.LINE1_CHARS; osdparam[tpoint.channel].LINE1_CHARS = tpoint.LINE1_CHARS; *(volatile unsigned long *)(iomap+8) = tpoint.HOST_CLOCK_SECS; *(volatile unsigned long *)(iomap+8) = tpoint.CLOCK_MODIFY; *(volatile unsigned long *)(iomap+4) = 0x81ffc000 + tpoint.channel * 128; for(i=0; i<32; i++) { *(volatile unsigned long *)(iomap+8) = tpoint.LINE_BUF[i]; osdparam[tpoint.channel].LINE_BUF[i] = tpoint.LINE_BUF[i]; } }end: *(volatile unsigned long *)(iomap+4) = OSD_MODIFY_FLAG0 + tpoint.channel * 128; i = *(volatile unsigned long *)(iomap+0x1c); *(volatile unsigned long *)(iomap+8) = tpoint.MODIFY_FLAG | i; *(volatile unsigned long *)(iomap+4) = SET_OSDPARAM_FUNC0 + tpoint.channel * 128; *(volatile unsigned long *)(iomap+8) = 1; *(volatile unsigned long *)(iomap+0) = 0x00020002; return 0;}static int getosdparams(unsigned long point){ struct ioctl_get_osdparams tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_get_osdparams)); if(tpoint.channel > 3) return -1; copy_to_user(point,osdparam + sizeof(struct ioctl_get_osdparams) * tpoint.channel, sizeof(struct ioctl_get_osdparams)); return 0;}static int setdspclock(unsigned long point){ struct ioctl_set_dsp_clock tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_set_dsp_clock)); if(tpoint.channel > 3) return -1; *(volatile unsigned long *)(iomap+4) = OSD_HOST_CLOCK_SECS0 + tpoint.channel * 128; *(volatile unsigned long *)(iomap+8) = tpoint.HOST_CLOCK_SECS; *(volatile unsigned long *)(iomap+8) = 1; *(volatile unsigned long *)(iomap+0) = 0x00020002; return 0;}static int setosdcontral(unsigned long point){ unsigned long ul1,ul2; struct ioctl_set_osdcontral tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_set_osdcontral)); if(tpoint.channel > 3) return -1; if((tpoint.contral_flag & 0xfffcfcfc) != 0) return -1; *(volatile unsigned long *)(iomap+4) = OSD_START_STOP_FLAG0 + tpoint.channel * 128; ul1 = *(volatile unsigned long *)(iomap+0x1c); if((tpoint.contral_flag & 0x00020000) != 0) { ul2 = ul1 & 0x00010000; } else { ul2 = tpoint.contral_flag & 0x00010000; } if((tpoint.contral_flag & 0x00000200) != 0) { ul2 |= ul1 & 0x00000100; } else { ul2 |= tpoint.contral_flag & 0x00000100; } if((tpoint.contral_flag & 0x00000002) != 0) { ul2 |= ul1 & 0x00000001; } else { ul2 |= tpoint.contral_flag & 0x00000001; } *(volatile unsigned long *)(iomap+0x0c) = ul2; *(volatile unsigned long *)(iomap+0) = 0x00020002; return 0;}static int getosdcontral(unsigned long point){ struct ioctl_get_osdcontral tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_get_osdcontral)); if(tpoint.channel > 3) return -1; *(volatile unsigned long *)(iomap+4) = OSD_START_STOP_FLAG0 + tpoint.channel * 128; tpoint.contral_flag = *(volatile unsigned long *)(iomap+0x1c); copy_to_user(point, &tpoint, sizeof(struct ioctl_get_osdcontral)); return 0;}static int setlogo(unsigned long point){ int i; struct ioctl_set_logo tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_set_logo)); if(tpoint.channel > 3) return -1; if(tpoint.size > 32 * 1024) return -1; for(i=0; i<4*32*1024; i+=4) { *(unsigned long *)(logobuf+i)=*(volatile unsigned long *)(logomap + i); } copy_from_user(&logobuf[tpoint.channel*32*1024],tpoint.buf,tpoint.size); *(volatile unsigned long *)(iomap+4) = 0x81fdc000 + tpoint.channel * 32 * 1024; for (i = 0; i < tpoint.size; i+=4) { *(volatile unsigned long *)(iomap+8) = *(unsigned long *)(logobuf+tpoint.channel*32*1024 + i); } *(volatile unsigned long *)(iomap+0) = 0x00020002; EraseFlash(logomap, 0x20000); writeflash16(logomap, logobuf, 0x20000); return 0;}static void ksetrtc(unsigned long point){ unsigned long uc1,uc2; uc1 = ((struct ioctl_set_rtc *)point)->second /10; uc2 = ((struct ioctl_set_rtc *)point)->second - (uc1 * 10); uc2 += uc1 << 4; __REG(0x57000070) = uc2; uc1 = ((struct ioctl_set_rtc *)point)->minute /10; uc2 = ((struct ioctl_set_rtc *)point)->minute - (uc1 * 10); uc2 += uc1 << 4; __REG(0x57000074) = uc2; uc1 = ((struct ioctl_set_rtc *)point)->hour /10; uc2 = ((struct ioctl_set_rtc *)point)->hour - (uc1 * 10); uc2 += uc1 << 4; __REG(0x57000078) = uc2; uc1 = ((struct ioctl_set_rtc *)point)->day /10; uc2 = ((struct ioctl_set_rtc *)point)->day - (uc1 * 10); uc2 += uc1 << 4; __REG(0x5700007c) = uc2; __REG(0x57000080) = ((struct ioctl_set_rtc *)point)->week; uc1 = ((struct ioctl_set_rtc *)point)->month /10; uc2 = ((struct ioctl_set_rtc *)point)->month - (uc1 * 10); uc2 += uc1 << 4; __REG(0x57000084) = uc2; __REG(0x57000088) = ((struct ioctl_set_rtc *)point)->year;}static void setrtc(unsigned long point){ unsigned long uc1,uc2; struct ioctl_set_rtc tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_set_rtc)); ksetrtc(&tpoint); dm642_irq_rtc(NULL,NULL,NULL);}static void kgetrtc(unsigned long point){ unsigned char uc1,uc2; ((struct ioctl_get_rtc *)point)->year = __REG(0x57000088); uc1 = __REG(0x57000084) & 0x0f; uc2 = (__REG(0x57000084) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->month = uc2; ((struct ioctl_get_rtc *)point)->week = __REG(0x57000080); uc1 = __REG(0x5700007c) & 0x0f; uc2 = (__REG(0x5700007c) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->day = uc2; uc1 = __REG(0x57000078) & 0x0f; uc2 = (__REG(0x57000078) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->hour = uc2; uc1 = __REG(0x57000074) & 0x0f; uc2 = (__REG(0x57000074) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->minute = uc2; uc1 = __REG(0x57000070) & 0x0f; uc2 = (__REG(0x57000070) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->second = uc2; if(((struct ioctl_get_rtc *)point)->second == 0) { uc1 = __REG(0x57000074) & 0x0f; uc2 = (__REG(0x57000074) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->minute = uc2; uc1 = __REG(0x57000078) & 0x0f; uc2 = (__REG(0x57000078) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->hour = uc2; uc1 = __REG(0x5700007c) & 0x0f; uc2 = (__REG(0x5700007c) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->day = uc2; ((struct ioctl_get_rtc *)point)->week = __REG(0x57000080); uc1 = __REG(0x57000084) & 0x0f; uc2 = (__REG(0x57000084) >> 4) * 10 + uc1; ((struct ioctl_get_rtc *)point)->month = uc2; ((struct ioctl_get_rtc *)point)->year = __REG(0x57000088); }}static void getrtc(unsigned long point){ unsigned char uc1,uc2; struct ioctl_get_rtc tpoint; kgetrtc(&tpoint); copy_to_user(point, &tpoint, sizeof(struct ioctl_get_rtc));}static void setmac(unsigned long point){}static void getmac(unsigned long point){ readflash(maciomap); copy_to_user(&((struct ioctl_get_mac *)point)->mac[0], maciomap, 6);}static void setser(unsigned long point){}static void getser(unsigned long point){ readflash(maciomap); copy_to_user(&((struct ioctl_get_ser *)point)->ser[0], maciomap+16, 16);}static void setlednum(unsigned long point){ setled=point;}static int updata(unsigned long point){ int i; int updatamap; tUPDATASection * section; tUPDATAMainHeader * mainhead = ((struct ioctl_updata *)point)->buf; if (mainhead->targetID != update_targetID) return -2; if ((mainhead->type & update_type) == 0) return -3; if ((mainhead->version & update_version) == 0) return -4; if (mainhead->sectionCount == 0) return -5; for (i=1; i<=mainhead->sectionCount; i++) { section = ((struct ioctl_updata *)point)->buf + i * 4; if(section->count == 0) return -6; if(section->dest + section->count > flash_maxadd) return -7; if(section->dest < flash_minadd) return -8; if(section->type == 0) continue; if(section->src + section->count > ((struct ioctl_updata *)point)->size) return -9; } write_gpio_bit(GPIO_G1,1); __REG(0x53000000) = 0; for (i=1; i<=mainhead->sectionCount; i++) { section = ((struct ioctl_updata *)point)->buf + i * 4; updatamap = ioremap(section->dest, section->count); EraseFlash(updatamap, section->count); if(section->type != 0) { writeflash16(updatamap, (unsigned char *)(((struct ioctl_updata *)point)->buf) + section->src, section->count); } iounmap(updatamap); } write_gpio_bit(GPIO_G1,0); return 0;}#ifdef Design_For_GDWstatic unsigned long g_pass[4];static unsigned long g_pass_size=0;static int userdata(unsigned long point){ unsigned long bufaddr,buflen,nCount; int j; unsigned long * pWork; unsigned long data; struct ioctl_get_data tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_get_data)); if(tpoint.channel > 1) { return 0; } if(tpoint.flag < 2) { return 0; } *(volatile unsigned long *)(iomap+4) = NET_RECEIVEDFLAG0 + tpoint.channel * 128; if(*(volatile unsigned long *)(iomap+0x1c) != 0) return 0; *(volatile unsigned long *)(iomap+4) = NET_ADDRESS0 + tpoint.channel * 128; bufaddr = *(volatile unsigned long *)(iomap+0x18); buflen = *(volatile unsigned long *)(iomap+0x18); if(tpoint.size < buflen) { DEBUG_ERR_PRINT("get userdata tpoint.size < buflen %x < %x\n",tpoint.size,buflen); return -1; } *(volatile unsigned long *)(iomap+4) = bufaddr; pWork = tpoint.buf; nCount=buflen>>2; for(j=0; j<nCount; j++, pWork++) { put_user(*(volatile unsigned long *)(iomap+0x18), pWork); } if(buflen&0x03) { data = *(volatile unsigned long *)(iomap+0x18); copy_to_user(pWork, (unsigned char*)&data, buflen&0x03); } *(volatile unsigned long *)(iomap+4) = NET_RECEIVEDFLAG0 + tpoint.channel * 128; *(volatile unsigned long *)(iomap+0x0c) = 1; return buflen;}static int recieveuserdata(unsigned long point){ unsigned long bufaddr,buflen,nCount; int j; unsigned long * pWork; unsigned long data; struct ioctl_get_data tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_get_data)); if(tpoint.channel > 1) { return 0; } *(volatile unsigned long *)(iomap+4) = NET_SEND_FLAG0 + tpoint.channel * 128; if(*(volatile unsigned long *)(iomap+0x1c) != 0) return 0; *(volatile unsigned long *)(iomap+4) = NET_SEND_ADDRESS0 + tpoint.channel * 128; bufaddr = *(volatile unsigned long *)(iomap+0x18); buflen = *(volatile unsigned long *)(iomap+0x18); if(tpoint.size > buflen) { DEBUG_ERR_PRINT("recieve userdata tpoint.size > buflen %x > %x\n",tpoint.size,buflen); return -1; } *(volatile unsigned long *)(iomap+4) = bufaddr; pWork = tpoint.buf; nCount=tpoint.size>>2; printk("recieve data:"); for(j=0; j<nCount; j++, pWork++) { copy_from_user((unsigned char*)&data, pWork, 4); *(volatile unsigned long *)(iomap+8)=data; printk("%x",data); } printk("\n"); if(tpoint.size&0x03) { copy_from_user((unsigned char*)&data, pWork, 4); *(volatile unsigned long *)(iomap+8)=data; } *(volatile unsigned long *)(iomap+4) = NET_SEND_LENGTH0 + tpoint.channel * 128; *(volatile unsigned long *)(iomap+8) = tpoint.size; *(volatile unsigned long *)(iomap+8) = 1; *(volatile unsigned long *)(iomap+0) = 0x00020002; return tpoint.size;}static int pass(unsigned long point){ struct ioctl_updata tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_updata)); if(tpoint.size>16) { DEBUG_ERR_PRINT("pass size = %d > 16\n",tpoint.size); return -1; } g_pass_size=tpoint.size; copy_from_user(g_pass, tpoint.buf, tpoint.size); DEBUG_PRINT("pass size=%d,%x %x %x %x\n",tpoint.size,g_pass[0],g_pass[1],g_pass[2],g_pass[3]); return 0;}static int watchdog(unsigned long point){ unsigned long ul; *(volatile unsigned long *)(iomap+4) = WATCHDOG_STATUS; if(*(volatile unsigned long *)(iomap+0x18) != 0) return 1; *(volatile unsigned long *)(iomap+4) = WATCHDOG_ADDRESS; ul = *(volatile unsigned long *)(iomap+0x18); *(volatile unsigned long *)(iomap+8) = 0; return ul;}static int sendserial(unsigned long point){ unsigned long bufaddr,buflen,nCount; int j; unsigned long * pWork; unsigned long data; struct ioctl_updata tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_updata)); *(volatile unsigned long *)(iomap+4) = SERIAL_RECEIVEDFLAG; if(*(volatile unsigned long *)(iomap+0x1c) != 0) return 0; *(volatile unsigned long *)(iomap+4) = SERIAL_ADDRESS; bufaddr = *(volatile unsigned long *)(iomap+0x18); buflen = *(volatile unsigned long *)(iomap+0x18); if(tpoint.size < buflen) { DEBUG_ERR_PRINT("sendserial tpoint.size < buflen %x < %x\n",tpoint.size,buflen); return -1; } *(volatile unsigned long *)(iomap+4) = bufaddr; pWork = tpoint.buf; nCount=buflen>>2; for(j=0; j<nCount; j++, pWork++) { put_user(*(volatile unsigned long *)(iomap+0x18), pWork); } if(buflen&0x03) { data = *(volatile unsigned long *)(iomap+0x18); copy_to_user(pWork, (unsigned char*)&data, buflen&0x03); } *(volatile unsigned long *)(iomap+4) = SERIAL_RECEIVEDFLAG; *(volatile unsigned long *)(iomap+0x0c) = 1; return buflen;}static int recievesendserial(unsigned long point){ unsigned long bufaddr,buflen,nCount; int j; unsigned long * pWork; unsigned long data; struct ioctl_updata tpoint; copy_from_user(&tpoint, point, sizeof(struct ioctl_updata)); *(volatile unsigned long *)(iomap+4) = SERIAL_SEND_FLAG; if(*(volatile unsigned long *)(iomap+0x1c) != 0) return 0; *(volatile unsigned long *)(iomap+4) = SERIAL_SEND_ADDRESS; bufaddr = *(volatile unsigned long *)(iomap+0x18); buflen = *(volatile unsigned long *)(iomap+0x18); if(tpoint.size > buflen) { DEBUG_ERR_PRINT("recievesendserial tpoint.size > buflen %x > %x\n",tpoint.size,buflen); return -1; } *(volatile unsigned long *)(iomap+4) = bufaddr; pWork = tpoint.buf; nCount=tpoint.size>>2; for(j=0; j<nCount; j++, pWork++) { copy_from_user((unsigned char*)&data, pWork, 4); *(volatile unsigned long *)(iomap+8)=data; } if(tpoint.size&0x03) { copy_from_user((unsigned char*)&data, pWork, 4); *(volatile unsigned long *)(iomap+8)=data; } *(volatile unsigned long *)(iomap+4) = SERIAL_SEND_LENGTH; *(volatile unsigned long *)(iomap+8) = tpoint.size; *(volatile unsigned long *)(iomap+8) = 1; *(volatile unsigned long *)(iomap+0) = 0x00020002; return tpoint.size;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -