Starting point for the RDK webserver files added.
parent
0363b47c66
commit
659a27800f
@ -0,0 +1,260 @@
|
|||||||
|
/*
|
||||||
|
FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd.
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* If you are: *
|
||||||
|
* *
|
||||||
|
* + New to FreeRTOS, *
|
||||||
|
* + Wanting to learn FreeRTOS or multitasking in general quickly *
|
||||||
|
* + Looking for basic training, *
|
||||||
|
* + Wanting to improve your FreeRTOS skills and productivity *
|
||||||
|
* *
|
||||||
|
* then take a look at the FreeRTOS eBook *
|
||||||
|
* *
|
||||||
|
* "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
|
||||||
|
* http://www.FreeRTOS.org/Documentation *
|
||||||
|
* *
|
||||||
|
* A pdf reference manual is also available. Both are usually delivered *
|
||||||
|
* to your inbox within 20 minutes to two hours when purchased between 8am *
|
||||||
|
* and 8pm GMT (although please allow up to 24 hours in case of *
|
||||||
|
* exceptional circumstances). Thank you for your support! *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||||
|
***NOTE*** The exception to the GPL is included to allow you to distribute
|
||||||
|
a combined work that includes FreeRTOS without being obliged to provide the
|
||||||
|
source code for proprietary components outside of the FreeRTOS kernel.
|
||||||
|
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details. You should have received a copy of the GNU General Public
|
||||||
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||||
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||||
|
by writing to Richard Barry, contact details for whom are available on the
|
||||||
|
FreeRTOS WEB site.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Standard includes. */
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* Scheduler includes. */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
|
||||||
|
/* uip includes. */
|
||||||
|
#include "net/uip.h"
|
||||||
|
#include "net/uip_arp.h"
|
||||||
|
#include "apps/httpd/httpd.h"
|
||||||
|
#include "sys/timer.h"
|
||||||
|
#include "net/clock-arch.h"
|
||||||
|
|
||||||
|
/* Demo includes. */
|
||||||
|
#include "ParTest.h"
|
||||||
|
|
||||||
|
/* Hardware includes. */
|
||||||
|
#include "hwEthernet.h"
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* How long to wait before attempting to connect the MAC again. */
|
||||||
|
#define uipINIT_WAIT ( 100 / portTICK_RATE_MS )
|
||||||
|
|
||||||
|
/* Shortcut to the header within the Rx buffer. */
|
||||||
|
#define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ])
|
||||||
|
|
||||||
|
/* Standard constant. */
|
||||||
|
#define uipTOTAL_FRAME_HEADER_SIZE 54
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup the MAC address in the MAC itself, and in the uIP stack.
|
||||||
|
*/
|
||||||
|
static void prvSetMACAddress( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Port functions required by the uIP stack.
|
||||||
|
*/
|
||||||
|
void clock_init( void );
|
||||||
|
clock_time_t clock_time( void );
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* The semaphore used by the ISR to wake the uIP task. */
|
||||||
|
xSemaphoreHandle xEMACSemaphore = NULL;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void clock_init(void)
|
||||||
|
{
|
||||||
|
/* This is done when the scheduler starts. */
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
clock_time_t clock_time( void )
|
||||||
|
{
|
||||||
|
return xTaskGetTickCount();
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vuIP_Task( void *pvParameters )
|
||||||
|
{
|
||||||
|
portBASE_TYPE i;
|
||||||
|
uip_ipaddr_t xIPAddr;
|
||||||
|
struct timer periodic_timer, arp_timer;
|
||||||
|
extern void ( vEMAC_ISR_Wrapper )( void );
|
||||||
|
|
||||||
|
( void ) pvParameters;
|
||||||
|
|
||||||
|
/* Initialise the uIP stack. */
|
||||||
|
timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
|
||||||
|
timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
|
||||||
|
uip_init();
|
||||||
|
uip_ipaddr( &xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
|
||||||
|
uip_sethostaddr( &xIPAddr );
|
||||||
|
uip_ipaddr( &xIPAddr, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 );
|
||||||
|
uip_setnetmask( &xIPAddr );
|
||||||
|
prvSetMACAddress();
|
||||||
|
httpd_init();
|
||||||
|
|
||||||
|
/* Create the semaphore used to wake the uIP task. */
|
||||||
|
vSemaphoreCreateBinary( xEMACSemaphore );
|
||||||
|
|
||||||
|
/* Initialise the MAC. */
|
||||||
|
vInitEmac();
|
||||||
|
|
||||||
|
while( lEMACWaitForLink() != pdPASS )
|
||||||
|
{
|
||||||
|
vTaskDelay( uipINIT_WAIT );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
/* Is there received data ready to be processed? */
|
||||||
|
uip_len = ( unsigned short ) ulEMACRead();
|
||||||
|
|
||||||
|
if( ( uip_len > 0 ) && ( uip_buf != NULL ) )
|
||||||
|
{
|
||||||
|
/* Standard uIP loop taken from the uIP manual. */
|
||||||
|
if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
|
||||||
|
{
|
||||||
|
uip_arp_ipin();
|
||||||
|
uip_input();
|
||||||
|
|
||||||
|
/* If the above function invocation resulted in data that
|
||||||
|
should be sent out on the network, the global variable
|
||||||
|
uip_len is set to a value > 0. */
|
||||||
|
if( uip_len > 0 )
|
||||||
|
{
|
||||||
|
uip_arp_out();
|
||||||
|
vEMACWrite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
|
||||||
|
{
|
||||||
|
uip_arp_arpin();
|
||||||
|
|
||||||
|
/* If the above function invocation resulted in data that
|
||||||
|
should be sent out on the network, the global variable
|
||||||
|
uip_len is set to a value > 0. */
|
||||||
|
if( uip_len > 0 )
|
||||||
|
{
|
||||||
|
vEMACWrite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( timer_expired( &periodic_timer ) && ( uip_buf != NULL ) )
|
||||||
|
{
|
||||||
|
timer_reset( &periodic_timer );
|
||||||
|
for( i = 0; i < UIP_CONNS; i++ )
|
||||||
|
{
|
||||||
|
uip_periodic( i );
|
||||||
|
|
||||||
|
/* If the above function invocation resulted in data that
|
||||||
|
should be sent out on the network, the global variable
|
||||||
|
uip_len is set to a value > 0. */
|
||||||
|
if( uip_len > 0 )
|
||||||
|
{
|
||||||
|
uip_arp_out();
|
||||||
|
vEMACWrite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call the ARP timer function every 10 seconds. */
|
||||||
|
if( timer_expired( &arp_timer ) )
|
||||||
|
{
|
||||||
|
timer_reset( &arp_timer );
|
||||||
|
uip_arp_timer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We did not receive a packet, and there was no periodic
|
||||||
|
processing to perform. Block for a fixed period. If a packet
|
||||||
|
is received during this period we will be woken by the ISR
|
||||||
|
giving us the Semaphore. */
|
||||||
|
xSemaphoreTake( xEMACSemaphore, configTICK_RATE_HZ / 2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvSetMACAddress( void )
|
||||||
|
{
|
||||||
|
struct uip_eth_addr xAddr;
|
||||||
|
|
||||||
|
/* Configure the MAC address in the uIP stack. */
|
||||||
|
xAddr.addr[ 0 ] = configMAC_ADDR0;
|
||||||
|
xAddr.addr[ 1 ] = configMAC_ADDR1;
|
||||||
|
xAddr.addr[ 2 ] = configMAC_ADDR2;
|
||||||
|
xAddr.addr[ 3 ] = configMAC_ADDR3;
|
||||||
|
xAddr.addr[ 4 ] = configMAC_ADDR4;
|
||||||
|
xAddr.addr[ 5 ] = configMAC_ADDR5;
|
||||||
|
uip_setethaddr( xAddr );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vApplicationProcessFormInput( char *pcInputString )
|
||||||
|
{
|
||||||
|
char *c;
|
||||||
|
|
||||||
|
/* Process the form input sent by the IO page of the served HTML. */
|
||||||
|
|
||||||
|
c = strstr( pcInputString, "?" );
|
||||||
|
if( c )
|
||||||
|
{
|
||||||
|
/* Turn the FIO1 LED's on or off in accordance with the check box status. */
|
||||||
|
if( strstr( c, "LED0=1" ) != NULL )
|
||||||
|
{
|
||||||
|
/* Turn LED 4 on. */
|
||||||
|
vParTestSetLED( 4, 1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Turn LED 4 off. */
|
||||||
|
vParTestSetLED( 4, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,558 @@
|
|||||||
|
/*
|
||||||
|
FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd.
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* If you are: *
|
||||||
|
* *
|
||||||
|
* + New to FreeRTOS, *
|
||||||
|
* + Wanting to learn FreeRTOS or multitasking in general quickly *
|
||||||
|
* + Looking for basic training, *
|
||||||
|
* + Wanting to improve your FreeRTOS skills and productivity *
|
||||||
|
* *
|
||||||
|
* then take a look at the FreeRTOS eBook *
|
||||||
|
* *
|
||||||
|
* "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
|
||||||
|
* http://www.FreeRTOS.org/Documentation *
|
||||||
|
* *
|
||||||
|
* A pdf reference manual is also available. Both are usually delivered *
|
||||||
|
* to your inbox within 20 minutes to two hours when purchased between 8am *
|
||||||
|
* and 8pm GMT (although please allow up to 24 hours in case of *
|
||||||
|
* exceptional circumstances). Thank you for your support! *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||||
|
***NOTE*** The exception to the GPL is included to allow you to distribute
|
||||||
|
a combined work that includes FreeRTOS without being obliged to provide the
|
||||||
|
source code for proprietary components outside of the FreeRTOS kernel.
|
||||||
|
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details. You should have received a copy of the GNU General Public
|
||||||
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||||
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||||
|
by writing to Richard Barry, contact details for whom are available on the
|
||||||
|
FreeRTOS WEB site.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Hardware specific includes. */
|
||||||
|
#include "iodefine.h"
|
||||||
|
#include "typedefine.h"
|
||||||
|
#include "hwEthernet.h"
|
||||||
|
#include "hwEthernetPhy.h"
|
||||||
|
|
||||||
|
/* FreeRTOS includes. */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
|
||||||
|
/* uIP includes. */
|
||||||
|
#include "net/uip.h"
|
||||||
|
|
||||||
|
/* The time to wait between attempts to obtain a free buffer. */
|
||||||
|
#define emacBUFFER_WAIT_DELAY_ms ( 3 / portTICK_RATE_MS )
|
||||||
|
|
||||||
|
/* The number of times emacBUFFER_WAIT_DELAY_ms should be waited before giving
|
||||||
|
up on attempting to obtain a free buffer all together. */
|
||||||
|
#define emacBUFFER_WAIT_ATTEMPTS ( 30 )
|
||||||
|
|
||||||
|
/* The number of Rx descriptors. */
|
||||||
|
#define emacNUM_RX_DESCRIPTORS 3
|
||||||
|
|
||||||
|
/* The number of Tx descriptors. When using uIP there is not point in having
|
||||||
|
more than two. */
|
||||||
|
#define emacNUM_TX_BUFFERS 2
|
||||||
|
|
||||||
|
/* The total number of EMAC buffers to allocate. */
|
||||||
|
#define emacNUM_BUFFERS ( emacNUM_RX_DESCRIPTORS + emacNUM_TX_BUFFERS )
|
||||||
|
|
||||||
|
/* The time to wait for the Tx descriptor to become free. */
|
||||||
|
#define emacTX_WAIT_DELAY_ms ( 10 / portTICK_RATE_MS )
|
||||||
|
|
||||||
|
/* The total number of times to wait emacTX_WAIT_DELAY_ms for the Tx descriptor to
|
||||||
|
become free. */
|
||||||
|
#define emacTX_WAIT_ATTEMPTS ( 5 )
|
||||||
|
|
||||||
|
/* Only Rx end and Tx end interrupts are used by this driver. */
|
||||||
|
#define emacTX_END_INTERRUPT ( 1UL << 21UL )
|
||||||
|
#define emacRX_END_INTERRUPT ( 1UL << 18UL )
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* The buffers and descriptors themselves. */
|
||||||
|
#pragma section RX_DESCR
|
||||||
|
ethfifo xRxDescriptors[ emacNUM_RX_DESCRIPTORS ];
|
||||||
|
#pragma section TX_DESCR
|
||||||
|
ethfifo xTxDescriptors[ emacNUM_TX_BUFFERS ];
|
||||||
|
#pragma section _ETHERNET_BUFFERS
|
||||||
|
char xEthernetBuffers[ emacNUM_BUFFERS ][ UIP_BUFSIZE ];
|
||||||
|
#pragma section
|
||||||
|
|
||||||
|
/* Used to indicate which buffers are free and which are in use. If an index
|
||||||
|
contains 0 then the corresponding buffer in xEthernetBuffers is free, otherwise
|
||||||
|
the buffer is in use or about to be used. */
|
||||||
|
static unsigned char ucBufferInUse[ emacNUM_BUFFERS ];
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialise both the Rx and Tx descriptors.
|
||||||
|
*/
|
||||||
|
static void prvInitialiseDescriptors( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a pointer to a free buffer within xEthernetBuffers.
|
||||||
|
*/
|
||||||
|
static unsigned char *prvGetNextBuffer( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a buffer to the list of free buffers.
|
||||||
|
*/
|
||||||
|
static void prvReturnBuffer( unsigned char *pucBuffer );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Examine the status of the next Rx FIFO to see if it contains new data.
|
||||||
|
*/
|
||||||
|
static unsigned long prvCheckRxFifoStatus( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup the microcontroller for communication with the PHY.
|
||||||
|
*/
|
||||||
|
static void prvSetupPortPinsAndReset( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configure the Ethernet interface peripherals.
|
||||||
|
*/
|
||||||
|
static void prvConfigureEtherCAndEDMAC( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Something has gone wrong with the descriptor usage. Reset all the buffers
|
||||||
|
* and descriptors.
|
||||||
|
*/
|
||||||
|
static void prvResetEverything( void );
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Points to the Rx descriptor currently in use. */
|
||||||
|
static ethfifo *xCurrentRxDesc = NULL;
|
||||||
|
|
||||||
|
/* The buffer used by the uIP stack to both receive and send. This points to
|
||||||
|
one of the Ethernet buffers when its actually in use. */
|
||||||
|
unsigned char *uip_buf = NULL;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vInitEmac( void )
|
||||||
|
{
|
||||||
|
/* Setup the SH hardware for MII communications. */
|
||||||
|
prvSetupPortPinsAndReset();
|
||||||
|
|
||||||
|
/* Set the Rx and Tx descriptors into their initial state. */
|
||||||
|
prvInitialiseDescriptors();
|
||||||
|
|
||||||
|
/* Set the MAC address into the ETHERC */
|
||||||
|
EtherC.MAHR = ( ( unsigned long ) configMAC_ADDR0 << 24UL ) |
|
||||||
|
( ( unsigned long ) configMAC_ADDR1 << 16UL ) |
|
||||||
|
( ( unsigned long ) configMAC_ADDR2 << 8UL ) |
|
||||||
|
( unsigned long ) configMAC_ADDR3;
|
||||||
|
|
||||||
|
EtherC.MALR.BIT.MA = ( ( unsigned long ) configMAC_ADDR4 << 8UL ) |
|
||||||
|
( unsigned long ) configMAC_ADDR5;
|
||||||
|
|
||||||
|
/* Perform rest of interface hardware configuration. */
|
||||||
|
prvConfigureEtherCAndEDMAC();
|
||||||
|
|
||||||
|
/* Nothing received yet, so uip_buf points nowhere. */
|
||||||
|
uip_buf = NULL;
|
||||||
|
|
||||||
|
/* Initialize the PHY */
|
||||||
|
phyReset();
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vEMACWrite( void )
|
||||||
|
{
|
||||||
|
long x;
|
||||||
|
|
||||||
|
/* Wait until the second transmission of the last packet has completed. */
|
||||||
|
for( x = 0; x < emacTX_WAIT_ATTEMPTS; x++ )
|
||||||
|
{
|
||||||
|
if( ( xTxDescriptors[ 1 ].status & ACT ) != 0 )
|
||||||
|
{
|
||||||
|
/* Descriptor is still active. */
|
||||||
|
vTaskDelay( emacTX_WAIT_DELAY_ms );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Is the descriptor free after waiting for it? */
|
||||||
|
if( ( xTxDescriptors[ 1 ].status & ACT ) != 0 )
|
||||||
|
{
|
||||||
|
/* Something has gone wrong. */
|
||||||
|
prvResetEverything();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup both descriptors to transmit the frame. */
|
||||||
|
xTxDescriptors[ 0 ].buf_p = ( char * ) uip_buf;
|
||||||
|
xTxDescriptors[ 0 ].bufsize = uip_len;
|
||||||
|
xTxDescriptors[ 1 ].buf_p = ( char * ) uip_buf;
|
||||||
|
xTxDescriptors[ 1 ].bufsize = uip_len;
|
||||||
|
|
||||||
|
/* uip_buf is being sent by the Tx descriptor. Allocate a new buffer
|
||||||
|
for use by the stack. */
|
||||||
|
uip_buf = prvGetNextBuffer();
|
||||||
|
|
||||||
|
/* Clear previous settings and go. */
|
||||||
|
xTxDescriptors[0].status &= ~( FP1 | FP0 );
|
||||||
|
xTxDescriptors[0].status |= ( FP1 | FP0 | ACT );
|
||||||
|
xTxDescriptors[1].status &= ~( FP1 | FP0 );
|
||||||
|
xTxDescriptors[1].status |= ( FP1 | FP0 | ACT );
|
||||||
|
|
||||||
|
EDMAC.EDTRR.LONG = 0x00000001;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
unsigned long ulEMACRead( void )
|
||||||
|
{
|
||||||
|
unsigned long ulBytesReceived;
|
||||||
|
|
||||||
|
ulBytesReceived = prvCheckRxFifoStatus();
|
||||||
|
|
||||||
|
if( ulBytesReceived > 0 )
|
||||||
|
{
|
||||||
|
xCurrentRxDesc->status &= ~( FP1 | FP0 );
|
||||||
|
xCurrentRxDesc->status |= ACT;
|
||||||
|
|
||||||
|
if( EDMAC.EDRRR.LONG == 0x00000000L )
|
||||||
|
{
|
||||||
|
/* Restart Ethernet if it has stopped */
|
||||||
|
EDMAC.EDRRR.LONG = 0x00000001L;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark the pxDescriptor buffer as free as uip_buf is going to be set to
|
||||||
|
the buffer that contains the received data. */
|
||||||
|
prvReturnBuffer( uip_buf );
|
||||||
|
|
||||||
|
uip_buf = ( void * ) xCurrentRxDesc->buf_p;
|
||||||
|
|
||||||
|
/* Move onto the next buffer in the ring. */
|
||||||
|
xCurrentRxDesc = xCurrentRxDesc->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ulBytesReceived;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
long lEMACWaitForLink( void )
|
||||||
|
{
|
||||||
|
long lReturn;
|
||||||
|
|
||||||
|
/* Set the link status. */
|
||||||
|
switch( phyStatus() )
|
||||||
|
{
|
||||||
|
/* Half duplex link */
|
||||||
|
case PHY_LINK_100H:
|
||||||
|
case PHY_LINK_10H:
|
||||||
|
EtherC.ECMR.BIT.DM = 0;
|
||||||
|
lReturn = pdPASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Full duplex link */
|
||||||
|
case PHY_LINK_100F:
|
||||||
|
case PHY_LINK_10F:
|
||||||
|
EtherC.ECMR.BIT.DM = 1;
|
||||||
|
lReturn = pdPASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
lReturn = pdFAIL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lReturn == pdPASS )
|
||||||
|
{
|
||||||
|
/* Enable receive and transmit. */
|
||||||
|
EtherC.ECMR.BIT.RE = 1;
|
||||||
|
EtherC.ECMR.BIT.TE = 1;
|
||||||
|
|
||||||
|
/* Enable EDMAC receive */
|
||||||
|
EDMAC.EDRRR.LONG = 0x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lReturn;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvInitialiseDescriptors( void )
|
||||||
|
{
|
||||||
|
ethfifo *pxDescriptor;
|
||||||
|
long x;
|
||||||
|
|
||||||
|
for( x = 0; x < emacNUM_BUFFERS; x++ )
|
||||||
|
{
|
||||||
|
/* Ensure none of the buffers are shown as in use at the start. */
|
||||||
|
ucBufferInUse[ x ] = pdFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialise the Rx descriptors. */
|
||||||
|
for( x = 0; x < emacNUM_RX_DESCRIPTORS; x++ )
|
||||||
|
{
|
||||||
|
pxDescriptor = &( xRxDescriptors[ x ] );
|
||||||
|
pxDescriptor->buf_p = &( xEthernetBuffers[ x ][ 0 ] );
|
||||||
|
|
||||||
|
pxDescriptor->bufsize = UIP_BUFSIZE;
|
||||||
|
pxDescriptor->size = 0;
|
||||||
|
pxDescriptor->status = ACT;
|
||||||
|
pxDescriptor->next = &xRxDescriptors[ x + 1 ];
|
||||||
|
|
||||||
|
/* Mark this buffer as in use. */
|
||||||
|
ucBufferInUse[ x ] = pdTRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The last descriptor points back to the start. */
|
||||||
|
pxDescriptor->status |= DL;
|
||||||
|
pxDescriptor->next = &xRxDescriptors[ 0 ];
|
||||||
|
|
||||||
|
/* Initialise the Tx descriptors. */
|
||||||
|
for( x = 0; x < emacNUM_TX_BUFFERS; x++ )
|
||||||
|
{
|
||||||
|
pxDescriptor = &( xTxDescriptors[ x ] );
|
||||||
|
|
||||||
|
/* A buffer is not allocated to the Tx descriptor until a send is
|
||||||
|
actually required. */
|
||||||
|
pxDescriptor->buf_p = NULL;
|
||||||
|
|
||||||
|
pxDescriptor->bufsize = UIP_BUFSIZE;
|
||||||
|
pxDescriptor->size = 0;
|
||||||
|
pxDescriptor->status = 0;
|
||||||
|
pxDescriptor->next = &xTxDescriptors[ x + 1 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The last descriptor points back to the start. */
|
||||||
|
pxDescriptor->status |= DL;
|
||||||
|
pxDescriptor->next = &( xTxDescriptors[ 0 ] );
|
||||||
|
|
||||||
|
/* Use the first Rx descriptor to start with. */
|
||||||
|
xCurrentRxDesc = &( xRxDescriptors[ 0 ] );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static unsigned char *prvGetNextBuffer( void )
|
||||||
|
{
|
||||||
|
long x;
|
||||||
|
unsigned char *pucReturn = NULL;
|
||||||
|
unsigned long ulAttempts = 0;
|
||||||
|
|
||||||
|
while( pucReturn == NULL )
|
||||||
|
{
|
||||||
|
/* Look through the buffers to find one that is not in use by
|
||||||
|
anything else. */
|
||||||
|
for( x = 0; x < emacNUM_BUFFERS; x++ )
|
||||||
|
{
|
||||||
|
if( ucBufferInUse[ x ] == pdFALSE )
|
||||||
|
{
|
||||||
|
ucBufferInUse[ x ] = pdTRUE;
|
||||||
|
pucReturn = ( unsigned char * ) &( xEthernetBuffers[ x ][ 0 ] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Was a buffer found? */
|
||||||
|
if( pucReturn == NULL )
|
||||||
|
{
|
||||||
|
ulAttempts++;
|
||||||
|
|
||||||
|
if( ulAttempts >= emacBUFFER_WAIT_ATTEMPTS )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait then look again. */
|
||||||
|
vTaskDelay( emacBUFFER_WAIT_DELAY_ms );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pucReturn;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvReturnBuffer( unsigned char *pucBuffer )
|
||||||
|
{
|
||||||
|
unsigned long ul;
|
||||||
|
|
||||||
|
/* Return a buffer to the pool of free buffers. */
|
||||||
|
for( ul = 0; ul < emacNUM_BUFFERS; ul++ )
|
||||||
|
{
|
||||||
|
if( &( xEthernetBuffers[ ul ][ 0 ] ) == ( void * ) pucBuffer )
|
||||||
|
{
|
||||||
|
ucBufferInUse[ ul ] = pdFALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvResetEverything( void )
|
||||||
|
{
|
||||||
|
/* Temporary code just to see if this gets called. This function has not
|
||||||
|
been implemented. */
|
||||||
|
portDISABLE_INTERRUPTS();
|
||||||
|
for( ;; );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static unsigned long prvCheckRxFifoStatus( void )
|
||||||
|
{
|
||||||
|
unsigned long ulReturn = 0;
|
||||||
|
|
||||||
|
if( ( xCurrentRxDesc->status & ACT ) != 0 )
|
||||||
|
{
|
||||||
|
/* Current descriptor is still active. */
|
||||||
|
}
|
||||||
|
else if( ( xCurrentRxDesc->status & FE ) != 0 )
|
||||||
|
{
|
||||||
|
/* Frame error. Clear the error. */
|
||||||
|
xCurrentRxDesc->status &= ~( FP1 | FP0 | FE );
|
||||||
|
xCurrentRxDesc->status &= ~( RMAF | RRF | RTLF | RTSF | PRE | CERF );
|
||||||
|
xCurrentRxDesc->status |= ACT;
|
||||||
|
xCurrentRxDesc = xCurrentRxDesc->next;
|
||||||
|
|
||||||
|
if( EDMAC.EDRRR.LONG == 0x00000000UL )
|
||||||
|
{
|
||||||
|
/* Restart Ethernet if it has stopped. */
|
||||||
|
EDMAC.EDRRR.LONG = 0x00000001UL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The descriptor contains a frame. Because of the size of the buffers
|
||||||
|
the frame should always be complete. */
|
||||||
|
if( (xCurrentRxDesc->status & FP0) == FP0 )
|
||||||
|
{
|
||||||
|
ulReturn = xCurrentRxDesc->size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Do not expect to get here. */
|
||||||
|
prvResetEverything();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ulReturn;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvSetupPortPinsAndReset( void )
|
||||||
|
{
|
||||||
|
/* Initialisation code taken from Renesas example project. */
|
||||||
|
|
||||||
|
PFC.PACRL4.BIT.PA12MD = 0x7; /* Set TX_CLK input (EtherC) */
|
||||||
|
PFC.PACRL3.BIT.PA11MD = 0x7; /* Set TX_EN output (EtherC) */
|
||||||
|
PFC.PACRL3.BIT.PA10MD = 0x7; /* Set MII_TXD0 output (EtherC) */
|
||||||
|
PFC.PACRL3.BIT.PA9MD = 0x7; /* Set MII_TXD1 output (EtherC) */
|
||||||
|
PFC.PACRL3.BIT.PA8MD = 0x7; /* Set MII_TXD2 output (EtherC) */
|
||||||
|
PFC.PACRL2.BIT.PA7MD = 0x7; /* Set MII_TXD3 output (EtherC) */
|
||||||
|
PFC.PACRL2.BIT.PA6MD = 0x7; /* Set TX_ER output (EtherC) */
|
||||||
|
PFC.PDCRH4.BIT.PD31MD = 0x7; /* Set RX_DV input (EtherC) */
|
||||||
|
PFC.PDCRH4.BIT.PD30MD = 0x7; /* Set RX_ER input (EtherC) */
|
||||||
|
PFC.PDCRH4.BIT.PD29MD = 0x7; /* Set MII_RXD3 input (EtherC) */
|
||||||
|
PFC.PDCRH4.BIT.PD28MD = 0x7; /* Set MII_RXD2 input (EtherC) */
|
||||||
|
PFC.PDCRH3.BIT.PD27MD = 0x7; /* Set MII_RXD1 input (EtherC) */
|
||||||
|
PFC.PDCRH3.BIT.PD26MD = 0x7; /* Set MII_RXD0 input (EtherC) */
|
||||||
|
PFC.PDCRH3.BIT.PD25MD = 0x7; /* Set RX_CLK input (EtherC) */
|
||||||
|
PFC.PDCRH3.BIT.PD24MD = 0x7; /* Set CRS input (EtherC) */
|
||||||
|
PFC.PDCRH2.BIT.PD23MD = 0x7; /* Set COL input (EtherC) */
|
||||||
|
PFC.PDCRH2.BIT.PD22MD = 0x7; /* Set WOL output (EtherC) */
|
||||||
|
PFC.PDCRH2.BIT.PD21MD = 0x7; /* Set EXOUT output (EtherC) */
|
||||||
|
PFC.PDCRH2.BIT.PD20MD = 0x7; /* Set MDC output (EtherC) */
|
||||||
|
PFC.PDCRH1.BIT.PD19MD = 0x7; /* Set LINKSTA input (EtherC) */
|
||||||
|
PFC.PDCRH1.BIT.PD18MD = 0x7; /* Set MDIO input/output (EtherC) */
|
||||||
|
|
||||||
|
STB.CR4.BIT._ETHER = 0x0;
|
||||||
|
EDMAC.EDMR.BIT.SWR = 1;
|
||||||
|
|
||||||
|
/* Crude wait for reset to complete. */
|
||||||
|
vTaskDelay( 500 / portTICK_RATE_MS );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvConfigureEtherCAndEDMAC( void )
|
||||||
|
{
|
||||||
|
/* Initialisation code taken from Renesas example project. */
|
||||||
|
|
||||||
|
/* TODO: Check bit 5 */
|
||||||
|
EtherC.ECSR.LONG = 0x00000037; /* Clear all EtherC statuS BFR, PSRTO, LCHNG, MPD, ICD */
|
||||||
|
|
||||||
|
/* TODO: Check bit 5 */
|
||||||
|
EtherC.ECSIPR.LONG = 0x00000020; /* Disable EtherC status change interrupt */
|
||||||
|
EtherC.RFLR.LONG = 1518; /* Ether payload is 1500+ CRC */
|
||||||
|
EtherC.IPGR.LONG = 0x00000014; /* Intergap is 96-bit time */
|
||||||
|
|
||||||
|
/* EDMAC */
|
||||||
|
EDMAC.EESR.LONG = 0x47FF0F9F; /* Clear all EtherC and EDMAC status bits */
|
||||||
|
EDMAC.RDLAR = ( void * ) xCurrentRxDesc; /* Initialaize Rx Descriptor List Address */
|
||||||
|
EDMAC.TDLAR = &( xTxDescriptors[ 0 ] ); /* Initialaize Tx Descriptor List Address */
|
||||||
|
EDMAC.TRSCER.LONG = 0x00000000; /* Copy-back status is RFE & TFE only */
|
||||||
|
EDMAC.TFTR.LONG = 0x00000000; /* Threshold of Tx_FIFO */
|
||||||
|
EDMAC.FDR.LONG = 0x00000000; /* Transmit fifo & receive fifo is 256 bytes */
|
||||||
|
EDMAC.RMCR.LONG = 0x00000003; /* Receive function is normal mode(continued) */
|
||||||
|
|
||||||
|
/* Set the EDMAC interrupt priority - the interrupt priority must be
|
||||||
|
configKERNEL_INTERRUPT_PRIORITY no matter which peripheral is used to
|
||||||
|
generate the tick interrupt. */
|
||||||
|
INTC.IPR19.BIT._EDMAC = portKERNEL_INTERRUPT_PRIORITY;
|
||||||
|
EDMAC.EESIPR.LONG = emacTX_END_INTERRUPT | emacRX_END_INTERRUPT; /* Enable Rx and Tx end interrupts. */
|
||||||
|
|
||||||
|
/* Clear the interrupt flag. */
|
||||||
|
CMT0.CMCSR.BIT.CMF = 0;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vEMAC_ISR_Handler( void )
|
||||||
|
{
|
||||||
|
unsigned long ul = EDMAC.EESR.LONG;
|
||||||
|
long lHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
extern xSemaphoreHandle xEMACSemaphore;
|
||||||
|
static long ulTxEndInts = 0;
|
||||||
|
|
||||||
|
/* Has a Tx end occurred? */
|
||||||
|
if( ul & emacTX_END_INTERRUPT )
|
||||||
|
{
|
||||||
|
++ulTxEndInts;
|
||||||
|
if( ulTxEndInts >= 2 )
|
||||||
|
{
|
||||||
|
/* Only return the buffer to the pool once both Txes have completed. */
|
||||||
|
prvReturnBuffer( ( void * ) xTxDescriptors[ 0 ].buf_p );
|
||||||
|
ulTxEndInts = 0;
|
||||||
|
}
|
||||||
|
EDMAC.EESR.LONG = emacTX_END_INTERRUPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Has an Rx end occurred? */
|
||||||
|
if( ul & emacRX_END_INTERRUPT )
|
||||||
|
{
|
||||||
|
/* Make sure the Ethernet task is not blocked waiting for a packet. */
|
||||||
|
xSemaphoreGiveFromISR( xEMACSemaphore, &lHigherPriorityTaskWoken );
|
||||||
|
portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
|
||||||
|
EDMAC.EESR.LONG = emacRX_END_INTERRUPT;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
;/*
|
||||||
|
; FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd.
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * *
|
||||||
|
; * If you are: *
|
||||||
|
; * *
|
||||||
|
; * + New to FreeRTOS, *
|
||||||
|
; * + Wanting to learn FreeRTOS or multitasking in general quickly *
|
||||||
|
; * + Looking for basic training, *
|
||||||
|
; * + Wanting to improve your FreeRTOS skills and productivity *
|
||||||
|
; * *
|
||||||
|
; * then take a look at the FreeRTOS eBook *
|
||||||
|
; * *
|
||||||
|
; * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
|
||||||
|
; * http://www.FreeRTOS.org/Documentation *
|
||||||
|
; * *
|
||||||
|
; * A pdf reference manual is also available. Both are usually delivered *
|
||||||
|
; * to your inbox within 20 minutes to two hours when purchased between 8am *
|
||||||
|
; * and 8pm GMT (although please allow up to 24 hours in case of *
|
||||||
|
; * exceptional circumstances). Thank you for your support! *
|
||||||
|
; * *
|
||||||
|
; ***************************************************************************
|
||||||
|
;
|
||||||
|
; This file is part of the FreeRTOS distribution.
|
||||||
|
;
|
||||||
|
; FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
; the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
; Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||||
|
; ***NOTE*** The exception to the GPL is included to allow you to distribute
|
||||||
|
; a combined work that includes FreeRTOS without being obliged to provide the
|
||||||
|
; source code for proprietary components outside of the FreeRTOS kernel.
|
||||||
|
; FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
; more details. You should have received a copy of the GNU General Public
|
||||||
|
; License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||||
|
; can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||||
|
; by writing to Richard Barry, contact details for whom are available on the
|
||||||
|
; FreeRTOS WEB site.
|
||||||
|
;
|
||||||
|
; 1 tab == 4 spaces!
|
||||||
|
;
|
||||||
|
; http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
; contact details.
|
||||||
|
;
|
||||||
|
; http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
; critical systems.
|
||||||
|
;
|
||||||
|
; http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
; licensing and training services.
|
||||||
|
;*/
|
||||||
|
|
||||||
|
.import _vEMAC_ISR_Handler
|
||||||
|
.import _pxCurrentTCB
|
||||||
|
.export _vEMAC_ISR_Wrapper
|
||||||
|
|
||||||
|
.INCLUDE "ISR_Support.inc"
|
||||||
|
|
||||||
|
.section P
|
||||||
|
|
||||||
|
;-----------------------------------------------------------
|
||||||
|
|
||||||
|
_vEMAC_ISR_Wrapper:
|
||||||
|
|
||||||
|
portSAVE_CONTEXT
|
||||||
|
|
||||||
|
mov.l #_vEMAC_ISR_Handler, r0
|
||||||
|
jsr @r0
|
||||||
|
nop
|
||||||
|
|
||||||
|
portRESTORE_CONTEXT
|
||||||
|
|
||||||
|
;-----------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.end
|
||||||
|
|
@ -0,0 +1,254 @@
|
|||||||
|
/**
|
||||||
|
* \addtogroup httpd
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Web server script interface
|
||||||
|
* \author
|
||||||
|
* Adam Dunkels <adam@sics.se>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2006, Adam Dunkels.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
* This file is part of the uIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
* $Id: httpd-cgi.c,v 1.2 2006/06/11 21:46:37 adam Exp $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "net/uip.h"
|
||||||
|
#include "net/psock.h"
|
||||||
|
#include "apps/httpd/httpd.h"
|
||||||
|
#include "apps/httpd/httpd-cgi.h"
|
||||||
|
#include "apps/httpd/httpd-fs.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
HTTPD_CGI_CALL( file, "file-stats", file_stats );
|
||||||
|
HTTPD_CGI_CALL( tcp, "tcp-connections", tcp_stats );
|
||||||
|
HTTPD_CGI_CALL( net, "net-stats", net_stats );
|
||||||
|
HTTPD_CGI_CALL( rtos, "rtos-stats", rtos_stats );
|
||||||
|
HTTPD_CGI_CALL( run, "run-time", run_time );
|
||||||
|
HTTPD_CGI_CALL( io, "led-io", led_io );
|
||||||
|
|
||||||
|
static const struct httpd_cgi_call *calls[] = { &file, &tcp, &net, &rtos, &run, &io, NULL };
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static PT_THREAD( nullfunction ( struct httpd_state *s, char *ptr ) )
|
||||||
|
{
|
||||||
|
PSOCK_BEGIN( &s->sout );
|
||||||
|
( void ) ptr;
|
||||||
|
PSOCK_END( &s->sout );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
httpd_cgifunction httpd_cgi( char *name )
|
||||||
|
{
|
||||||
|
const struct httpd_cgi_call **f;
|
||||||
|
|
||||||
|
/* Find the matching name in the table, return the function. */
|
||||||
|
for( f = calls; *f != NULL; ++f )
|
||||||
|
{
|
||||||
|
if( strncmp((*f)->name, name, strlen((*f)->name)) == 0 )
|
||||||
|
{
|
||||||
|
return( *f )->function;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullfunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static unsigned short generate_file_stats( void *arg )
|
||||||
|
{
|
||||||
|
char *f = ( char * ) arg;
|
||||||
|
return sprintf( ( char * ) uip_appdata, "%5u", httpd_fs_count(f) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static PT_THREAD( file_stats ( struct httpd_state *s, char *ptr ) )
|
||||||
|
{
|
||||||
|
PSOCK_BEGIN( &s->sout );
|
||||||
|
|
||||||
|
PSOCK_GENERATOR_SEND( &s->sout, generate_file_stats, strchr(ptr, ' ') + 1 );
|
||||||
|
|
||||||
|
PSOCK_END( &s->sout );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static const char closed[] = /* "CLOSED",*/ { 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0 };
|
||||||
|
static const char syn_rcvd[] = /* "SYN-RCVD",*/ { 0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 0x44, 0 };
|
||||||
|
static const char syn_sent[] = /* "SYN-SENT",*/ { 0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 0x54, 0 };
|
||||||
|
static const char established[] = /* "ESTABLISHED",*/ { 0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 0x45, 0x44, 0 };
|
||||||
|
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/ { 0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 0x54, 0x2d, 0x31, 0 };
|
||||||
|
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/ { 0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 0x54, 0x2d, 0x32, 0 };
|
||||||
|
static const char closing[] = /* "CLOSING",*/ { 0x43, 0x4c, 0x4f, 0x53, 0x49, 0x4e, 0x47, 0 };
|
||||||
|
static const char time_wait[] = /* "TIME-WAIT,"*/ { 0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 0x49, 0x54, 0 };
|
||||||
|
static const char last_ack[] = /* "LAST-ACK"*/ { 0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 0x4b, 0 };
|
||||||
|
|
||||||
|
static const char *states[] = { closed, syn_rcvd, syn_sent, established, fin_wait_1, fin_wait_2, closing, time_wait, last_ack };
|
||||||
|
|
||||||
|
static unsigned short generate_tcp_stats( void *arg )
|
||||||
|
{
|
||||||
|
struct uip_conn *conn;
|
||||||
|
struct httpd_state *s = ( struct httpd_state * ) arg;
|
||||||
|
|
||||||
|
conn = &uip_conns[s->count];
|
||||||
|
return sprintf( ( char * ) uip_appdata,
|
||||||
|
"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n", htons(conn->lport),
|
||||||
|
htons(conn->ripaddr.u16[0]) >> 8, htons(conn->ripaddr.u16[0]) & 0xff, htons(conn->ripaddr.u16[1]) >> 8,
|
||||||
|
htons(conn->ripaddr.u16[1]) & 0xff, htons(conn->rport), states[conn->tcpstateflags & UIP_TS_MASK], conn->nrtx, conn->timer,
|
||||||
|
(uip_outstanding(conn)) ? '*' : ' ', (uip_stopped(conn)) ? '!' : ' ' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static PT_THREAD( tcp_stats ( struct httpd_state *s, char *ptr ) )
|
||||||
|
{
|
||||||
|
PSOCK_BEGIN( &s->sout );
|
||||||
|
( void ) ptr;
|
||||||
|
for( s->count = 0; s->count < UIP_CONNS; ++s->count )
|
||||||
|
{
|
||||||
|
if( (uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED )
|
||||||
|
{
|
||||||
|
PSOCK_GENERATOR_SEND( &s->sout, generate_tcp_stats, s );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PSOCK_END( &s->sout );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static unsigned short generate_net_stats( void *arg )
|
||||||
|
{
|
||||||
|
struct httpd_state *s = ( struct httpd_state * ) arg;
|
||||||
|
return sprintf( ( char * ) uip_appdata, "%5u\n", (( uip_stats_t * ) &uip_stat)[s->count] );
|
||||||
|
}
|
||||||
|
|
||||||
|
static PT_THREAD( net_stats ( struct httpd_state *s, char *ptr ) )
|
||||||
|
{
|
||||||
|
PSOCK_BEGIN( &s->sout );
|
||||||
|
( void ) ptr;
|
||||||
|
#if UIP_STATISTICS
|
||||||
|
for( s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t); ++s->count )
|
||||||
|
{
|
||||||
|
PSOCK_GENERATOR_SEND( &s->sout, generate_net_stats, s );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* UIP_STATISTICS */
|
||||||
|
|
||||||
|
PSOCK_END( &s->sout );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
extern void vTaskList( signed char *pcWriteBuffer );
|
||||||
|
extern char *pcGetTaskStatusMessage( void );
|
||||||
|
static char cCountBuf[128];
|
||||||
|
long lRefreshCount = 0;
|
||||||
|
static unsigned short generate_rtos_stats( void *arg )
|
||||||
|
{
|
||||||
|
( void ) arg;
|
||||||
|
lRefreshCount++;
|
||||||
|
sprintf( cCountBuf, "<p><br>Refresh count = %d<p><br>%s", ( int ) lRefreshCount, pcGetTaskStatusMessage() );
|
||||||
|
vTaskList( uip_appdata );
|
||||||
|
strcat( uip_appdata, cCountBuf );
|
||||||
|
|
||||||
|
return strlen( uip_appdata );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static PT_THREAD( rtos_stats ( struct httpd_state *s, char *ptr ) )
|
||||||
|
{
|
||||||
|
PSOCK_BEGIN( &s->sout );
|
||||||
|
( void ) ptr;
|
||||||
|
PSOCK_GENERATOR_SEND( &s->sout, generate_rtos_stats, NULL );
|
||||||
|
PSOCK_END( &s->sout );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
char *pcStatus;
|
||||||
|
unsigned long ulString;
|
||||||
|
|
||||||
|
static unsigned short generate_io_state( void *arg )
|
||||||
|
{
|
||||||
|
extern long lParTestGetLEDState( void );
|
||||||
|
( void ) arg;
|
||||||
|
|
||||||
|
/* Get the state of the LEDs that are on the FIO1 port. */
|
||||||
|
if( lParTestGetLEDState() )
|
||||||
|
{
|
||||||
|
pcStatus = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pcStatus = "checked";
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf( uip_appdata, "<input type=\"checkbox\" name=\"LED0\" value=\"1\" %s>LED<p><p>", pcStatus );
|
||||||
|
|
||||||
|
return strlen( uip_appdata );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
extern void vTaskGetRunTimeStats( signed char *pcWriteBuffer );
|
||||||
|
static unsigned short generate_runtime_stats( void *arg )
|
||||||
|
{
|
||||||
|
( void ) arg;
|
||||||
|
lRefreshCount++;
|
||||||
|
sprintf( cCountBuf, "<p><br>Refresh count = %d", ( int ) lRefreshCount );
|
||||||
|
vTaskGetRunTimeStats( uip_appdata );
|
||||||
|
strcat( uip_appdata, cCountBuf );
|
||||||
|
|
||||||
|
return strlen( uip_appdata );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static PT_THREAD( run_time ( struct httpd_state *s, char *ptr ) )
|
||||||
|
{
|
||||||
|
PSOCK_BEGIN( &s->sout );
|
||||||
|
( void ) ptr;
|
||||||
|
PSOCK_GENERATOR_SEND( &s->sout, generate_runtime_stats, NULL );
|
||||||
|
PSOCK_END( &s->sout );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static PT_THREAD( led_io ( struct httpd_state *s, char *ptr ) )
|
||||||
|
{
|
||||||
|
PSOCK_BEGIN( &s->sout );
|
||||||
|
( void ) ptr;
|
||||||
|
PSOCK_GENERATOR_SEND( &s->sout, generate_io_state, NULL );
|
||||||
|
PSOCK_END( &s->sout );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @} */
|
@ -0,0 +1,8 @@
|
|||||||
|
<html>
|
||||||
|
<body bgcolor="white">
|
||||||
|
<center>
|
||||||
|
<h1>404 - file not found</h1>
|
||||||
|
<h3>Go <a href="/">here</a> instead.</h3>
|
||||||
|
</center>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FreeRTOS.org uIP WEB server demo</title>
|
||||||
|
</head>
|
||||||
|
<BODY onLoad="window.setTimeout("location.href='index.shtml'",100)">
|
||||||
|
<font face="arial">
|
||||||
|
Loading index.shtml. Click <a href="index.shtml">here</a> if not automatically redirected.
|
||||||
|
</font>
|
||||||
|
</font>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FreeRTOS.org uIP WEB server demo</title>
|
||||||
|
</head>
|
||||||
|
<BODY onLoad="window.setTimeout("location.href='index.shtml'",2000)">
|
||||||
|
<font face="arial">
|
||||||
|
<a href="index.shtml">Task Stats</a> <b>|</b> <a href="runtime.shtml">Run Time Stats</a> <b>|</b> <a href="stats.shtml">TCP Stats</a> <b>|</b> <a href="tcp.shtml">Connections</a> <b>|</b> <a href="http://www.freertos.org/">FreeRTOS Homepage</a> <b>|</b> <a href="io.shtml">IO</a> <b>|</b> <a href="logo.jpg">37K jpg</a>
|
||||||
|
<br><p>
|
||||||
|
<hr>
|
||||||
|
<br><p>
|
||||||
|
<h2>Task statistics</h2>
|
||||||
|
Page will refresh every 2 seconds.<p>
|
||||||
|
<font face="courier"><pre>Task State Priority Stack #<br>************************************************<br>
|
||||||
|
%! rtos-stats
|
||||||
|
</pre></font>
|
||||||
|
</font>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,28 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FreeRTOS.org uIP WEB server demo</title>
|
||||||
|
</head>
|
||||||
|
<BODY>
|
||||||
|
<font face="arial">
|
||||||
|
<a href="index.shtml">Task Stats</a> <b>|</b> <a href="runtime.shtml">Run Time Stats</a> <b>|</b> <a href="stats.shtml">TCP Stats</a> <b>|</b> <a href="tcp.shtml">Connections</a> <b>|</b> <a href="http://www.freertos.org/">FreeRTOS Homepage</a> <b>|</b> <a href="io.shtml">IO</a> <b>|</b> <a href="logo.jpg">37K jpg</a>
|
||||||
|
<br><p>
|
||||||
|
<hr>
|
||||||
|
<b>LED and LCD IO</b><br>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
|
||||||
|
Use the check box to turn on or off LED 4, then click "Update IO".
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<form name="aForm" action="/io.shtml" method="get">
|
||||||
|
%! led-io
|
||||||
|
<p>
|
||||||
|
<input type="submit" value="Update IO">
|
||||||
|
</form>
|
||||||
|
<br><p>
|
||||||
|
</font>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FreeRTOS.org uIP WEB server demo</title>
|
||||||
|
</head>
|
||||||
|
<BODY onLoad="window.setTimeout("location.href='runtime.shtml'",2000)">
|
||||||
|
<font face="arial">
|
||||||
|
<a href="index.shtml">Task Stats</a> <b>|</b> <a href="runtime.shtml">Run Time Stats</a> <b>|</b> <a href="stats.shtml">TCP Stats</a> <b>|</b> <a href="tcp.shtml">Connections</a> <b>|</b> <a href="http://www.freertos.org/">FreeRTOS Homepage</a> <b>|</b> <a href="io.shtml">IO</a> <b>|</b> <a href="logo.jpg">37K jpg</a>
|
||||||
|
<br><p>
|
||||||
|
<hr>
|
||||||
|
<br><p>
|
||||||
|
<h2>Run-time statistics</h2>
|
||||||
|
Page will refresh every 2 seconds.<p>
|
||||||
|
<font face="courier"><pre>Task Abs Time % Time<br>****************************************<br>
|
||||||
|
%! run-time
|
||||||
|
</pre></font>
|
||||||
|
</font>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,47 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FreeRTOS.org uIP WEB server demo</title>
|
||||||
|
</head>
|
||||||
|
<BODY>
|
||||||
|
<font face="arial">
|
||||||
|
<a href="index.shtml">Task Stats</a> <b>|</b> <a href="runtime.shtml">Run Time Stats</a> <b>|</b> <a href="stats.shtml">TCP Stats</a> <b>|</b> <a href="tcp.shtml">Connections</a> <b>|</b> <a href="http://www.freertos.org/">FreeRTOS Homepage</a> <b>|</b> <a href="io.shtml">IO</a> <b>|</b> <a href="logo.jpg">37K jpg</a>
|
||||||
|
<br><p>
|
||||||
|
<hr>
|
||||||
|
<br><p>
|
||||||
|
<h2>Network statistics</h2>
|
||||||
|
<table width="300" border="0">
|
||||||
|
<tr><td align="left"><font face="courier"><pre>
|
||||||
|
IP Packets received
|
||||||
|
Packets sent
|
||||||
|
Forwaded
|
||||||
|
Dropped
|
||||||
|
IP errors IP version/header length
|
||||||
|
IP length, high byte
|
||||||
|
IP length, low byte
|
||||||
|
IP fragments
|
||||||
|
Header checksum
|
||||||
|
Wrong protocol
|
||||||
|
ICMP Packets received
|
||||||
|
Packets sent
|
||||||
|
Packets dropped
|
||||||
|
Type errors
|
||||||
|
Checksum errors
|
||||||
|
TCP Packets received
|
||||||
|
Packets sent
|
||||||
|
Packets dropped
|
||||||
|
Checksum errors
|
||||||
|
Data packets without ACKs
|
||||||
|
Resets
|
||||||
|
Retransmissionsa
|
||||||
|
Syn to closed port
|
||||||
|
UDP Packets dropped
|
||||||
|
Packets received
|
||||||
|
Packets sent
|
||||||
|
Packets chkerr
|
||||||
|
No connection avaliable
|
||||||
|
</pre></font></td><td><font face="courier"><pre>%! net-stats
|
||||||
|
</pre></font></td></table>
|
||||||
|
</font>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FreeRTOS.org uIP WEB server demo</title>
|
||||||
|
</head>
|
||||||
|
<BODY>
|
||||||
|
<font face="arial">
|
||||||
|
<a href="index.shtml">Task Stats</a> <b>|</b> <a href="runtime.shtml">Run Time Stats</a> <b>|</b> <a href="stats.shtml">TCP Stats</a> <b>|</b> <a href="tcp.shtml">Connections</a> <b>|</b> <a href="http://www.freertos.org/">FreeRTOS Homepage</a> <b>|</b> <a href="io.shtml">IO</a> <b>|</b> <a href="logo.jpg">37K jpg</a>
|
||||||
|
<br><p>
|
||||||
|
<hr>
|
||||||
|
<br>
|
||||||
|
<h2>Network connections</h2>
|
||||||
|
<p>
|
||||||
|
<table>
|
||||||
|
<tr><th>Local</th><th>Remote</th><th>State</th><th>Retransmissions</th><th>Timer</th><th>Flags</th></tr>
|
||||||
|
%! tcp-connections
|
||||||
|
</pre></font>
|
||||||
|
</font>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,78 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
open(OUTPUT, "> httpd-fsdata.c");
|
||||||
|
|
||||||
|
chdir("httpd-fs");
|
||||||
|
|
||||||
|
opendir(DIR, ".");
|
||||||
|
@files = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
|
||||||
|
closedir(DIR);
|
||||||
|
|
||||||
|
foreach $file (@files) {
|
||||||
|
|
||||||
|
if(-d $file && $file !~ /^\./) {
|
||||||
|
print "Processing directory $file\n";
|
||||||
|
opendir(DIR, $file);
|
||||||
|
@newfiles = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
|
||||||
|
closedir(DIR);
|
||||||
|
printf "Adding files @newfiles\n";
|
||||||
|
@files = (@files, map { $_ = "$file/$_" } @newfiles);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach $file (@files) {
|
||||||
|
if(-f $file) {
|
||||||
|
|
||||||
|
print "Adding file $file\n";
|
||||||
|
|
||||||
|
open(FILE, $file) || die "Could not open file $file\n";
|
||||||
|
|
||||||
|
$file =~ s-^-/-;
|
||||||
|
$fvar = $file;
|
||||||
|
$fvar =~ s-/-_-g;
|
||||||
|
$fvar =~ s-\.-_-g;
|
||||||
|
# for AVR, add PROGMEM here
|
||||||
|
print(OUTPUT "static const unsigned char data".$fvar."[] = {\n");
|
||||||
|
print(OUTPUT "\t/* $file */\n\t");
|
||||||
|
for($j = 0; $j < length($file); $j++) {
|
||||||
|
printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
|
||||||
|
}
|
||||||
|
printf(OUTPUT "0,\n");
|
||||||
|
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
while(read(FILE, $data, 1)) {
|
||||||
|
if($i == 0) {
|
||||||
|
print(OUTPUT "\t");
|
||||||
|
}
|
||||||
|
printf(OUTPUT "%#02x, ", unpack("C", $data));
|
||||||
|
$i++;
|
||||||
|
if($i == 10) {
|
||||||
|
print(OUTPUT "\n");
|
||||||
|
$i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print(OUTPUT "0};\n\n");
|
||||||
|
close(FILE);
|
||||||
|
push(@fvars, $fvar);
|
||||||
|
push(@pfiles, $file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i = 0; $i < @fvars; $i++) {
|
||||||
|
$file = $pfiles[$i];
|
||||||
|
$fvar = $fvars[$i];
|
||||||
|
|
||||||
|
if($i == 0) {
|
||||||
|
$prevfile = "NULL";
|
||||||
|
} else {
|
||||||
|
$prevfile = "file" . $fvars[$i - 1];
|
||||||
|
}
|
||||||
|
print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
|
||||||
|
print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
|
||||||
|
print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
|
||||||
|
print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n");
|
@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
* \addtogroup uipopt
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Project-specific configuration options
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* uIP has a number of configuration options that can be overridden
|
||||||
|
* for each project. These are kept in a project-specific uip-conf.h
|
||||||
|
* file and all configuration names have the prefix UIP_CONF.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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 of the Institute 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 INSTITUTE 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 INSTITUTE 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.
|
||||||
|
*
|
||||||
|
* This file is part of the uIP TCP/IP stack
|
||||||
|
*
|
||||||
|
* $Id: uip-conf.h,v 1.6 2006/06/12 08:00:31 adam Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* An example uIP configuration file
|
||||||
|
* \author
|
||||||
|
* Adam Dunkels <adam@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __UIP_CONF_H__
|
||||||
|
#define __UIP_CONF_H__
|
||||||
|
|
||||||
|
#define UIP_CONF_EXTERNAL_BUFFER
|
||||||
|
#define UIP_CONF_PROCESS_HTTPD_FORMS 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 8 bit datatype
|
||||||
|
*
|
||||||
|
* This typedef defines the 8-bit type used throughout uIP.
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
typedef unsigned char u8_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 16 bit datatype
|
||||||
|
*
|
||||||
|
* This typedef defines the 16-bit type used throughout uIP.
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
typedef unsigned short u16_t;
|
||||||
|
|
||||||
|
typedef unsigned long u32_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Statistics datatype
|
||||||
|
*
|
||||||
|
* This typedef defines the dataype used for keeping statistics in
|
||||||
|
* uIP.
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
typedef unsigned short uip_stats_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of TCP connections.
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
#define UIP_CONF_MAX_CONNECTIONS 40
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of listening TCP ports.
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
#define UIP_CONF_MAX_LISTENPORTS 40
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uIP buffer size.
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
#define UIP_CONF_BUFFER_SIZE 1480
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CPU byte order.
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
#define UIP_CONF_BYTE_ORDER UIP_BIG_ENDIAN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logging on or off
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
#define UIP_CONF_LOGGING 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UDP support on or off
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
#define UIP_CONF_UDP 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UDP checksums on or off
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uIP statistics on or off
|
||||||
|
*
|
||||||
|
* \hideinitializer
|
||||||
|
*/
|
||||||
|
#define UIP_CONF_STATISTICS 1
|
||||||
|
|
||||||
|
/* Here we include the header file for the application(s) we use in
|
||||||
|
our project. */
|
||||||
|
/*#include "smtp.h"*/
|
||||||
|
/*#include "hello-world.h"*/
|
||||||
|
/*#include "telnetd.h"*/
|
||||||
|
#include "webserver.h"
|
||||||
|
/*#include "dhcpc.h"*/
|
||||||
|
/*#include "resolv.h"*/
|
||||||
|
/*#include "webclient.h"*/
|
||||||
|
|
||||||
|
#define CCIF
|
||||||
|
#define CC_REGISTER_ARG
|
||||||
|
|
||||||
|
#endif /* __UIP_CONF_H__ */
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
/** @} */
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2002, Adam Dunkels.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
* This file is part of the uIP TCP/IP stack
|
||||||
|
*
|
||||||
|
* $Id: webserver.h,v 1.2 2006/06/11 21:46:38 adam Exp $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef __WEBSERVER_H__
|
||||||
|
#define __WEBSERVER_H__
|
||||||
|
|
||||||
|
#include "apps/httpd/httpd.h"
|
||||||
|
|
||||||
|
typedef struct httpd_state uip_tcp_appstate_t;
|
||||||
|
/* UIP_APPCALL: the name of the application function. This function
|
||||||
|
must return void and take no arguments (i.e., C type "void
|
||||||
|
appfunc(void)"). */
|
||||||
|
#define UIP_APPCALL httpd_appcall
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __WEBSERVER_H__ */
|
Loading…
Reference in New Issue