Rev 43 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 43 | Rev 44 | ||
|---|---|---|---|
| Line 98... | Line 98... | ||
| 98 | DRIVER_OBJ drv; |
98 | DRIVER_OBJ drv; |
| 99 | 99 | ||
| 100 | /*--- LOCALS ------------------------------------------------------------------------------*/ |
100 | /*--- LOCALS ------------------------------------------------------------------------------*/ |
| 101 | 101 | ||
| 102 | /*--- FUNCTIONS ---------------------------------------------------------------------------*/ |
102 | /*--- FUNCTIONS ---------------------------------------------------------------------------*/ |
| - | 103 | ||
| - | 104 | struct proc_dir_entry *proc; |
|
| - | 105 | ||
| 103 | static int my_interrupt(u16 intCSR) |
106 | static int my_interrupt(u16 intCSR) |
| 104 | { |
107 | { |
| 105 | int result = NOT_MY_INTERRUPT; |
108 | int result = NOT_MY_INTERRUPT; |
| 106 | 109 | ||
| 107 | if (intCSR & 0x0040) // it is global enabled |
110 | if (intCSR & 0x0040) // it is global enabled |
| Line 287... | Line 290... | ||
| 287 | 290 | ||
| 288 | writew(0x0000, (volatile void *) dwADRH); |
291 | writew(0x0000, (volatile void *) dwADRH); |
| 289 | writew(0xFFFF, (volatile void *) dwADRL); |
292 | writew(0xFFFF, (volatile void *) dwADRL); |
| 290 | wRet = readw((const volatile void *) dwADRH); |
293 | wRet = readw((const volatile void *) dwADRH); |
| 291 | if (wRet != 0x0000) |
294 | if (wRet != 0x0000) |
| 292 | { |
295 | { |
| 293 | error = 1; |
296 | error = 1; |
| 294 | break; |
297 | break; |
| 295 | } |
298 | } |
| 296 | 299 | ||
| 297 | writew(0xFFFF, (volatile void *) dwADRH); |
300 | writew(0xFFFF, (volatile void *) dwADRH); |
| 298 | writew(0x0000, (volatile void *) dwADRL); |
301 | writew(0x0000, (volatile void *) dwADRL); |
| 299 | wRet = readw((const volatile void *) dwADRH); |
302 | wRet = readw((const volatile void *) dwADRH); |
| Line 321... | Line 324... | ||
| 321 | { |
324 | { |
| 322 | u16 intCSR_store; |
325 | u16 intCSR_store; |
| 323 | u16 cntrl_store; |
326 | u16 cntrl_store; |
| 324 | int found = 0; |
327 | int found = 0; |
| 325 | u16 data; |
328 | u16 data; |
| 326 | 329 | ||
| 327 | cntrl_store = readw((const volatile void *) pd->pPCIADACntrl); /* read CONTROL register */ |
330 | cntrl_store = readw((const volatile void *) pd->pPCIADACntrl); /* read CONTROL register */ |
| 328 | intCSR_store = readw((const volatile void *) pd->pPCIADAIntCSR); /* read interrupt + CSR register */ |
331 | intCSR_store = readw((const volatile void *) pd->pPCIADAIntCSR); /* read interrupt + CSR register */ |
| 329 | 332 | ||
| 330 | PRINTK(KERN_DEBUG "%s : cntrl=0x%04x, intCSR=0x%04x\n", DEVICE_NAME, cntrl_store, intCSR_store); |
333 | PRINTK(KERN_DEBUG "%s : cntrl=0x%04x, intCSR=0x%04x\n", DEVICE_NAME, cntrl_store, intCSR_store); |
| 331 | 334 | ||
| Line 353... | Line 356... | ||
| 353 | pd->cWordMode = (data & 0x0004); |
356 | pd->cWordMode = (data & 0x0004); |
| 354 | } |
357 | } |
| 355 | 358 | ||
| 356 | // clear possible interrupts |
359 | // clear possible interrupts |
| 357 | writew(cntrl_store & ~0x0100, (volatile void *) pd->pPCIADACntrl); /* clear potential interrupt */ |
360 | writew(cntrl_store & ~0x0100, (volatile void *) pd->pPCIADACntrl); /* clear potential interrupt */ |
| 358 | 361 | ||
| 359 | /* restore all contents */ |
362 | /* restore all contents */ |
| 360 | writew(cntrl_store, (volatile void *) pd->pPCIADACntrl); |
363 | writew(cntrl_store, (volatile void *) pd->pPCIADACntrl); |
| 361 | writew(intCSR_store, (volatile void *) pd->pPCIADAIntCSR); |
364 | writew(intCSR_store, (volatile void *) pd->pPCIADAIntCSR); |
| 362 | } |
365 | } |
| 363 | 366 | ||
| Line 375... | Line 378... | ||
| 375 | DEVICE_OBJ *pd; |
378 | DEVICE_OBJ *pd; |
| 376 | PCIConfig *ch; |
379 | PCIConfig *ch; |
| 377 | u16 cntrl; |
380 | u16 cntrl; |
| 378 | char *cause = "none"; |
381 | char *cause = "none"; |
| 379 | struct list_head *ptr; |
382 | struct list_head *ptr; |
| - | 383 | PRINTK(KERN_DEBUG "%s : pcivme_read_proc()\n",DEVICE_NAME); |
|
| 380 | 384 | ||
| - | 385 | if (*offp != 0) return 0; |
|
| 381 | pos += sprintf(buf + pos, "\nPCIVME information. Version %d.%d of %s from Klaus Hitschler.\n", VERSION_HI, VERSION_LO, __DATE__); |
386 | pos += sprintf(buf + pos, "\nPCIVME information. Version %d.%d of %s from Klaus Hitschler.\n", VERSION_HI, VERSION_LO, __DATE__); |
| 382 | 387 | ||
| 383 | pos += sprintf(buf + pos, " ---------------------\n"); |
388 | pos += sprintf(buf + pos, " ---------------------\n"); |
| 384 | pos += sprintf(buf + pos, " Interfaces found : %d\n", drv.count); |
389 | pos += sprintf(buf + pos, " Interfaces found : %d\n", drv.count); |
| 385 | pos += sprintf(buf + pos, " Major Number : %d\n", drv.nMajor); |
390 | pos += sprintf(buf + pos, " Major Number : %d\n", drv.nMajor); |
| Line 403... | Line 408... | ||
| 403 | pos += sprintf(buf + pos, " Systemcontroller : %s\n", (pd->cSystemController) ? "yes" : "no"); |
408 | pos += sprintf(buf + pos, " Systemcontroller : %s\n", (pd->cSystemController) ? "yes" : "no"); |
| 404 | pos += sprintf(buf + pos, " Word Mode : %s\n", (pd->cWordMode) ? "yes" : "no"); |
409 | pos += sprintf(buf + pos, " Word Mode : %s\n", (pd->cWordMode) ? "yes" : "no"); |
| 405 | } |
410 | } |
| 406 | else |
411 | else |
| 407 | pos += sprintf(buf + pos, " VMEMM is or was : not (software) connected.\n"); |
412 | pos += sprintf(buf + pos, " VMEMM is or was : not (software) connected.\n"); |
| 408 | 413 | ||
| 409 | if (!((cntrl & 0x0800) && (!(cntrl & 0x0600)))) |
414 | if (!((cntrl & 0x0800) && (!(cntrl & 0x0600)))) |
| 410 | pos += sprintf(buf + pos, " VMEMM is : powered off or cable disconnected.\n"); |
415 | pos += sprintf(buf + pos, " VMEMM is : powered off or cable disconnected.\n"); |
| 411 | 416 | ||
| 412 | pos += sprintf(buf + pos, " IrqCount : %d\n", pd->dwInterruptCount); |
417 | pos += sprintf(buf + pos, " IrqCount : %d\n", pd->dwInterruptCount); |
| 413 | if (pd->wIrqStatus & PCIADA_INTERRUPT) |
418 | if (pd->wIrqStatus & PCIADA_INTERRUPT) |
| Line 417... | Line 422... | ||
| 417 | cause = "VME"; |
422 | cause = "VME"; |
| 418 | pos += sprintf(buf + pos, " Pending IrqStatus : %s\n", cause); |
423 | pos += sprintf(buf + pos, " Pending IrqStatus : %s\n", cause); |
| 419 | } |
424 | } |
| 420 | 425 | ||
| 421 | pos += sprintf(buf + pos, "\n"); |
426 | pos += sprintf(buf + pos, "\n"); |
| - | 427 | if (pos>count) { |
|
| - | 428 | buf[count-1]=0; |
|
| - | 429 | pos=count; |
|
| 422 | 430 | } |
|
| - | 431 | PRINTK(KERN_DEBUG "%s : pcivme_read_proc() end count=%d\n",DEVICE_NAME, pos); |
|
| 423 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) |
432 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) |
| 424 | //*eof = 1; |
433 | //*eof = 1; |
| 425 | #endif |
434 | #endif |
| - | 435 | *offp = pos; |
|
| 426 | 436 | ||
| 427 | return pos; |
437 | return pos; |
| 428 | } |
438 | } |
| 429 | 439 | ||
| 430 | 440 | ||
| 431 | 441 | ||
| Line 438... | Line 448... | ||
| 438 | mode: S_IFREG | S_IRUGO, /* mode */ |
448 | mode: S_IFREG | S_IRUGO, /* mode */ |
| 439 | nlink: 1, /* nlinks */ |
449 | nlink: 1, /* nlinks */ |
| 440 | get_info: pcivme_read_proc, /* function used to read data */ |
450 | get_info: pcivme_read_proc, /* function used to read data */ |
| 441 | }; |
451 | }; |
| 442 | #else |
452 | #else |
| 443 | struct file_operations |
453 | struct file_operations pcivme_read_proc_fops = { |
| 444 | read: pcivme_read_proc |
454 | read: pcivme_read_proc |
| 445 | }; |
455 | }; |
| 446 | #endif |
456 | #endif |
| 447 | 457 | ||
| 448 | static void deleteMyLists(void) |
458 | static void deleteMyLists(void) |
| Line 458... | Line 468... | ||
| 458 | } |
468 | } |
| 459 | 469 | ||
| 460 | DeletePCIConfig(&drv); |
470 | DeletePCIConfig(&drv); |
| 461 | } |
471 | } |
| 462 | 472 | ||
| 463 | int |
473 | int pcivme_module_init(void) |
| 464 | { |
474 | { |
| 465 | PCIConfig *ch; |
475 | PCIConfig *ch; |
| 466 | DEVICE_OBJ *pd; |
476 | DEVICE_OBJ *pd; |
| 467 | int result = 0; |
477 | int result = 0; |
| 468 | struct list_head *ptr; |
478 | struct list_head *ptr; |
| Line 574... | Line 584... | ||
| 574 | 584 | ||
| 575 | printk(KERN_DEBUG "%s : major #%d assigned.\n", DEVICE_NAME, drv.nMajor); |
585 | printk(KERN_DEBUG "%s : major #%d assigned.\n", DEVICE_NAME, drv.nMajor); |
| 576 | } |
586 | } |
| 577 | 587 | ||
| 578 | /* register the proc device */ |
588 | /* register the proc device */ |
| 579 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) |
- | |
| 580 | proc_register_dynamic(&proc_root, &pcimod_proc_entry); |
- | |
| 581 | 589 | ||
| 582 | return 0; |
- | |
| 583 | #else |
- | |
| 584 | // create_proc_read_entry is depricated since kernel 3.10 |
590 | // create_proc_read_entry is depricated since kernel 3.10 |
| 585 | //return create_proc_read_entry(DEVICE_NAME, 0, NULL, pcivme_read_proc, NULL) ? 0 : -ENODEV; |
591 | //return create_proc_read_entry(DEVICE_NAME, 0, NULL, pcivme_read_proc, NULL) ? 0 : -ENODEV; |
| 586 |
|
592 | proc = proc_create_data(DEVICE_NAME, 0, NULL, &pcivme_read_proc_fops, NULL); |
| - | 593 | return (proc) ? 0 : -ENODEV; |
|
| 587 | #endif |
594 | |
| 588 | } |
595 | } |
| 589 | 596 | ||
| 590 | void |
597 | void pcivme_module_exit(void) |
| 591 | { |
598 | { |
| 592 | PCIConfig *ch; |
599 | PCIConfig *ch; |
| 593 | DEVICE_OBJ *pd; |
600 | DEVICE_OBJ *pd; |
| 594 | struct list_head *ptr; |
601 | struct list_head *ptr; |
| 595 | 602 | ||
| 596 | PRINTK(KERN_DEBUG "%s : cleanup_module.\n", DEVICE_NAME); |
603 | PRINTK(KERN_DEBUG "%s : cleanup_module.\n", DEVICE_NAME); |
| 597 | 604 | ||
| 598 | unregister_chrdev(drv.nMajor, DEVICE_NAME); |
605 | unregister_chrdev(drv.nMajor, DEVICE_NAME); |
| 599 | 606 | ||
| 600 | /* unregister the proc device */ |
607 | /* unregister the proc device */ |
| 601 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) |
608 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) |
| 602 | proc_unregister(&proc_root, pcimod_proc_entry.low_ino); |
609 | proc_unregister(&proc_root, pcimod_proc_entry.low_ino); |
| Line 618... | Line 625... | ||
| 618 | default: pd->wInitStep = 0; |
625 | default: pd->wInitStep = 0; |
| 619 | } |
626 | } |
| 620 | 627 | ||
| 621 | drv.count--; |
628 | drv.count--; |
| 622 | } |
629 | } |
| 623 | 630 | ||
| 624 | deleteMyLists(); |
631 | deleteMyLists(); |
| 625 | 632 | ||
| 626 | return; |
633 | return; |
| 627 | } |
634 | } |
| - | 635 | ||
| - | 636 | module_init(pcivme_module_init); |
|
| - | 637 | module_exit(pcivme_module_exit); |
|
| 628 | 638 | ||