Lines 48-53
Link Here
|
48 |
#include "defs.h" |
48 |
#include "defs.h" |
49 |
#include "lib.h" |
49 |
#include "lib.h" |
50 |
#include "driver.h" |
50 |
#include "driver.h" |
|
|
51 |
#include <linux/proc_fs.h> |
52 |
#include <linux/seq_file.h> |
51 |
|
53 |
|
52 |
/*---------------------------------------------------------------------------*\ |
54 |
/*---------------------------------------------------------------------------*\ |
53 |
\*---------------------------------------------------------------------------*/ |
55 |
\*---------------------------------------------------------------------------*/ |
Lines 99-105
Link Here
|
99 |
static unsigned long crit_flags; |
101 |
static unsigned long crit_flags; |
100 |
static atomic_t scheduler_enabled = ATOMIC_INIT (0); |
102 |
static atomic_t scheduler_enabled = ATOMIC_INIT (0); |
101 |
static atomic_t scheduler_id = ATOMIC_INIT (-1); |
103 |
static atomic_t scheduler_id = ATOMIC_INIT (-1); |
102 |
static spinlock_t stack_lock = SPIN_LOCK_UNLOCKED; |
104 |
static spinlock_t sched_lock = SPIN_LOCK_UNLOCKED; |
103 |
#if !defined (__fcclassic__) |
105 |
#if !defined (__fcclassic__) |
104 |
static int card_id = 0; |
106 |
static int card_id = 0; |
105 |
#endif |
107 |
#endif |
Lines 107-117
Link Here
|
107 |
/*---------------------------------------------------------------------------*\ |
109 |
/*---------------------------------------------------------------------------*\ |
108 |
\*---------------------------------------------------------------------------*/ |
110 |
\*---------------------------------------------------------------------------*/ |
109 |
static void scheduler (unsigned long data); |
111 |
static void scheduler (unsigned long data); |
110 |
static irqreturn_t irq_handler (int irq, void * args |
112 |
static irqreturn_t irq_handler (int irq, void * args); |
111 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) |
|
|
112 |
, struct pt_regs * regs |
113 |
#endif |
114 |
); |
115 |
|
113 |
|
116 |
static DECLARE_TASKLET_DISABLED (scheduler_tasklet, scheduler, 0); |
114 |
static DECLARE_TASKLET_DISABLED (scheduler_tasklet, scheduler, 0); |
117 |
|
115 |
|
Lines 198-204
Link Here
|
198 |
} |
196 |
} |
199 |
lib_strncpy (ctrl->serial, tmp, CAPI_SERIAL_LEN); |
197 |
lib_strncpy (ctrl->serial, tmp, CAPI_SERIAL_LEN); |
200 |
lib_memcpy (&ctrl->profile, card->string[6], sizeof (capi_profile)); |
198 |
lib_memcpy (&ctrl->profile, card->string[6], sizeof (capi_profile)); |
201 |
strncpy (ctrl->manu, "AVM GmbH", CAPI_MANUFACTURER_LEN); |
199 |
lib_strncpy (ctrl->manu, "AVM GmbH", CAPI_MANUFACTURER_LEN); |
202 |
ctrl->version.majorversion = 2; |
200 |
ctrl->version.majorversion = 2; |
203 |
ctrl->version.minorversion = 0; |
201 |
ctrl->version.minorversion = 0; |
204 |
tmp = card->string[0]; |
202 |
tmp = card->string[0]; |
Lines 224-239
Link Here
|
224 |
} /* kill_version */ |
222 |
} /* kill_version */ |
225 |
|
223 |
|
226 |
/*---------------------------------------------------------------------------*\ |
224 |
/*---------------------------------------------------------------------------*\ |
227 |
\*---------------------------------------------------------------------------*/ |
|
|
228 |
static void pprintf (char * page, int * len, const char * fmt, ...) { |
229 |
va_list args; |
230 |
|
231 |
va_start (args, fmt); |
232 |
*len += vsprintf (page + *len, fmt, args); |
233 |
va_end (args); |
234 |
} /* pprintf */ |
235 |
|
236 |
/*---------------------------------------------------------------------------*\ |
237 |
\*-C-------------------------------------------------------------------------*/ |
225 |
\*-C-------------------------------------------------------------------------*/ |
238 |
static inline int in_critical (void) { |
226 |
static inline int in_critical (void) { |
239 |
|
227 |
|
Lines 378-386
Link Here
|
378 |
card->irq, |
366 |
card->irq, |
379 |
&irq_handler, |
367 |
&irq_handler, |
380 |
#if defined (__fcpci__) || defined (__fcpcmcia__) |
368 |
#if defined (__fcpci__) || defined (__fcpcmcia__) |
381 |
SA_INTERRUPT | SA_SHIRQ, |
369 |
IRQF_DISABLED | IRQF_SHARED, |
382 |
#else |
370 |
#else |
383 |
SA_INTERRUPT, |
371 |
IRQF_DISABLED, |
384 |
#endif |
372 |
#endif |
385 |
TARGET, |
373 |
TARGET, |
386 |
card |
374 |
card |
Lines 494-532
Link Here
|
494 |
|
482 |
|
495 |
/*---------------------------------------------------------------------------*\ |
483 |
/*---------------------------------------------------------------------------*\ |
496 |
\*---------------------------------------------------------------------------*/ |
484 |
\*---------------------------------------------------------------------------*/ |
497 |
static int __kcapi ctr_info ( |
485 |
|
498 |
char * page, |
486 |
static int __kcapi ctr_info (struct seq_file *m, void *v |
499 |
char ** start, |
|
|
500 |
off_t ofs, |
501 |
int count, |
502 |
int * eof, |
503 |
struct capi_ctr * ctrl |
504 |
) { |
487 |
) { |
|
|
488 |
struct capi_ctr *ctrl = m->private; |
505 |
card_t * card; |
489 |
card_t * card; |
506 |
char * temp; |
490 |
char * temp; |
507 |
unsigned char flag; |
491 |
unsigned char flag; |
508 |
int len = 0; |
|
|
509 |
|
492 |
|
510 |
assert (ctrl != NULL); |
493 |
assert (ctrl != NULL); |
511 |
card = (card_t *) ctrl->driverdata; |
494 |
card = (card_t *) ctrl->driverdata; |
512 |
assert (card != NULL); |
495 |
assert (card != NULL); |
513 |
pprintf (page, &len, "%-16s %s\n", "name", SHORT_LOGO); |
496 |
seq_printf(m, "%-16s %s\n", "name", SHORT_LOGO); |
514 |
pprintf (page, &len, "%-16s 0x%04x\n", "io", card->base); |
497 |
seq_printf(m, "%-16s 0x%04x\n", "io", card->base); |
515 |
pprintf (page, &len, "%-16s %d\n", "irq", card->irq); |
498 |
seq_printf(m, "%-16s %d\n", "irq", card->irq); |
516 |
temp = card->version ? card->string[1] : "A1"; |
499 |
temp = card->version ? card->string[1] : "A1"; |
517 |
pprintf (page, &len, "%-16s %s\n", "type", temp); |
500 |
seq_printf(m, "%-16s %s\n", "type", temp); |
518 |
temp = card->version ? card->string[0] : "-"; |
501 |
temp = card->version ? card->string[0] : "-"; |
519 |
#if defined (__fcclassic__) || defined (__fcpcmcia__) |
502 |
#if defined (__fcclassic__) || defined (__fcpcmcia__) |
520 |
pprintf (page, &len, "%-16s 0x%04x\n", "revision", card->info); |
503 |
seq_printf(m, "%-16s 0x%04x\n", "revision", card->info); |
521 |
#elif defined (__fcpci__) |
504 |
#elif defined (__fcpci__) |
522 |
pprintf (page, &len, "%-16s %d\n", "class", card_id); |
505 |
seq_printf(m, "%-16s %d\n", "class", card_id); |
523 |
#endif |
506 |
#endif |
524 |
pprintf (page, &len, "%-16s %s\n", "ver_driver", temp); |
507 |
seq_printf(m, "%-16s %s\n", "ver_driver", temp); |
525 |
pprintf (page, &len, "%-16s %s\n", "ver_cardtype", SHORT_LOGO); |
508 |
seq_printf(m, "%-16s %s\n", "ver_cardtype", SHORT_LOGO); |
526 |
|
509 |
|
527 |
flag = ((unsigned char *) (ctrl->profile.manu))[3]; |
510 |
flag = ((unsigned char *) (ctrl->profile.manu))[3]; |
528 |
if (flag) { |
511 |
if (flag) { |
529 |
pprintf(page, &len, "%-16s%s%s%s%s%s%s%s\n", "protocol", |
512 |
seq_printf(m, "%-16s%s%s%s%s%s%s%s\n", "protocol", |
530 |
(flag & 0x01) ? " DSS1" : "", |
513 |
(flag & 0x01) ? " DSS1" : "", |
531 |
(flag & 0x02) ? " CT1" : "", |
514 |
(flag & 0x02) ? " CT1" : "", |
532 |
(flag & 0x04) ? " VN3" : "", |
515 |
(flag & 0x04) ? " VN3" : "", |
Lines 538-558
Link Here
|
538 |
} |
521 |
} |
539 |
flag = ((unsigned char *) (ctrl->profile.manu))[5]; |
522 |
flag = ((unsigned char *) (ctrl->profile.manu))[5]; |
540 |
if (flag) { |
523 |
if (flag) { |
541 |
pprintf(page, &len, "%-16s%s%s%s%s\n", "linetype", |
524 |
seq_printf(m, "%-16s%s%s%s%s\n", "linetype", |
542 |
(flag & 0x01) ? " point to point" : "", |
525 |
(flag & 0x01) ? " point to point" : "", |
543 |
(flag & 0x02) ? " point to multipoint" : "", |
526 |
(flag & 0x02) ? " point to multipoint" : "", |
544 |
(flag & 0x08) ? " leased line without D-channel" : "", |
527 |
(flag & 0x08) ? " leased line without D-channel" : "", |
545 |
(flag & 0x04) ? " leased line with D-channel" : "" |
528 |
(flag & 0x04) ? " leased line with D-channel" : "" |
546 |
); |
529 |
); |
547 |
} |
530 |
} |
548 |
if (len < ofs) { |
531 |
|
549 |
return 0; |
532 |
return 0; |
550 |
} |
|
|
551 |
*eof = 1; |
552 |
*start = page - ofs; |
553 |
return ((count < len - ofs) ? count : len - ofs); |
554 |
} /* ctr_info */ |
533 |
} /* ctr_info */ |
555 |
|
534 |
|
|
|
535 |
static int ctr_proc_open(struct inode *inode, struct file *file) |
536 |
{ |
537 |
return single_open(file, ctr_info, PDE(inode)->data); |
538 |
} |
539 |
|
540 |
const struct file_operations ctr_proc_fops = { |
541 |
.owner = THIS_MODULE, |
542 |
.open = ctr_proc_open, |
543 |
.read = seq_read, |
544 |
.llseek = seq_lseek, |
545 |
.release = single_release, |
546 |
}; |
547 |
|
556 |
/*---------------------------------------------------------------------------*\ |
548 |
/*---------------------------------------------------------------------------*\ |
557 |
\*---------------------------------------------------------------------------*/ |
549 |
\*---------------------------------------------------------------------------*/ |
558 |
static void __kcapi reset_ctrl (struct capi_ctr * ctrl) { |
550 |
static void __kcapi reset_ctrl (struct capi_ctr * ctrl) { |
Lines 573-579
Link Here
|
573 |
} |
565 |
} |
574 |
} |
566 |
} |
575 |
stop (card); |
567 |
stop (card); |
576 |
capi_ctr_reseted (ctrl); |
568 |
capi_ctr_down (ctrl); |
577 |
#if defined (__fcpnp__) |
569 |
#if defined (__fcpnp__) |
578 |
pnp_disable_dev (card->dev); |
570 |
pnp_disable_dev (card->dev); |
579 |
#endif |
571 |
#endif |
Lines 630-636
Link Here
|
630 |
ctrl->release_appl = release_appl; |
622 |
ctrl->release_appl = release_appl; |
631 |
ctrl->send_message = send_msg; |
623 |
ctrl->send_message = send_msg; |
632 |
ctrl->procinfo = proc_info; |
624 |
ctrl->procinfo = proc_info; |
633 |
ctrl->ctr_read_proc = ctr_info; |
625 |
ctrl->proc_fops = &ctr_proc_fops; |
634 |
if (0 != (res = attach_capi_ctr (ctrl))) { |
626 |
if (0 != (res = attach_capi_ctr (ctrl))) { |
635 |
dec_use_count (); |
627 |
dec_use_count (); |
636 |
stop (card); |
628 |
stop (card); |
Lines 825-831
Link Here
|
825 |
|
817 |
|
826 |
UNUSED_ARG (data); |
818 |
UNUSED_ARG (data); |
827 |
atomic_set (&scheduler_id, smp_processor_id ()); |
819 |
atomic_set (&scheduler_id, smp_processor_id ()); |
828 |
if (spin_trylock (&stack_lock)) { |
820 |
if (spin_trylock (&sched_lock)) { |
829 |
while (!atomic_read (&dont_sched)) { |
821 |
while (!atomic_read (&dont_sched)) { |
830 |
atomic_set (&dont_sched, 1); |
822 |
atomic_set (&dont_sched, 1); |
831 |
os_timer_poll (); |
823 |
os_timer_poll (); |
Lines 833-864
Link Here
|
833 |
scheduler_control (TRUE); |
825 |
scheduler_control (TRUE); |
834 |
} |
826 |
} |
835 |
} |
827 |
} |
836 |
spin_unlock (&stack_lock); |
828 |
spin_unlock (&sched_lock); |
837 |
} |
829 |
} |
838 |
atomic_set (&scheduler_id, -1); |
830 |
atomic_set (&scheduler_id, -1); |
839 |
} /* scheduler */ |
831 |
} /* scheduler */ |
840 |
|
832 |
|
841 |
/*---------------------------------------------------------------------------*\ |
833 |
/*---------------------------------------------------------------------------*\ |
842 |
\*---------------------------------------------------------------------------*/ |
834 |
\*---------------------------------------------------------------------------*/ |
843 |
static irqreturn_t irq_handler (int irq, void * args |
835 |
static irqreturn_t irq_handler (int irq, void * args) { |
844 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) |
|
|
845 |
, struct pt_regs * regs |
846 |
#endif |
847 |
) { |
848 |
int res = IRQ_NONE; |
836 |
int res = IRQ_NONE; |
849 |
|
837 |
|
850 |
UNUSED_ARG (irq); |
838 |
UNUSED_ARG (irq); |
851 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) |
|
|
852 |
UNUSED_ARG (regs); |
853 |
#endif |
854 |
if (args != NULL) { |
839 |
if (args != NULL) { |
855 |
assert (capi_lib->cm_handle_events != NULL); |
840 |
assert (capi_lib->cm_handle_events != NULL); |
856 |
if (atomic_read (&scheduler_id) == smp_processor_id ()) { |
841 |
if (atomic_read (&scheduler_id) == smp_processor_id ()) { |
857 |
res = IRQ_RETVAL ((*capi_lib->cm_handle_events) ()); |
842 |
res = IRQ_RETVAL ((*capi_lib->cm_handle_events) ()); |
858 |
} else { |
843 |
} else { |
859 |
spin_lock (&stack_lock); |
844 |
spin_lock (&sched_lock); |
860 |
res = IRQ_RETVAL ((*capi_lib->cm_handle_events) ()); |
845 |
res = IRQ_RETVAL ((*capi_lib->cm_handle_events) ()); |
861 |
spin_unlock (&stack_lock); |
846 |
spin_unlock (&sched_lock); |
862 |
} |
847 |
} |
863 |
if (res == IRQ_HANDLED) { |
848 |
if (res == IRQ_HANDLED) { |
864 |
atomic_set (&dont_sched, 0); |
849 |
atomic_set (&dont_sched, 0); |
Lines 911-920
Link Here
|
911 |
|
896 |
|
912 |
/*---------------------------------------------------------------------------*\ |
897 |
/*---------------------------------------------------------------------------*\ |
913 |
\*---------------------------------------------------------------------------*/ |
898 |
\*---------------------------------------------------------------------------*/ |
914 |
int driver_init (void) { |
899 |
int avm_driver_init (void) { |
915 |
|
900 |
|
916 |
return (NULL != (capi_lib = link_library (NULL))); |
901 |
return (NULL != (capi_lib = link_library (NULL))); |
917 |
} /* driver_init */ |
902 |
} /* avm_driver_init */ |
918 |
|
903 |
|
919 |
/*---------------------------------------------------------------------------*\ |
904 |
/*---------------------------------------------------------------------------*\ |
920 |
\*---------------------------------------------------------------------------*/ |
905 |
\*---------------------------------------------------------------------------*/ |