source: rtems/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h @ cb2651d

5
Last change on this file since cb2651d was cb2651d, checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/16 at 07:47:12

network: Align with Newlib type definitions

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