📄 httpserv.s
字号:
; fflush(stream);
movw R16,R10
xcall _fflush
.dbline 525
;
; return 0;
clr R16
clr R17
.dbline -2
L72:
.dbline 0 ; func end
adiw R28,6
xjmp pop_xgsetF0FC
.dbsym r st_P 22 pkc
.dbsym r ts 20 pS[tcp_socket]
.dbsym r req 12 pS[_REQUEST]
.dbsym r stream 10 pS[__iobuf]
.dbend
.area lit(rom, con, rel)
L109:
.byte 60,'H,'T,'M,'L,62,60,'B,'O,'D,'Y,62,60,'B,'R,62
.byte 60,'H,49,62,'F,'o,'r,'m,32,'R,'e,'s,'u,'l,'t,60
.byte 47,'H,49,62,60,'B,'R,62,60,'B,'R,62,0
L110:
.byte 60,'B,'R,62,60,'B,'R,62,60,'p,62,60,'a,32,'h,'r
.byte 'e,'f,61,34,46,46,47,'i,'n,'d,'e,'x,46,'h,'t,'m
.byte 'l,34,62,'r,'e,'t,'u,'r,'n,32,'t,'o,32,'m,'a,'i
.byte 'n,60,47,'a,62,60,47,'B,'O,'D,'Y,62,60,47,'H,'T
.byte 'M,'L,62,60,47,'p,62,0
.area text(rom, con, rel)
.dbfile C:\ethernut-4.9.7\nutapp_13h\httpd\httpserv.c
.dbfunc e ShowForm _ShowForm fI
.dbsym s html_body L110 A[72:72]kc
.dbsym s html_head L109 A[45:45]kc
; count -> R12,R13
; value -> R10,R11
; name -> R14,R15
; i -> R22,R23
; req -> R20,R21
; stream -> y+16
.even
_ShowForm::
xcall push_arg4
xcall push_xgsetF0FC
movw R20,R18
sbiw R28,6
.dbline -1
.dbline 538
; }
;
; /*
; * CGI Sample: Proccessing a form.
; *
; * This routine must have been registered by NutRegisterCgi() and is
; * automatically called by NutHttpProcessRequest() when the client
; * request the URL 'cgi-bin/form.cgi'.
; *
; * Thanks to Tom Boettger, who provided this sample for ICCAVR.
; */
; int ShowForm(FILE * stream, REQUEST * req)
; {
.dbline 542
; static prog_char html_head[] = "<HTML><BODY><BR><H1>Form Result</H1><BR><BR>";
; static prog_char html_body[] = "<BR><BR><p><a href=\"../index.html\">return to main</a></BODY></HTML></p>";
;
; NutHttpSendHeaderTop(stream, req, 200, "Ok");
ldi R24,<L22
ldi R25,>L22
std y+3,R25
std y+2,R24
ldi R24,200
ldi R25,0
std y+1,R25
std y+0,R24
movw R18,R20
ldd R16,y+16
ldd R17,y+17
xcall _NutHttpSendHeaderTop
.dbline 543
; NutHttpSendHeaderBottom(stream, req, html_mt, -1);
ldi R24,255
ldi R25,255
ldi R26,255
ldi R27,255
std y+2,R24
std y+3,R25
std y+4,R26
std y+5,R27
lds R2,_html_mt
lds R3,_html_mt+1
std y+1,R3
std y+0,R2
movw R18,R20
ldd R16,y+16
ldd R17,y+17
xcall _NutHttpSendHeaderBottom
.dbline 546
;
; /* Send HTML header. */
; fputs_P(html_head, stream);
ldd R18,y+16
ldd R19,y+17
ldi R16,<L109
ldi R17,>L109
xcall _fputs_P
.dbline 548
;
; if (req->req_query) {
movw R30,R20
ldd R2,z+10
ldd R3,z+11
tst R2
brne X33
tst R3
breq L111
X33:
.dbline 548
.dbline 554
; char *name;
; char *value;
; int i;
; int count;
;
; count = NutHttpGetParameterCount(req);
movw R16,R30
xcall _NutHttpGetParameterCount
movw R12,R16
.dbline 556
; /* Extract count parameters. */
; for (i = 0; i < count; i++) {
clr R22
clr R23
xjmp L116
L113:
.dbline 556
.dbline 557
; name = NutHttpGetParameterName(req, i);
movw R18,R22
movw R16,R20
xcall _NutHttpGetParameterName
movw R14,R16
.dbline 558
; value = NutHttpGetParameterValue(req, i);
movw R18,R22
movw R16,R20
xcall _NutHttpGetParameterValue
movw R10,R16
.dbline 563
;
; /* Send the parameters back to the client. */
;
; #ifdef __IMAGECRAFT__
; fprintf(stream, "%s: %s<BR>\r\n", name, value);
std y+3,R11
std y+2,R10
std y+1,R15
std y+0,R14
ldi R18,<L117
ldi R19,>L117
ldd R16,y+16
ldd R17,y+17
xcall _fprintf
.dbline 567
; #else
; fprintf_P(stream, PSTR("%s: %s<BR>\r\n"), name, value);
; #endif
; }
L114:
.dbline 556
subi R22,255 ; offset = 1
sbci R23,255
L116:
.dbline 556
cp R22,R12
cpc R23,R13
brlt L113
X34:
.dbline 568
; }
L111:
.dbline 570
;
; fputs_P(html_body, stream);
ldd R18,y+16
ldd R19,y+17
ldi R16,<L110
ldi R17,>L110
xcall _fputs_P
.dbline 571
; fflush(stream);
ldd R16,y+16
ldd R17,y+17
xcall _fflush
.dbline 573
;
; return 0;
clr R16
clr R17
.dbline -2
L108:
.dbline 0 ; func end
adiw R28,6
xcall pop_xgsetF0FC
adiw R28,4
ret
.dbsym r count 12 I
.dbsym r value 10 pc
.dbsym r name 14 pc
.dbsym r i 22 I
.dbsym r req 20 pS[_REQUEST]
.dbsym l stream 16 pS[__iobuf]
.dbend
.dbfunc e SSIDemoCGI _SSIDemoCGI fI
.dbstruct 0 18 _tm
.dbfield 0 tm_sec I
.dbfield 2 tm_min I
.dbfield 4 tm_hour I
.dbfield 6 tm_mday I
.dbfield 8 tm_mon I
.dbfield 10 tm_year I
.dbfield 12 tm_wday I
.dbfield 14 tm_yday I
.dbfield 16 tm_isdst I
.dbend
; now -> y+30
; loc_time -> y+12
; count -> R12,R13
; value -> R10,R11
; name -> R14,R15
; i -> R20,R21
; req -> R22,R23
; stream -> y+44
.even
_SSIDemoCGI::
xcall push_arg4
xcall push_xgsetF0FC
movw R22,R18
sbiw R28,34
.dbline -1
.dbline 586
; }
;
; /*
; * CGI Sample: Dynamic output cgi included by ssi.shtml file
; *
; * This routine must have been registered by NutRegisterCgi() and is
; * automatically called by NutHttpProcessRequest() when the client
; * request the URL 'cgi-bin/form.cgi'.
; *
; * Thanks to Tom Boettger, who provided this sample for ICCAVR.
; */
; int SSIDemoCGI(FILE * stream, REQUEST * req)
; {
.dbline 587
; if (req->req_query) {
movw R30,R22
ldd R2,z+10
ldd R3,z+11
tst R2
brne X35
tst R3
breq L119
X35:
.dbline 587
.dbline 593
; char *name;
; char *value;
; int i;
; int count;
;
; count = NutHttpGetParameterCount(req);
movw R16,R30
xcall _NutHttpGetParameterCount
movw R12,R16
.dbline 597
;
; /* Extract count parameters. */
; #ifdef __IMAGECRAFT__
; fprintf(stream, "CGI ssi-demo.cgi called with parameters: These are the parameters\r\n<p>");
ldi R18,<L121
ldi R19,>L121
ldd R16,y+44
ldd R17,y+45
xcall _fprintf
.dbline 601
; #else
; fprintf_P(stream, PSTR("CGI ssi-demo.cgi called with parameters: These are the parameters\r\n<p>"));
; #endif
; for (i = 0; i < count; i++) {
clr R20
clr R21
xjmp L125
L122:
.dbline 601
.dbline 602
; name = NutHttpGetParameterName(req, i);
movw R18,R20
movw R16,R22
xcall _NutHttpGetParameterName
movw R14,R16
.dbline 603
; value = NutHttpGetParameterValue(req, i);
movw R18,R20
movw R16,R22
xcall _NutHttpGetParameterValue
movw R10,R16
.dbline 608
;
; /* Send the parameters back to the client. */
;
; #ifdef __IMAGECRAFT__
; fprintf(stream, "%s: %s<BR>\r\n", name, value);
std y+3,R11
std y+2,R10
std y+1,R15
std y+0,R14
ldi R18,<L117
ldi R19,>L117
ldd R16,y+44
ldd R17,y+45
xcall _fprintf
.dbline 612
; #else
; fprintf_P(stream, PSTR("%s: %s<BR>\r\n"), name, value);
; #endif
; }
L123:
.dbline 601
subi R20,255 ; offset = 1
sbci R21,255
L125:
.dbline 601
cp R20,R12
cpc R21,R13
brlt L122
X36:
.dbline 613
; } else {
xjmp L120
L119:
.dbline 613
.dbline 618
; time_t now;
; tm loc_time;
;
; /* Called without any parameter, show the current time */
; now = time(NULL);
clr R16
clr R17
xcall _time
std y+30,R16
std y+31,R17
std y+32,R18
std y+33,R19
.dbline 619
; localtime_r(&now, &loc_time);
movw R18,R28
subi R18,244 ; offset = 12
sbci R19,255
movw R16,R28
subi R16,226 ; offset = 30
sbci R17,255
xcall _localtime_r
.dbline 621
; #ifdef __IMAGECRAFT__
; fprintf(stream, "CGI ssi-demo.cgi called without any parameter.<br><br>Current time is: %02d.%02d.%04d -- %02d:%02d:%02d<br>\r\n",
ldd R2,y+12
ldd R3,y+13
std y+11,R3
std y+10,R2
ldd R2,y+14
ldd R3,y+15
std y+9,R3
std y+8,R2
ldd R2,y+16
ldd R3,y+17
std y+7,R3
std y+6,R2
ldd R24,y+22
ldd R25,y+23
subi R24,148 ; offset = 1900
sbci R25,248
std y+5,R25
std y+4,R24
ldd R24,y+20
ldd R25,y+21
adiw R24,1
std y+3,R25
std y+2,R24
ldd R2,y+18
ldd R3,y+19
std y+1,R3
std y+0,R2
ldi R18,<L126
ldi R19,>L126
ldd R16,y+44
ldd R17,y+45
xcall _fprintf
.dbline 627
; loc_time.tm_mday, loc_time.tm_mon+1, loc_time.tm_year+1900, loc_time.tm_hour, loc_time.tm_min, loc_time.tm_sec);
; #else
; fprintf_P(stream, PSTR("CGI ssi-demo.cgi called without any parameter.<br><br>Current time is: %02d.%02d.%04d -- %02d:%02d:%02d<br>\r\n"),
; loc_time.tm_mday, loc_time.tm_mon+1, loc_time.tm_year+1900, loc_time.tm_hour, loc_time.tm_min, loc_time.tm_sec);
; #endif
; }
L120:
.dbline 629
;
; fflush(stream);
ldd R16,y+44
ldd R17,y+45
xcall _fflush
.dbline 631
;
; return 0;
clr R16
clr R17
.dbline -2
L118:
.dbline 0 ; func end
adiw R28,34
xcall pop_xgsetF0FC
adiw R28,4
ret
.dbsym l now 30 L
.dbsym l loc_time 12 S[_tm]
.dbsym r count 12 I
.dbsym r value 10 pc
.dbsym r name 14 pc
.dbsym r i 20 I
.dbsym r req 22 pS[_REQUEST]
.dbsym l stream 44 pS[__iobuf]
.dbend
.dbfunc e Service _Service fV
; stream -> R14,R15
; sock -> R12,R13
; id -> R10
; arg -> R10,R11
.even
_Service::
xcall push_xgset30FC
movw R10,R16
sbiw R28,2
.dbline -1
.dbline 647
; }
;
; /*! \fn Service(void *arg)
; * \brief HTTP service thread.
; *
; * The endless loop in this thread waits for a client connect,
; * processes the HTTP request and disconnects. Nut/Net doesn't
; * support a server backlog. If one client has established a
; * connection, further connect attempts will be rejected.
; * Typically browsers open more than one connection in order
; * to load images concurrently. So we run this routine by
; * several threads.
; *
; */
; THREAD(Service, arg)
; {
.dbline 650
; TCPSOCKET *sock;
; FILE *stream;
; u_char id = (u_char) ((uptr_t) arg);
.dbline 655
;
; /*
; * Now loop endless for connections.
; */
; for (;;) {
L133:
.dbline 655
.dbline 660
;
; /*
; * Create a socket.
; */
; if ((sock = NutTcpCreateSocket()) == 0) {
xcall _NutTcpCreateSocket
movw R12,R16
tst R12
brne L137
tst R13
brne L137
X37:
.dbline 660
.dbline 661
; printf("[%u] Creating socket failed\n", id);
mov R18,R10
clr R19
ldi R16,<L139
ldi R17,>L139
xcall _printf_M
.dbline 662
; NutSleep(5000);
ldi R16,136
ldi R17,19
ldi R18,0
ldi R19,0
xcall _NutSleep
.dbline 663
; continue;
xjmp L133
L137:
.dbline 670
; }
;
; /*
; * Listen on port 80. This call will block until we get a connection
; * from a client.
; */
; NutTcpAccept(sock, 80);
ldi R18,80
ldi R19,0
movw R16,R12
xcall _NutTcpAccept
.dbline 672
; #if defined(__AVR__)
; printf("[%u] Connected, %u bytes free\n", id, NutHeapAvailable());
ldi R16,<_heapFreeList
ldi R17,>_heapFreeList
xcall _NutHeapRootAvailable
std y+1,R17
std y+0,R16
mov R18,R10
clr R19
ldi R16,<L140
ldi R17,>L140
xcall _printf_M
xjmp L142
L141:
.dbline 682
; #else
; printf("[%u] Connected, %lu bytes free\n", id, NutHeapAvailable());
; #endif
;
; /*
; * Wait until at least 8 kByte of free RAM is available. This will
; * keep the client connected in low memory situations.
; */
; #if defined(__AVR__)
; while (NutHeapAvailable() < 8192) {
.dbline 686
; #else
; while (NutHeapAvailable() < 4096) {
; #endif
; printf("[%u] Low mem\n", id);
mov R18,R10
clr R19
ldi R16,<L144
ldi R17,>L144
xcall _printf_M
.dbline 687
; NutSleep(1000);
ldi R16,232
ldi R17,3
ldi R18,0
ldi R19,0
xcall _NutSleep
.dbline 688
; }
L142:
.dbline 682
ldi R16,<_heapFreeList
ldi R17,>_heapFreeList
xcall _NutHeapRootAvailable
movw R20,R16
cpi R16,0
ldi R30,32
cpc R17,R30
brlo L141
X38:
.dbline 693
;
; /*
; * Associate a stream with the socket so we can use standard I/O calls.
; */
; if ((stream = _fdopen((int) ((uptr_t) sock), "r+b")) == 0) {
ldi R18,<L147
ldi R19,>L147
movw R16,R12
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -