📄 param.h
字号:
#define mono_time cyg_mono_time
#define mrt6stat cyg_mrt6stat
#define mtab_lock cyg_mtab_lock
#define multicast_register_if cyg_multicast_register_if
#define n6expire cyg_n6expire
#define nd6_defifindex cyg_nd6_defifindex
#define nd6_slowtimo_ch cyg_nd6_slowtimo_ch
#define nd6_timer_ch cyg_nd6_timer_ch
#define nd_defrouter cyg_nd_defrouter
#define netint_flags cyg_netint_flags
#define ng_ether_attach_p cyg_ng_ether_attach_p
#define ng_ether_detach_p cyg_ng_ether_detach_p
#define ng_ether_input_orphan_p cyg_ng_ether_input_orphan_p
#define ng_ether_input_p cyg_ng_ether_input_p
#define ng_ether_output_p cyg_ng_ether_output_p
#define nstab_lock cyg_nstab_lock
#define rawcb_list cyg_rawcb_list
#define rip6stat cyg_rip6stat
#define ripcb cyg_ripcb
#define ripcbinfo cyg_ripcbinfo
#define route_cb cyg_route_cb
#define rt_tables cyg_rt_tables
#define sig_pending cyg_sig_pending
#define signal_mutex cyg_signal_mutex
#define signal_sigwait cyg_signal_sigwait
#define so_gencnt cyg_so_gencnt
#define socket_zone cyg_socket_zone
#define tcb cyg_tcb
#define tcbinfo cyg_tcbinfo
#define tcp_ccgen cyg_tcp_ccgen
#define tcp_delacktime cyg_tcp_delacktime
#define tcp_keepidle cyg_tcp_keepidle
#define tcp_keepinit cyg_tcp_keepinit
#define tcp_keepintvl cyg_tcp_keepintvl
#define tcp_maxidle cyg_tcp_maxidle
#define tcp_maxpersistidle cyg_tcp_maxpersistidle
#define tcp_msl cyg_tcp_msl
#define tcpstat cyg_tcpstat
#define udb cyg_udb
#define udbinfo cyg_udbinfo
#define udp_ip6 cyg_udp_ip6
#define udpstat cyg_udpstat
#endif
#include <pkgconf/net.h>
#include <cyg/infra/cyg_type.h> // Standard eCos types
#define __P(protos) protos
#if defined(__cplusplus)
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS };
#else
#define __BEGIN_DECLS
#define __END_DECLS
#endif
#include <sys/types.h>
#include <sys/endian.h>
#include <errno.h>
#ifdef _KERNEL
// External [common] variables
extern int hz;
extern volatile struct timeval ktime;
#define time_second ktime.tv_sec
extern int tick;
extern int proc0;
#define curproc 0
extern void microtime(struct timeval *tp);
extern void getmicrotime(struct timeval *tp);
extern void getmicrouptime(struct timeval *tp);
extern int tvtohz(struct timeval *tv);
extern int arc4random(void);
//extern u_int in_cksum_hdr(const struct ip *ip);
//extern u_short in_cksum_skip(struct mbuf *m, int len, int skip);
//extern u_short in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c);
// Function mappings
extern int cyg_ticks(void);
#define ticks cyg_ticks()
extern int cyg_tsleep(void *, int, char *, int);
extern void cyg_wakeup(void *);
#define tsleep(e,p,w,t) cyg_tsleep(e,0,w,t)
#define wakeup(e) cyg_wakeup(e)
#define wakeup_one(e) cyg_wakeup(e)
#ifdef CYGIMPL_TRACE_SPLX
extern cyg_uint32 cyg_splimp(const char *file, const int line);
extern cyg_uint32 cyg_splnet(const char *file, const int line);
extern cyg_uint32 cyg_splclock(const char *file, const int line);
extern cyg_uint32 cyg_splsoftnet(const char *file, const int line);
extern void cyg_splx(cyg_uint32, const char *file, const int line);
#define splimp() cyg_splimp(__FUNCTION__, __LINE__)
#define splnet() cyg_splnet(__FUNCTION__, __LINE__)
#define splclock() cyg_splclock(__FUNCTION__, __LINE__)
#define splsoftnet() cyg_splsoftnet(__FUNCTION__, __LINE__)
#define splx(x) cyg_splx(x, __FUNCTION__, __LINE__)
#define cyg_scheduler_lock() _cyg_scheduler_lock(__FUNCTION__, __LINE__)
#define cyg_scheduler_safe_lock() _cyg_scheduler_safe_lock(__FUNCTION__, __LINE__)
#define cyg_scheduler_unlock() _cyg_scheduler_unlock(__FUNCTION__, __LINE__)
#else
extern cyg_uint32 cyg_splimp(void);
extern cyg_uint32 cyg_splnet(void);
extern cyg_uint32 cyg_splclock(void);
extern cyg_uint32 cyg_splsoftnet(void);
extern cyg_uint32 cyg_splhigh(void);
extern void cyg_splx(cyg_uint32);
#define splimp cyg_splimp
#define splnet cyg_splnet
#define splclock cyg_splclock
#define splsoftnet cyg_splsoftnet
#define splhigh cyg_splhigh
#define splx cyg_splx
#endif
extern void cyg_panic(const char *msg, ...);
#define panic cyg_panic
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than CLBYTES (the software page size), and,
* on machines that exchange pages of input or output buffers with mbuf
* clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
* of the hardware page size.
*/
#define MSIZE 128 /* size of an mbuf */
#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
#define MCLOFSET (MCLBYTES - 1) /* offset within a m_buf cluster */
#define CLBYTES 4096 /* size of actual cluster */
#define PAGE_SIZE CLBYTES
/*
* Round p (pointer or byte index) up to a correctly-aligned value
* for all data types (int, long, ...). The result is u_int and
* must be cast to any desired pointer type.
*/
#define ALIGNBYTES (sizeof(int) - 1)
#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
// These symbols are used in the IPV6 stuff
// (be more defensive about external setup)
#undef __linux__
#undef __bsdi__
#undef __FreeBSD__
#undef __OpenBSD__
#undef __NetBSD__
#define __FreeBSD__ 4
#define __FreeBSD_version 440000
// TEMP
#include <cyg/infra/diag.h>
#include <cyg/hal/hal_intr.h>
#include <cyg/kernel/kapi.h>
#include <cyg/io/file.h>
struct net_stats {
int count;
cyg_uint32 min_time, max_time, total_time;
};
#ifdef CYGDBG_NET_TIMING_STATS
#define START_STATS() \
cyg_uint32 start_time, end_time, elapsed_time; \
HAL_CLOCK_READ(&start_time);
#define FINISH_STATS(stats) \
HAL_CLOCK_READ(&end_time); \
if (end_time < start_time) { \
elapsed_time = (end_time+CYGNUM_KERNEL_COUNTERS_RTC_PERIOD) - start_time; \
} else { \
elapsed_time = end_time - start_time; \
} \
if (stats.min_time == 0) { \
stats.min_time = 0x7FFFFFFF; \
} \
if (elapsed_time < stats.min_time) \
stats.min_time = elapsed_time; \
if (elapsed_time > stats.max_time) \
stats.max_time = elapsed_time; \
stats.total_time += elapsed_time; \
stats.count++;
#else
#define START_STATS()
#define FINISH_STATS(X)
#endif
// TEMP
// timeout support
typedef void (timeout_fun)(void *);
typedef struct callout {
struct callout *next, *prev;
cyg_int32 delta; // Number of "ticks" in the future for this timeout
timeout_fun *fun; // Function to execute when it expires
void *arg; // Argument to pass when it does
int flags; // Info about this item
} timeout_entry;
#define CALLOUT_LOCAL 0x0001
#define CALLOUT_ACTIVE 0x0002
#define CALLOUT_PENDING 0x0004
extern cyg_uint32 timeout(timeout_fun *fun, void *arg, cyg_int32 delta);
extern void untimeout(timeout_fun *fun, void *arg);
extern void callout_init(struct callout *);
extern void callout_reset(struct callout *, int, timeout_fun *, void *);
extern void callout_stop(struct callout *);
extern int callout_active(struct callout *);
extern void callout_deactivate(struct callout *);
extern int callout_pending(struct callout *);
extern int uiomove(caddr_t cp, int n, struct uio *uio);
extern int copyout(const void *s, void *d, size_t len);
extern int copyin(const void *s, void *d, size_t len);
extern void ovbcopy(const void *s, void *d, size_t len);
extern void get_mono_time(void);
extern int arc4random(void);
extern void get_random_bytes(void *buf, size_t len);
extern void read_random_unlimited(void *buf, size_t len);
extern void *hashinit(int elements, void *type, u_long *hashmask);
// Initialization support - cross between RedBoot & FreeBSD
typedef void _init_fun(void *);
typedef _init_fun *_init_fun_ptr;
struct init_tab_entry {
_init_fun_ptr fun;
void *data;
char *name;
} CYG_HAL_TABLE_TYPE;
#define _cat(a,b) a##b
#define __Net_init(_p1_,_p2_,_f_,_d_) \
struct init_tab_entry _cat(_net_init_tab,_p1_##_p2_##_f_) \
CYG_HAL_TABLE_QUALIFIED_ENTRY(_Net_inits,_p1_##_p2_##_f_) = { _f_, _d_, #_f_ };
#define _Net_init(_p1_,_p2_,_f_,_d_) \
__Net_init(_p1_,_p2_,_f_,_d_)
#define SI_ORDER_FIRST 000000
#define SI_ORDER_SECOND 000001
#define SI_ORDER_THIRD 000002
#define SI_ORDER_MIDDLE 080000
#define SI_ORDER_ANY FFFFFF
#define SI_SUB_MBUF 0x50
#define SI_SUB_DEVICES 0x60
#define SI_SUB_PSEUDO 0x70
#define SI_SUB_PROTO_IF 0x84
#define SI_SUB_PROTO_DOMAIN 0x88
#define SYSINIT(label, group, order, fun, ident) \
_Net_init(_cat(group,order), label, fun, ident)
#define PSEUDO_SET(fun, sys) \
SYSINIT(sys, SI_SUB_PSEUDO, SI_ORDER_FIRST, fun, NULL)
// VM zone stuff
#define ZONE_INTERRUPT 1
typedef struct _elem {
struct _elem *next;
} elem;
typedef struct vm_zone {
char *name;
int elem_size, free, total;
int alloc_tries, alloc_fails, alloc_frees;
elem *pool;
struct vm_zone *next;
} *vm_zone_t;
vm_zone_t zinit(char *name, int size, int nentries, int flags, int zalloc);
void * zalloci(vm_zone_t z);
void zfreei(vm_zone_t z, void *item);
// Function mapping
#define printf diag_printf
#define sprintf diag_sprintf
#define snprintf diag_snprintf
// Missing standard functions
static __inline int imax(int a, int b) { return (a > b ? a : b); }
static __inline int imin(int a, int b) { return (a < b ? a : b); }
static __inline long lmax(long a, long b) { return (a > b ? a : b); }
static __inline long lmin(long a, long b) { return (a < b ? a : b); }
static __inline u_int max(u_int a, u_int b) { return (a > b ? a : b); }
static __inline u_int min(u_int a, u_int b) { return (a < b ? a : b); }
static __inline quad_t qmax(quad_t a, quad_t b) { return (a > b ? a : b); }
static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); }
static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); }
static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); }
// Align a value to a natural multiple (4)
#define _ALIGN(n) (((n)+3)&~3) // Is this right?
// Round a number 'n' up to a multiple of 'm'
#define roundup(n,m) ((((n)+((m)-1))/(m))*(m))
#define NEW_STRUCT_ROUTE
extern char *hostname;
// Logging facilities
#ifdef CYGPKG_NET_FREEBSD_LOGGING
extern int cyg_net_log_mask;
#define LOG_ERR 0x0001
#define LOG_WARNING 0x0002
#define LOG_NOTICE 0x0004
#define LOG_INFO 0x0008
#define LOG_DEBUG 0x0010
#define LOG_MDEBUG 0x0020
#define LOG_IOCTL 0x0040
#define LOG_ADDR 0x0100
#define LOG_FAIL 0x0200
#define LOG_INIT 0x0080
#define LOG_EMERG 0x4000
#define LOG_CRIT 0x8000
#define log(lvl, args...) \
do { if (cyg_net_log_mask & lvl) diag_printf(args); } while (0)
#define log_dump(lvl, buf, len) \
do { if (cyg_net_log_mask & lvl) diag_dump_buf(buf, len); } while (0)
#define log_(lvl) \
if (cyg_net_log_mask & lvl)
#else
#define log(lvl, args...)
#define log_dump(lvl, buf, len)
#define log_(lvl)
#endif
#endif // _KERNEL
#endif //_SYS_PARAM_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -