3 * Copyright 1999 Digi International (www.digi.com)
4 * James Puzzo <jamesp at digi dot com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
13 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
18 #ifndef __DGRP_COMMON_H
19 #define __DGRP_COMMON_H
21 #define DIGI_VERSION "1.9-29"
24 #include <linux/timer.h>
27 #define DGRP_TTIME 100
28 #define DGRP_RTIME 100
30 /************************************************************************
31 * All global storage allocation.
32 ************************************************************************/
34 extern int dgrp_rawreadok
; /* Allow raw writing of input */
35 extern int dgrp_register_cudevices
; /* enable legacy cu devices */
36 extern int dgrp_register_prdevices
; /* enable transparent print devices */
37 extern int dgrp_poll_tick
; /* Poll interval - in ms */
39 extern struct list_head nd_struct_list
;
41 struct dgrp_poll_data
{
43 struct timer_list timer
;
45 ulong poll_round
; /* Timer rouding factor */
46 long node_active_count
;
49 extern struct dgrp_poll_data dgrp_poll_data
;
50 extern void dgrp_poll_handler(unsigned long arg
);
52 /* from dgrp_mon_ops.c */
53 extern void dgrp_register_mon_hook(struct proc_dir_entry
*de
);
56 extern int dgrp_tty_init(struct nd_struct
*nd
);
57 extern void dgrp_tty_uninit(struct nd_struct
*nd
);
59 /* from dgrp_ports_ops.c */
60 extern void dgrp_register_ports_hook(struct proc_dir_entry
*de
);
62 /* from dgrp_net_ops.c */
63 extern void dgrp_register_net_hook(struct proc_dir_entry
*de
);
65 /* from dgrp_dpa_ops.c */
66 extern void dgrp_register_dpa_hook(struct proc_dir_entry
*de
);
67 extern void dgrp_dpa_data(struct nd_struct
*, int, u8
*, int);
69 /* from dgrp_sysfs.c */
70 extern void dgrp_create_class_sysfs_files(void);
71 extern void dgrp_remove_class_sysfs_files(void);
73 extern void dgrp_create_node_class_sysfs_files(struct nd_struct
*nd
);
74 extern void dgrp_remove_node_class_sysfs_files(struct nd_struct
*nd
);
76 extern void dgrp_create_tty_sysfs(struct un_struct
*un
, struct device
*c
);
77 extern void dgrp_remove_tty_sysfs(struct device
*c
);
79 /* from dgrp_specproc.c */
81 * The list of DGRP entries with r/w capabilities. These
82 * magic numbers are used for identification purposes.
85 DGRP_CONFIG
= 1, /* Configure portservers */
86 DGRP_NETDIR
= 2, /* Directory for "net" devices */
87 DGRP_MONDIR
= 3, /* Directory for "mon" devices */
88 DGRP_PORTSDIR
= 4, /* Directory for "ports" devices */
89 DGRP_INFO
= 5, /* Get info. about the running module */
90 DGRP_NODEINFO
= 6, /* Get info. about the configured nodes */
91 DGRP_DPADIR
= 7, /* Directory for the "dpa" devices */
95 * Directions for proc handlers
98 INBOUND
= 1, /* Data being written to kernel */
99 OUTBOUND
= 2, /* Data being read from the kernel */
103 * dgrp_proc_entry: structure for dgrp proc dirs
104 * @id: ID number associated with this particular entry. Should be
105 * unique across all of DGRP.
106 * @name: text name associated with the /proc entry
107 * @mode: file access permisssions for the /proc entry
108 * @child: pointer to table describing a subdirectory for this entry
109 * @de: pointer to directory entry for this object once registered. Used
110 * to grab the handle of the object for unregistration
111 * @excl_sem: semaphore to provide exclusive to struct
112 * @excl_cnt: counter of current accesses
114 * Each entry in a DGRP proc directory is described with a
115 * dgrp_proc_entry structure. A collection of these
116 * entries (in an array) represents the members associated
117 * with a particular /proc directory, and is referred to
118 * as a table. All tables are terminated by an entry with
119 * zeros for every member.
121 struct dgrp_proc_entry
{
122 int id
; /* Integer identifier */
123 const char *name
; /* ASCII identifier */
124 mode_t mode
; /* File access permissions */
125 struct dgrp_proc_entry
*child
; /* Child pointer */
127 /* file ops to use, pass NULL to use default */
128 struct file_operations
*proc_file_ops
;
130 struct proc_dir_entry
*de
; /* proc entry pointer */
131 struct semaphore excl_sem
; /* Protects exclusive access var */
132 int excl_cnt
; /* Counts number of curr accesses */
135 extern void dgrp_unregister_proc(void);
136 extern void dgrp_register_proc(void);
138 /*-----------------------------------------------------------------------*
140 * Declarations for common operations:
142 * (either used by more than one of net, mon, or tty,
143 * or in interrupt context (i.e. the poller))
145 *-----------------------------------------------------------------------*/
147 void dgrp_carrier(struct ch_struct
*ch
);
148 extern int dgrp_inode_permission(struct inode
*inode
, int op
);
149 extern int dgrp_chk_perm(int mode
, int op
);
153 * ID manipulation macros (where c1 & c2 are characters, i is
154 * a long integer, and s is a character array of at least three members
157 static inline void ID_TO_CHAR(long i
, char *s
)
159 s
[0] = ((i
& 0xff00)>>8);
164 static inline long CHAR_TO_ID(char *s
)
166 return ((s
[0] & 0xff) << 8) | (s
[1] & 0xff);
169 static inline struct nd_struct
*nd_struct_get(long major
)
171 struct nd_struct
*nd
;
173 list_for_each_entry(nd
, &nd_struct_list
, list
) {
174 if (major
== nd
->nd_major
)
181 static inline int nd_struct_add(struct nd_struct
*entry
)
183 struct nd_struct
*ptr
;
185 ptr
= nd_struct_get(entry
->nd_major
);
190 list_add_tail(&entry
->list
, &nd_struct_list
);
195 static inline int nd_struct_del(struct nd_struct
*entry
)
197 struct nd_struct
*nd
;
199 nd
= nd_struct_get(entry
->nd_major
);
208 #endif /* __DGRP_COMMON_H */