Manually fixup merge botches via direct comparison with NuttX r5447.

This commit is contained in:
px4dev
2013-01-11 02:14:43 -08:00
parent 48c5d63319
commit f127495caa
428 changed files with 13932 additions and 3888 deletions
+41 -35
View File
@@ -47,7 +47,8 @@ config CAN_EXTID
bool "CAN extended IDs"
default n
---help---
Enables support for the 29-bit extended ID. Default Standard 11-bit IDs.
Enables support for the 29-bit extended ID. Default Standard 11-bit
IDs.
config CAN_FIFOSIZE
int "CAN driver I/O buffer size"
@@ -83,10 +84,10 @@ config PWM_PULSECOUNT
bool "PWM Pulse Count Support"
default n
---help---
Some hardware will support generation of a fixed number of pulses. This
might be used, for example to support a stepper motor. If the hardware
will support a fixed pulse count, then this configuration should be set to
enable the capability.
Some hardware will support generation of a fixed number of pulses.
This might be used, for example to support a stepper motor. If the
hardware will support a fixed pulse count, then this configuration
should be set to enable the capability.
endif
@@ -147,23 +148,25 @@ config SPI_OWNBUS
bool "SPI single device"
default n
---help---
Set if there is only one active device on the SPI bus. No locking or SPI
configuration will be performed. It is not necessary for clients to lock,
re-configure, etc..
Set if there is only one active device on the SPI bus. No locking or
SPI configuration will be performed. It is not necessary for clients to
lock, re-configure, etc..
config SPI_EXCHANGE
bool "SPI exchange"
default y
---help---
Driver supports a single exchange method (vs a recvblock() and sndblock ()methods).
Driver supports a single exchange method (vs a recvblock() and
sndblock() methods).
config SPI_CMDDATA
bool "SPI CMD/DATA"
default n
---help---
Devices on the SPI bus require out-of-band support to distinguish command
transfers from data transfers. Such devices will often support either 9-bit
SPI (yech) or 8-bit SPI and a GPIO output that selects between command and data.
Devices on the SPI bus require out-of-band support to distinguish
command transfers from data transfers. Such devices will often support
either 9-bit SPI (yech) or 8-bit SPI and a GPIO output that selects
between command and data.
endif
@@ -173,35 +176,36 @@ menuconfig RTC
---help---
This selection enables configuration of a real time clock (RTCdriver.
See include/nuttx/rtc.h for further watchdog timer driver information.
Most RTC drivers are MCU specific and may require other specific settings.
Most RTC drivers are MCU specific and may require other specific
settings.
config RTC_DATETIME
bool "Date/Time RTC Support"
default n
depends on RTC
---help---
There are two general types of RTC: (1) A simple battery backed counter
that keeps the time when power is down, and (2) a full date / time RTC the
provides the date and time information, often in BCD format. If
RTC_DATETIME is selected, it specifies this second kind of RTC. In this
case, the RTC is used to "seed" the normal NuttX timer and the NuttX system
timer provides for higher resolution time.
There are two general types of RTC: (1) A simple battery backed
counter that keeps the time when power is down, and (2) a full
date / time RTC the provides the date and time information, often in
BCD format. If RTC_DATETIME is selected, it specifies this second kind
of RTC. In this case, the RTC is used to "seed" the normal NuttX timer
and the NuttX system timer provides for higher resolution time.
config RTC_HIRES
bool "Hi-Res RTC Support"
default n
depends on RTC && !RTC_DATETIME
---help---
If RTC_DATETIME not selected, then the simple, battery backed counter is
used. There are two different implementations of such simple counters
based on the time resolution of the counter: The typical RTC keeps time
to resolution of 1 second, usually supporting a 32-bit time_t value. In
this case, the RTC is used to "seed" the normal NuttX timer and the NuttX
timer provides for higherresoution time.
If RTC_DATETIME not selected, then the simple, battery backed counter
is used. There are two different implementations of such simple
counters based on the time resolution of the counter: The typical RTC
keeps time to resolution of 1 second, usually supporting a 32-bit
time_t value. In this case, the RTC is used to "seed" the normal NuttX
timer and the NuttX timer provides for higherresoution time.
If RTC_HIRES is enabled in the NuttX configuration, then the RTC provides
higher resolution time and completely replaces the system timer for purpose
of date and time.
If RTC_HIRES is enabled in the NuttX configuration, then the RTC
provides higher resolution time and completely replaces the system
timer for purpose of date and time.
config RTC_FREQUENCY
int "Hi-Res RTC frequency"
@@ -209,8 +213,8 @@ config RTC_FREQUENCY
depends on RTC && !RTC_DATETIME && RTC_HIRES
---help---
If RTC_HIRES is defined, then the frequency of the high resolution RTC
must be provided. If RTC_HIRES is not defined, RTC_FREQUENCY is assumed
to be one Hz.
must be provided. If RTC_HIRES is not defined, RTC_FREQUENCY is
assumed to be one Hz.
config RTC_ALARM
bool "RTC Alarm Support"
@@ -224,8 +228,9 @@ menuconfig WATCHDOG
bool "Watchdog Timer Support"
default n
---help---
This selection enables building of the "upper-half" watchdog timer driver.
See include/nuttx/watchdog.h for further watchdog timer driver information.
This selection enables building of the "upper-half" watchdog timer
driver. See include/nuttx/watchdog.h for further watchdog timer driver
information.
if WATCHDOG
endif
@@ -348,7 +353,8 @@ menuconfig POWER
bool "Power Management Support"
default n
---help---
Enable building of power-related devices (battery monitors, chargers, etc).
Enable building of power-related devices (battery monitors, chargers,
etc).
if POWER
source drivers/power/Kconfig
@@ -386,8 +392,8 @@ menuconfig SERIAL
default y
---help---
Front-end character drivers for chip-specific UARTs. This provide
some TTY-like functionality and are commonly used (but not required for)
the NuttX system console. See also include/nuttx/serial/serial.h
some TTY-like functionality and are commonly used (but not required
for) the NuttX system console. See also include/nuttx/serial/serial.h
if SERIAL
source drivers/serial/Kconfig
+13 -14
View File
@@ -86,15 +86,15 @@ ifeq ($(CONFIG_WATCHDOG),y)
endif
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
BIN = libdrivers$(LIBEXT)
BIN = libdrivers$(LIBEXT)
all: $(BIN)
all: $(BIN)
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
@@ -102,22 +102,21 @@ $(AOBJS): %$(OBJEXT): %.S
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
$(BIN): $(OBJS)
@( for obj in $(OBJS) ; do \
$(call ARCHIVE, $@, $${obj}); \
done ; )
$(BIN): $(OBJS)
$(call ARCHIVE, $@, $(OBJS))
.depend: Makefile $(SRCS)
@$(MKDEP) $(DEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@
$(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
$(Q) touch $@
depend: .depend
clean:
@rm -f $(BIN) *~ .*.swp
$(call DELFILE, $(BIN))
$(call CLEAN)
distclean: clean
@rm -f Make.dep .depend
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep
+13 -2
View File
@@ -143,7 +143,7 @@ static int adc_open(FAR struct file *filep)
dev->ad_recv.af_head = 0;
dev->ad_recv.af_tail = 0;
/* Finally, Enable the CAN RX interrupt */
/* Finally, Enable the ADC RX interrupt */
dev->ad_ops->ao_rxint(dev, true);
@@ -151,9 +151,11 @@ static int adc_open(FAR struct file *filep)
dev->ad_ocount = tmp;
}
irqrestore(flags);
}
}
sem_post(&dev->ad_closesem);
}
return ret;
@@ -370,6 +372,10 @@ static int adc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: adc_receive
****************************************************************************/
int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data)
{
FAR struct adc_fifo_s *fifo = &dev->ad_recv;
@@ -390,7 +396,7 @@ int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data)
if (nexttail != fifo->af_head)
{
/* Add the new, decoded CAN message at the tail of the FIFO */
/* Add the new, decoded ADC sample at the tail of the FIFO */
fifo->af_buffer[fifo->af_tail].am_channel = ch;
fifo->af_buffer[fifo->af_tail].am_data = data;
@@ -403,11 +409,16 @@ int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data)
{
sem_post(&fifo->af_sem);
}
err = OK;
}
return err;
}
/****************************************************************************
* Name: adc_register
****************************************************************************/
int adc_register(FAR const char *path, FAR struct adc_dev_s *dev)
{
/* Initialize the ADC device structure */
File diff suppressed because it is too large Load Diff
+167
View File
@@ -0,0 +1,167 @@
/********************************************************************************************
* drivers/input/max11802.h
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Petteri Aimonen <jpa@nx.mail.kapsi.fi>
*
* References:
* "Low-Power, Ultra-Small Resistive Touch-Screen Controllers
* with I2C/SPI Interface" Maxim IC, Rev 3, 10/2010
*
* 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.
*
********************************************************************************************/
#ifndef __DRIVERS_INPUT_MAX11802_H
#define __DRIVERS_INPUT_MAX11802_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <semaphore.h>
#include <poll.h>
#include <wdog.h>
#include <nuttx/wqueue.h>
#include <nuttx/spi.h>
#include <nuttx/clock.h>
#include <nuttx/input/max11802.h>
/********************************************************************************************
* Pre-Processor Definitions
********************************************************************************************/
/* Configuration ****************************************************************************/
/* MAX11802 Interfaces *********************************************************************/
/* LSB of register addresses specifies read (1) or write (0). */
#define MAX11802_CMD_XPOSITION ((0x52 << 1) | 1)
#define MAX11802_CMD_YPOSITION ((0x54 << 1) | 1)
#define MAX11802_CMD_MEASUREXY (0x70 << 1)
#define MAX11802_CMD_MODE_WR (0x0B << 1)
#define MAX11802_CMD_MODE_RD ((0x0B << 1) | 1)
#define MAX11802_CMD_AVG_WR (0x03 << 1)
#define MAX11802_CMD_TIMING_WR (0x05 << 1)
#define MAX11802_CMD_DELAY_WR (0x06 << 1)
/* Register values to set */
#define MAX11802_MODE 0x0E
#define MAX11802_AVG 0x55
#define MAX11802_TIMING 0x77
#define MAX11802_DELAY 0x55
/* Driver support **************************************************************************/
/* This format is used to construct the /dev/input[n] device driver path. It
* defined here so that it will be used consistently in all places.
*/
#define DEV_FORMAT "/dev/input%d"
#define DEV_NAMELEN 16
/* Poll the pen position while the pen is down at this rate (50MS): */
#define MAX11802_WDOG_DELAY ((50 + (MSEC_PER_TICK-1))/ MSEC_PER_TICK)
/********************************************************************************************
* Public Types
********************************************************************************************/
/* This describes the state of one contact */
enum max11802_contact_3
{
CONTACT_NONE = 0, /* No contact */
CONTACT_DOWN, /* First contact */
CONTACT_MOVE, /* Same contact, possibly different position */
CONTACT_UP, /* Contact lost */
};
/* This structure describes the results of one MAX11802 sample */
struct max11802_sample_s
{
uint8_t id; /* Sampled touch point ID */
uint8_t contact; /* Contact state (see enum ads7843e_contact_e) */
bool valid; /* True: x,y contain valid, sampled data */
uint16_t x; /* Measured X position */
uint16_t y; /* Measured Y position */
};
/* This structure describes the state of one MAX11802 driver instance */
struct max11802_dev_s
{
#ifdef CONFIG_ADS7843E_MULTIPLE
FAR struct ads7843e_dev_s *flink; /* Supports a singly linked list of drivers */
#endif
uint8_t nwaiters; /* Number of threads waiting for MAX11802 data */
uint8_t id; /* Current touch point ID */
volatile bool penchange; /* An unreported event is buffered */
uint16_t threshx; /* Thresholding X value */
uint16_t threshy; /* Thresholding Y value */
sem_t devsem; /* Manages exclusive access to this structure */
sem_t waitsem; /* Used to wait for the availability of data */
FAR struct max11802_config_s *config; /* Board configuration data */
FAR struct spi_dev_s *spi; /* Saved SPI driver instance */
struct work_s work; /* Supports the interrupt handling "bottom half" */
struct max11802_sample_s sample; /* Last sampled touch point data */
WDOG_ID wdog; /* Poll the position while the pen is down */
/* The following is a list if poll structures of threads waiting for
* driver events. The 'struct pollfd' reference for each open is also
* retained in the f_priv field of the 'struct file'.
*/
#ifndef CONFIG_DISABLE_POLL
struct pollfd *fds[CONFIG_ADS7843E_NPOLLWAITERS];
#endif
};
/********************************************************************************************
* Public Function Prototypes
********************************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __DRIVERS_INPUT_ADS7843E_H */
+77 -4
View File
@@ -183,12 +183,85 @@ config NOKIA6100_RGBORD
endif
config LCD_UG9664HSWAG01
bool "9664HSWAG01 OLED Display Module"
bool "UG-9664HSWAG01 OLED Display Module"
default n
---help---
ug-9664hswag01.c. OLED Display Module, UG-9664HSWAG01", Univision
Technology Inc. Used with the LPC Xpresso and Embedded Artists
base board.
OLED Display Module, UG-9664HSWAG01, Univision Technology Inc. Used
with the LPCXpresso and Embedded Artists base board.
Required LCD driver settings:
LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted.
LCD_MAXPOWER should be 1: 0=off, 1=on
Required SPI driver settings:
SPI_CMDDATA - Include support for cmd/data selection.
if LCD_UG9664HSWAG01
config UG9664HSWAG01_SPIMODE
int "UG-9664HSWAG01 SPI Mode"
default 0
---help---
Controls the SPI mode
config UG9664HSWAG01_FREQUENCY
int "UG-9664HSWAG01 SPI Frequency"
default 3500000
---help---
Define to use a different bus frequency
config UG9664HSWAG01_NINTERFACES
int "Number of UG-9664HSWAG01 Devices"
default 1
---help---
Specifies the number of physical UG-9664HSWAG01 devices that will be
supported. NOTE: At present, this must be undefined or defined to be 1.
config UG9664HSWAG01_POWER
bool "Power control"
default n
---help---
If the hardware supports a controllable OLED a power supply, this
configuration should be defined. In this case the system must
provide an interface ug_power().
endif
config LCD_UG2864AMBAG01
bool "UG-2864AMBAG01 OLED Display Module"
default n
---help---
OLED Display Module, UG-2864AMBAG01, Univision Technology Inc.
Required LCD driver settings:
LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted.
LCD_MAXPOWER should be 1: 0=off, 1=on
Required SPI driver settings:
SPI_CMDDATA - Include support for cmd/data selection.
if LCD_UG2864AMBAG01
config UG2864AMBAG01_SPIMODE
int "UG-2864AMBAG01 SPI Mode"
default 3
---help---
Controls the SPI mode
config UG2864AMBAG01_FREQUENCY
int "UG-2864AMBAG01 SPI Frequency"
default 3500000
---help---
Define to use a different bus frequency
config UG2864AMBAG01_NINTERFACES
int "Number of UG-2864AMBAG01 Devices"
default 1
---help---
Specifies the number of physical UG-9664HSWAG01 devices that will be
supported. NOTE: At present, this must be undefined or defined to be 1.
endif
config LCD_SSD1289
bool "LCD Based on SSD1289 Controller"
+6 -9
View File
@@ -73,8 +73,6 @@
* CONFIG_UG9664HSWAG01_POWER
* If the hardware supports a controllable OLED a power supply, this
* configuration shold be defined. (See ug_power() below).
* CONFIG_LCD_UGDEBUG - Enable detailed UG-9664HSWAG01 debug output
* (CONFIG_DEBUG and CONFIG_VERBOSE must also be enabled).
*
* Required LCD driver settings:
* CONFIG_LCD_UG9664HSWAG01 - Enable UG-9664HSWAG01 support
@@ -119,11 +117,10 @@
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_VERBOSE
# undef CONFIG_DEBUG_GRAPHICS
#endif
#ifndef CONFIG_DEBUG_VERBOSE
# undef CONFIG_LCD_UGDEBUG
# undef CONFIG_DEBUG_LCD
#endif
/* Check contrast selection */
@@ -182,7 +179,7 @@
#define UG_BPP 1
#define UG_COLORFMT FB_FMT_Y1
/* Bytes per logical row andactual device row */
/* Bytes per logical row and actual device row */
#define UG_XSTRIDE (UG_XRES >> 3) /* Pixels arrange "horizontally for user" */
#define UG_YSTRIDE (UG_YRES >> 3) /* But actual device arrangement is "vertical" */
@@ -198,10 +195,10 @@
/* Debug ******************************************************************************/
#ifdef CONFIG_LCD_UGDEBUG
# define ugdbg(format, arg...) vdbg(format, ##arg)
#ifdef CONFIG_DEBUG_LCD
# define lcddbg(format, arg...) vdbg(format, ##arg)
#else
# define ugdbg(x...)
# define lcddbg(x...)
#endif
/**************************************************************************************
@@ -997,7 +994,7 @@ FAR struct lcd_dev_s *ug_initialize(FAR struct spi_dev_s *spi, unsigned int devn
SPI_CMDDATA(spi, SPIDEV_DISPLAY, true);
/* Set the starting position for the run */
/* Configure the device */
(void)SPI_SEND(spi, SSD1305_SETCOLL + 2); /* Set low column address */
(void)SPI_SEND(spi, SSD1305_SETCOLH + 2); /* Set high column address */
+5
View File
@@ -38,6 +38,9 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined (CONFIG_MMCSD) && defined (CONFIG_MMCSD_SDIO)
#include <nuttx/compiler.h>
#include <sys/types.h>
@@ -3179,3 +3182,5 @@ errout_with_alloc:
kfree(priv);
return ret;
}
#endif /* defined (CONFIG_MMCSD) && defined (CONFIG_MMCSD_SDIO) */
+9 -2
View File
@@ -38,6 +38,9 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined (CONFIG_MMCSD) && defined (CONFIG_MMCSD_SPI)
#include <sys/types.h>
#include <stdint.h>
@@ -508,7 +511,7 @@ static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot,
}
break;
/* The R3 response is 5 bytes long */
/* The R3 response is 5 bytes long. The first byte is identical to R1. */
case MMCSD_CMDRESP_R3:
{
@@ -520,8 +523,10 @@ static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot,
fvdbg("CMD%d[%08x] R1=%02x OCR=%08x\n",
cmd->cmd & 0x3f, arg, response, slot->ocr);
}
break;
/* The R7 response is 5 bytes long. The first byte is identical to R1. */
/* The R7 response is 5 bytes long */
case MMCSD_CMDRESP_R7:
default:
{
@@ -1876,3 +1881,5 @@ int mmcsd_spislotinitialize(int minor, int slotno, FAR struct spi_dev_s *spi)
(void)SPI_REGISTERCALLBACK(spi, mmcsd_mediachanged, (void*)slot);
return OK;
}
#endif /* defined (CONFIG_MMCSD) && defined (CONFIG_MMCSD_SPI) */
+145 -152
View File
@@ -60,6 +60,7 @@
#include <rgmp/pmap.h>
#include <rgmp/string.h>
#include <rgmp/stdio.h>
#include <rgmp/utils.h>
#include <rgmp/arch/pci.h>
#include <rgmp/memio.h>
#include "e1000.h"
@@ -104,9 +105,9 @@ struct e1000_dev {
uint32_t io_mem_base;
uint32_t mem_size;
int pci_dev_id;
uint16_t pci_addr;
unsigned char src_mac[6];
unsigned char dst_mac[6];
int irq;
struct irq_action int_desc;
struct tx_ring tx_ring;
struct rx_ring rx_ring;
@@ -308,16 +309,16 @@ void e1000_init(struct e1000_dev *dev)
e1000_outl(dev, E1000_FCRTH, pba*9/10);
// setup tx rings
txd_phys = PADDR(dev->tx_ring.desc);
kmem_phys = PADDR(dev->tx_ring.buf);
txd_phys = PADDR((uintptr_t)dev->tx_ring.desc);
kmem_phys = PADDR((uintptr_t)dev->tx_ring.buf);
for (i=0; i<CONFIG_E1000_N_TX_DESC; i++,kmem_phys+=CONFIG_E1000_BUFF_SIZE) {
dev->tx_ring.desc[i].base_address = kmem_phys;
dev->tx_ring.desc[i].packet_length = 0;
dev->tx_ring.desc[i].cksum_offset = 0;
dev->tx_ring.desc[i].cksum_origin = 0;
dev->tx_ring.desc[i].desc_status = 1;
dev->tx_ring.desc[i].desc_command = (1<<0)|(1<<1)|(1<<3);
dev->tx_ring.desc[i].special_info = 0;
dev->tx_ring.desc[i].base_address = kmem_phys;
dev->tx_ring.desc[i].packet_length = 0;
dev->tx_ring.desc[i].cksum_offset = 0;
dev->tx_ring.desc[i].cksum_origin = 0;
dev->tx_ring.desc[i].desc_status = 1;
dev->tx_ring.desc[i].desc_command = (1<<0)|(1<<1)|(1<<3);
dev->tx_ring.desc[i].special_info = 0;
}
dev->tx_ring.tail = 0;
e1000_outl(dev, E1000_TDT, 0);
@@ -329,15 +330,15 @@ void e1000_init(struct e1000_dev *dev)
e1000_outl(dev, E1000_TXDCTL, 0x01010000);
// setup rx rings
rxd_phys = PADDR(dev->rx_ring.desc);
kmem_phys = PADDR(dev->rx_ring.buf);
rxd_phys = PADDR((uintptr_t)dev->rx_ring.desc);
kmem_phys = PADDR((uintptr_t)dev->rx_ring.buf);
for (i=0; i<CONFIG_E1000_N_RX_DESC; i++,kmem_phys+=CONFIG_E1000_BUFF_SIZE) {
dev->rx_ring.desc[i].base_address = kmem_phys;
dev->rx_ring.desc[i].packet_length = 0;
dev->rx_ring.desc[i].packet_cksum = 0;
dev->rx_ring.desc[i].desc_status = 0;
dev->rx_ring.desc[i].desc_errors = 0;
dev->rx_ring.desc[i].vlan_tag = 0;
dev->rx_ring.desc[i].base_address = kmem_phys;
dev->rx_ring.desc[i].packet_length = 0;
dev->rx_ring.desc[i].packet_cksum = 0;
dev->rx_ring.desc[i].desc_status = 0;
dev->rx_ring.desc[i].desc_errors = 0;
dev->rx_ring.desc[i].vlan_tag = 0;
}
dev->rx_ring.head = 0;
dev->rx_ring.tail = CONFIG_E1000_N_RX_DESC-1;
@@ -378,7 +379,7 @@ static int e1000_transmit(struct e1000_dev *e1000)
{
int tail = e1000->tx_ring.tail;
unsigned char *cp = (unsigned char *)
(e1000->tx_ring.buf + tail * CONFIG_E1000_BUFF_SIZE);
(e1000->tx_ring.buf + tail * CONFIG_E1000_BUFF_SIZE);
int count = e1000->uip_dev.d_len;
/* Verify that the hardware is ready to send another packet. If we get
@@ -387,7 +388,7 @@ static int e1000_transmit(struct e1000_dev *e1000)
*/
if (!e1000->tx_ring.desc[tail].desc_status)
return -1;
return -1;
/* Increment statistics */
@@ -445,14 +446,14 @@ static int e1000_uiptxpoll(struct uip_driver_s *dev)
*/
if (e1000->uip_dev.d_len > 0) {
uip_arp_out(&e1000->uip_dev);
e1000_transmit(e1000);
uip_arp_out(&e1000->uip_dev);
e1000_transmit(e1000);
/* Check if there is room in the device to hold another packet. If not,
* return a non-zero value to terminate the poll.
*/
if (!e1000->tx_ring.desc[tail].desc_status)
return -1;
/* Check if there is room in the device to hold another packet. If not,
* return a non-zero value to terminate the poll.
*/
if (!e1000->tx_ring.desc[tail].desc_status)
return -1;
}
/* If zero is returned, the polling will continue until all connections have
@@ -483,75 +484,75 @@ static void e1000_receive(struct e1000_dev *e1000)
{
int head = e1000->rx_ring.head;
unsigned char *cp = (unsigned char *)
(e1000->rx_ring.buf + head * CONFIG_E1000_BUFF_SIZE);
(e1000->rx_ring.buf + head * CONFIG_E1000_BUFF_SIZE);
int cnt;
while (e1000->rx_ring.desc[head].desc_status) {
/* Check for errors and update statistics */
/* Check for errors and update statistics */
// Here we do not handle packets that exceed packet-buffer size
if ((e1000->rx_ring.desc[head].desc_status & 3) == 1) {
cprintf("NIC READ: Oversized packet\n");
goto next;
}
// Here we do not handle packets that exceed packet-buffer size
if ((e1000->rx_ring.desc[head].desc_status & 3) == 1) {
cprintf("NIC READ: Oversized packet\n");
goto next;
}
/* Check if the packet is a valid size for the uIP buffer configuration */
/* Check if the packet is a valid size for the uIP buffer configuration */
// get the number of actual data-bytes in this packet
cnt = e1000->rx_ring.desc[head].packet_length;
// get the number of actual data-bytes in this packet
cnt = e1000->rx_ring.desc[head].packet_length;
if (cnt > CONFIG_NET_BUFSIZE || cnt < 14) {
cprintf("NIC READ: invalid package size\n");
goto next;
}
if (cnt > CONFIG_NET_BUFSIZE || cnt < 14) {
cprintf("NIC READ: invalid package size\n");
goto next;
}
/* Copy the data data from the hardware to e1000->uip_dev.d_buf. Set
* amount of data in e1000->uip_dev.d_len
*/
/* Copy the data data from the hardware to e1000->uip_dev.d_buf. Set
* amount of data in e1000->uip_dev.d_len
*/
// now we try to copy these data-bytes to the UIP buffer
memcpy(e1000->uip_dev.d_buf, cp, cnt);
e1000->uip_dev.d_len = cnt;
// now we try to copy these data-bytes to the UIP buffer
memcpy(e1000->uip_dev.d_buf, cp, cnt);
e1000->uip_dev.d_len = cnt;
/* We only accept IP packets of the configured type and ARP packets */
/* We only accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv6
if (BUF->type == HTONS(UIP_ETHTYPE_IP6))
if (BUF->type == HTONS(UIP_ETHTYPE_IP6))
#else
if (BUF->type == HTONS(UIP_ETHTYPE_IP))
if (BUF->type == HTONS(UIP_ETHTYPE_IP))
#endif
{
uip_arp_ipin(&e1000->uip_dev);
uip_input(&e1000->uip_dev);
{
uip_arp_ipin(&e1000->uip_dev);
uip_input(&e1000->uip_dev);
/* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0.
*/
/* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0.
*/
if (e1000->uip_dev.d_len > 0) {
uip_arp_out(&e1000->uip_dev);
e1000_transmit(e1000);
}
}
else if (BUF->type == htons(UIP_ETHTYPE_ARP)) {
uip_arp_arpin(&e1000->uip_dev);
if (e1000->uip_dev.d_len > 0) {
uip_arp_out(&e1000->uip_dev);
e1000_transmit(e1000);
}
}
else if (BUF->type == htons(UIP_ETHTYPE_ARP)) {
uip_arp_arpin(&e1000->uip_dev);
/* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0.
*/
/* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0.
*/
if (e1000->uip_dev.d_len > 0) {
e1000_transmit(e1000);
}
}
if (e1000->uip_dev.d_len > 0) {
e1000_transmit(e1000);
}
}
next:
e1000->rx_ring.desc[head].desc_status = 0;
e1000->rx_ring.head = (head + 1) % CONFIG_E1000_N_RX_DESC;
e1000->rx_ring.free++;
head = e1000->rx_ring.head;
cp = (unsigned char *)(e1000->rx_ring.buf + head * CONFIG_E1000_BUFF_SIZE);
e1000->rx_ring.desc[head].desc_status = 0;
e1000->rx_ring.head = (head + 1) % CONFIG_E1000_N_RX_DESC;
e1000->rx_ring.free++;
head = e1000->rx_ring.head;
cp = (unsigned char *)(e1000->rx_ring.buf + head * CONFIG_E1000_BUFF_SIZE);
}
}
@@ -615,7 +616,7 @@ static void e1000_polltimer(int argc, uint32_t arg, ...)
* the TX poll if he are unable to accept another packet for transmission.
*/
if (!e1000->tx_ring.desc[tail].desc_status)
return;
return;
/* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
* might be bug here. Does this mean if there is a transmit in progress,
@@ -651,8 +652,8 @@ static int e1000_ifup(struct uip_driver_s *dev)
struct e1000_dev *e1000 = (struct e1000_dev *)dev->d_private;
ndbg("Bringing up: %d.%d.%d.%d\n",
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */
e1000_init(e1000);
@@ -662,9 +663,9 @@ static int e1000_ifup(struct uip_driver_s *dev)
(void)wd_start(e1000->txpoll, E1000_WDDELAY, e1000_polltimer, 1, (uint32_t)e1000);
if (e1000_inl(e1000, E1000_STATUS) & 2)
e1000->bifup = true;
e1000->bifup = true;
else
e1000->bifup = false;
e1000->bifup = false;
return OK;
}
@@ -749,9 +750,9 @@ static int e1000_txavail(struct uip_driver_s *dev)
/* Ignore the notification if the interface is not yet up */
if (e1000->bifup) {
/* Check if there is room in the hardware to hold another outgoing packet. */
if (e1000->tx_ring.desc[tail].desc_status)
(void)uip_poll(&e1000->uip_dev, e1000_uiptxpoll);
/* Check if there is room in the hardware to hold another outgoing packet. */
if (e1000->tx_ring.desc[tail].desc_status)
(void)uip_poll(&e1000->uip_dev, e1000_uiptxpoll);
}
irqrestore(flags);
@@ -779,11 +780,11 @@ static int e1000_txavail(struct uip_driver_s *dev)
#ifdef CONFIG_NET_IGMP
static int e1000_addmac(struct uip_driver_s *dev, const uint8_t *mac)
{
struct e1000_dev *e1000 = (struct e1000_dev *)dev->d_private;
struct e1000_dev *e1000 = (struct e1000_dev *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */
/* Add the MAC address to the hardware multicast routing table */
return OK;
return OK;
}
#endif
@@ -808,15 +809,15 @@ static int e1000_addmac(struct uip_driver_s *dev, const uint8_t *mac)
#ifdef CONFIG_NET_IGMP
static int e1000_rmmac(struct uip_driver_s *dev, const uint8_t *mac)
{
struct e1000_dev *e1000 = (struct e1000_dev *)dev->d_private;
struct e1000_dev *e1000 = (struct e1000_dev *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */
/* Add the MAC address to the hardware multicast routing table */
return OK;
return OK;
}
#endif
irqreturn_t e1000_interrupt_handler(struct Trapframe *tf, void *dev_id)
static irqreturn_t e1000_interrupt_handler(int irq, void *dev_id)
{
struct e1000_dev *e1000 = (struct e1000_dev *)dev_id;
@@ -826,27 +827,27 @@ irqreturn_t e1000_interrupt_handler(struct Trapframe *tf, void *dev_id)
// not for me
if (intr_cause == 0)
return IRQ_NONE;
return IRQ_NONE;
/* Handle interrupts according to status bit settings */
// Link status change
if (intr_cause & (1<<2)) {
if (e1000_inl(e1000, E1000_STATUS) & 2)
e1000->bifup = true;
else
e1000->bifup = false;
if (e1000_inl(e1000, E1000_STATUS) & 2)
e1000->bifup = true;
else
e1000->bifup = false;
}
/* Check if we received an incoming packet, if so, call skel_receive() */
// Rx-descriptor Timer expired
if (intr_cause & (1<<7))
e1000_receive(e1000);
e1000_receive(e1000);
// Tx queue empty
if (intr_cause & (1<<1))
wd_cancel(e1000->txtimeout);
wd_cancel(e1000->txtimeout);
/* Check is a packet transmission just completed. If so, call skel_txdone.
* This may disable further Tx interrupts if there are no pending
@@ -855,17 +856,17 @@ irqreturn_t e1000_interrupt_handler(struct Trapframe *tf, void *dev_id)
// Tx-descriptor Written back
if (intr_cause & (1<<0))
uip_poll(&e1000->uip_dev, e1000_uiptxpoll);
uip_poll(&e1000->uip_dev, e1000_uiptxpoll);
// Rx-Descriptors Low
if (intr_cause & (1<<4)) {
int tail;
tail = e1000->rx_ring.tail + e1000->rx_ring.free;
tail %= CONFIG_E1000_N_RX_DESC;
e1000->rx_ring.tail = tail;
e1000->rx_ring.free = 0;
e1000_outl(e1000, E1000_RDT, tail);
int tail;
tail = e1000->rx_ring.tail + e1000->rx_ring.free;
tail %= CONFIG_E1000_N_RX_DESC;
e1000->rx_ring.tail = tail;
e1000->rx_ring.free = 0;
e1000_outl(e1000, E1000_RDT, tail);
}
return IRQ_HANDLED;
@@ -885,20 +886,21 @@ static pci_id_t e1000_id_table[] = {
static int e1000_probe(uint16_t addr, pci_id_t id)
{
uint32_t mmio_base, mmio_size;
uint32_t pci_cmd, size;
int err, irq, flags;
uint32_t size;
int err;
void *kmem, *omem;
struct e1000_dev *dev;
// alloc e1000_dev memory
dev = kzalloc(sizeof(struct e1000_dev));
if (dev == NULL)
return -1;
if ((dev = kzalloc(sizeof(struct e1000_dev))) == NULL)
return -1;
// save pci addr
dev->pci_addr = addr;
// enable device
err = pci_enable_device(addr, PCI_RESOURCE_MEM);
if (err)
goto error;
if ((err = pci_enable_device(addr, PCI_BUS_MASTER)) < 0)
goto error;
// get e1000 device type
dev->pci_dev_id = id.join;
@@ -908,33 +910,20 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
mmio_size = pci_resource_len(addr, 0);
err = rgmp_memmap_nocache(mmio_base, mmio_size, mmio_base);
if (err)
goto error;
goto error;
dev->phy_mem_base = mmio_base;
dev->io_mem_base = mmio_base;
dev->mem_size = mmio_size;
// make sure the controller's Bus Master capability is enabled
pci_cmd = pci_config_readl(addr, PCI_COMMAND);
pci_cmd |= (1<<2);
pci_config_writel(addr, PCI_COMMAND, pci_cmd);
// MAC address
memset(dev->dst_mac, 0xFF, 6);
memcpy(dev->src_mac, (void *)(dev->io_mem_base+E1000_RA), 6);
// get e1000 IRQ
flags = 0;
irq = pci_enable_msi(addr);
if (irq == 0) {
irq = pci_read_irq(addr);
flags |= IDC_SHARE;
}
dev->irq = irq;
// IRQ setup
dev->int_desc.handler = e1000_interrupt_handler;
dev->int_desc.dev_id = dev;
err = rgmp_request_irq(irq, &dev->int_desc, flags);
if (err)
goto err0;
if ((err = pci_request_irq(addr, &dev->int_desc, 0)) < 0)
goto err0;
// Here we alloc a big block of memory once and make it
// aligned to page boundary and multiple of page size. This
@@ -942,15 +931,19 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
// should be mapped no-cache which will hugely reduce memory
// access performance. The page size alloc will restrict
// this bad effect only within the memory we alloc here.
//
// NEED FIX: the memalign may alloc memory continous in
// virtual address but dis-continous in physical address
// due to RGMP memory setup.
size = CONFIG_E1000_N_TX_DESC * sizeof(struct tx_desc) +
CONFIG_E1000_N_TX_DESC * CONFIG_E1000_BUFF_SIZE +
CONFIG_E1000_N_RX_DESC * sizeof(struct rx_desc) +
CONFIG_E1000_N_RX_DESC * CONFIG_E1000_BUFF_SIZE;
CONFIG_E1000_N_TX_DESC * CONFIG_E1000_BUFF_SIZE +
CONFIG_E1000_N_RX_DESC * sizeof(struct rx_desc) +
CONFIG_E1000_N_RX_DESC * CONFIG_E1000_BUFF_SIZE;
size = ROUNDUP(size, PGSIZE);
omem = kmem = memalign(PGSIZE, size);
if (kmem == NULL) {
err = -ENOMEM;
goto err1;
err = -ENOMEM;
goto err1;
}
rgmp_memremap_nocache((uintptr_t)kmem, size);
@@ -991,7 +984,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
/* Register the device with the OS so that socket IOCTLs can be performed */
err = netdev_register(&dev->uip_dev);
if (err)
goto err2;
goto err2;
// insert into e1000_list
dev->next = e1000_list.next;
@@ -1000,14 +993,14 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
return 0;
err2:
err2:
rgmp_memremap((uintptr_t)omem, size);
free(omem);
err1:
rgmp_free_irq(irq, &dev->int_desc);
err0:
err1:
pci_free_irq(addr);
err0:
rgmp_memunmap(mmio_base, mmio_size);
error:
error:
kfree(dev);
cprintf("e1000 device probe fail: %d\n", err);
return err;
@@ -1028,21 +1021,21 @@ void e1000_mod_exit(void)
struct e1000_dev *dev;
size = CONFIG_E1000_N_TX_DESC * sizeof(struct tx_desc) +
CONFIG_E1000_N_TX_DESC * CONFIG_E1000_BUFF_SIZE +
CONFIG_E1000_N_RX_DESC * sizeof(struct rx_desc) +
CONFIG_E1000_N_RX_DESC * CONFIG_E1000_BUFF_SIZE;
CONFIG_E1000_N_TX_DESC * CONFIG_E1000_BUFF_SIZE +
CONFIG_E1000_N_RX_DESC * sizeof(struct rx_desc) +
CONFIG_E1000_N_RX_DESC * CONFIG_E1000_BUFF_SIZE;
size = ROUNDUP(size, PGSIZE);
for (dev=e1000_list.next; dev!=NULL; dev=dev->next) {
netdev_unregister(&dev->uip_dev);
e1000_reset(dev);
wd_delete(dev->txpoll);
wd_delete(dev->txtimeout);
rgmp_memremap((uintptr_t)dev->tx_ring.desc, size);
free(dev->tx_ring.desc);
rgmp_free_irq(dev->irq, &dev->int_desc);
rgmp_memunmap((uintptr_t)dev->io_mem_base, dev->mem_size);
kfree(dev);
netdev_unregister(&dev->uip_dev);
e1000_reset(dev);
wd_delete(dev->txpoll);
wd_delete(dev->txtimeout);
rgmp_memremap((uintptr_t)dev->tx_ring.desc, size);
free(dev->tx_ring.desc);
pci_free_irq(dev->pci_addr);
rgmp_memunmap((uintptr_t)dev->io_mem_base, dev->mem_size);
kfree(dev);
}
e1000_list.next = NULL;
+1 -3
View File
@@ -44,9 +44,7 @@
* Included Files
****************************************************************************/
#include <rgmp/types.h>
#include <rgmp/trap.h>
#include <rgmp/arch/arch.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
+163 -164
View File
@@ -168,30 +168,30 @@ static int vnet_transmit(FAR struct vnet_driver_s *vnet)
{
int err;
/* Verify that the hardware is ready to send another packet. If we get
* here, then we are committed to sending a packet; Higher level logic
* must have assured that there is not transmission in progress.
*/
/* Verify that the hardware is ready to send another packet. If we get
* here, then we are committed to sending a packet; Higher level logic
* must have assured that there is not transmission in progress.
*/
/* Increment statistics */
/* Increment statistics */
/* Send the packet: address=vnet->sk_dev.d_buf, length=vnet->sk_dev.d_len */
/* Send the packet: address=vnet->sk_dev.d_buf, length=vnet->sk_dev.d_len */
err = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len);
if (err) {
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
//(void)wd_start(vnet->sk_txtimeout, VNET_TXTIMEOUT, vnet_txtimeout, 1, (uint32_t)vnet);
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
//(void)wd_start(vnet->sk_txtimeout, VNET_TXTIMEOUT, vnet_txtimeout, 1, (uint32_t)vnet);
// When vnet_xmit fail, it means TX buffer is full. Watchdog
// is of no use here because no TX done INT will happen. So
// we reset the TX buffer directly.
// When vnet_xmit fail, it means TX buffer is full. Watchdog
// is of no use here because no TX done INT will happen. So
// we reset the TX buffer directly.
#ifdef CONFIG_DEBUG
cprintf("VNET: TX buffer is full\n");
cprintf("VNET: TX buffer is full\n");
#endif
return ERROR;
return ERROR;
}
else {
// this step may be unnecessary here
vnet_txdone(vnet);
// this step may be unnecessary here
vnet_txdone(vnet);
}
return OK;
@@ -223,29 +223,29 @@ static int vnet_transmit(FAR struct vnet_driver_s *vnet)
static int vnet_uiptxpoll(struct uip_driver_s *dev)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
if (vnet->sk_dev.d_len > 0)
if (vnet->sk_dev.d_len > 0)
{
uip_arp_out(&vnet->sk_dev);
vnet_transmit(vnet);
uip_arp_out(&vnet->sk_dev);
vnet_transmit(vnet);
/* Check if there is room in the device to hold another packet. If not,
* return a non-zero value to terminate the poll.
*/
if (vnet_is_txbuff_full(vnet->vnet))
return 1;
/* Check if there is room in the device to hold another packet. If not,
* return a non-zero value to terminate the poll.
*/
if (vnet_is_txbuff_full(vnet->vnet))
return 1;
}
/* If zero is returned, the polling will continue until all connections have
* been examined.
*/
/* If zero is returned, the polling will continue until all connections have
* been examined.
*/
return 0;
return 0;
}
/****************************************************************************
@@ -265,54 +265,53 @@ static int vnet_uiptxpoll(struct uip_driver_s *dev)
*
****************************************************************************/
void rtos_vnet_recv(struct rgmp_vnet *vnet_dummy, char *data, int len)
void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len)
{
// now only support 1 vnet
struct vnet_driver_s *vnet = &g_vnet[0];
struct vnet_driver_s *vnet = rgmp_vnet->priv;
do {
/* Check for errors and update statistics */
/* Check for errors and update statistics */
/* Check if the packet is a valid size for the uIP buffer configuration */
if (len > CONFIG_NET_BUFSIZE || len < 14) {
/* Check if the packet is a valid size for the uIP buffer configuration */
if (len > CONFIG_NET_BUFSIZE || len < 14) {
#ifdef CONFIG_DEBUG
cprintf("VNET: receive invalid packet of size %d\n", len);
cprintf("VNET: receive invalid packet of size %d\n", len);
#endif
return;
}
return;
}
// Copy the data data from the hardware to vnet->sk_dev.d_buf. Set
// amount of data in vnet->sk_dev.d_len
memcpy(vnet->sk_dev.d_buf, data, len);
vnet->sk_dev.d_len = len;
// Copy the data data from the hardware to vnet->sk_dev.d_buf. Set
// amount of data in vnet->sk_dev.d_len
memcpy(vnet->sk_dev.d_buf, data, len);
vnet->sk_dev.d_len = len;
/* We only accept IP packets of the configured type and ARP packets */
/* We only accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv6
if (BUF->type == HTONS(UIP_ETHTYPE_IP6))
if (BUF->type == HTONS(UIP_ETHTYPE_IP6))
#else
if (BUF->type == HTONS(UIP_ETHTYPE_IP))
if (BUF->type == HTONS(UIP_ETHTYPE_IP))
#endif
{
uip_arp_ipin(&vnet->sk_dev);
uip_input(&vnet->sk_dev);
{
uip_arp_ipin(&vnet->sk_dev);
uip_input(&vnet->sk_dev);
// If the above function invocation resulted in data that should be
// sent out on the network, the field d_len will set to a value > 0.
if (vnet->sk_dev.d_len > 0) {
uip_arp_out(&vnet->sk_dev);
vnet_transmit(vnet);
}
}
else if (BUF->type == htons(UIP_ETHTYPE_ARP)) {
uip_arp_arpin(&vnet->sk_dev);
// If the above function invocation resulted in data that should be
// sent out on the network, the field d_len will set to a value > 0.
if (vnet->sk_dev.d_len > 0) {
uip_arp_out(&vnet->sk_dev);
vnet_transmit(vnet);
}
}
else if (BUF->type == htons(UIP_ETHTYPE_ARP)) {
uip_arp_arpin(&vnet->sk_dev);
// If the above function invocation resulted in data that should be
// sent out on the network, the field d_len will set to a value > 0.
if (vnet->sk_dev.d_len > 0) {
vnet_transmit(vnet);
}
}
// If the above function invocation resulted in data that should be
// sent out on the network, the field d_len will set to a value > 0.
if (vnet->sk_dev.d_len > 0) {
vnet_transmit(vnet);
}
}
}
while (0); /* While there are more packets to be processed */
}
@@ -336,17 +335,17 @@ void rtos_vnet_recv(struct rgmp_vnet *vnet_dummy, char *data, int len)
static void vnet_txdone(FAR struct vnet_driver_s *vnet)
{
/* Check for errors and update statistics */
/* Check for errors and update statistics */
/* If no further xmits are pending, then cancel the TX timeout and
* disable further Tx interrupts.
*/
/* If no further xmits are pending, then cancel the TX timeout and
* disable further Tx interrupts.
*/
//wd_cancel(vnet->sk_txtimeout);
//wd_cancel(vnet->sk_txtimeout);
/* Then poll uIP for new XMIT data */
/* Then poll uIP for new XMIT data */
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
}
/****************************************************************************
@@ -370,15 +369,15 @@ static void vnet_txdone(FAR struct vnet_driver_s *vnet)
static void vnet_txtimeout(int argc, uint32_t arg, ...)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
/* Increment statistics and dump debug info */
/* Increment statistics and dump debug info */
/* Then reset the hardware */
/* Then reset the hardware */
/* Then poll uIP for new XMIT data */
/* Then poll uIP for new XMIT data */
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
}
/****************************************************************************
@@ -401,28 +400,28 @@ static void vnet_txtimeout(int argc, uint32_t arg, ...)
static void vnet_polltimer(int argc, uint32_t arg, ...)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
if (vnet_is_txbuff_full(vnet->vnet)) {
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
if (vnet_is_txbuff_full(vnet->vnet)) {
#ifdef CONFIG_DEBUG
cprintf("VNET: TX buffer is full\n");
cprintf("VNET: TX buffer is full\n");
#endif
return;
}
return;
}
/* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
* might be bug here. Does this mean if there is a transmit in progress,
* we will missing TCP time state updates?
*/
/* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
* might be bug here. Does this mean if there is a transmit in progress,
* we will missing TCP time state updates?
*/
(void)uip_timer(&vnet->sk_dev, vnet_uiptxpoll, VNET_POLLHSEC);
(void)uip_timer(&vnet->sk_dev, vnet_uiptxpoll, VNET_POLLHSEC);
/* Setup the watchdog poll timer again */
/* Setup the watchdog poll timer again */
(void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, arg);
(void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, arg);
}
/****************************************************************************
@@ -444,20 +443,20 @@ static void vnet_polltimer(int argc, uint32_t arg, ...)
static int vnet_ifup(struct uip_driver_s *dev)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
ndbg("Bringing up: %d.%d.%d.%d\n",
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
ndbg("Bringing up: %d.%d.%d.%d\n",
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */
/* Set and activate a timer process */
/* Set and activate a timer process */
(void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, (uint32_t)vnet);
(void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, (uint32_t)vnet);
vnet->sk_bifup = true;
return OK;
vnet->sk_bifup = true;
return OK;
}
/****************************************************************************
@@ -478,28 +477,28 @@ static int vnet_ifup(struct uip_driver_s *dev)
static int vnet_ifdown(struct uip_driver_s *dev)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
irqstate_t flags;
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
irqstate_t flags;
/* Disable the Ethernet interrupt */
/* Disable the Ethernet interrupt */
flags = irqsave();
flags = irqsave();
/* Cancel the TX poll timer and TX timeout timers */
/* Cancel the TX poll timer and TX timeout timers */
wd_cancel(vnet->sk_txpoll);
//wd_cancel(vnet->sk_txtimeout);
wd_cancel(vnet->sk_txpoll);
//wd_cancel(vnet->sk_txtimeout);
/* Put the the EMAC is its reset, non-operational state. This should be
* a known configuration that will guarantee the vnet_ifup() always
* successfully brings the interface back up.
*/
/* Put the the EMAC is its reset, non-operational state. This should be
* a known configuration that will guarantee the vnet_ifup() always
* successfully brings the interface back up.
*/
/* Mark the device "down" */
/* Mark the device "down" */
vnet->sk_bifup = false;
irqrestore(flags);
return OK;
vnet->sk_bifup = false;
irqrestore(flags);
return OK;
}
/****************************************************************************
@@ -523,35 +522,35 @@ static int vnet_ifdown(struct uip_driver_s *dev)
static int vnet_txavail(struct uip_driver_s *dev)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
irqstate_t flags;
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
irqstate_t flags;
/* Disable interrupts because this function may be called from interrupt
* level processing.
*/
/* Disable interrupts because this function may be called from interrupt
* level processing.
*/
flags = irqsave();
flags = irqsave();
/* Ignore the notification if the interface is not yet up */
/* Ignore the notification if the interface is not yet up */
if (vnet->sk_bifup)
if (vnet->sk_bifup)
{
/* Check if there is room in the hardware to hold another outgoing packet. */
if (vnet_is_txbuff_full(vnet->vnet)) {
/* Check if there is room in the hardware to hold another outgoing packet. */
if (vnet_is_txbuff_full(vnet->vnet)) {
#ifdef CONFIG_DEBUG
cprintf("VNET: TX buffer is full\n");
cprintf("VNET: TX buffer is full\n");
#endif
goto out;
}
goto out;
}
/* If so, then poll uIP for new XMIT data */
/* If so, then poll uIP for new XMIT data */
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
(void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
}
out:
irqrestore(flags);
return OK;
out:
irqrestore(flags);
return OK;
}
/****************************************************************************
@@ -575,11 +574,11 @@ static int vnet_txavail(struct uip_driver_s *dev)
#ifdef CONFIG_NET_IGMP
static int vnet_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */
/* Add the MAC address to the hardware multicast routing table */
return OK;
return OK;
}
#endif
@@ -604,11 +603,11 @@ static int vnet_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac)
#ifdef CONFIG_NET_IGMP
static int vnet_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac)
{
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */
/* Add the MAC address to the hardware multicast routing table */
return OK;
return OK;
}
#endif
@@ -633,41 +632,41 @@ static int vnet_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac)
*
****************************************************************************/
void vnet_initialize(void)
int vnet_init(struct rgmp_vnet *vnet)
{
struct vnet_driver_s *priv;
struct rgmp_vnet *vnet = vnet_list.next;
int i;
struct vnet_driver_s *priv;
static int i = 0;
for (i=0; i<CONFIG_VNET_NINTERFACES; i++) {
if (vnet == NULL)
break;
priv = &g_vnet[i];
if (i >= CONFIG_VNET_NINTERFACES)
return -1;
/* Initialize the driver structure */
priv = &g_vnet[i++];
memset(priv, 0, sizeof(struct vnet_driver_s));
priv->sk_dev.d_ifup = vnet_ifup; /* I/F down callback */
priv->sk_dev.d_ifdown = vnet_ifdown; /* I/F up (new IP address) callback */
priv->sk_dev.d_txavail = vnet_txavail; /* New TX data callback */
/* Initialize the driver structure */
memset(priv, 0, sizeof(struct vnet_driver_s));
priv->sk_dev.d_ifup = vnet_ifup; /* I/F down callback */
priv->sk_dev.d_ifdown = vnet_ifdown; /* I/F up (new IP address) callback */
priv->sk_dev.d_txavail = vnet_txavail; /* New TX data callback */
#ifdef CONFIG_NET_IGMP
priv->sk_dev.d_addmac = vnet_addmac; /* Add multicast MAC address */
priv->sk_dev.d_rmmac = vnet_rmmac; /* Remove multicast MAC address */
priv->sk_dev.d_addmac = vnet_addmac; /* Add multicast MAC address */
priv->sk_dev.d_rmmac = vnet_rmmac; /* Remove multicast MAC address */
#endif
priv->sk_dev.d_private = (void*)g_vnet; /* Used to recover private state from dev */
priv->sk_dev.d_private = (void*)priv; /* Used to recover private state from dev */
/* Create a watchdog for timing polling for and timing of transmisstions */
/* Create a watchdog for timing polling for and timing of transmisstions */
priv->sk_txpoll = wd_create(); /* Create periodic poll timer */
//priv->sk_txtimeout = wd_create(); /* Create TX timeout timer */
priv->sk_txpoll = wd_create(); /* Create periodic poll timer */
//priv->sk_txtimeout = wd_create(); /* Create TX timeout timer */
priv->vnet = vnet;
priv->vnet = vnet;
vnet->priv = priv;
/* Register the device with the OS */
/* Register the device with the OS */
(void)netdev_register(&priv->sk_dev);
vnet = vnet->next;
}
(void)netdev_register(&priv->sk_dev);
return 0;
}
#endif /* CONFIG_NET && CONFIG_NET_VNET */
+1 -1
View File
@@ -132,7 +132,7 @@
/* USB Controller */
#ifndef CONFIG_USBDEV_SELFPOWERED
# define SELFPOWERED USB_CONFIG_ATT_SELFPOWER
# define SELFPOWERED USB_CONFIG_ATTR_SELFPOWER
#else
# define SELFPOWERED (0)
#endif
+1 -1
View File
@@ -227,7 +227,7 @@
/* USB Controller */
#ifndef CONFIG_USBDEV_SELFPOWERED
# define SELFPOWERED USB_CONFIG_ATT_SELFPOWER
# define SELFPOWERED USB_CONFIG_ATTR_SELFPOWER
#else
# define SELFPOWERED (0)
#endif