source: rtems/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h @ 714617e

5
Last change on this file since 714617e was 714617e, checked in by Sebastian Huber <sebastian.huber@…>, on 01/13/17 at 10:43:40

configure: Remove RTEMS_HAVE_DECL_SIGALTSTACK

  • Property mode set to 100644
File size: 6.5 KB
Line 
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
19extern "C" {
20#endif
21
22typedef __uintptr_t             vm_offset_t;
23typedef __intptr_t              vm_ooffset_t;
24typedef __uintptr_t             vm_pindex_t;
25typedef __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
40struct mdproc {
41        int     md_flags;
42        int     *md_regs;
43};
44
45/*
46 * Other RTEMS/BSD glue
47 */
48struct socket;
49extern int soconnsleep (struct socket *so);
50extern 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 */
56void *memcpy(void *dest, const void *src, size_t n);
57void *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
79typedef u_int64_t       u_quad_t;       /* quads */
80typedef int64_t         quad_t;
81typedef quad_t *        qaddr_t;
82
83typedef void __sighandler_t(int);
84typedef __sighandler_t  *sig_t; /* type of pointer to a signal function */
85#define NSIG    32
86
87#ifdef _KERNEL
88typedef 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
125in_addr_t        inet_addr(const char *);
126
127typedef quad_t          rlim_t;         /* resource limit */
128typedef 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 */
135struct  proc;
136struct  pgrp;
137struct  ucred;
138struct  rusage;
139struct  buf;
140struct  tty;
141struct  uio;
142struct  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
152void *rtems_bsdnet_malloc (size_t size, int type, int flags);
153void rtems_bsdnet_free (void *addr, int type);
154
155void rtems_bsdnet_semaphore_obtain (void);
156void rtems_bsdnet_semaphore_release (void);
157void rtems_bsdnet_semaphore_obtain_recursive (uint32_t nest_count);
158uint32_t rtems_bsdnet_semaphore_release_recursive (void);
159void rtems_bsdnet_schednetisr (int n);
160int rtems_bsdnet_parse_driver_name (const struct rtems_bsdnet_ifconfig *config, char **namep);
161
162static inline unsigned long rtems_bsdnet_seconds_since_boot(void)
163{
164  return (unsigned long) rtems_clock_get_uptime_seconds() + 1UL;
165}
166
167unsigned long rtems_bsdnet_random (void);
168
169rtems_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 */
178rtems_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
188rtems_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
195static 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 */
206extern int rtems_bsdnet_ticks_per_second;
207extern int rtems_bsdnet_microseconds_per_tick;
208extern struct in_addr rtems_bsdnet_log_host_address;
209extern 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 */
219int sethostname (const char *name, size_t namelen);
220void domaininit (void *);
221void ifinit (void *);
222void ipintr (void);
223void arpintr (void);
224int socket (int, int, int);
225int 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
242struct socket *rtems_bsdnet_fdToSocket(int fd);
243
244void sysctl_register_all(void *);
245
246void rtems_set_udp_buffer_sizes(u_long, u_long);
247
248void rtems_set_tcp_buffer_sizes(u_long, u_long);
249
250void rtems_set_sb_efficiency(u_long);
251
252#ifdef __cplusplus
253}
254#endif
255
256#endif /* _RTEMS_RTEMS_BSDNET_INTERNAL_H */
Note: See TracBrowser for help on using the repository browser.