diff --git a/cfg/a2bin.cfg b/cfg/a2bin.cfg index 1e6ebfb..0f6ae7c 100644 --- a/cfg/a2bin.cfg +++ b/cfg/a2bin.cfg @@ -19,8 +19,8 @@ SEGMENTS { DATA: load = RAM, type = rw; SELF_MODIFIED_CODE: load = RAM, type = rw, optional = yes; IP65_DEFAULTS: load = RAM, type = rw; + HTTP_VARS: load = RAM, type = rw, optional = yes; BSS: load = RAM, type = bss, define = yes; APP_SCRATCH: load = RAM, type = bss, optional = yes; TCP_VARS: load = RAM, type = bss, optional = yes; - HTTP_VARS: load = RAM, type = bss, optional = yes; } diff --git a/cfg/c64prg.cfg b/cfg/c64prg.cfg index dcfabcc..5ae3db2 100644 --- a/cfg/c64prg.cfg +++ b/cfg/c64prg.cfg @@ -20,8 +20,8 @@ SEGMENTS { DATA: load = RAM, type = rw; SELF_MODIFIED_CODE: load = RAM, type = rw, optional = yes; IP65_DEFAULTS: load = RAM, type = rw, optional = yes; + HTTP_VARS: load = RAM, type = rw, optional = yes; BSS: load = RAM, type = bss; APP_SCRATCH: load = RAM, type = bss, optional = yes; TCP_VARS: load = RAM, type = bss, optional = yes; - HTTP_VARS: load = RAM, type = bss, optional = yes; } diff --git a/cfg/vic20prg.cfg b/cfg/vic20prg.cfg index 0f142fa..966ecef 100644 --- a/cfg/vic20prg.cfg +++ b/cfg/vic20prg.cfg @@ -21,8 +21,8 @@ SEGMENTS { DATA: load = RAM, type = rw; SELF_MODIFIED_CODE: load = RAM, type = rw, optional = yes; IP65_DEFAULTS: load = RAM, type = rw, optional = yes; + HTTP_VARS: load = RAM, type = rw, optional = yes; BSS: load = RAM, type = bss; APP_SCRATCH: load = RAM, type = bss, optional = yes; TCP_VARS: load = RAM, type = bss, optional = yes; - HTTP_VARS: load = RAM, type = bss, optional = yes; } diff --git a/ip65/http.s b/ip65/http.s index a5cb3ef..01df737 100644 --- a/ip65/http.s +++ b/ip65/http.s @@ -32,7 +32,7 @@ hex_digit: .res 1 .data -http_variables_buffer: .addr $2800 ; work area for storing variables extracted from query string +http_variables_buffer: .addr $4800 ; work area for storing variables extracted from query string .code diff --git a/ip65/httpd.s b/ip65/httpd.s index 4131016..31d7c6d 100644 --- a/ip65/httpd.s +++ b/ip65/httpd.s @@ -29,15 +29,8 @@ HTTPD_TIMEOUT_SECONDS = 5 ; what's the maximum time we let 1 connection be .import tcp_send_data_len .import tcp_send .import tcp_close -.import io_read_catalogue .import native_to_ascii -.import io_read_file_with_callback -.import io_filename -.import io_callback .import timer_seconds -.import __HTTP_VARS_LOAD__ -.import __HTTP_VARS_RUN__ -.import __HTTP_VARS_SIZE__ temp_ptr = copy_src @@ -57,8 +50,8 @@ temp_x: .res 1 .segment "HTTP_VARS" -httpd_io_buffer: .addr $2000 ; by default, use a 3k buffer at $2000 for storing inbound requests. -httpd_scratch_buffer: .addr $2B00 ; by default, use a 1k buffer at $2b00 as a scratchpad +httpd_io_buffer: .addr $4000 ; by default, use a 3k buffer at $4000 for storing inbound requests. +httpd_scratch_buffer: .addr $4B00 ; by default, use a 1k buffer at $4B00 as a scratchpad httpd_port_number: .word 80 jump_to_callback: @@ -103,32 +96,11 @@ skip_emit_a: ; this routine will stay in an endless loop that is broken only if user press the ABORT key (runstop on a c64) ; inputs: ; httpd_port_number = port number to listen on -; AX = pointer to routine to callback for each inbound HTTP request= -; set this to $0000 to use the default handler (which will look for requested files on the local disk). +; AX = pointer to routine to callback for each inbound HTTP request ; outputs: ; none httpd_start: - pha ; save AX while we relocate self modifying code - txa - pha - - ; relocate the self-modifying code - ldax #__HTTP_VARS_LOAD__ - stax copy_src - ldax #__HTTP_VARS_RUN__ - stax copy_dest - ldax #__HTTP_VARS_SIZE__ - jsr copymem - pla - tax - pla - - stx jump_to_callback+2 - bne @not_default_handler - ldax #default_httpd_handler - jmp httpd_start -@not_default_handler: - sta jump_to_callback+1 + stax jump_to_callback+1 @listen: jsr tcp_close @@ -242,66 +214,6 @@ http_callback: bne @look_for_eol rts -default_httpd_handler: - lda #$02 - jsr http_get_value - bcc @not_error - ldy #5 - clc - rts -@not_error: - stax temp_ptr - ldy #1 - lda (temp_ptr),y - bne @not_index - ldax #default_html - ldy #2 - clc - rts -@not_index: - ; assume that 'path' is a filename - inc temp_ptr - bne :+ - inc temp_ptr -: lda #0 - sta sent_header - ldax temp_ptr - stax io_filename - ldax #send_file_callback - stax io_callback - ldax httpd_scratch_buffer - jsr io_read_file_with_callback - bcc @sent_ok - ldy #4 - clc - rts -@sent_ok: - sec - rts - -send_file_callback: - sty buffer_size ; only 1 (the last) sector can ever be != $100 bytes - lda sent_header - bne @sent_header - ldy #3 ; "application/octet-stream" - jsr send_header - inc sent_header -@sent_header: - ldax httpd_scratch_buffer - stax temp_ptr - ldy #0 -@loop: - tya - pha - lda (temp_ptr),y - jsr emit_a - pla - tay - iny - cpy buffer_size - bne @loop - rts - reset_output_buffer: ldax httpd_io_buffer sta emit_a_ptr+1 @@ -312,54 +224,6 @@ reset_output_buffer: sta skip_mode rts -emit_disk_catalogue: - ldax httpd_scratch_buffer - jsr io_read_catalogue - lda get_next_byte+1 - pha - lda get_next_byte+2 - pha - ldax httpd_scratch_buffer - stax get_next_byte+1 - -@next_filename: - jsr get_next_byte - cmp #0 - beq @done - pha - - ldax #file_li_preamble - jsr emit_string - pla - pha - jsr emit_a - ldax get_next_byte+1 - jsr emit_string - - ldax #file_li_middle - jsr emit_string - pla - bne @convert_byte -@next_byte: - jsr get_next_byte - cmp #0 - beq @done_this_filename -@convert_byte: - jsr native_to_ascii - jsr emit_a - jmp @next_byte -@done_this_filename: - ldax #file_li_postamble - jsr emit_string - - jmp @next_filename -@done: - pla - sta get_next_byte+2 - pla - sta get_next_byte+1 - rts - send_response: stax get_next_byte+1 jsr reset_output_buffer @@ -450,7 +314,7 @@ send_buffer: jsr tcp_send jmp reset_output_buffer - send_header: +send_header: ; inputs: Y = header type ; $00 = no header (assume header sent already) ; $01 = 200 OK, 'text/text' @@ -471,7 +335,6 @@ send_buffer: @not_text: cpy #2 - bne @not_html jsr emit_ok_status_line_and_content_type ldax #text_html @@ -533,12 +396,6 @@ emit_string: .rodata -default_html: -.byte "

Index of /


kipper - the 100%% 6502 m/l web server " -.byte 0 - CR = $0D LF = $0A @@ -571,13 +428,6 @@ end_of_header: .byte "Server: Kipper_httpd/0.c64",CR,LF .byte CR,LF,0 -file_li_preamble: - .byte "
  • ",0 -file_li_postamble: - .byte "
  • ",0 - ; -- LICENSE FOR httpd.s --