Add DM90x0 driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@362 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
b91d6d3b2f
commit
d7d1145863
@ -213,4 +213,6 @@
|
||||
* Provide support for multiple network devices
|
||||
* Implement socket ioctl() calls to set addresses
|
||||
* Added listen() and accept()
|
||||
* Added DM90x0 ethernet driver
|
||||
* ARP timer is now built into the network layer
|
||||
|
||||
|
@ -646,6 +646,8 @@ Other memory:
|
||||
* Provide support for multiple network devices
|
||||
* Implement socket ioctl() calls to set addresses
|
||||
* Added listen() and accept()
|
||||
* Added DM90x0 ethernet driver
|
||||
* ARP timer is now built into the network layer
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
|
@ -100,5 +100,9 @@ void up_initialize(void)
|
||||
/* Initialize the serial device driver */
|
||||
|
||||
up_serialinit();
|
||||
|
||||
/* Initialize the netwok */
|
||||
|
||||
up_netinitialize();
|
||||
up_ledon(LED_IRQSENABLED);
|
||||
}
|
||||
|
@ -157,6 +157,13 @@ extern void up_ledoff(int led);
|
||||
# define up_ledoff(led)
|
||||
#endif
|
||||
|
||||
/* Defined in board/up_network.c */
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
extern up_netinitialize(void);
|
||||
#else
|
||||
# define up_netinitialize()
|
||||
#endif
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __UP_INTERNAL_H */
|
||||
|
@ -266,7 +266,7 @@ void tapdev_init(void)
|
||||
|
||||
/* Assign an IPv4 address to the tap device */
|
||||
|
||||
snprintf(buf, sizeof(buf), "ifconfig tap0 inet %d.%d.%d.%d\n",
|
||||
snprintf(buf, sizeof(buf), "/sbin/ifconfig tap0 inet %d.%d.%d.%d\n",
|
||||
UIP_IPADDR0, UIP_IPADDR1, UIP_IPADDR2, UIP_IPADDR3);
|
||||
system(buf);
|
||||
}
|
||||
|
@ -81,7 +81,6 @@ struct timer
|
||||
****************************************************************************/
|
||||
|
||||
static struct timer g_periodic_timer;
|
||||
static struct timer g_arp_timer;
|
||||
static struct uip_driver_s g_sim_dev;
|
||||
|
||||
/****************************************************************************
|
||||
@ -216,14 +215,6 @@ void uipdriver_loop(void)
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NET_UDP */
|
||||
|
||||
/* Call the ARP timer function every 10 seconds. */
|
||||
|
||||
if (timer_expired(&g_arp_timer))
|
||||
{
|
||||
timer_reset(&g_arp_timer);
|
||||
uip_arp_timer();
|
||||
}
|
||||
}
|
||||
sched_unlock();
|
||||
}
|
||||
@ -233,7 +224,6 @@ int uipdriver_init(void)
|
||||
/* Internal initalization */
|
||||
|
||||
timer_set(&g_periodic_timer, 500);
|
||||
timer_set(&g_arp_timer, 10000 );
|
||||
tapdev_init();
|
||||
(void)tapdev_getmacaddr(g_sim_dev.d_mac.addr);
|
||||
|
||||
|
@ -81,6 +81,7 @@
|
||||
#define GIO_KEY_SCAN3 4
|
||||
#define GIO_KEY_SCAN4 5
|
||||
#define GIO_MS_DETECT 5
|
||||
#define GIO_DM9000A_INT 6
|
||||
#define GIO_MMC_DETECT 8
|
||||
#define GIO_CFC_DETECT 9
|
||||
#define GIO_VIDEO_IN 10
|
||||
|
@ -40,7 +40,7 @@ CFLAGS += -I$(TOPDIR)/sched
|
||||
|
||||
ASRCS =
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
CSRCS = up_leds.c
|
||||
CSRCS = up_leds.c up_network.c
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
|
92
configs/ntosd-dm320/src/up_network.c
Normal file
92
configs/ntosd-dm320/src/up_network.c
Normal file
@ -0,0 +1,92 @@
|
||||
/****************************************************************************
|
||||
* board/up_network.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_DM90x0)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <arch/board.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
#include "chip/dm320_gio.h"
|
||||
|
||||
extern void dm9x_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_netinitialize
|
||||
****************************************************************************/
|
||||
|
||||
void up_netinitialize(void)
|
||||
{
|
||||
/* CS4 is used for DM9000A Ethernet. Interrupt is provided via GIO6
|
||||
* which must be configured to interrupt on the rising edge. Bus
|
||||
* width is 16-bits.
|
||||
*/
|
||||
|
||||
/* It is assumed that bootloader has already configured CS4. Here,
|
||||
* we will only make certain that the GIO is properly configured
|
||||
*/
|
||||
|
||||
GIO_INPUT(GIO_DM9000A_INT);
|
||||
GIO_NONINVERTED(GIO_DM9000A_INT);
|
||||
GIO_INTERRUPT(GIO_DM9000A_INT);
|
||||
GIO_RISINGEDGE(GIO_DM9000A_INT);
|
||||
|
||||
/* Then initialize the driver */
|
||||
|
||||
dm9x_initialize();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_DM90x0 */
|
@ -37,10 +37,14 @@
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
|
||||
ASRCS =
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
include net/Make.defs
|
||||
endif
|
||||
|
||||
ASRCS = $(NET_ASRCS)
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
CSRCS = dev_null.c serial.c
|
||||
CSRCS = dev_null.c serial.c $(NET_CSRCS)
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
@ -48,6 +52,8 @@ OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
BIN = libdrivers$(LIBEXT)
|
||||
|
||||
VPATH = net
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
@ -63,7 +69,11 @@ $(BIN): $(OBJS)
|
||||
done ; )
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
$(MKDEP) --dep-path . --dep-path net $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
else
|
||||
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
endif
|
||||
touch $@
|
||||
|
||||
depend: .depend
|
||||
|
@ -168,6 +168,15 @@ struct uip_driver_s
|
||||
*/
|
||||
|
||||
uint16 d_sndlen;
|
||||
|
||||
/* Driver callbacks */
|
||||
|
||||
int (*ifup)(struct uip_driver_s *dev);
|
||||
int (*ifdown)(struct uip_driver_s *dev);
|
||||
|
||||
/* Drivers may attached device-specific, private information */
|
||||
|
||||
void *d_private;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -1,4 +1,4 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* arch.h
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
@ -31,37 +31,37 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_H
|
||||
#define __ARCH_H
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <sched.h>
|
||||
#include <arch/arch.h>
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
typedef void (*sig_deliver_t)(_TCB *tcb);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
@ -70,12 +70,12 @@ extern "C" {
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* These are standard interfaces that must be exported to the
|
||||
* scheduler from architecture-specific code.
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_initialize
|
||||
*
|
||||
* Description:
|
||||
@ -93,11 +93,11 @@ extern "C" {
|
||||
* libraries have been initialized. OS services and driver
|
||||
* services are available.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_initialize(void);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_idle
|
||||
*
|
||||
* Description:
|
||||
@ -109,11 +109,11 @@ EXTERN void up_initialize(void);
|
||||
* Processing in this state may be processor-specific. e.g.,
|
||||
* this is where power management operations might be performed.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_idle(void);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_initial_state
|
||||
*
|
||||
* Description:
|
||||
@ -125,11 +125,11 @@ EXTERN void up_idle(void);
|
||||
* and/or stack so that execution will begin at tcb->start
|
||||
* on the next context switch.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_initial_state(FAR _TCB *tcb);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_create_stack
|
||||
*
|
||||
* Description:
|
||||
@ -149,13 +149,13 @@ EXTERN void up_initial_state(FAR _TCB *tcb);
|
||||
* stack_size: The requested stack size. At least this much
|
||||
* must be allocated.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
EXTERN STATUS up_create_stack(FAR _TCB *tcb, size_t stack_size);
|
||||
#endif
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_use_stack
|
||||
*
|
||||
* Description:
|
||||
@ -174,26 +174,26 @@ EXTERN STATUS up_create_stack(FAR _TCB *tcb, size_t stack_size);
|
||||
* tcb: The TCB of new task
|
||||
* stack_size: The allocated stack size.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
EXTERN STATUS up_use_stack(FAR _TCB *tcb, FAR void *stack, size_t stack_size);
|
||||
#endif
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_release_stack
|
||||
*
|
||||
* Description:
|
||||
* A task has been stopped. Free all stack
|
||||
* related resources retained int the defunct TCB.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
EXTERN void up_release_stack(FAR _TCB *dtcb);
|
||||
#endif
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_unblock_task
|
||||
*
|
||||
* Description:
|
||||
@ -211,11 +211,11 @@ EXTERN void up_release_stack(FAR _TCB *dtcb);
|
||||
* the ready-to-run list and, if it is the highest priority
|
||||
* ready to run taks, executed.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_unblock_task(FAR _TCB *tcb);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_block_task
|
||||
*
|
||||
* Description:
|
||||
@ -237,11 +237,11 @@ EXTERN void up_unblock_task(FAR _TCB *tcb);
|
||||
* task_state: Specifies which waiting task list should be
|
||||
* hold the blocked task TCB.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_block_task(FAR _TCB *tcb, tstate_t task_state);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_release_pending
|
||||
*
|
||||
* Description:
|
||||
@ -256,11 +256,11 @@ EXTERN void up_block_task(FAR _TCB *tcb, tstate_t task_state);
|
||||
* logic when pre-emptioni is re-enabled. Interrupts will
|
||||
* always be disabled when this function is called.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_release_pending(void);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_reprioritize_rtr
|
||||
*
|
||||
* Description:
|
||||
@ -282,11 +282,11 @@ EXTERN void up_release_pending(void);
|
||||
* tcb: The TCB of the task that has been reprioritized
|
||||
* priority: The new task priority
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_reprioritize_rtr(FAR _TCB *tcb, ubyte priority);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: _exit
|
||||
*
|
||||
* Description:
|
||||
@ -298,20 +298,20 @@ EXTERN void up_reprioritize_rtr(FAR _TCB *tcb, ubyte priority);
|
||||
* implementation of this function should diable interrupts
|
||||
* before performing scheduling operations.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
/* Prototype is in unistd.h */
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_assert and up_assert_code
|
||||
*
|
||||
* Description:
|
||||
* Assertions may be handled in an architecture-specific
|
||||
* way.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
/* Prototype is in assert.h */
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_schedule_sigaction
|
||||
*
|
||||
* Description:
|
||||
@ -342,13 +342,13 @@ EXTERN void up_reprioritize_rtr(FAR _TCB *tcb, ubyte priority);
|
||||
* currently executing task -- just call the signal
|
||||
* handler now.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
EXTERN void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver);
|
||||
#endif
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_allocate_heap
|
||||
*
|
||||
* Description:
|
||||
@ -357,59 +357,59 @@ EXTERN void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver);
|
||||
* are not defined, then this function will be called to
|
||||
* dynamically set aside the heap region.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_HEAP_BASE
|
||||
EXTERN void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
|
||||
#endif
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_interrupt_context
|
||||
*
|
||||
* Description:
|
||||
* Return TRUE is we are currently executing in
|
||||
* the interrupt handler context.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN boolean up_interrupt_context(void);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_disable_irq
|
||||
*
|
||||
* Description:
|
||||
* Disable the IRQ specified by 'irq'
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_disable_irq(int irq);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_enable_irq
|
||||
*
|
||||
* Description:
|
||||
* Enable the IRQ specified by 'irq'
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_enable_irq(int irq);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_disable_irq
|
||||
*
|
||||
* Description:
|
||||
* Disable the IRQ specified by 'irq'
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_disable_irq(int irq);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* These are standard interfaces that are exported by the OS
|
||||
* for use by the architecture specific logic
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: sched_process_timer
|
||||
*
|
||||
* Description:
|
||||
@ -419,34 +419,46 @@ EXTERN void up_disable_irq(int irq);
|
||||
* function periodically -- the calling interval must be
|
||||
* MSEC_PER_TICK.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void sched_process_timer(void);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: irq_dispatch
|
||||
*
|
||||
* Description:
|
||||
* This function must be called from the achitecture-
|
||||
* specific logic in order to dispaly an interrupt to
|
||||
* specific logic in order to dispatch an interrupt to
|
||||
* the appropriate, registered handling logic.
|
||||
*
|
||||
***********************************************************/
|
||||
***************************************************************************/
|
||||
|
||||
EXTERN void irq_dispatch(int irq, FAR void *context);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_mdelay and up_udelay
|
||||
*
|
||||
* Description:
|
||||
* Some device drivers may require that the plaform-specific logic
|
||||
* provide these timing loops for short delays.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
EXTERN void up_mdelay(unsigned int milliseconds);
|
||||
EXTERN void up_udelay(unsigned int microseconds);
|
||||
|
||||
/****************************************************************************
|
||||
* Debug interfaces exported by the architecture-specific
|
||||
* logic
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_putc
|
||||
*
|
||||
* Description:
|
||||
* Output one character on the console
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
# ifdef CONFIG_ARCH_LOWPUTC
|
||||
EXTERN int up_putc(int ch);
|
||||
|
@ -46,7 +46,7 @@ SOCK_CSRCS = socket.c bind.c connect.c listen.c accept.c send.c sendto.c \
|
||||
ifeq ($(CONFIG_NET_SOCKOPTS),y)
|
||||
SOCK_CSRCS += setsockopt.c getsockopt.c
|
||||
ifneq ($(CONFIG_DISABLE_CLOCK),y)
|
||||
SOCK_CSRCS += net-timeo.c net-dsec2timeval.c net-timeval2dsec.c
|
||||
SOCK_CSRCS += net-timeo.c net-dsec2timeval.c net-timeval2dsec.c net-arptimer.c
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -355,7 +355,6 @@ static inline int tcp_connect(FAR struct socket *psock, const struct sockaddr_in
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: connect
|
||||
*
|
||||
|
130
net/net-arptimer.c
Normal file
130
net/net-arptimer.c
Normal file
@ -0,0 +1,130 @@
|
||||
/****************************************************************************
|
||||
* net/net-arptimer.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
|
||||
#include <time.h>
|
||||
#include <wdog.h>
|
||||
|
||||
#include <net/uip/uip-arp.h>
|
||||
|
||||
#include "net-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* ARP timer interval = 10 seconds. CLK_TCK is the number of clock ticks
|
||||
* per second
|
||||
*/
|
||||
|
||||
#define ARPTIMER_WDINTERVAL (10*CLK_TCK)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static WDOG_ID g_arptimer; /* ARP timer */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: arptimer_poll
|
||||
*
|
||||
* Description:
|
||||
* Periodic timer handler. Called from the timer interrupt handler.
|
||||
*
|
||||
* Parameters:
|
||||
* argc - The number of available arguments
|
||||
* arg - The first argument
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void arptimer_poll(int argc, uint32 arg, ...)
|
||||
{
|
||||
dbg("ARP timer expiration\n");
|
||||
|
||||
/* Call the ARP timer function every 10 seconds. */
|
||||
|
||||
uip_arp_timer();
|
||||
|
||||
/* Setup the watchdog timer again */
|
||||
|
||||
(void)wd_start(g_arptimer, ARPTIMER_WDINTERVAL, arptimer_poll, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: arptimer_init
|
||||
*
|
||||
* Description:
|
||||
* Initialized the 10 second timer that is need by uIP to age ARP
|
||||
* associations
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Called once at system initialization time
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void arptimer_init(void)
|
||||
{
|
||||
/* Create and start the ARP timer */
|
||||
|
||||
g_arptimer = wd_create();
|
||||
(void)wd_start(g_arptimer, ARPTIMER_WDINTERVAL, arptimer_poll, 0);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET */
|
@ -176,6 +176,10 @@ EXTERN FAR struct uip_driver_s *netdev_find(const char *ifname);
|
||||
EXTERN int netdev_count(void);
|
||||
#endif
|
||||
|
||||
/* net-arptimer.c ************************************************************/
|
||||
|
||||
EXTERN void arptimer_init(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
@ -107,6 +107,10 @@ void net_initialize(void)
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
sem_init(&g_netdev_sem, 0, 1);
|
||||
#endif
|
||||
|
||||
/* Initialize the periodic ARP timer */
|
||||
|
||||
arptimer_init();
|
||||
}
|
||||
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
|
@ -67,14 +67,14 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: _get_ipaddr / _set_ipaddr
|
||||
* Name: ioctl_getipaddr / ioctl_setipaddr
|
||||
*
|
||||
* Description:
|
||||
* Copy IP addresses into and out of device structure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void _get_ipaddr(struct sockaddr *outaddr, uip_ipaddr_t *inaddr)
|
||||
static void ioctl_getipaddr(struct sockaddr *outaddr, uip_ipaddr_t *inaddr)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#error " big enough for IPv6 address"
|
||||
@ -90,7 +90,7 @@ static void _get_ipaddr(struct sockaddr *outaddr, uip_ipaddr_t *inaddr)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _set_ipaddr(uip_ipaddr_t *outaddr, struct sockaddr *inaddr)
|
||||
static void ioctl_setipaddr(uip_ipaddr_t *outaddr, struct sockaddr *inaddr)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct sockaddr_in6 *src = (struct sockaddr_in6 *)inaddr;
|
||||
@ -101,6 +101,22 @@ static void _set_ipaddr(uip_ipaddr_t *outaddr, struct sockaddr *inaddr)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ioctl_ifup(FAR struct uip_driver_s *dev)
|
||||
{
|
||||
if (dev->ifup)
|
||||
{
|
||||
dev->ifup(dev);
|
||||
}
|
||||
}
|
||||
|
||||
static void ioctl_ifdown(FAR struct uip_driver_s *dev)
|
||||
{
|
||||
if (dev->ifdown)
|
||||
{
|
||||
dev->ifdown(dev);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
@ -170,27 +186,29 @@ int netdev_ioctl(int sockfd, int cmd, struct ifreq *req)
|
||||
switch (cmd)
|
||||
{
|
||||
case SIOCGIFADDR: /* Get IP address */
|
||||
_get_ipaddr(&req->ifr_addr, &dev->d_ipaddr);
|
||||
ioctl_getipaddr(&req->ifr_addr, &dev->d_ipaddr);
|
||||
break;
|
||||
|
||||
case SIOCSIFADDR: /* Set IP address */
|
||||
_set_ipaddr(&dev->d_ipaddr, &req->ifr_addr);
|
||||
ioctl_ifdown(dev);
|
||||
ioctl_setipaddr(&dev->d_ipaddr, &req->ifr_addr);
|
||||
ioctl_ifup(dev);
|
||||
break;
|
||||
|
||||
case SIOCGIFDSTADDR: /* Get P-to-P address */
|
||||
_get_ipaddr(&req->ifr_dstaddr, &dev->d_draddr);
|
||||
ioctl_getipaddr(&req->ifr_dstaddr, &dev->d_draddr);
|
||||
break;
|
||||
|
||||
case SIOCSIFDSTADDR: /* Set P-to-P address */
|
||||
_set_ipaddr(&dev->d_draddr, &req->ifr_dstaddr);
|
||||
ioctl_setipaddr(&dev->d_draddr, &req->ifr_dstaddr);
|
||||
break;
|
||||
|
||||
case SIOCGIFNETMASK: /* Get network mask */
|
||||
_get_ipaddr(&req->ifr_addr, &dev->d_netmask);
|
||||
ioctl_getipaddr(&req->ifr_addr, &dev->d_netmask);
|
||||
break;
|
||||
|
||||
case SIOCSIFNETMASK: /* Set network mask */
|
||||
_set_ipaddr(&dev->d_netmask, &req->ifr_addr);
|
||||
ioctl_setipaddr(&dev->d_netmask, &req->ifr_addr);
|
||||
break;
|
||||
|
||||
case SIOCGIFMTU: /* Get MTU size */
|
||||
|
@ -105,6 +105,6 @@ clean:
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
@rm -f $(STRNG_CSRCS) $(STRNG_ASRCS)
|
||||
@rm -f Make.str netutil-strings.h makestrings$(EXEEXT)
|
||||
@rm -f rm .strings make.str netutil-strings.h makestrings$(EXEEXT)
|
||||
|
||||
-include Make.dep
|
||||
|
Loading…
Reference in New Issue
Block a user