1 | /* |
---|
2 | * Declarations to fit FreeBSD to RTEMS. |
---|
3 | * |
---|
4 | ******************************************************************* |
---|
5 | * WARNING * |
---|
6 | * This file should *never* be included by any application program * |
---|
7 | ******************************************************************* |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef _RTEMS_RTEMS_BSDNET_INTERNAL_H |
---|
11 | #define _RTEMS_RTEMS_BSDNET_INTERNAL_H |
---|
12 | |
---|
13 | #include <sys/_types.h> |
---|
14 | #include <rtems.h> |
---|
15 | #include <rtems/fs.h> |
---|
16 | #include <rtems/score/timecounter.h> |
---|
17 | |
---|
18 | #ifdef __cplusplus |
---|
19 | extern "C" { |
---|
20 | #endif |
---|
21 | |
---|
22 | typedef __uintptr_t vm_offset_t; |
---|
23 | typedef __intptr_t vm_ooffset_t; |
---|
24 | typedef __uintptr_t vm_pindex_t; |
---|
25 | typedef __uintptr_t vm_size_t; |
---|
26 | |
---|
27 | #define _BSD_OFF_T_ int32_t |
---|
28 | #define _BSD_PID_T_ rtems_id |
---|
29 | #define _BSD_VA_LIST_ char * |
---|
30 | |
---|
31 | /* make sure we get the network versions of these */ |
---|
32 | #include <machine/types.h> |
---|
33 | #include <machine/param.h> |
---|
34 | #include <machine/endian.h> |
---|
35 | #include <sys/cdefs.h> |
---|
36 | |
---|
37 | #include <sys/time.h> |
---|
38 | #include <sys/ioctl.h> |
---|
39 | |
---|
40 | struct mdproc { |
---|
41 | int md_flags; |
---|
42 | int *md_regs; |
---|
43 | }; |
---|
44 | |
---|
45 | /* |
---|
46 | * Other RTEMS/BSD glue |
---|
47 | */ |
---|
48 | struct socket; |
---|
49 | extern int soconnsleep (struct socket *so); |
---|
50 | extern void soconnwakeup (struct socket *so); |
---|
51 | #define splnet() 0 |
---|
52 | #define splimp() 0 |
---|
53 | #define splx(_s) do { (_s) = 0; (void) (_s); } while(0) |
---|
54 | |
---|
55 | /* to avoid warnings */ |
---|
56 | void *memcpy(void *dest, const void *src, size_t n); |
---|
57 | void *memset(void *s, int c, size_t n); |
---|
58 | |
---|
59 | #define ovbcopy(f,t,n) bcopy(f,t,n) |
---|
60 | #define copyout(f,t,n) (memcpy(t,f,n),0) |
---|
61 | #define copyin(f,t,n) (memcpy(t,f,n),0) |
---|
62 | |
---|
63 | #define random() rtems_bsdnet_random() |
---|
64 | #define panic rtems_panic |
---|
65 | #define suser(a,b) 0 |
---|
66 | |
---|
67 | #define microtime(_tvp) _Timecounter_Microtime(_tvp) |
---|
68 | |
---|
69 | #define hz rtems_bsdnet_ticks_per_second |
---|
70 | #define tick rtems_bsdnet_microseconds_per_tick |
---|
71 | |
---|
72 | #define log rtems_bsdnet_log |
---|
73 | |
---|
74 | /* |
---|
75 | * Since we can't have two sys/types.h files, we'll hack around |
---|
76 | * and copy the contents of the BSD sys/types.h to here.... |
---|
77 | */ |
---|
78 | |
---|
79 | typedef u_int64_t u_quad_t; /* quads */ |
---|
80 | typedef int64_t quad_t; |
---|
81 | typedef quad_t * qaddr_t; |
---|
82 | |
---|
83 | typedef void __sighandler_t(int); |
---|
84 | typedef __sighandler_t *sig_t; /* type of pointer to a signal function */ |
---|
85 | #define NSIG 32 |
---|
86 | |
---|
87 | #ifdef _KERNEL |
---|
88 | typedef int boolean_t; |
---|
89 | #endif |
---|
90 | |
---|
91 | #ifndef _POSIX_SOURCE |
---|
92 | /* |
---|
93 | * minor() gives a cookie instead of an index since we don't want to |
---|
94 | * change the meanings of bits 0-15 or waste time and space shifting |
---|
95 | * bits 16-31 for devices that don't use them. |
---|
96 | */ |
---|
97 | #define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ |
---|
98 | #define minor(x) ((int)((x)&0xffff00ff)) /* minor number */ |
---|
99 | #define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ |
---|
100 | #endif |
---|
101 | |
---|
102 | #ifndef _BYTEORDER_PROTOTYPED |
---|
103 | #define _BYTEORDER_PROTOTYPED |
---|
104 | __BEGIN_DECLS |
---|
105 | __uint32_t htonl(__uint32_t); |
---|
106 | __uint16_t htons(__uint16_t); |
---|
107 | __uint32_t ntohl(__uint32_t); |
---|
108 | __uint16_t ntohs(__uint16_t); |
---|
109 | __END_DECLS |
---|
110 | #endif |
---|
111 | |
---|
112 | #ifndef _BYTEORDER_FUNC_DEFINED |
---|
113 | #define _BYTEORDER_FUNC_DEFINED |
---|
114 | #define htonl(x) __htonl(x) |
---|
115 | #define htons(x) __htons(x) |
---|
116 | #define ntohl(x) __ntohl(x) |
---|
117 | #define ntohs(x) __ntohs(x) |
---|
118 | #endif /* !_BYTEORDER_FUNC_DEFINED */ |
---|
119 | |
---|
120 | #define NTOHS(x) (x) = ntohs(x) |
---|
121 | #define HTONS(x) (x) = htons(x) |
---|
122 | #define NTOHL(x) (x) = ntohl(x) |
---|
123 | #define HTONL(x) (x) = htonl(x) |
---|
124 | |
---|
125 | in_addr_t inet_addr(const char *); |
---|
126 | |
---|
127 | typedef quad_t rlim_t; /* resource limit */ |
---|
128 | typedef u_int32_t fixpt_t; /* fixed point number */ |
---|
129 | |
---|
130 | /* |
---|
131 | * Forward structure declarations for function prototypes. We include the |
---|
132 | * common structures that cross subsystem boundaries here; others are mostly |
---|
133 | * used in the same place that the structure is defined. |
---|
134 | */ |
---|
135 | struct proc; |
---|
136 | struct pgrp; |
---|
137 | struct ucred; |
---|
138 | struct rusage; |
---|
139 | struct buf; |
---|
140 | struct tty; |
---|
141 | struct uio; |
---|
142 | struct rtems_bsdnet_ifconfig; |
---|
143 | |
---|
144 | /* |
---|
145 | * Redo kernel memory allocation |
---|
146 | */ |
---|
147 | #define malloc(size,type,flags) rtems_bsdnet_malloc(size,type,flags) |
---|
148 | #define free(ptr,type) rtems_bsdnet_free(ptr,type) |
---|
149 | #define timeout(ftn,arg,ticks) rtems_bsdnet_timeout(ftn,arg,ticks) |
---|
150 | |
---|
151 | #define M_NOWAIT 0x0001 |
---|
152 | void *rtems_bsdnet_malloc (size_t size, int type, int flags); |
---|
153 | void rtems_bsdnet_free (void *addr, int type); |
---|
154 | |
---|
155 | void rtems_bsdnet_semaphore_obtain (void); |
---|
156 | void rtems_bsdnet_semaphore_release (void); |
---|
157 | void rtems_bsdnet_semaphore_obtain_recursive (uint32_t nest_count); |
---|
158 | uint32_t rtems_bsdnet_semaphore_release_recursive (void); |
---|
159 | void rtems_bsdnet_schednetisr (int n); |
---|
160 | int rtems_bsdnet_parse_driver_name (const struct rtems_bsdnet_ifconfig *config, char **namep); |
---|
161 | |
---|
162 | static inline unsigned long rtems_bsdnet_seconds_since_boot(void) |
---|
163 | { |
---|
164 | return (unsigned long) rtems_clock_get_uptime_seconds() + 1UL; |
---|
165 | } |
---|
166 | |
---|
167 | unsigned long rtems_bsdnet_random (void); |
---|
168 | |
---|
169 | rtems_id rtems_bsdnet_newproc ( |
---|
170 | char *name, |
---|
171 | int stacksize, |
---|
172 | void (*entry)(void *), |
---|
173 | void *arg |
---|
174 | ); |
---|
175 | |
---|
176 | #ifdef RTEMS_SMP |
---|
177 | /* As rtems_bsdnet_newproc() but with ability to set CPU affinity too */ |
---|
178 | rtems_id rtems_bsdnet_newproc_affinity ( |
---|
179 | char *name, |
---|
180 | int stacksize, |
---|
181 | void (*entry)(void *), |
---|
182 | void *arg, |
---|
183 | const cpu_set_t *set, |
---|
184 | const size_t setsize |
---|
185 | ); |
---|
186 | #endif |
---|
187 | |
---|
188 | rtems_status_code rtems_bsdnet_event_receive ( |
---|
189 | rtems_event_set event_in, |
---|
190 | rtems_option option_set, |
---|
191 | rtems_interval ticks, |
---|
192 | rtems_event_set *event_out |
---|
193 | ); |
---|
194 | |
---|
195 | static inline rtems_status_code rtems_bsdnet_event_send ( |
---|
196 | rtems_id task_id, |
---|
197 | rtems_event_set event_in |
---|
198 | ) |
---|
199 | { |
---|
200 | return rtems_event_system_send (task_id, event_in); |
---|
201 | } |
---|
202 | |
---|
203 | /* |
---|
204 | * Network configuration |
---|
205 | */ |
---|
206 | extern int rtems_bsdnet_ticks_per_second; |
---|
207 | extern int rtems_bsdnet_microseconds_per_tick; |
---|
208 | extern struct in_addr rtems_bsdnet_log_host_address; |
---|
209 | extern char *rtems_bsdnet_domain_name; |
---|
210 | |
---|
211 | /* |
---|
212 | * Internal IOCTL command |
---|
213 | */ |
---|
214 | #define SIO_RTEMS_SHOW_STATS _IO('i', 250) |
---|
215 | |
---|
216 | /* |
---|
217 | * Some extra prototypes |
---|
218 | */ |
---|
219 | int sethostname (const char *name, size_t namelen); |
---|
220 | void domaininit (void *); |
---|
221 | void ifinit (void *); |
---|
222 | void ipintr (void); |
---|
223 | void arpintr (void); |
---|
224 | int socket (int, int, int); |
---|
225 | int ioctl (int, ioctl_command_t, ...); |
---|
226 | |
---|
227 | /* |
---|
228 | * Events used by networking routines. |
---|
229 | * Everything will break if the application |
---|
230 | * tries to use these events or if the `sleep' |
---|
231 | * events are equal to any of the NETISR * events. |
---|
232 | */ |
---|
233 | #define SBWAIT_EVENT RTEMS_EVENT_SYSTEM_NETWORK_SBWAIT |
---|
234 | #define SOSLEEP_EVENT RTEMS_EVENT_SYSTEM_NETWORK_SOSLEEP |
---|
235 | #define NETISR_IP_EVENT (1L << NETISR_IP) |
---|
236 | #define NETISR_ARP_EVENT (1L << NETISR_ARP) |
---|
237 | #define NETISR_EVENTS (NETISR_IP_EVENT|NETISR_ARP_EVENT) |
---|
238 | #if (SBWAIT_EVENT & SOSLEEP_EVENT & NETISR_EVENTS & RTEMS_EVENT_SYSTEM_NETWORK_CLOSE) |
---|
239 | # error "Network event conflict" |
---|
240 | #endif |
---|
241 | |
---|
242 | struct socket *rtems_bsdnet_fdToSocket(int fd); |
---|
243 | |
---|
244 | void sysctl_register_all(void *); |
---|
245 | |
---|
246 | void rtems_set_udp_buffer_sizes(u_long, u_long); |
---|
247 | |
---|
248 | void rtems_set_tcp_buffer_sizes(u_long, u_long); |
---|
249 | |
---|
250 | void rtems_set_sb_efficiency(u_long); |
---|
251 | |
---|
252 | #ifdef __cplusplus |
---|
253 | } |
---|
254 | #endif |
---|
255 | |
---|
256 | #endif /* _RTEMS_RTEMS_BSDNET_INTERNAL_H */ |
---|