RTEMS CPU Kit with SuperCore  4.11.3
rtems_bsdnet_internal.h
Go to the documentation of this file.
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 <rtems.h>
14 #include <rtems/fs.h>
15 #include <rtems/bsd.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 typedef unsigned int vm_offset_t;
22 typedef long long vm_ooffset_t;
23 typedef unsigned int vm_pindex_t;
24 typedef unsigned int vm_size_t;
25 
26 #define _BSD_OFF_T_ int32_t
27 #define _BSD_PID_T_ rtems_id
28 #define _BSD_VA_LIST_ char *
29 
30 /* make sure we get the network versions of these */
31 #include <machine/types.h>
32 #include <machine/param.h>
33 #include <sys/cdefs.h>
34 
35 #include <sys/time.h>
36 #include <sys/ioctl.h>
37 
38 struct mdproc {
39  int md_flags;
40  int *md_regs;
41 };
42 
43 /*
44  * Other RTEMS/BSD glue
45  */
46 struct socket;
47 extern int soconnsleep (struct socket *so);
48 extern void soconnwakeup (struct socket *so);
49 #define splnet() 0
50 #define splimp() 0
51 #define splx(_s) do { (_s) = 0; (void) (_s); } while(0)
52 
53 /* to avoid warnings */
54 void *memcpy(void *dest, const void *src, size_t n);
55 void *memset(void *s, int c, size_t n);
56 
57 #define ovbcopy(f,t,n) bcopy(f,t,n)
58 #define copyout(f,t,n) (memcpy(t,f,n),0)
59 #define copyin(f,t,n) (memcpy(t,f,n),0)
60 
61 #define random() rtems_bsdnet_random()
62 #define panic rtems_panic
63 #define suser(a,b) 0
64 
65 #define microtime(tv) rtems_bsd_microtime(tv)
66 
67 #define hz rtems_bsdnet_ticks_per_second
68 #define tick rtems_bsdnet_microseconds_per_tick
69 
70 #define log rtems_bsdnet_log
71 
72 /*
73  * Since we can't have two sys/types.h files, we'll hack around
74  * and copy the contents of the BSD sys/types.h to here....
75  */
76 
77 typedef u_int64_t u_quad_t; /* quads */
78 typedef int64_t quad_t;
79 typedef quad_t * qaddr_t;
80 
81 typedef void __sighandler_t(int);
82 typedef __sighandler_t *sig_t; /* type of pointer to a signal function */
83 #define NSIG 32
84 #if (__RTEMS_HAVE_DECL_SIGALTSTACK__ == 0)
85 struct sigaltstack {
86  char *ss_sp; /* signal stack base */
87  int ss_size; /* signal stack length */
88  int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
89 };
90 #endif
91 
92 #ifdef _KERNEL
93 typedef int boolean_t;
94 #endif
95 
96 #ifndef _POSIX_SOURCE
97 /*
98  * minor() gives a cookie instead of an index since we don't want to
99  * change the meanings of bits 0-15 or waste time and space shifting
100  * bits 16-31 for devices that don't use them.
101  */
102 #define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
103 #define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
104 #define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
105 #endif
106 
107 #include <rtems/endian.h>
108 
109 typedef quad_t rlim_t; /* resource limit */
110 typedef u_int32_t fixpt_t; /* fixed point number */
111 
112 /*
113  * Forward structure declarations for function prototypes. We include the
114  * common structures that cross subsystem boundaries here; others are mostly
115  * used in the same place that the structure is defined.
116  */
117 struct proc;
118 struct pgrp;
119 struct ucred;
120 struct rusage;
121 struct buf;
122 struct tty;
123 struct uio;
124 struct rtems_bsdnet_ifconfig;
125 
126 /*
127  * Redo kernel memory allocation
128  */
129 #define malloc(size,type,flags) rtems_bsdnet_malloc(size,type,flags)
130 #define free(ptr,type) rtems_bsdnet_free(ptr,type)
131 #define timeout(ftn,arg,ticks) rtems_bsdnet_timeout(ftn,arg,ticks)
132 
133 #define M_NOWAIT 0x0001
134 void *rtems_bsdnet_malloc (size_t size, int type, int flags);
135 void rtems_bsdnet_free (void *addr, int type);
136 
137 void rtems_bsdnet_semaphore_obtain (void);
138 void rtems_bsdnet_semaphore_release (void);
139 void rtems_bsdnet_semaphore_obtain_recursive (uint32_t nest_count);
140 uint32_t rtems_bsdnet_semaphore_release_recursive (void);
141 void rtems_bsdnet_schednetisr (int n);
142 int rtems_bsdnet_parse_driver_name (const struct rtems_bsdnet_ifconfig *config, char **namep);
143 
144 static inline unsigned long rtems_bsdnet_seconds_since_boot(void)
145 {
146  return (unsigned long) rtems_clock_get_uptime_seconds() + 1UL;
147 }
148 
149 unsigned long rtems_bsdnet_random (void);
150 
151 rtems_id rtems_bsdnet_newproc (
152  char *name,
153  int stacksize,
154  void (*entry)(void *),
155  void *arg
156 );
157 
158 #ifdef RTEMS_SMP
159 /* As rtems_bsdnet_newproc() but with ability to set CPU affinity too */
160 rtems_id rtems_bsdnet_newproc_affinity (
161  char *name,
162  int stacksize,
163  void (*entry)(void *),
164  void *arg,
165  const cpu_set_t *set,
166  const size_t setsize
167 );
168 #endif
169 
170 rtems_status_code rtems_bsdnet_event_receive (
171  rtems_event_set event_in,
172  rtems_option option_set,
173  rtems_interval ticks,
174  rtems_event_set *event_out
175 );
176 
177 static inline rtems_status_code rtems_bsdnet_event_send (
178  rtems_id task_id,
179  rtems_event_set event_in
180 )
181 {
182  return rtems_event_system_send (task_id, event_in);
183 }
184 
185 /*
186  * Network configuration
187  */
188 extern int rtems_bsdnet_ticks_per_second;
189 extern int rtems_bsdnet_microseconds_per_tick;
190 extern struct in_addr rtems_bsdnet_log_host_address;
191 extern char *rtems_bsdnet_domain_name;
192 
193 /*
194  * Internal IOCTL command
195  */
196 #define SIO_RTEMS_SHOW_STATS _IO('i', 250)
197 
198 /*
199  * Some extra prototypes
200  */
201 int sethostname (const char *name, size_t namelen);
202 void domaininit (void *);
203 void ifinit (void *);
204 void ipintr (void);
205 void arpintr (void);
206 int socket (int, int, int);
207 int ioctl (int, ioctl_command_t, ...);
208 
209 /*
210  * Events used by networking routines.
211  * Everything will break if the application
212  * tries to use these events or if the `sleep'
213  * events are equal to any of the NETISR * events.
214  */
215 #define SBWAIT_EVENT RTEMS_EVENT_SYSTEM_NETWORK_SBWAIT
216 #define SOSLEEP_EVENT RTEMS_EVENT_SYSTEM_NETWORK_SOSLEEP
217 #define NETISR_IP_EVENT (1L << NETISR_IP)
218 #define NETISR_ARP_EVENT (1L << NETISR_ARP)
219 #define NETISR_EVENTS (NETISR_IP_EVENT|NETISR_ARP_EVENT)
220 #if (SBWAIT_EVENT & SOSLEEP_EVENT & NETISR_EVENTS & RTEMS_EVENT_SYSTEM_NETWORK_CLOSE)
221 # error "Network event conflict"
222 #endif
223 
224 struct socket *rtems_bsdnet_fdToSocket(int fd);
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 
230 #endif /* _RTEMS_RTEMS_BSDNET_INTERNAL_H */
Definition: deflate.c:116
RTEMS_INLINE_ROUTINE time_t rtems_clock_get_uptime_seconds(void)
Returns the system uptime in seconds.
Definition: clock.h:307
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:80
Definition: ucred.h:47
int rtems_bsdnet_parse_driver_name(const struct rtems_bsdnet_ifconfig *config, char **namep)
Splits a network interface name with interface configuration config into the unit name and number par...
Definition: rtems_glue.c:1230
BSD Compatibility API.
This include file provides endian information about the target.
Definition: rtems_bsdnet_internal.h:86
Definition: socketvar.h:49
Definition: proc.h:5
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:119
rtems_status_code
Classic API Status.
Definition: status.h:46
uint32_t rtems_event_set
Integer type to hold an event set of up to 32 events represented as a bit field.
Definition: event.h:51
Definition: inet.h:93
uint32_t rtems_option
The following type defines the control block used to manage option sets.
Definition: options.h:45
Definition: rtems_bsdnet_internal.h:39
Definition: rtems_bsdnet.h:74
Basic Filesystem Types.
Definition: nfs_prot.h:234
rtems_status_code rtems_event_system_send(rtems_id id, rtems_event_set event_in)
See rtems_event_send().
Definition: systemeventsend.c:31