mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2024-09-13 12:55:26 +00:00
Introduced cc.h formatters.
This commit is contained in:
parent
d95d7cd960
commit
b89160f34e
@ -20,6 +20,14 @@ typedef signed long s32_t;
|
|||||||
|
|
||||||
typedef u32_t mem_ptr_t;
|
typedef u32_t mem_ptr_t;
|
||||||
|
|
||||||
|
/* Define (sn)printf formatters for these lwIP types */
|
||||||
|
#define U16_F "hu"
|
||||||
|
#define S16_F "hd"
|
||||||
|
#define X16_F "hx"
|
||||||
|
#define U32_F "lu"
|
||||||
|
#define S32_F "ld"
|
||||||
|
#define X32_F "lx"
|
||||||
|
|
||||||
/* LW: Supported in at least >=v7.5 r2, but lwIP worked without the "_packed" attribute already */
|
/* LW: Supported in at least >=v7.5 r2, but lwIP worked without the "_packed" attribute already */
|
||||||
#define PACK_STRUCT_BEGIN _packed
|
#define PACK_STRUCT_BEGIN _packed
|
||||||
#define PACK_STRUCT_STRUCT
|
#define PACK_STRUCT_STRUCT
|
||||||
|
@ -75,6 +75,6 @@ void cs8900if_service(struct netif *);
|
|||||||
void cs8900if_input(struct netif *netif);
|
void cs8900if_input(struct netif *netif);
|
||||||
err_t cs8900if_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr);
|
err_t cs8900if_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr);
|
||||||
|
|
||||||
void cs8900_send_debug(unsigned char *p, unsigned int len);
|
void cs8900_send_debug(u8_t *p, u16_t len);
|
||||||
|
|
||||||
#endif /* __NETIF_CS8900IF_H__ */
|
#endif /* __NETIF_CS8900IF_H__ */
|
||||||
|
@ -142,7 +142,7 @@ static const struct eth_addr ethbroadcast = {{0xffU,0xffU,0xffU,0xffU,0xffU,0xff
|
|||||||
static err_t cs8900_output(struct netif *netif, struct pbuf *p);
|
static err_t cs8900_output(struct netif *netif, struct pbuf *p);
|
||||||
static struct pbuf *cs8900_input(struct netif *netif);
|
static struct pbuf *cs8900_input(struct netif *netif);
|
||||||
static void cs8900_service(struct netif *netif);
|
static void cs8900_service(struct netif *netif);
|
||||||
static u32_t cs8900_chksum(void *dataptr, int len);
|
static u32_t cs8900_chksum(void *dataptr, s16_t len);
|
||||||
static void cs8900_reset(struct netif *netif);
|
static void cs8900_reset(struct netif *netif);
|
||||||
|
|
||||||
// Define these to match your hardware setup
|
// Define these to match your hardware setup
|
||||||
@ -320,7 +320,7 @@ static err_t cs8900_init(struct netif *netif)
|
|||||||
*/
|
*/
|
||||||
static err_t cs8900_output(struct netif *netif, struct pbuf *p)
|
static err_t cs8900_output(struct netif *netif, struct pbuf *p)
|
||||||
{
|
{
|
||||||
int tries = 0;
|
s16_t tries = 0;
|
||||||
err_t result;
|
err_t result;
|
||||||
|
|
||||||
// exit if link has failed
|
// exit if link has failed
|
||||||
@ -352,7 +352,7 @@ static err_t cs8900_output(struct netif *netif, struct pbuf *p)
|
|||||||
// ready to transmit?
|
// ready to transmit?
|
||||||
if ((PPDATA & 0x0100U/*Rdy4TxNOW*/) != 0)
|
if ((PPDATA & 0x0100U/*Rdy4TxNOW*/) != 0)
|
||||||
{
|
{
|
||||||
unsigned long sent_bytes = 0;
|
u32_t sent_bytes = 0;
|
||||||
/* q traverses through linked list of pbuf's
|
/* q traverses through linked list of pbuf's
|
||||||
* This list MUST consist of a single packet ONLY */
|
* This list MUST consist of a single packet ONLY */
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
@ -440,7 +440,7 @@ static struct pbuf *cs8900_input(struct netif *netif)
|
|||||||
event_type = 0;
|
event_type = 0;
|
||||||
// read RxLength
|
// read RxLength
|
||||||
len = RXTXREG;
|
len = RXTXREG;
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: packet len %u\n", len));
|
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: packet len %"U16_F"\n", len));
|
||||||
snmp_add_ifinoctets(len);
|
snmp_add_ifinoctets(len);
|
||||||
// positive length?
|
// positive length?
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
@ -456,7 +456,7 @@ static struct pbuf *cs8900_input(struct netif *netif)
|
|||||||
|
|
||||||
for (q = p; q != 0; q = q->next)
|
for (q = p; q != 0; q = q->next)
|
||||||
{
|
{
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: pbuf @%p tot_len %u len %u\n", q, q->tot_len, q->len));
|
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: pbuf @%p tot_len %"U16_F" len %"U16_F"\n", q, q->tot_len, q->len));
|
||||||
ptr = q->payload;
|
ptr = q->payload;
|
||||||
// TODO: CHECK: what if q->len is odd? we don't use the last byte?
|
// TODO: CHECK: what if q->len is odd? we don't use the last byte?
|
||||||
for (i = 0; i < (q->len + 1) / 2; i++)
|
for (i = 0; i < (q->len + 1) / 2; i++)
|
||||||
@ -509,9 +509,9 @@ static struct pbuf *cs8900_input(struct netif *netif)
|
|||||||
static void cs8900_service(struct netif *netif)
|
static void cs8900_service(struct netif *netif)
|
||||||
{
|
{
|
||||||
/* amount of ISQ's to handle (> 0) in one cs8900_service() call */
|
/* amount of ISQ's to handle (> 0) in one cs8900_service() call */
|
||||||
unsigned char events2service = 1;
|
u8_t events2service = 1;
|
||||||
#if (CS8900_STATS > 0)
|
#if (CS8900_STATS > 0)
|
||||||
unsigned int miss_count = 0, coll_count = 0;
|
u16_t miss_count = 0, coll_count = 0;
|
||||||
#endif
|
#endif
|
||||||
// NOTES:
|
// NOTES:
|
||||||
// static, so only initialized to zero at program start.
|
// static, so only initialized to zero at program start.
|
||||||
@ -595,10 +595,10 @@ static void cs8900_service(struct netif *netif)
|
|||||||
#if (CS8900_STATS > 0)
|
#if (CS8900_STATS > 0)
|
||||||
/* copy statistics counters into netif state fields */
|
/* copy statistics counters into netif state fields */
|
||||||
((struct cs8900if *)netif->state)->missed += miss_count;
|
((struct cs8900if *)netif->state)->missed += miss_count;
|
||||||
if (miss_count > 0) LWIP_DEBUGF(NETIF_DEBUG | 1, ("cs8900_input: %u missed packets due to rx buffer overrun\n", miss_count));
|
if (miss_count > 0) LWIP_DEBUGF(NETIF_DEBUG | 1, ("cs8900_input: %"U16_F" missed packets due to rx buffer overrun\n", miss_count));
|
||||||
|
|
||||||
((struct cs8900if *)netif->state)->collisions += coll_count;
|
((struct cs8900if *)netif->state)->collisions += coll_count;
|
||||||
if (coll_count > 0) LWIP_DEBUGF(NETIF_DEBUG | 1, ("cs8900_input: %u packet collisions\n", coll_count));
|
if (coll_count > 0) LWIP_DEBUGF(NETIF_DEBUG | 1, ("cs8900_input: %"U16_F" packet collisions\n", coll_count));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,9 +776,9 @@ err_t cs8900if_init(struct netif *netif)
|
|||||||
* @param p pointer to an array of bytes, at least with length 'len'
|
* @param p pointer to an array of bytes, at least with length 'len'
|
||||||
* @param len number of bytes available at the address pointed to by 'p'
|
* @param len number of bytes available at the address pointed to by 'p'
|
||||||
*/
|
*/
|
||||||
void cs8900_send_debug(unsigned char *p, unsigned int len)
|
void cs8900_send_debug(u8_t *p, u16_t len)
|
||||||
{
|
{
|
||||||
int tries = 0, i;
|
s16_t tries = 0, i;
|
||||||
|
|
||||||
// network interface state
|
// network interface state
|
||||||
extern struct netif *ethif;
|
extern struct netif *ethif;
|
||||||
@ -887,7 +887,7 @@ void cs8900_send_debug(unsigned char *p, unsigned int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32_t cs8900_chksum(void *dataptr, int len)
|
static u32_t cs8900_chksum(void *dataptr, s16_t len)
|
||||||
{
|
{
|
||||||
u32_t acc = 0;
|
u32_t acc = 0;
|
||||||
u16_t *ptr = (u16_t *)dataptr;
|
u16_t *ptr = (u16_t *)dataptr;
|
||||||
|
@ -50,6 +50,14 @@ typedef signed long s32_t;
|
|||||||
|
|
||||||
typedef u32_t mem_ptr_t;
|
typedef u32_t mem_ptr_t;
|
||||||
|
|
||||||
|
/* Define (sn)printf formatters for these lwIP types */
|
||||||
|
#define U16_F "hu"
|
||||||
|
#define S16_F "hd"
|
||||||
|
#define X16_F "hx"
|
||||||
|
#define U32_F "lu"
|
||||||
|
#define S32_F "ld"
|
||||||
|
#define X32_F "lx"
|
||||||
|
|
||||||
/* Compiler hints for packing structures */
|
/* Compiler hints for packing structures */
|
||||||
#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
|
#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
|
||||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||||
|
@ -54,7 +54,7 @@ CFLAGS:=$(CFLAGS) \
|
|||||||
COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
|
COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
|
||||||
$(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/raw.c $(LWIPDIR)/core/stats.c \
|
$(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/raw.c $(LWIPDIR)/core/stats.c \
|
||||||
$(LWIPDIR)/core/sys.c $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \
|
$(LWIPDIR)/core/sys.c $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \
|
||||||
$(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c
|
$(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c $(LWIPDIR)/core/dhcp.c
|
||||||
CORE4FILES=$(wildcard $(LWIPDIR)/core/ipv4/*.c) $(LWIPDIR)/core/inet.c
|
CORE4FILES=$(wildcard $(LWIPDIR)/core/ipv4/*.c) $(LWIPDIR)/core/inet.c
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,8 +188,7 @@ a lot of data that needs to be copied, this should be set high. */
|
|||||||
|
|
||||||
/* ---------- DHCP options ---------- */
|
/* ---------- DHCP options ---------- */
|
||||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
|
interfaces. */
|
||||||
turning this on does currently not work. */
|
|
||||||
#define LWIP_DHCP 0
|
#define LWIP_DHCP 0
|
||||||
|
|
||||||
/* 1 if you want to do an ARP check on the offered address
|
/* 1 if you want to do an ARP check on the offered address
|
||||||
|
@ -320,7 +320,6 @@ main_thread(void *arg)
|
|||||||
netif_add(&netif, &ipaddr, &netmask, &gw, NULL, tapif_init,
|
netif_add(&netif, &ipaddr, &netmask, &gw, NULL, tapif_init,
|
||||||
tcpip_input);
|
tcpip_input);
|
||||||
netif_set_default(&netif);
|
netif_set_default(&netif);
|
||||||
dhcp_init();
|
|
||||||
dhcp_start(&netif);
|
dhcp_start(&netif);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user