⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cgi.s

📁 uIP是免费的TCP/IP协议栈,我们将它移植到我们的AVR以太网开发板中
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module cgi.c
	.area data(ram, con, rel)
_cgitab::
	.blkw 1
	.area idata
	.word PL_print_stats
	.area data(ram, con, rel)
	.blkw 1
	.area idata
	.word PL_file_stats
	.area data(ram, con, rel)
	.blkw 1
	.area idata
	.word PL_tcp_stats
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.dbsym e cgitab _cgitab A[6:3]pfc
	.area lit(rom, con, rel)
_closed:
	.byte 'C,'L
	.byte 'O,'S
	.byte 'E,'D
	.byte 0
	.dbsym s closed _closed A[7:7]kc
_syn_rcvd:
	.byte 'S,'Y
	.byte 'N,45
	.byte 'R,'C
	.byte 'V,'D
	.byte 0
	.dbsym s syn_rcvd _syn_rcvd A[9:9]kc
_syn_sent:
	.byte 'S,'Y
	.byte 'N,45
	.byte 'S,'E
	.byte 'N,'T
	.byte 0
	.dbsym s syn_sent _syn_sent A[9:9]kc
_established:
	.byte 'E,'S
	.byte 'T,'A
	.byte 'B,'L
	.byte 'I,'S
	.byte 'H,'E
	.byte 'D,0
	.dbsym s established _established A[12:12]kc
_fin_wait_1:
	.byte 'F,'I
	.byte 'N,45
	.byte 'W,'A
	.byte 'I,'T
	.byte 45,49
	.byte 0
	.dbsym s fin_wait_1 _fin_wait_1 A[11:11]kc
_fin_wait_2:
	.byte 'F,'I
	.byte 'N,45
	.byte 'W,'A
	.byte 'I,'T
	.byte 45,50
	.byte 0
	.dbsym s fin_wait_2 _fin_wait_2 A[11:11]kc
_closing:
	.byte 'C,'L
	.byte 'O,'S
	.byte 'I,'N
	.byte 'G,0
	.dbsym s closing _closing A[8:8]kc
_time_wait:
	.byte 'T,'I
	.byte 'M,'E
	.byte 45,'W
	.byte 'A,'I
	.byte 'T,0
	.dbsym s time_wait _time_wait A[10:10]kc
_last_ack:
	.byte 'L,'A
	.byte 'S,'T
	.byte 45,'A
	.byte 'C,'K
	.byte 0
	.dbsym s last_ack _last_ack A[9:9]kc
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
_states:
	.blkw 1
	.area idata
	.word _closed
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.blkw 1
	.area idata
	.word _syn_rcvd
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.blkw 1
	.area idata
	.word _syn_sent
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.blkw 1
	.area idata
	.word _established
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.blkw 1
	.area idata
	.word _fin_wait_1
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.blkw 1
	.area idata
	.word _fin_wait_2
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.blkw 1
	.area idata
	.word _closing
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.blkw 1
	.area idata
	.word _time_wait
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.blkw 1
	.area idata
	.word _last_ack
	.area data(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.dbsym s states _states A[18:9]pkc
	.area text(rom, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\cgi.c
	.dbfunc s print_stats _print_stats fc
;              j -> R12,R13
;      databytes -> y+2
;              i -> R14,R15
;            buf -> R10,R11
;           next -> R10
	.even
_print_stats:
	xcall push_gset5x
	mov R10,R16
	sbiw R28,4
	.dbline -1
	.dbline 120
; /**
;  * \addtogroup httpd
;  * @{
;  */
; 
; /**
;  * \file
;  * HTTP server script language C functions file.
;  * \author Adam Dunkels <adam@dunkels.com>
;  *
;  * This file contains functions that are called by the web server
;  * scripts. The functions takes one argument, and the return value is
;  * interpreted as follows. A zero means that the function did not
;  * complete and should be invoked for the next packet as well. A
;  * non-zero value indicates that the function has completed and that
;  * the web server should move along to the next script line.
;  *
;  */
; 
; /*
;  * Copyright (c) 2001, 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: cgi.c,v 1.23.2.4 2003/10/07 13:22:27 adam Exp $
;  *
;  */
; 
; #include "uip.h"
; #include "cgi.h"
; #include "httpd.h"
; #include "fs.h"
; 
; #include <stdio.h>
; #include <string.h>
; 
; static u8_t print_stats(u8_t next);
; static u8_t file_stats(u8_t next);
; static u8_t tcp_stats(u8_t next);
; 
; cgifunction cgitab[] = {
;   print_stats,   /* CGI function "a" */
;   file_stats,    /* CGI function "b" */
;   tcp_stats      /* CGI function "c" */
; };
; 
; 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};
;   
; 
; /*-----------------------------------------------------------------------------------*/
; /* print_stats:
;  *
;  * Prints out a part of the uIP statistics. The statistics data is
;  * written into the uip_appdata buffer. It overwrites any incoming
;  * packet.
;  */
; static u8_t
; print_stats(u8_t next)
; {
	.dbline 126
; #if UIP_STATISTICS
;   u16_t i, j;
;   u8_t *buf;
;   u16_t *databytes;
;   
;   if(next) {
	tst R10
	breq L8
	.dbline 126
	.dbline 129
;     /* If our last data has been acknowledged, we move on the next
;        chunk of statistics. */
;     hs->count = hs->count + 4;
	lds R24,_hs
	lds R25,_hs+1
	adiw R24,1
	movw R30,R24
	ldd R24,z+0
	ldd R25,z+1
	adiw R24,4
	std z+1,R25
	std z+0,R24
	.dbline 130
;     if(hs->count >= sizeof(struct uip_stats)/sizeof(u16_t)) {
	lds R30,_hs
	lds R31,_hs+1
	ldd R24,z+1
	ldd R25,z+2
	cpi R24,22
	ldi R30,0
	cpc R25,R30
	brlo L10
	.dbline 130
	.dbline 133
;       /* We have printed out all statistics, so we return 1 to
; 	 indicate that we are done. */
;       return 1;
	ldi R16,1
	xjmp L7
L10:
	.dbline 135
;     }
;   }
L8:
	.dbline 138
; 
;   /* Write part of the statistics into the uip_appdata buffer. */
;   databytes = (u16_t *)&uip_stat + hs->count;
	lds R30,_hs
	lds R31,_hs+1
	ldd R18,z+1
	ldd R19,z+2
	ldi R16,2
	ldi R17,0
	xcall empy16s
	ldi R24,<_uip_stat
	ldi R25,>_uip_stat
	movw R2,R16
	add R2,R24
	adc R3,R25
	std y+3,R3
	std y+2,R2
	.dbline 139
;   buf       = (u8_t *)uip_appdata;
	lds R10,_uip_appdata
	lds R11,_uip_appdata+1
	.dbline 141
; 
;   j = 4 + 1;
	ldi R24,5
	ldi R25,0
	movw R12,R24
	.dbline 142
;   i = hs->count;
	lds R30,_hs
	lds R31,_hs+1
	ldd R14,z+1
	ldd R15,z+2
	xjmp L13
L12:
	.dbline 143
	.dbline 144
	ldd R30,y+2
	ldd R31,y+3
	ldd R2,z+0
	ldd R3,z+1
	std y+1,R3
	std y+0,R2
	ldi R18,<L15
	ldi R19,>L15
	movw R16,R10
	xcall _sprintf
	.dbline 145
	ldd R24,y+2
	ldd R25,y+3
	adiw R24,2
	std y+3,R25
	std y+2,R24
	.dbline 146
	movw R24,R10
	adiw R24,6
	movw R10,R24
	.dbline 147
	movw R24,R14
	adiw R24,1
	movw R14,R24
	.dbline 148
L13:
	.dbline 143
;   while (i < sizeof(struct uip_stats)/sizeof(u16_t) && --j > 0) {
	movw R24,R14
	cpi R24,22
	ldi R30,0
	cpc R25,R30
	brsh L16
	movw R24,R12
	sbiw R24,1
	movw R12,R24
	tst R12
	brne L12
	tst R13
	brne L12
X0:
L16:
L17:
	.dbline 151
	.dbline 151
	lds R2,_uip_appdata
	lds R3,_uip_appdata+1
	sts _uip_sappdata+1,R3
	sts _uip_sappdata,R2
	.dbline 151
	movw R4,R10
	sub R4,R2
	sbc R5,R3
	sts _uip_slen+1,R5
	sts _uip_slen,R4
	.dbline 151
L18:
	.dbline 151
;     sprintf((char *)buf, "%5u\r\n", *databytes);
;     ++databytes;
;     buf += 6;
;     ++i;
;   }
; 
;   /* Send the data. */
;   uip_send(uip_appdata, buf - uip_appdata);
	.dbline 153
;   
;   return 0;
	clr R16
	.dbline -2
L7:
	adiw R28,4
	xcall pop_gset5x
	.dbline 0 ; func end
	ret
	.dbsym r j 12 s
	.dbsym l databytes 2 ps
	.dbsym r i 14 s
	.dbsym r buf 10 pc
	.dbsym r next 10 c
	.dbend
	.dbfunc s file_stats _file_stats fc
;           next -> R10
	.even
_file_stats:
	xcall push_gset3x
	mov R10,R16
	sbiw R28,2
	.dbline -1
	.dbline 161
; #else
;   return 1;
; #endif /* UIP_STATISTICS */
; }
; /*-----------------------------------------------------------------------------------*/
; static u8_t
; file_stats(u8_t next)
; {
	.dbline 165
;   /* We use sprintf() to print the number of file accesses to a

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -