1 //==========================================================================
3 // include/machine/param.h
5 // Architecture/platform specific parameters
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
10 // -------------------------------------------
12 // Portions of this software may have been derived from OpenBSD or other sources,
13 // and are covered by the appropriate copyright disclaimers included herein.
15 // -------------------------------------------
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
22 // Contributors: gthomas
28 //####DESCRIPTIONEND####
30 //==========================================================================
33 #ifndef _MACHINE_PARAM_H_
34 #define _MACHINE_PARAM_H_
36 #include <pkgconf/net.h>
39 * Constants related to network buffer management.
40 * MCLBYTES must be no larger than CLBYTES (the software page size), and,
41 * on machines that exchange pages of input or output buffers with mbuf
42 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
43 * of the hardware page size.
45 #define MSIZE 128 /* size of an mbuf */
46 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
47 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
48 #define MCLOFSET (MCLBYTES - 1) /* offset within a m_buf cluster */
49 #define CLBYTES 4096 /* size of actual cluster */
52 * Round p (pointer or byte index) up to a correctly-aligned value
53 * for all data types (int, long, ...). The result is u_int and
54 * must be cast to any desired pointer type.
56 #define ALIGNBYTES (sizeof(int) - 1)
57 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
59 // These symbols are used in the IPV6 stuff
60 // (be more defensive about external setup)
84 // These definitions here to avoid needing <sys/systm.h>
85 // This probably doesn't belong here, but we need these definitions
86 #include <lib/libkern/libkern.h>
87 #define SCARG(p,k) ((p)->k.datum) /* get arg from args pointer */
92 #include <cyg/infra/diag.h>
93 #include <cyg/hal/hal_intr.h>
94 #include <cyg/kernel/kapi.h>
95 #include <cyg/io/file.h>
99 cyg_uint32 min_time, max_time, total_time;
102 #ifdef CYGDBG_NET_TIMING_STATS
103 #define START_STATS() \
104 cyg_uint32 start_time, end_time, elapsed_time; \
105 HAL_CLOCK_READ(&start_time);
106 #define FINISH_STATS(stats) \
107 HAL_CLOCK_READ(&end_time); \
108 if (end_time < start_time) { \
109 elapsed_time = (end_time+CYGNUM_KERNEL_COUNTERS_RTC_PERIOD) - start_time; \
111 elapsed_time = end_time - start_time; \
113 if (stats.min_time == 0) { \
114 stats.min_time = 0x7FFFFFFF; \
116 if (elapsed_time < stats.min_time) \
117 stats.min_time = elapsed_time; \
118 if (elapsed_time > stats.max_time) \
119 stats.max_time = elapsed_time; \
120 stats.total_time += elapsed_time; \
123 #define START_STATS()
124 #define FINISH_STATS(X)
128 typedef void (timeout_fun)(void *);
129 extern cyg_uint32 timeout(timeout_fun *fun, void *arg, cyg_int32 delta);
130 extern void untimeout(timeout_fun *fun, void *arg);
131 extern int uiomove(caddr_t cp, int n, struct uio *uio);
132 extern int copyout(const void *s, void *d, size_t len);
133 extern int copyin(const void *s, void *d, size_t len);
134 extern void ovbcopy(const void *s, void *d, size_t len);
135 extern void get_mono_time(void);
136 extern int arc4random(void);
137 extern void get_random_bytes(void *buf, size_t len);
139 extern void *hashinit(int elements, int type, int flags, u_long *hashmask);
141 #endif // _MACHINE_PARAM_H_