static irqreturn_t dev_interrupt(int irq,void *dev_id) { unsigned char ucKey = 0; /* delay 50ms*/ udelay(50); ucKey = dev_scan(irq); if( ucKey >=1 && ucKey <=6) { if(((dev_buffer.head+1) & (MAX_KEY_COUNT -1 )) != dev_buffer.tail ) { spin_lock_irq(&buffer_lock); dev_buffer.buf[dev_buffer.tail] = ucKey; dev_buffer.jiffy[dev_buffer.tail] = get_tick_count(); dev_buffer.tail++; dev_buffer.tail &= (MAX_KEY_COUNT - 1); spin_unlock_irq(&buffer_lock); } } init_gpio(); return IRQ_RETVAL(IRQ_HANDLED); }
int main(int argc, char *argv[]) { int i = 0, idx = -1; unsigned int lzf_mem = 0xfa000000; unsigned int phys_mem = 0xa0000000; unsigned sum; int cnt = 64, loop = 0, dst_cnt = 0; unsigned int opt = 0, p = 0; FILE *fp = NULL; while ((p = getopt(argc, argv, "NMCUAFhn:fr:vl:g:d:")) != EOF) { switch (p) { case 'd': dst_cnt = atoi(optarg); break; case 'l': loop = atoi(optarg); break; case 'v': verbose = 1; break; case 'r': fp = fopen(optarg, "r"); if (fp == NULL) { perror("fopen"); return 0; } break; case 'h': printf("%s: \t-n cnt\n" "\t-N DO NULL\n" "\t-F DO FILL\n" "\t-M DO MEMCPY\n" "\t-C DO COMPRESS\n" "\t-U DO Uncompress\n" "\t-A ALL tested\n", argv[0]); return -1; case 'n': cnt = atoi(optarg); break; } } if (dst_cnt == 0) dst_cnt = cnt; printf("%d, %d\n", cnt, dst_cnt); init_memory_pool(POOL_SIZE, system_mem); pcisim_init(".", qemu_peek, qemu_poke); pci_reset(phys_mem); //show all the pci device idx = dev_scan(-1); if (idx != -1) printf("Found %04X:%04X at %d\n", 0x100, 0x3, idx); else goto done; /* master memory_enable */ int val; val = pcisim_config_read((1<<idx) + 4*1); pcisim_config_write((1<<idx) + 4*1, val | 1<<1| 1<<2); pcisim_config_write((1<<idx) + 4*6, lzf_mem); /* bar1 */ /* cache line */ pcisim_config_write((1<<idx) + 4*3, 0x4004); pcisim_writel(lzf_mem, 0xAA55); pcisim_wait(400, 0); done: return 0; }