From 5218deb352c97ec45bd3c882c105725091a3b956 Mon Sep 17 00:00:00 2001 From: jonnosan Date: Thu, 22 Oct 2009 10:49:08 +0000 Subject: [PATCH] added mozilla public license git-svn-id: http://svn.code.sf.net/p/netboot65/code@207 93682198-c243-4bdb-bd91-e943c89aac3b --- client/carts/bootmenu.s | 19 + client/carts/c64_cart_ram_header.s | 20 +- client/carts/d64_upload.s | 20 +- client/carts/dupe_cart.rb | 20 +- client/carts/fix_cart.rb | 20 +- client/carts/kipperkart.s | 19 + client/carts/kipperterm.s | 19 + client/carts/nb65_skeleton.s | 20 +- client/carts/netboot.s | 19 + client/carts/set_ip_config.rb | 20 +- client/drivers/a2charconv.s | 21 + client/drivers/a2input.s | 21 + client/drivers/a2kernal.s | 22 +- client/drivers/a2print.s | 21 + client/drivers/a2timer.s | 21 + client/drivers/c64_disk_access.s | 22 +- client/drivers/c64charconv.s | 21 + client/drivers/c64inputs.s | 21 + client/drivers/c64kernal.s | 21 + client/drivers/c64print.s | 21 + client/drivers/c64timer.s | 21 + client/drivers/c64timer_nb65.s | 22 +- client/drivers/rr-net.s | 75 ++- client/drivers/uthernet.s | 58 +- client/examples/dasm_d64_upload.asm | 21 + client/examples/dasm_example.asm | 21 + client/examples/httpd.asm | 21 + client/examples/irc.s | 21 + client/examples/make_sine_data.rb | 22 +- client/examples/raster.s | 21 + client/examples/sidplay.s | 21 + client/examples/sidplay_zigzag.s | 21 + client/examples/sine_data.i | 22 +- client/examples/upnatom.s | 21 + client/inc/a2keycodes.i | 22 +- client/inc/c64keycodes.i | 22 +- client/inc/common.i | 56 +- client/inc/commonprint.i | 21 + client/inc/disk_transfer.i | 21 + client/inc/gopher.i | 21 + client/inc/kipper_constants.i | 21 + client/inc/menu.i | 21 + client/inc/net.i | 22 +- client/inc/petscii.i | 65 ++- client/inc/ping.i | 21 + client/inc/printf.i | 131 +++-- client/inc/sidplay.i | 21 + client/inc/telnet.i | 21 + client/inc/version.i | 21 + client/ip65/arithmetic.s | 21 + client/ip65/arp.s | 767 +++++++++++++------------ client/ip65/config.s | 47 +- client/ip65/copymem.s | 123 ++-- client/ip65/cs8900a.i | 34 +- client/ip65/cs8900a.s | 547 +++++++++--------- client/ip65/debug.s | 21 + client/ip65/dhcp.s | 73 ++- client/ip65/dns.s | 21 + client/ip65/dottedquad.s | 22 +- client/ip65/eth.s | 125 +++-- client/ip65/function_dispatcher.s | 22 +- client/ip65/http.s | 46 +- client/ip65/httpd.s | 49 +- client/ip65/icmp.s | 446 ++++++++------- client/ip65/ip.s | 685 ++++++++++++----------- client/ip65/ip65.s | 159 +++--- client/ip65/output_buffer.s | 22 +- client/ip65/parser.s | 21 + client/ip65/printf.s | 809 ++++++++++++++------------- client/ip65/sntp.s | 22 +- client/ip65/string_utils.s | 77 ++- client/ip65/tcp.s | 34 +- client/ip65/telnet.s | 22 +- client/ip65/tftp.s | 22 +- client/ip65/timer.s | 79 ++- client/ip65/udp.s | 621 ++++++++++---------- client/ip65/url.s | 22 +- client/test/test_cart_api.s | 22 +- client/test/test_disk_io.s | 21 + client/test/test_get_url.s | 21 + client/test/test_httpd.s | 21 + client/test/test_parse_querystring.s | 21 + client/test/test_parser.s | 22 +- client/test/test_ping.s | 68 ++- client/test/test_sntp.s | 70 ++- client/test/test_tcp.s | 74 ++- client/test/testdns.s | 77 ++- client/test/testdottedquad.s | 73 ++- client/test/testtftp.s | 72 ++- client/uthernet/bankswitch_eeprom.s | 21 + client/uthernet/c700_rom.s | 21 + client/uthernet/patch_applewin.rb | 22 +- client/uthernet/utherboot.s | 21 + 93 files changed, 4431 insertions(+), 2478 deletions(-) diff --git a/client/carts/bootmenu.s b/client/carts/bootmenu.s index a54c934..d63d48b 100644 --- a/client/carts/bootmenu.s +++ b/client/carts/bootmenu.s @@ -143,3 +143,22 @@ startup_msg: .byte "NETBOOT65 FOR APPLE 2 V0.1",13 .byte 0 + +;-- LICENSE FOR bootmenu.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is netboot65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/carts/c64_cart_ram_header.s b/client/carts/c64_cart_ram_header.s index 9350530..521f32f 100644 --- a/client/carts/c64_cart_ram_header.s +++ b/client/carts/c64_cart_ram_header.s @@ -77,4 +77,22 @@ copymem: ;this is where the cart data will be appended to: cart_data: - \ No newline at end of file + +;-- LICENSE FOR c64_cart_ram_header.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is netboot65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/carts/d64_upload.s b/client/carts/d64_upload.s index 80d996b..bdd296c 100644 --- a/client/carts/d64_upload.s +++ b/client/carts/d64_upload.s @@ -541,4 +541,22 @@ position_cursor_for_track_display: position_cursor_for_error_display: .byte $13,13,13,13,"LAST ",0 -cname: .byte '#' \ No newline at end of file +cname: .byte '#' +;-- LICENSE FOR d64_upload.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is netboot65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/carts/dupe_cart.rb b/client/carts/dupe_cart.rb index 53359e0..a686ece 100644 --- a/client/carts/dupe_cart.rb +++ b/client/carts/dupe_cart.rb @@ -12,4 +12,22 @@ infile=File.open(infilename,"rb").read puts "copying #{infilename} to #{outfilename} #{duplication} times" outfile=File.open(outfilename,"wb") duplication.times {outfile<(.right (.tcount (arg)-1, arg)) - .else ; assume absolute or zero page - lda arg - ldx 1+(arg) - .endif - .endmacro - -; store A/X macro - .macro stax arg - sta arg - stx 1+(arg) - .endmacro - +; load A/X macro + .macro ldax arg + .if (.match (.left (1, arg), #)) ; immediate mode + lda #<(.right (.tcount (arg)-1, arg)) + ldx #>(.right (.tcount (arg)-1, arg)) + .else ; assume absolute or zero page + lda arg + ldx 1+(arg) + .endif + .endmacro + +; store A/X macro + .macro stax arg + sta arg + stx 1+(arg) + .endmacro + .macro phax pha @@ -30,4 +30,24 @@ COMMON__I__ = 1 pla .endmacro -.endif \ No newline at end of file +.endif + + +;-- LICENSE FOR common.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/commonprint.i b/client/inc/commonprint.i index a83060d..787f66a 100644 --- a/client/inc/commonprint.i +++ b/client/inc/commonprint.i @@ -365,3 +365,24 @@ error_code: press_a_key_to_continue: .byte "PRESS A KEY TO CONTINUE",13,0 + + + +;-- LICENSE FOR commonprint.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/disk_transfer.i b/client/inc/disk_transfer.i index 6d8016e..3400338 100644 --- a/client/inc/disk_transfer.i +++ b/client/inc/disk_transfer.i @@ -245,3 +245,24 @@ position_cursor_for_track_display: position_cursor_for_error_display: .byte $13,13,13,0 enter_filename: .asciiz "FILENAME: " + + + +;-- LICENSE FOR disk_transfer.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/gopher.i b/client/inc/gopher.i index f7c799b..36f4263 100644 --- a/client/inc/gopher.i +++ b/client/inc/gopher.i @@ -652,3 +652,24 @@ query: .byte "QUERY :",0 + + + +;-- LICENSE FOR gopher.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/kipper_constants.i b/client/inc/kipper_constants.i index cd2d8cb..bf8a634 100644 --- a/client/inc/kipper_constants.i +++ b/client/inc/kipper_constants.i @@ -147,3 +147,24 @@ KPR_ERROR_MALFORMED_URL EQU $A0 KPR_ERROR_DNS_LOOKUP_FAILED EQU $A1 KPR_ERROR_OPTION_NOT_SUPPORTED EQU $FE KPR_ERROR_FUNCTION_NOT_SUPPORTED EQU $FF + + + +;-- LICENSE FOR kipper_constants.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/menu.i b/client/inc/menu.i index 4142036..5006930 100644 --- a/client/inc/menu.i +++ b/client/inc/menu.i @@ -318,3 +318,24 @@ navigation_instructions: .byte 13,"ARROW KEYS NAVIGATE BETWEEN MENU PAGES",13 .byte " TO QUIT",13,0 jump_to_prompt: .byte "JUMP TO:",0 + + + +;-- LICENSE FOR menu.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/net.i b/client/inc/net.i index c3d8970..ae05fd2 100644 --- a/client/inc/net.i +++ b/client/inc/net.i @@ -37,4 +37,24 @@ print_ok clc @end_macro: -.endmacro \ No newline at end of file +.endmacro + + +;-- LICENSE FOR net.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/petscii.i b/client/inc/petscii.i index cd2d9a4..6fc2fe2 100644 --- a/client/inc/petscii.i +++ b/client/inc/petscii.i @@ -1,22 +1,43 @@ -petscii_black = 144 -petscii_white = 5 -petscii_red = 28 -petscii_cyan = 159 -petscii_purple = 156 -petscii_green = 30 -petscii_blue = 31 -petscii_yellow = 158 -petscii_orange = 129 -petscii_brown = 149 -petscii_ltred = 150 -petscii_dkgray = 151 -petscii_gray = 152 -petscii_ltgreen = 153 -petscii_ltblue = 154 -petscii_ltgray = 155 - -petscii_lower = 14 -petscii_home = 19 -petscii_clear = 147 - -petscii_down = 17 +petscii_black = 144 +petscii_white = 5 +petscii_red = 28 +petscii_cyan = 159 +petscii_purple = 156 +petscii_green = 30 +petscii_blue = 31 +petscii_yellow = 158 +petscii_orange = 129 +petscii_brown = 149 +petscii_ltred = 150 +petscii_dkgray = 151 +petscii_gray = 152 +petscii_ltgreen = 153 +petscii_ltblue = 154 +petscii_ltgray = 155 + +petscii_lower = 14 +petscii_home = 19 +petscii_clear = 147 + +petscii_down = 17 + + + +;-- LICENSE FOR petscii.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/ping.i b/client/inc/ping.i index b4f8f7b..a35deaa 100644 --- a/client/inc/ping.i +++ b/client/inc/ping.i @@ -64,3 +64,24 @@ bcs @ping_error ms: .byte " MS",13,0 pinging: .byte "PINGING ",0 + + + +;-- LICENSE FOR ping.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/printf.i b/client/inc/printf.i index 0aa435f..598a678 100644 --- a/client/inc/printf.i +++ b/client/inc/printf.i @@ -1,55 +1,76 @@ - .import console_printf - - - .macro printfargs arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 - .ifnblank arg1 - .addr arg1 - printfargs arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 - .endif - .endmacro - - .macro printf str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 - - .local arglist - .local string - - pha - .ifpc02 - phx - phy - .else - txa - pha - tya - pha - .endif - ldax #arglist - jsr console_printf - .ifpc02 - ply - plx - .else - pla - tay - pla - tax - .endif - pla - - .pushseg - .rodata - .if (.match(str, "")) -string: - .asciiz str -arglist: - .addr string - .else -arglist: - .addr str - .endif - - printfargs arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 - - .popseg - - .endmacro + .import console_printf + + + .macro printfargs arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 + .ifnblank arg1 + .addr arg1 + printfargs arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 + .endif + .endmacro + + .macro printf str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 + + .local arglist + .local string + + pha + .ifpc02 + phx + phy + .else + txa + pha + tya + pha + .endif + ldax #arglist + jsr console_printf + .ifpc02 + ply + plx + .else + pla + tay + pla + tax + .endif + pla + + .pushseg + .rodata + .if (.match(str, "")) +string: + .asciiz str +arglist: + .addr string + .else +arglist: + .addr str + .endif + + printfargs arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 + + .popseg + + .endmacro + + + +;-- LICENSE FOR printf.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/sidplay.i b/client/inc/sidplay.i index 52aeea6..a41a7ed 100644 --- a/client/inc/sidplay.i +++ b/client/inc/sidplay.i @@ -277,3 +277,24 @@ play_song_handler: jmp_old_irq: jmp $ffff + + + +;-- LICENSE FOR sidplay.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/telnet.i b/client/inc/telnet.i index e9da047..c2ba8f3 100644 --- a/client/inc/telnet.i +++ b/client/inc/telnet.i @@ -134,3 +134,24 @@ remote_host: .byte "HOSTNAME (LEAVE BLANK TO QUIT)",13,": ",0 remote_port: .byte "PORT # (LEAVE BLANK FOR DEFAULT)",13,": ",0 char_mode_prompt: .byte "MODE - A=ASCII, P=PETSCII, L=LINE",13,0 + + + +;-- LICENSE FOR telnet.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/inc/version.i b/client/inc/version.i index 15e09c0..50e646d 100644 --- a/client/inc/version.i +++ b/client/inc/version.i @@ -1 +1,22 @@ .byte "0.9.37" + + + +;-- LICENSE FOR version.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/arithmetic.s b/client/ip65/arithmetic.s index 136e8a1..9de1bf5 100644 --- a/client/ip65/arithmetic.s +++ b/client/ip65/arithmetic.s @@ -147,3 +147,24 @@ mul_8_16: sta acc16 sta acc16+1 rts + + + +;-- LICENSE FOR arithmetic.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/arp.s b/client/ip65/arp.s index 926a367..e4647d7 100644 --- a/client/ip65/arp.s +++ b/client/ip65/arp.s @@ -1,123 +1,123 @@ -; ARP address resolution - -.include "../inc/common.i" - - .export arp_init - .export arp_lookup - .export arp_process - .export arp_add - .export arp_calculate_gateway_mask - .export arp_ip - .export arp_mac - .export arp_cache +; ARP address resolution + +.include "../inc/common.i" + + .export arp_init + .export arp_lookup + .export arp_process + .export arp_add + .export arp_calculate_gateway_mask + .export arp_ip + .export arp_mac + .export arp_cache .exportzp ac_size - - .import eth_inp - .import eth_inp_len - .import eth_outp - .import eth_outp_len - .import eth_tx - .import eth_set_broadcast_dest - .import eth_set_my_mac_src - .import eth_set_proto - .importzp eth_proto_arp - - .import cfg_mac - .import cfg_ip - .import cfg_netmask - .import cfg_gateway - - .import timer_read - .import timer_timeout - - .segment "IP65ZP" : zeropage - -ap: .res 2 - - - .bss - -; arp state machine -arp_idle = 1 ; idling -arp_wait = 2 ; waiting for reply -arp_state: .res 1 ; current activity - -; arguments for lookup and add -arp: ; ptr to mac/ip pair -arp_mac: .res 6 ; result is delivered here when arp_lookup returns with carry flag clear -arp_ip: .res 4 ; set arp_ip before calling arp_lookup - -; arp cache -ac_size = 8 ; lookup cache -ac_ip = 6 ; offset for ip -ac_mac = 0 ; offset for mac -arp_cache: .res (6+4)*ac_size ;cache of IP addresses and corresponding MAC addresses - -; offsets for arp packet generation -ap_hw = 14 ; hw type (eth = 0001) -ap_proto = 16 ; protocol (ip = 0800) -ap_hwlen = 18 ; hw addr len (eth = 06) -ap_protolen = 19 ; proto addr len (ip = 04) -ap_op = 20 ; request = 0001, reply = 0002 -ap_shw = 22 ; sender hw addr -ap_sp = 28 ; sender proto addr -ap_thw = 32 ; target hw addr -ap_tp = 38 ; target protoaddr -ap_packlen = 42 ; total length of packet - -; gateway handling -gw_mask: .res 4 ; inverted netmask -gw_test: .res 4 ; gateway ip or:d with inverted netmask -gw_last: .res 1 ; netmask length - 1 - -; timeout -arptimeout: .res 2 ; time when we will have timed out - - - .code + + .import eth_inp + .import eth_inp_len + .import eth_outp + .import eth_outp_len + .import eth_tx + .import eth_set_broadcast_dest + .import eth_set_my_mac_src + .import eth_set_proto + .importzp eth_proto_arp + + .import cfg_mac + .import cfg_ip + .import cfg_netmask + .import cfg_gateway + + .import timer_read + .import timer_timeout + + .segment "IP65ZP" : zeropage + +ap: .res 2 + + + .bss + +; arp state machine +arp_idle = 1 ; idling +arp_wait = 2 ; waiting for reply +arp_state: .res 1 ; current activity + +; arguments for lookup and add +arp: ; ptr to mac/ip pair +arp_mac: .res 6 ; result is delivered here when arp_lookup returns with carry flag clear +arp_ip: .res 4 ; set arp_ip before calling arp_lookup + +; arp cache +ac_size = 8 ; lookup cache +ac_ip = 6 ; offset for ip +ac_mac = 0 ; offset for mac +arp_cache: .res (6+4)*ac_size ;cache of IP addresses and corresponding MAC addresses + +; offsets for arp packet generation +ap_hw = 14 ; hw type (eth = 0001) +ap_proto = 16 ; protocol (ip = 0800) +ap_hwlen = 18 ; hw addr len (eth = 06) +ap_protolen = 19 ; proto addr len (ip = 04) +ap_op = 20 ; request = 0001, reply = 0002 +ap_shw = 22 ; sender hw addr +ap_sp = 28 ; sender proto addr +ap_thw = 32 ; target hw addr +ap_tp = 38 ; target protoaddr +ap_packlen = 42 ; total length of packet + +; gateway handling +gw_mask: .res 4 ; inverted netmask +gw_test: .res 4 ; gateway ip or:d with inverted netmask +gw_last: .res 1 ; netmask length - 1 + +; timeout +arptimeout: .res 2 ; time when we will have timed out + + + .code ;initialize arp (including clearing the arp cache) ;inputs: none -;outputs: none -arp_init: - lda #0 - - ldx #(6+4)*ac_size - 1 ; clear cache +;outputs: none +arp_init: + lda #0 + + ldx #(6+4)*ac_size - 1 ; clear cache : - sta arp_cache,x - dex - bpl :- + sta arp_cache,x + dex + bpl :- arp_calculate_gateway_mask: - - lda #$ff ; counter for netmask length - 1 - sta gw_last - - ldx #3 -@gw: - lda cfg_netmask,x - eor #$ff - cmp #$ff - bne :+ - inc gw_last -: sta gw_mask,x - ora cfg_gateway,x - sta gw_test,x - dex - bpl @gw - - lda #arp_idle ; start out idle - sta arp_state - - rts - - + + lda #$ff ; counter for netmask length - 1 + sta gw_last + + ldx #3 +@gw: + lda cfg_netmask,x + eor #$ff + cmp #$ff + bne :+ + inc gw_last +: sta gw_mask,x + ora cfg_gateway,x + sta gw_test,x + dex + bpl @gw + + lda #arp_idle ; start out idle + sta arp_state + + rts + + ;lookup the mac address for an ip ;inputs: arp_ip should be set to ip address to be resolved ;outputs: ; if carry flag is clear, then arp_mac will be set to correct mac address ; if carry flag is set, then the correct mac address could not be found in ; the arp cache, so an arp request was sent. so the caller should wait a while -; (to allow time for an arp response message to arrive) and then call arp_lookup again. +; (to allow time for an arp response message to arrive) and then call arp_lookup again. arp_lookup: lda arp_ip ; check for broadcast IP (255.255.255.255) @@ -134,130 +134,130 @@ arp_lookup: rts @notbroadcast: - - ldx gw_last ; check if address is on our subnet -: lda arp_ip,x - ora gw_mask,x - cmp gw_test,x - bne @notlocal - dex - bpl :- - bmi @local - + + ldx gw_last ; check if address is on our subnet +: lda arp_ip,x + ora gw_mask,x + cmp gw_test,x + bne @notlocal + dex + bpl :- + bmi @local + @notlocal: - - ldx #3 ; copy gateway's ip address -: lda cfg_gateway,x - sta arp_ip,x - dex - bpl :- - -@local: - jsr findip - bcs @cachemiss - - ldy #ac_ip - 1 ; copy mac -: lda (ap),y - sta arp,y - dey - bpl :- - rts - -@cachemiss: - lda arp_state ; are we already waiting for a reply? - cmp #arp_idle - beq @sendrequest ; yes, send request - - ldax arptimeout ; check if we've timed out - jsr timer_timeout - bcs @notimeout ; no, don't send - -@sendrequest: ; send out arp request - jsr eth_set_broadcast_dest - jsr eth_set_my_mac_src - - jsr makearppacket ; add arp, eth, ip, hwlen, protolen - - lda #0 ; set opcode (request = 0001) - sta eth_outp + ap_op - lda #1 - sta eth_outp + ap_op + 1 - - ldx #5 -: lda cfg_mac,x ; set source mac addr - sta eth_outp + ap_shw,x - lda #0 ; set target mac addr - sta eth_outp + ap_thw,x - dex - bpl :- - - ldx #3 -: lda cfg_ip,x ; set source ip addr - sta eth_outp + ap_sp,x - lda arp_ip,x ; set target ip addr - sta eth_outp + ap_tp,x - dex - bpl :- - - lda #ap_packlen - sta eth_outp_len + 1 - - jsr eth_tx ; send packet - - lda #arp_wait ; waiting for reply - sta arp_state - - jsr timer_read ; read current timer value - clc - adc #<1000 ; set timeout to now + 1000 ms - sta arptimeout - txa - adc #>1000 - sta arptimeout + 1 - -@notimeout: - sec ; set carry to indicate that - rts ; no result is availble - - -; find arp_ip in the cache -; clc returns pointer to entry in (ap) + + ldx #3 ; copy gateway's ip address +: lda cfg_gateway,x + sta arp_ip,x + dex + bpl :- + +@local: + jsr findip + bcs @cachemiss + + ldy #ac_ip - 1 ; copy mac +: lda (ap),y + sta arp,y + dey + bpl :- + rts + +@cachemiss: + lda arp_state ; are we already waiting for a reply? + cmp #arp_idle + beq @sendrequest ; yes, send request + + ldax arptimeout ; check if we've timed out + jsr timer_timeout + bcs @notimeout ; no, don't send + +@sendrequest: ; send out arp request + jsr eth_set_broadcast_dest + jsr eth_set_my_mac_src + + jsr makearppacket ; add arp, eth, ip, hwlen, protolen + + lda #0 ; set opcode (request = 0001) + sta eth_outp + ap_op + lda #1 + sta eth_outp + ap_op + 1 + + ldx #5 +: lda cfg_mac,x ; set source mac addr + sta eth_outp + ap_shw,x + lda #0 ; set target mac addr + sta eth_outp + ap_thw,x + dex + bpl :- + + ldx #3 +: lda cfg_ip,x ; set source ip addr + sta eth_outp + ap_sp,x + lda arp_ip,x ; set target ip addr + sta eth_outp + ap_tp,x + dex + bpl :- + + lda #ap_packlen + sta eth_outp_len + 1 + + jsr eth_tx ; send packet + + lda #arp_wait ; waiting for reply + sta arp_state + + jsr timer_read ; read current timer value + clc + adc #<1000 ; set timeout to now + 1000 ms + sta arptimeout + txa + adc #>1000 + sta arptimeout + 1 + +@notimeout: + sec ; set carry to indicate that + rts ; no result is availble + + +; find arp_ip in the cache +; clc returns pointer to entry in (ap) findip: - - ldax #arp_cache + + ldax #arp_cache stax ap - ldx #ac_size -@compare: ; compare cache entry - ldy #ac_ip - lda (ap),y - beq @notfound -: lda (ap),y - cmp arp,y - bne @next - iny - cpy #ac_ip + 4 - bne :- - - clc ; return - rts - -@next: ; next entry - lda ap - clc - adc #10 - sta ap - bcc :+ - inc ap + 1 -: dex - bne @compare - -@notfound: - sec - rts - - + ldx #ac_size +@compare: ; compare cache entry + ldy #ac_ip + lda (ap),y + beq @notfound +: lda (ap),y + cmp arp,y + bne @next + iny + cpy #ac_ip + 4 + bne :- + + clc ; return + rts + +@next: ; next entry + lda ap + clc + adc #10 + sta ap + bcc :+ + inc ap + 1 +: dex + bne @compare + +@notfound: + sec + rts + + ;handle incoming arp packets ;inputs: eth_inp should contain an arp packet ;outputs: @@ -266,156 +266,177 @@ findip: ; message was a request or a response). if the incoming packet was an arp ; request for this machine, then an arp response will be created (overwriting ; eth_outp) and sent out -arp_process: - - lda eth_inp + ap_op ; should be 0 - bne @badpacket - lda eth_inp + ap_op + 1 ; check opcode - cmp #1 ; request? - beq @request - cmp #2 ; reply? - beq @reply - -@badpacket: - sec - rts - -@request: - ldx #3 -: lda eth_inp + ap_tp,x ; check if they're asking for - cmp cfg_ip,x ; my address - bne @done - dex - bpl :- - - ldax #eth_inp + ap_shw - jsr ac_add_source ; add them to arp cache - - ldx #5 ; send reply -: lda eth_inp + ap_shw,x - sta eth_outp,x ; set sender packet dest - sta eth_outp + ap_thw,x ; and as target - lda cfg_mac,x ; me as source - sta eth_outp + ap_shw,x - dex - bpl :- - - jsr eth_set_my_mac_src ; me as packet source - - jsr makearppacket ; add arp, eth, ip, hwlen, protolen - - lda #0 ; set opcode (reply = 0002) - sta eth_outp + ap_op - lda #2 - sta eth_outp + ap_op + 1 - - ldx #3 -: lda eth_inp + ap_sp,x ; sender as target addr - sta eth_outp + ap_tp,x - lda cfg_ip,x ; my ip as source addr - sta eth_outp + ap_sp,x - dex - bpl :- - - lda #ap_packlen - sta eth_outp_len + 1 - - jsr eth_tx ; send packet - -@done: - clc - rts - -@reply: - lda arp_state - cmp #arp_wait ; are we waiting for a reply? - bne @badpacket - - ldax #eth_inp + ap_shw - jsr ac_add_source ; add to cache - - lda #arp_idle - sta arp_state - - rts - - +arp_process: + + lda eth_inp + ap_op ; should be 0 + bne @badpacket + lda eth_inp + ap_op + 1 ; check opcode + cmp #1 ; request? + beq @request + cmp #2 ; reply? + beq @reply + +@badpacket: + sec + rts + +@request: + ldx #3 +: lda eth_inp + ap_tp,x ; check if they're asking for + cmp cfg_ip,x ; my address + bne @done + dex + bpl :- + + ldax #eth_inp + ap_shw + jsr ac_add_source ; add them to arp cache + + ldx #5 ; send reply +: lda eth_inp + ap_shw,x + sta eth_outp,x ; set sender packet dest + sta eth_outp + ap_thw,x ; and as target + lda cfg_mac,x ; me as source + sta eth_outp + ap_shw,x + dex + bpl :- + + jsr eth_set_my_mac_src ; me as packet source + + jsr makearppacket ; add arp, eth, ip, hwlen, protolen + + lda #0 ; set opcode (reply = 0002) + sta eth_outp + ap_op + lda #2 + sta eth_outp + ap_op + 1 + + ldx #3 +: lda eth_inp + ap_sp,x ; sender as target addr + sta eth_outp + ap_tp,x + lda cfg_ip,x ; my ip as source addr + sta eth_outp + ap_sp,x + dex + bpl :- + + lda #ap_packlen + sta eth_outp_len + 1 + + jsr eth_tx ; send packet + +@done: + clc + rts + +@reply: + lda arp_state + cmp #arp_wait ; are we waiting for a reply? + bne @badpacket + + ldax #eth_inp + ap_shw + jsr ac_add_source ; add to cache + + lda #arp_idle + sta arp_state + + rts + + ; add arp_mac and arp_ip to the cache ;inputs: ; arp_ip is ip address to add to cache ; arp_mac is corresponding mac address of specified ip ;outputs: -; arp_cache is updated -arp_add: - jsr findip ; check if ip is already in cache - bcs @add - - ldy #9 ; update old entry -: lda arp,y ; move to top as well? - sta (ap),y - dey +; arp_cache is updated +arp_add: + jsr findip ; check if ip is already in cache + bcs @add + + ldy #9 ; update old entry +: lda arp,y ; move to top as well? + sta (ap),y + dey bpl :- - - rts - -@add: - ldax #arp ; add - - -;add source to cache -ac_add_source: - stax ap - - ldx #9 ; make space in the arp cache -: - + + rts + +@add: + ldax #arp ; add + + +;add source to cache +ac_add_source: + stax ap + + ldx #9 ; make space in the arp cache +: + lda arp_cache + 60,x - sta arp_cache + 70,x + sta arp_cache + 70,x lda arp_cache + 50,x - sta arp_cache + 60,x - lda arp_cache + 40,x - sta arp_cache + 50,x - lda arp_cache + 30,x - sta arp_cache + 40,x - lda arp_cache + 20,x - sta arp_cache + 30,x - lda arp_cache + 10,x - sta arp_cache + 20,x + sta arp_cache + 60,x + lda arp_cache + 40,x + sta arp_cache + 50,x + lda arp_cache + 30,x + sta arp_cache + 40,x + lda arp_cache + 20,x + sta arp_cache + 30,x + lda arp_cache + 10,x + sta arp_cache + 20,x lda arp_cache,x - sta arp_cache + 10,x - - dex - bpl :- - - ldy #9 -: lda (ap),y ; copy source - sta arp_cache,y - dey - bpl :- - - rts - - -; adds proto = arp, hw = eth, and proto = ip to outgoing packet -makearppacket: - lda #eth_proto_arp - jsr eth_set_proto - - lda #0 ; set hw type (eth = 0001) - sta eth_outp + ap_hw - lda #1 - sta eth_outp + ap_hw + 1 - - lda #8 ; set protcol (ip = 0800) - sta eth_outp + ap_proto - lda #0 - sta eth_outp + ap_proto + 1 - - lda #6 ; set hw addr len (eth = 06) - sta eth_outp + ap_hwlen - lda #4 ; set proto addr len (eth = 04) - sta eth_outp + ap_protolen - - rts + sta arp_cache + 10,x + + dex + bpl :- + + ldy #9 +: lda (ap),y ; copy source + sta arp_cache,y + dey + bpl :- + + rts + + +; adds proto = arp, hw = eth, and proto = ip to outgoing packet +makearppacket: + lda #eth_proto_arp + jsr eth_set_proto + + lda #0 ; set hw type (eth = 0001) + sta eth_outp + ap_hw + lda #1 + sta eth_outp + ap_hw + 1 + + lda #8 ; set protcol (ip = 0800) + sta eth_outp + ap_proto + lda #0 + sta eth_outp + ap_proto + 1 + + lda #6 ; set hw addr len (eth = 06) + sta eth_outp + ap_hwlen + lda #4 ; set proto addr len (eth = 04) + sta eth_outp + ap_protolen + + rts + + + +;-- LICENSE FOR arp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/config.s b/client/ip65/config.s index 16f9f6b..138911e 100644 --- a/client/ip65/config.s +++ b/client/ip65/config.s @@ -1,13 +1,13 @@ -;IP configuration defaults -;most of these will be overwritten if dhcp is used for configuration +;IP configuration defaults +;most of these will be overwritten if dhcp is used for configuration .include "../inc/common.i" - - .export cfg_mac - .export cfg_ip - .export cfg_netmask - .export cfg_gateway - .export cfg_dns + + .export cfg_mac + .export cfg_ip + .export cfg_netmask + .export cfg_gateway + .export cfg_dns .export cfg_tftp_server .export cfg_get_configuration_ptr .export cfg_init @@ -40,13 +40,13 @@ cfg_init: ldax #cfg_size jmp copymem -.segment "IP65_DEFAULTS" -cfg_mac_default: .byte $00, $80, $10, $6d, $76, $30 ;mac address to be assigned to local machine +.segment "IP65_DEFAULTS" +cfg_mac_default: .byte $00, $80, $10, $6d, $76, $30 ;mac address to be assigned to local machine cfg_ip_default: .byte 192, 168, 1, 64 ;ip address of local machine (will be overwritten if dhcp_init is called) -;cfg_ip_default: .byte 0,0,0,0 ;ip address of local machine (will be overwritten if dhcp_init is called) -cfg_netmask_default: .byte 255, 255, 255, 0; netmask of local network (will be overwritten if dhcp_init is called) +;cfg_ip_default: .byte 0,0,0,0 ;ip address of local machine (will be overwritten if dhcp_init is called) +cfg_netmask_default: .byte 255, 255, 255, 0; netmask of local network (will be overwritten if dhcp_init is called) ;cfg_gateway_default: .byte 0, 0, 0, 0 ;ip address of router on local network (will be overwritten if dhcp_init is called) -cfg_gateway_default: .byte 192, 168, 1, 1 ;ip address of router on local network (will be overwritten if dhcp_init is called) +cfg_gateway_default: .byte 192, 168, 1, 1 ;ip address of router on local network (will be overwritten if dhcp_init is called) cfg_dns_default: .byte 0, 0, 0, 0; ip address of dns server to use (will be overwritten if dhcp_init is called) dhcp_server_default: .res 4 ;will be set address of dhcp server that configuration was obtained from cfg_tftp_server_default: .byte $ff,$ff,$ff,$ff ; ip address of server to send tftp requests to (can be a broadcast address) @@ -64,3 +64,24 @@ cfg_dns: .res 4; ip address of dns server to use (will be overwritten if dhcp_in dhcp_server: .res 4 ;will be set address of dhcp server that configuration was obtained from cfg_tftp_server: .res 4 ; ip address of server to send tftp requests to (can be a broadcast address) + + + +;-- LICENSE FOR config.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/copymem.s b/client/ip65/copymem.s index b0fca31..0ff7d12 100644 --- a/client/ip65/copymem.s +++ b/client/ip65/copymem.s @@ -1,56 +1,77 @@ -; utility routine to copy memory - - - .export copymem - .exportzp copy_src - .exportzp copy_dest - - - .segment "IP65ZP" : zeropage - -; pointers for copying -copy_src: .res 2 ; source pointer -copy_dest: .res 2 ; destination pointer - - - .bss - -end: .res 1 - - - .code - -;copy memory +; utility routine to copy memory + + + .export copymem + .exportzp copy_src + .exportzp copy_dest + + + .segment "IP65ZP" : zeropage + +; pointers for copying +copy_src: .res 2 ; source pointer +copy_dest: .res 2 ; destination pointer + + + .bss + +end: .res 1 + + + .code + +;copy memory ;inputs: ; copy_src is address of buffer to copy from ; copy_dest is address of buffer to copy to ; AX = number of bytes to copy -;outputs: none -copymem: - sta end - ldy #0 - - cpx #0 - beq @tail - -: lda (copy_src),y - sta (copy_dest),y - iny - bne :- +;outputs: none +copymem: + sta end + ldy #0 + + cpx #0 + beq @tail + +: lda (copy_src),y + sta (copy_dest),y + iny + bne :- inc copy_src+1 ;next page - inc copy_dest+1 ;next page - dex - bne :- - -@tail: - lda end - beq @done - -: lda (copy_src),y - sta (copy_dest),y - iny - cpy end - bne :- - -@done: - rts + inc copy_dest+1 ;next page + dex + bne :- + +@tail: + lda end + beq @done + +: lda (copy_src),y + sta (copy_dest),y + iny + cpy end + bne :- + +@done: + rts + + + +;-- LICENSE FOR copymem.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/cs8900a.i b/client/ip65/cs8900a.i index 0486960..4a0bbc0 100644 --- a/client/ip65/cs8900a.i +++ b/client/ip65/cs8900a.i @@ -1,7 +1,31 @@ ;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 -pp_rx_ctl = $0104 -pp_line_ctl = $0112 -pp_self_ctl = $0114 -pp_bus_status = $0138 -pp_ia = $0158 +pp_rx_ctl = $0104 +pp_line_ctl = $0112 +pp_self_ctl = $0114 +pp_bus_status = $0138 +pp_ia = $0158 + + + + + + +;-- LICENSE FOR cs8900a.i -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/cs8900a.s b/client/ip65/cs8900a.s index a5763e8..0bd314e 100644 --- a/client/ip65/cs8900a.s +++ b/client/ip65/cs8900a.s @@ -1,287 +1,308 @@ -; Ethernet driver for CS8900A chip (as used in RR-NET and Uthernet adapters) -; -; Based on Doc Bacardi's tftp source - +; Ethernet driver for CS8900A chip (as used in RR-NET and Uthernet adapters) +; +; Based on Doc Bacardi's tftp source + .ifndef KPR_API_VERSION_NUMBER .define EQU = .include "../inc/kipper_constants.i" .endif - -.include "../inc/common.i" -.include "cs8900a.i" - - .export eth_init - .export eth_rx - .export eth_tx - - .export eth_inp - .export eth_inp_len - .export eth_outp - .export eth_outp_len - - .exportzp eth_dest - .exportzp eth_src - .exportzp eth_type - .exportzp eth_data - - .import cs_init - .import cs_packet_page - .import cs_packet_data - .import cs_rxtx_data - .import cs_tx_cmd - .import cs_tx_len - - .import cfg_mac - .import ip65_error - - .macro write_page page, value - lda #page/2 - ldx #value - jsr cs_write_page - .endmacro - - - .segment "IP65ZP" : zeropage - -eth_packet: .res 2 - - - .bss - -; input and output buffers -eth_inp_len: .res 2 ; input packet length -eth_inp: .res 1518 ; space for input packet -eth_outp_len: .res 2 ; output packet length -eth_outp: .res 1518 ; space for output packet - -; ethernet packet offsets -eth_dest = 0 ; offset of destination mac address in an ethernet packet -eth_src = 6 ; offset of source address in an ethernet packet -eth_type = 12 ; offset of packet type in an ethernet packet -eth_data = 14 ; offset of packet data in an ethernet packet - - - .code - +.include "../inc/common.i" +.include "cs8900a.i" + + .export eth_init + .export eth_rx + .export eth_tx + + .export eth_inp + .export eth_inp_len + .export eth_outp + .export eth_outp_len + + .exportzp eth_dest + .exportzp eth_src + .exportzp eth_type + .exportzp eth_data + + .import cs_init + .import cs_packet_page + .import cs_packet_data + .import cs_rxtx_data + .import cs_tx_cmd + .import cs_tx_len + + .import cfg_mac + + .import ip65_error + + .macro write_page page, value + lda #page/2 + ldx #value + jsr cs_write_page + .endmacro + + + .segment "IP65ZP" : zeropage + +eth_packet: .res 2 + + + .bss + +; input and output buffers +eth_inp_len: .res 2 ; input packet length +eth_inp: .res 1518 ; space for input packet +eth_outp_len: .res 2 ; output packet length +eth_outp: .res 1518 ; space for output packet + +; ethernet packet offsets +eth_dest = 0 ; offset of destination mac address in an ethernet packet +eth_src = 6 ; offset of source address in an ethernet packet +eth_type = 12 ; offset of packet type in an ethernet packet +eth_data = 14 ; offset of packet data in an ethernet packet + + + .code + ;initialize the ethernet adaptor ;inputs: none ;outputs: carry flag is set if there was an error, clear otherwise -eth_init: - jsr cs_init - - lda #0 ; check magic signature - jsr cs_read_page - cpx #$0e - bne @notfound - cpy #$63 - bne @notfound - - lda #1 - jsr cs_read_page - cpx #0 - bne @notfound - ; y contains chip rev - - write_page pp_self_ctl, $0055 ; $0114, reset chip - - write_page pp_rx_ctl, $0d05 ; $0104, accept individual and broadcast packets - - lda #pp_ia/2 ; $0158, write mac address - ldx cfg_mac - ldy cfg_mac + 1 - jsr cs_write_page - - lda #pp_ia/2 + 1 - ldx cfg_mac + 2 - ldy cfg_mac + 3 - jsr cs_write_page - - lda #pp_ia/2 + 2 - ldx cfg_mac + 4 - ldy cfg_mac + 5 - jsr cs_write_page - - write_page pp_line_ctl, $00d3 ; $0112, enable rx and tx - - clc - rts - -@notfound: - sec - rts - - +eth_init: + jsr cs_init + + lda #0 ; check magic signature + jsr cs_read_page + cpx #$0e + bne @notfound + cpy #$63 + bne @notfound + + lda #1 + jsr cs_read_page + cpx #0 + bne @notfound + ; y contains chip rev + + write_page pp_self_ctl, $0055 ; $0114, reset chip + + write_page pp_rx_ctl, $0d05 ; $0104, accept individual and broadcast packets + + lda #pp_ia/2 ; $0158, write mac address + ldx cfg_mac + ldy cfg_mac + 1 + jsr cs_write_page + + lda #pp_ia/2 + 1 + ldx cfg_mac + 2 + ldy cfg_mac + 3 + jsr cs_write_page + + lda #pp_ia/2 + 2 + ldx cfg_mac + 4 + ldy cfg_mac + 5 + jsr cs_write_page + + write_page pp_line_ctl, $00d3 ; $0112, enable rx and tx + + clc + rts + +@notfound: + sec + rts + + ;receive a packet ;inputs: none ;outputs: ; if there was an error receiving the packet (or no packet was ready) then carry flag is set ; if packet was received correctly then carry flag is clear, ; eth_inp contains the received packet, -; and eth_inp_len contains the length of the packet -eth_rx: - lda #$24 ; check rx status - sta cs_packet_page - lda #$01 - sta cs_packet_page + 1 - - lda cs_packet_data + 1 - and #$0d - bne :+ - - sec ; no packet ready - rts - -: lda cs_rxtx_data + 1 ; ignore status - lda cs_rxtx_data - - lda cs_rxtx_data + 1 ; read packet length - sta eth_inp_len + 1 - tax ; save - lda cs_rxtx_data - sta eth_inp_len - - lda #eth_inp - sta eth_packet + 1 - - ldy #0 - cpx #0 ; < 256 bytes left? - beq @tail - -@get256: - lda cs_rxtx_data - sta (eth_packet),y - iny - lda cs_rxtx_data + 1 - sta (eth_packet),y - iny - bne @get256 - inc eth_packet + 1 - dex - bne @get256 - -@tail: - lda eth_inp_len ; bytes left / 2, round up - lsr - adc #0 - beq @done - tax - -@get: - lda cs_rxtx_data - sta (eth_packet),y - iny - lda cs_rxtx_data + 1 - sta (eth_packet),y - iny - dex - bne @get - -@done: - clc - rts - - +; and eth_inp_len contains the length of the packet +eth_rx: + lda #$24 ; check rx status + sta cs_packet_page + lda #$01 + sta cs_packet_page + 1 + + lda cs_packet_data + 1 + and #$0d + bne :+ + + sec ; no packet ready + rts + +: lda cs_rxtx_data + 1 ; ignore status + lda cs_rxtx_data + + lda cs_rxtx_data + 1 ; read packet length + sta eth_inp_len + 1 + tax ; save + lda cs_rxtx_data + sta eth_inp_len + + lda #eth_inp + sta eth_packet + 1 + + ldy #0 + cpx #0 ; < 256 bytes left? + beq @tail + +@get256: + lda cs_rxtx_data + sta (eth_packet),y + iny + lda cs_rxtx_data + 1 + sta (eth_packet),y + iny + bne @get256 + inc eth_packet + 1 + dex + bne @get256 + +@tail: + lda eth_inp_len ; bytes left / 2, round up + lsr + adc #0 + beq @done + tax + +@get: + lda cs_rxtx_data + sta (eth_packet),y + iny + lda cs_rxtx_data + 1 + sta (eth_packet),y + iny + dex + bne @get + +@done: + clc + rts + + ; send a packet ;inputs: ; eth_outp: packet to send ; eth_outp_len: length of packet to send ;outputs: ; if there was an error sending the packet then carry flag is set -; otherwise carry flag is cleared -eth_tx: - - lda #$c9 ; ask for buffer space - sta cs_tx_cmd - lda #0 - sta cs_tx_cmd + 1 - - lda eth_outp_len ; set length - sta cs_tx_len - lda eth_outp_len + 1 - sta cs_tx_len + 1 - cmp #6 +; otherwise carry flag is cleared +eth_tx: + + lda #$c9 ; ask for buffer space + sta cs_tx_cmd + lda #0 + sta cs_tx_cmd + 1 + + lda eth_outp_len ; set length + sta cs_tx_len + lda eth_outp_len + 1 + sta cs_tx_len + 1 + cmp #6 bmi :+ lda #KPR_ERROR_INPUT_TOO_LARGE - sta ip65_error - sec ; oversized packet - rts - -: lda #pp_bus_status - sta cs_packet_page + 1 - -@waitspace: - lda cs_packet_data + 1 ; wait for space - ldx cs_packet_data - lsr - bcs @gotspace + sta ip65_error + sec ; oversized packet + rts + +: lda #pp_bus_status + sta cs_packet_page + 1 + +@waitspace: + lda cs_packet_data + 1 ; wait for space + ldx cs_packet_data + lsr + bcs @gotspace jsr @done ; polling too fast doesn't work, delay added by David Schmidt - jmp @waitspace -@gotspace: - ldax #eth_outp ; send packet - stax eth_packet - - ldy #0 - ldx eth_outp_len + 1 - beq @tail - -@send256: - lda (eth_packet),y - sta cs_rxtx_data - iny - lda (eth_packet),y - sta cs_rxtx_data + 1 - iny - bne @send256 - inc eth_packet + 1 - dex - bne @send256 - -@tail: - ldx eth_outp_len - beq @done - -@send: - lda (eth_packet),y - sta cs_rxtx_data - dex - beq @done - iny - lda (eth_packet),y - sta cs_rxtx_data + 1 - iny - dex - bne @send - -@done: ; also used by timeout code above - clc - rts - - -; read X/Y from page A * 2 -cs_read_page: - asl - sta cs_packet_page - lda #0 - rol - sta cs_packet_page + 1 - ldx cs_packet_data - ldy cs_packet_data + 1 - rts - -; write X/Y to page A * 2 -cs_write_page: - asl - sta cs_packet_page - lda #0 - rol - sta cs_packet_page + 1 - stx cs_packet_data - sty cs_packet_data + 1 - rts + jmp @waitspace +@gotspace: + ldax #eth_outp ; send packet + stax eth_packet + + ldy #0 + ldx eth_outp_len + 1 + beq @tail + +@send256: + lda (eth_packet),y + sta cs_rxtx_data + iny + lda (eth_packet),y + sta cs_rxtx_data + 1 + iny + bne @send256 + inc eth_packet + 1 + dex + bne @send256 + +@tail: + ldx eth_outp_len + beq @done + +@send: + lda (eth_packet),y + sta cs_rxtx_data + dex + beq @done + iny + lda (eth_packet),y + sta cs_rxtx_data + 1 + iny + dex + bne @send + +@done: ; also used by timeout code above + clc + rts + + +; read X/Y from page A * 2 +cs_read_page: + asl + sta cs_packet_page + lda #0 + rol + sta cs_packet_page + 1 + ldx cs_packet_data + ldy cs_packet_data + 1 + rts + +; write X/Y to page A * 2 +cs_write_page: + asl + sta cs_packet_page + lda #0 + rol + sta cs_packet_page + 1 + stx cs_packet_data + sty cs_packet_data + 1 + rts + + + +;-- LICENSE FOR cs8900a.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/debug.s b/client/ip65/debug.s index 016dcc8..2db1fe6 100644 --- a/client/ip65/debug.s +++ b/client/ip65/debug.s @@ -146,3 +146,24 @@ dbgout16: .bss val16: .res 2 + + + +;-- LICENSE FOR debug.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/dhcp.s b/client/ip65/dhcp.s index 660749d..3894425 100644 --- a/client/ip65/dhcp.s +++ b/client/ip65/dhcp.s @@ -20,36 +20,36 @@ MAX_DHCP_MESSAGES_SENT=12 ;timeout after sending 12 messages will be about 1 .export dhcp_state .import ip65_error - .import cfg_mac + .import cfg_mac .import cfg_ip .import cfg_netmask .import cfg_gateway .import cfg_dns .import arp_calculate_gateway_mask - - .import ip65_process - + + .import ip65_process + .import udp_add_listener .import udp_remove_listener - - .import udp_callback - .import udp_send - + + .import udp_callback + .import udp_send + .import udp_inp - - .importzp udp_data + + .importzp udp_data .import output_buffer - - .import udp_send_dest - .import udp_send_src_port - .import udp_send_dest_port - .import udp_send_len + + .import udp_send_dest + .import udp_send_src_port + .import udp_send_dest_port + .import udp_send_len .import check_for_abort_key .import timer_read - .bss + .bss ; dhcp packet offsets dhcp_inp = udp_inp + udp_data @@ -106,7 +106,7 @@ DHCPRELEASE =7 DHCPINFORM =8 - .code + .code ; ;inputs: none (although ip65_init should be called first) ;outputs: @@ -120,7 +120,7 @@ DHCPINFORM =8 ; 2 - sent a DHCPDISCOVER, waiting for a DHCPOFFER ; 3 - got a DHCPOFFER, ready to send a DHCPREQUEST ; 4 - sent a DHCPREQUEST, waiting for a DHCPACK -; 5 - we have been allocated an IP address +; 5 - we have been allocated an IP address dhcp_init: ldx #3 ; rewrite ip address @@ -131,13 +131,13 @@ dhcp_init: lda #dhcp_initializing sta dhcp_state - - ldax #dhcp_in - stax udp_callback - ldax #dhcp_client_port - jsr udp_add_listener - bcc :+ - rts + + ldax #dhcp_in + stax udp_callback + ldax #dhcp_client_port + jsr udp_add_listener + bcc :+ + rts : lda #0 ;reset the "message sent" counter sta dhcp_message_sent_count @@ -484,4 +484,25 @@ send_dhcprequest: sta dhcp_state rts : - rts + rts + + + +;-- LICENSE FOR dhcp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/dns.s b/client/ip65/dns.s index b6ecf99..ca24d5a 100644 --- a/client/ip65/dns.s +++ b/client/ip65/dns.s @@ -462,3 +462,24 @@ dns_in: rts + + + +;-- LICENSE FOR dns.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/dottedquad.s b/client/ip65/dottedquad.s index ec8f0cf..6cf401d 100644 --- a/client/ip65/dottedquad.s +++ b/client/ip65/dottedquad.s @@ -80,4 +80,24 @@ get_next_byte: bne :+ inc dotted_quad_ptr+2 : - rts \ No newline at end of file + rts + + +;-- LICENSE FOR dottedquad.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/eth.s b/client/ip65/eth.s index 80359c7..0976974 100644 --- a/client/ip65/eth.s +++ b/client/ip65/eth.s @@ -1,63 +1,84 @@ -; Common ethernet driver code (independant of host computer or ethernet chipset) - -.include "../inc/common.i" - - .export eth_set_broadcast_dest - .export eth_set_my_mac_src - .export eth_set_proto - - .exportzp eth_proto_ip - .exportzp eth_proto_arp - - .import eth_outp - - .import cfg_mac - - -; ethernet packet offsets -eth_dest = 0 ; offset of destination address in ethernet packet -eth_src = 6 ; offset of source address in ethernet packet -eth_type = 12 ; offset of packet type in ethernet packet -eth_data = 14 ; offset of packet data in ethernet packet - +; Common ethernet driver code (independant of host computer or ethernet chipset) + +.include "../inc/common.i" + + .export eth_set_broadcast_dest + .export eth_set_my_mac_src + .export eth_set_proto + + .exportzp eth_proto_ip + .exportzp eth_proto_arp + + .import eth_outp + + .import cfg_mac + + +; ethernet packet offsets +eth_dest = 0 ; offset of destination address in ethernet packet +eth_src = 6 ; offset of source address in ethernet packet +eth_type = 12 ; offset of packet type in ethernet packet +eth_data = 14 ; offset of packet data in ethernet packet + ; protocols - -eth_proto_ip = 0 -eth_proto_arp = 6 - - - .code + +eth_proto_ip = 0 +eth_proto_arp = 6 + + + .code ;set the destination address in the packet under construction to be the ethernet ;broadcast address (FF:FF:FF:FF:FF:FF) ;inputs: ; eth_outp: buffer in which outbound ethernet packet is being constructed -;outputs: none -eth_set_broadcast_dest: - ldx #5 - lda #$ff -: sta eth_outp,x - dex - bpl :- - rts - +;outputs: none +eth_set_broadcast_dest: + ldx #5 + lda #$ff +: sta eth_outp,x + dex + bpl :- + rts + ;set the source address in the packet under construction to be local mac address ;inputs: -; eth_outp: buffer in which outbound ethernet packet is being constructed +; eth_outp: buffer in which outbound ethernet packet is being constructed ;outputs: none -eth_set_my_mac_src: - ldx #5 -: lda cfg_mac,x - sta eth_outp + 6,x - dex - bpl :- - rts - +eth_set_my_mac_src: + ldx #5 +: lda cfg_mac,x + sta eth_outp + 6,x + dex + bpl :- + rts + ;set the 'protocol' field in the packet under construction ;inputs: ; A = protocol number (per 'eth_proto_*' constants) -;outputs: none -eth_set_proto: - sta eth_outp + eth_type + 1 - lda #8 - sta eth_outp + eth_type - rts +;outputs: none +eth_set_proto: + sta eth_outp + eth_type + 1 + lda #8 + sta eth_outp + eth_type + rts + + + +;-- LICENSE FOR eth.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/function_dispatcher.s b/client/ip65/function_dispatcher.s index 2cf1394..8cffa36 100644 --- a/client/ip65/function_dispatcher.s +++ b/client/ip65/function_dispatcher.s @@ -676,4 +676,24 @@ cpy #KPR_BLOCK_COPY lda #KPR_ERROR_FUNCTION_NOT_SUPPORTED sta ip65_error sec ;carry flag set = error - rts \ No newline at end of file + rts + + +;-- LICENSE FOR function_dispatcher.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/http.s b/client/ip65/http.s index e8d3303..60207dc 100644 --- a/client/ip65/http.s +++ b/client/ip65/http.s @@ -18,6 +18,7 @@ .importzp copy_src .importzp copy_dest .import output_buffer +.import parse_hex_digits ;reuse the copy_src zero page var string_ptr = copy_src table_ptr=copy_dest @@ -173,17 +174,9 @@ http_parse_request: @get_percent_encoded_byte: jsr get_next_byte_in_source - jsr parse_hex_digit - asl - asl - asl - asl - sta hex_digit - + tax jsr get_next_byte_in_source - jsr parse_hex_digit - clc - adc hex_digit + jsr parse_hex_digits jmp @got_byte put_byte: @@ -238,18 +231,25 @@ get_next_byte_in_source: : lda (string_ptr),y rts - -parse_hex_digit: - cmp #$3A - - bcs @not_digit - sec - sbc #$30 - rts -@not_digit: - ora #$20 ;make lower case - sec - sbc #'a'-10 - rts + + +;-- LICENSE FOR http.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/httpd.s b/client/ip65/httpd.s index cb3d09b..09cc579 100644 --- a/client/ip65/httpd.s +++ b/client/ip65/httpd.s @@ -20,6 +20,7 @@ HTTPD_TIMEOUT_SECONDS=5 ;what's the maximum time we let 1 connection be open for .import ip65_process .import check_for_abort_key .import ip65_error +.import parse_hex_digits .import print .import copymem .importzp copy_src @@ -59,6 +60,9 @@ httpd_port_number: .word 80 jump_to_callback: jmp $ffff +jump_to_embedded_routine: + jmp $ffff + get_next_byte: lda $ffff inc get_next_byte+1 @@ -184,8 +188,11 @@ http_callback: cmp #$ff bne @not_eof inc connection_closed +@done: rts @not_eof: + lda found_eol + bne @done ;copy this chunk to our input buffer ldax tcp_buffer_ptr @@ -382,12 +389,29 @@ send_response: beq @back_from_escape cmp #'C' bne :+ - jsr emit_disk_catalogue + jsr emit_disk_catalogue + jmp @response_loop + : + cmp #':' + bne :+ + jsr @get_next_hex_value + sta jump_to_embedded_routine+2 + + jsr @get_next_hex_value + sta jump_to_embedded_routine+1 + ldax #emit_a + jsr jump_to_embedded_routine jmp @response_loop : ;if we got here, it's an invalid escape code jmp @response_loop +@get_next_hex_value: + jsr get_next_byte + tax + jsr get_next_byte + jmp parse_hex_digits + send_buffer: ldax output_buffer_length stax tcp_send_data_len @@ -480,7 +504,7 @@ emit_string: .rodata default_html: -.byte "

Index of /


    %C

kipper - the 100%% 6502 m/l web server " +.byte "

Index of /


    %C

kipper - the 100%% 6502 m/l web server %:ab12" .byte 0 @@ -521,3 +545,24 @@ file_li_middle: .byte '"',">",0 file_li_postamble: .byte "",0 + + + +;-- LICENSE FOR httpd.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/icmp.s b/client/ip65/icmp.s index 662605a..dca9189 100644 --- a/client/ip65/icmp.s +++ b/client/ip65/icmp.s @@ -1,25 +1,25 @@ ;ICMP implementation ; -.include "../inc/common.i" +.include "../inc/common.i" .ifndef KPR_API_VERSION_NUMBER .define EQU = .include "../inc/kipper_constants.i" .endif - - .export icmp_init - .export icmp_process - .export icmp_add_listener - .export icmp_remove_listener - - .export icmp_callback - - .export icmp_inp - .export icmp_outp - .exportzp icmp_type - .exportzp icmp_code - .exportzp icmp_cksum - .exportzp icmp_data + + .export icmp_init + .export icmp_process + .export icmp_add_listener + .export icmp_remove_listener + + .export icmp_callback + + .export icmp_inp + .export icmp_outp + .exportzp icmp_type + .exportzp icmp_code + .exportzp icmp_cksum + .exportzp icmp_data .ifdef TCP .export icmp_echo_ip @@ -31,60 +31,60 @@ .import ip65_process .import ip65_error - - .import ip_calc_cksum - .import ip_inp - .import ip_outp + + .import ip_calc_cksum + .import ip_inp + .import ip_outp .import ip_broadcast .import ip_send .import ip_create_packet .importzp ip_proto .importzp ip_proto_icmp - - .importzp ip_cksum_ptr - .importzp ip_header_cksum - .importzp ip_src - .importzp ip_dest - .importzp ip_data + + .importzp ip_cksum_ptr + .importzp ip_header_cksum + .importzp ip_src + .importzp ip_dest + .importzp ip_data .importzp ip_len - - .import eth_tx - .import eth_inp - .import eth_inp_len - .import eth_outp + + .import eth_tx + .import eth_inp + .import eth_inp_len + .import eth_outp .import eth_outp_len - .import timer_read + .import timer_read .import timer_timeout .data icmp_cbtmp: jmp $0000 ; temporary vector - address filled in later - - - .bss - -; argument for icmp_add_listener + + + .bss + +; argument for icmp_add_listener icmp_callback: .res 2 - - -; icmp callbacks -icmp_cbmax = 2 -icmp_cbveclo: .res icmp_cbmax ; table of listener vectors (lsb) -icmp_cbvechi: .res icmp_cbmax ; table of listener vectors (msb) -icmp_cbtype: .res icmp_cbmax ; table of listener types -icmp_cbcount: .res 1 ; number of active listeners - -; icmp packet offsets -icmp_inp = ip_inp + ip_data ;pointer to inbound icmp packet -icmp_outp = ip_outp + ip_data ;pointer to outbound icmp packet -icmp_type = 0 ;offset of 'type' field in icmp packet -icmp_code = 1 ;offset of 'code' field in icmp packet -icmp_cksum = 2 ;offset of 'checksum' field in icmp packet -icmp_data = 4;offset of 'data' field in icmp packet - -; icmp echo packet offsets -icmp_echo_id = 4 ;offset of 'id' field in icmp echo request/echo response -icmp_echo_seq = 6 ;offset of 'sequence' field in icmp echo request/echo response -icmp_echo_data = 8 ;offset of 'data' field in icmp echo request/echo response + + +; icmp callbacks +icmp_cbmax = 2 +icmp_cbveclo: .res icmp_cbmax ; table of listener vectors (lsb) +icmp_cbvechi: .res icmp_cbmax ; table of listener vectors (msb) +icmp_cbtype: .res icmp_cbmax ; table of listener types +icmp_cbcount: .res 1 ; number of active listeners + +; icmp packet offsets +icmp_inp = ip_inp + ip_data ;pointer to inbound icmp packet +icmp_outp = ip_outp + ip_data ;pointer to outbound icmp packet +icmp_type = 0 ;offset of 'type' field in icmp packet +icmp_code = 1 ;offset of 'code' field in icmp packet +icmp_cksum = 2 ;offset of 'checksum' field in icmp packet +icmp_data = 4;offset of 'data' field in icmp packet + +; icmp echo packet offsets +icmp_echo_id = 4 ;offset of 'id' field in icmp echo request/echo response +icmp_echo_seq = 6 ;offset of 'sequence' field in icmp echo request/echo response +icmp_echo_data = 8 ;offset of 'data' field in icmp echo request/echo response ;icmp type codes icmp_msg_type_echo_reply=0 @@ -111,17 +111,17 @@ icmp_echo_cnt: .res 1 ;ping sequence counter ping_state: .res 1 ping_timer: .res 2 ; .endif - - .code - + + .code + ; initialize icmp ; inputs: none ; outputs: none -icmp_init: - lda #0 - sta icmp_cbcount - rts - +icmp_init: + lda #0 + sta icmp_cbcount + rts + ;process incoming icmp packet ;inputs: ; eth_inp points to an ethernet frame containing an icmp packet @@ -129,166 +129,166 @@ icmp_init: ; carry flag - set on any error, clear if OK ; if inbound packet is a request (e.g. 'echo request') and an icmp listener ; has been installed, then an appropriate response message will be -; generated and sent out (overwriting the eth_outp buffer) -icmp_process: - lda icmp_inp + icmp_type - cmp #icmp_msg_type_echo_request ; ping - beq @echo - - lda icmp_cbcount ; any installed icmp listeners? - beq @drop - - ldx icmp_cbcount ; check listened types - dex -: lda icmp_cbtype,x - cmp icmp_inp + icmp_type - beq @handle ; found a match - dex - bpl :- - -@drop: - sec - rts - -@handle: - lda icmp_cbveclo,x ; copy vector - sta icmp_cbtmp + 1 - lda icmp_cbvechi,x - sta icmp_cbtmp + 2 - jsr icmp_cbtmp ; call listener - clc - rts - -@echo: - lda ip_broadcast ; check if packet is broadcast - beq @notbc - sec ; don't reply to broadcast pings - rts -@notbc: - ldx #5 -: lda eth_inp,x ; swap dest and src mac - sta eth_outp + 6,x - lda eth_inp + 6,x - sta eth_outp,x - dex - bpl :- - - ldx #12 ; copy the packet -: lda eth_inp,x - sta eth_outp,x - inx - cpx eth_inp_len - bne :- - - ldx #3 -: lda ip_inp + ip_src,x ; swap dest and src ip - sta ip_outp + ip_dest,x - lda ip_inp + ip_dest,x - sta ip_outp + ip_src,x - dex - bpl :- - - lda #0 ; change type to reply - sta icmp_outp + icmp_type - - lda icmp_inp + icmp_cksum ; recalc checksum - clc - adc #8 - sta icmp_outp + icmp_cksum - bcc :+ - inc icmp_outp + icmp_cksum + 1 -: - lda eth_inp_len ; copy length - sta eth_outp_len - lda eth_inp_len + 1 - sta eth_outp_len + 1 - - lda #0 ; clear checksum - sta ip_outp + ip_header_cksum - sta ip_outp + ip_header_cksum + 1 - ldax #ip_outp ; calculate ip header checksum - stax ip_cksum_ptr - ldax #20 - jsr ip_calc_cksum - stax ip_outp + ip_header_cksum - - jsr eth_tx ; send packet - - clc - rts - - +; generated and sent out (overwriting the eth_outp buffer) +icmp_process: + lda icmp_inp + icmp_type + cmp #icmp_msg_type_echo_request ; ping + beq @echo + + lda icmp_cbcount ; any installed icmp listeners? + beq @drop + + ldx icmp_cbcount ; check listened types + dex +: lda icmp_cbtype,x + cmp icmp_inp + icmp_type + beq @handle ; found a match + dex + bpl :- + +@drop: + sec + rts + +@handle: + lda icmp_cbveclo,x ; copy vector + sta icmp_cbtmp + 1 + lda icmp_cbvechi,x + sta icmp_cbtmp + 2 + jsr icmp_cbtmp ; call listener + clc + rts + +@echo: + lda ip_broadcast ; check if packet is broadcast + beq @notbc + sec ; don't reply to broadcast pings + rts +@notbc: + ldx #5 +: lda eth_inp,x ; swap dest and src mac + sta eth_outp + 6,x + lda eth_inp + 6,x + sta eth_outp,x + dex + bpl :- + + ldx #12 ; copy the packet +: lda eth_inp,x + sta eth_outp,x + inx + cpx eth_inp_len + bne :- + + ldx #3 +: lda ip_inp + ip_src,x ; swap dest and src ip + sta ip_outp + ip_dest,x + lda ip_inp + ip_dest,x + sta ip_outp + ip_src,x + dex + bpl :- + + lda #0 ; change type to reply + sta icmp_outp + icmp_type + + lda icmp_inp + icmp_cksum ; recalc checksum + clc + adc #8 + sta icmp_outp + icmp_cksum + bcc :+ + inc icmp_outp + icmp_cksum + 1 +: + lda eth_inp_len ; copy length + sta eth_outp_len + lda eth_inp_len + 1 + sta eth_outp_len + 1 + + lda #0 ; clear checksum + sta ip_outp + ip_header_cksum + sta ip_outp + ip_header_cksum + 1 + ldax #ip_outp ; calculate ip header checksum + stax ip_cksum_ptr + ldax #20 + jsr ip_calc_cksum + stax ip_outp + ip_header_cksum + + jsr eth_tx ; send packet + + clc + rts + + ;add an icmp listener ;inputs: -; A = icmp type +; A = icmp type ; icmp_callback: vector to call when an icmp packet of specified type arrives ;outputs: -; carry flag - set if error, clear if no error -icmp_add_listener: - ldx icmp_cbcount ; any listeners at all? - beq @add - cpx #icmp_cbmax ; max? - beq @full - ldx #0 -: cmp icmp_cbtype,x ; check if type is already listened - beq @busy - inx - cpx icmp_cbcount - bne :- -@add: - inc icmp_cbcount ; increase counter - sta icmp_cbtype,x ; add type - lda icmp_callback ; and vector - sta icmp_cbveclo,x - lda icmp_callback + 1 - sta icmp_cbvechi,x - - clc - rts -@full: -@busy: - sec - rts - - +; carry flag - set if error, clear if no error +icmp_add_listener: + ldx icmp_cbcount ; any listeners at all? + beq @add + cpx #icmp_cbmax ; max? + beq @full + ldx #0 +: cmp icmp_cbtype,x ; check if type is already listened + beq @busy + inx + cpx icmp_cbcount + bne :- +@add: + inc icmp_cbcount ; increase counter + sta icmp_cbtype,x ; add type + lda icmp_callback ; and vector + sta icmp_cbveclo,x + lda icmp_callback + 1 + sta icmp_cbvechi,x + + clc + rts +@full: +@busy: + sec + rts + + ;remove an icmp listener ;inputs: ; A = icmp type ;outputs: ; carry flag - set if error (i.e. no listner for this type exists), ; clear if no error -icmp_remove_listener: - ldx icmp_cbcount ; any listeners installed? +icmp_remove_listener: + ldx icmp_cbcount ; any listeners installed? beq @notfound - dex -: cmp icmp_cbtype,x ; check if type is listened - beq @remove + dex +: cmp icmp_cbtype,x ; check if type is listened + beq @remove dex bpl :- -@notfound: - sec - rts -@remove: - txa ; number of listeners below - eor #$ff - clc - adc icmp_cbcount - beq @done -@move: - tay ; number of items to move -: lda icmp_cbtype + 1,x ; move type - sta icmp_cbtype,x - lda icmp_cbveclo + 1,x ; move vector lsb - sta icmp_cbveclo,x - lda icmp_cbvechi + 1,x ; move vector msb - sta icmp_cbvechi,x - inx - dey - bne :- -@done: - dec icmp_cbcount ; decrement counter - clc - rts +@notfound: + sec + rts +@remove: + txa ; number of listeners below + eor #$ff + clc + adc icmp_cbcount + beq @done +@move: + tay ; number of items to move +: lda icmp_cbtype + 1,x ; move type + sta icmp_cbtype,x + lda icmp_cbveclo + 1,x ; move vector lsb + sta icmp_cbveclo,x + lda icmp_cbvechi + 1,x ; move vector msb + sta icmp_cbvechi,x + inx + dey + bne :- +@done: + dec icmp_cbcount ; decrement counter + clc + rts .ifdef TCP @@ -443,4 +443,24 @@ icmp_ping_callback: ip65_msg: .byte "ip65 - the 6502 IP stack",0 -.endif \ No newline at end of file +.endif + + +;-- LICENSE FOR icmp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/ip.s b/client/ip65/ip.s index 3e39ad4..9275fb8 100644 --- a/client/ip65/ip.s +++ b/client/ip65/ip.s @@ -1,363 +1,363 @@ -.include "../inc/common.i" - - .export ip_init - .export ip_process - .export ip_calc_cksum - .export ip_create_packet - .export ip_send - .export ip_inp - .export ip_outp - .export ip_broadcast - .exportzp ip_cksum_ptr - .exportzp ip_ver_ihl - .exportzp ip_tos - .exportzp ip_len - .exportzp ip_id - .exportzp ip_frag - .exportzp ip_ttl - .exportzp ip_proto - .exportzp ip_header_cksum - .exportzp ip_src - .exportzp ip_dest - .exportzp ip_data - - .exportzp ip_proto_icmp - .exportzp ip_proto_tcp - .exportzp ip_proto_udp - - - .import cfg_mac - .import cfg_ip - - .import eth_tx - .import eth_set_proto - .import eth_inp - .import eth_inp_len - .import eth_outp - .import eth_outp_len - - .importzp eth_dest - .importzp eth_src - .importzp eth_type - .importzp eth_data - .importzp eth_proto_ip - .importzp eth_proto_arp - - .import arp_lookup - .import arp_mac - .import arp_ip - - .import icmp_init - .import icmp_process - - .import udp_init - .import udp_process +.include "../inc/common.i" + + .export ip_init + .export ip_process + .export ip_calc_cksum + .export ip_create_packet + .export ip_send + .export ip_inp + .export ip_outp + .export ip_broadcast + .exportzp ip_cksum_ptr + .exportzp ip_ver_ihl + .exportzp ip_tos + .exportzp ip_len + .exportzp ip_id + .exportzp ip_frag + .exportzp ip_ttl + .exportzp ip_proto + .exportzp ip_header_cksum + .exportzp ip_src + .exportzp ip_dest + .exportzp ip_data + + .exportzp ip_proto_icmp + .exportzp ip_proto_tcp + .exportzp ip_proto_udp + + + .import cfg_mac + .import cfg_ip + + .import eth_tx + .import eth_set_proto + .import eth_inp + .import eth_inp_len + .import eth_outp + .import eth_outp_len + + .importzp eth_dest + .importzp eth_src + .importzp eth_type + .importzp eth_data + .importzp eth_proto_ip + .importzp eth_proto_arp + + .import arp_lookup + .import arp_mac + .import arp_ip + + .import icmp_init + .import icmp_process + + .import udp_init + .import udp_process .ifdef TCP .import tcp_init .import tcp_process -.endif - .importzp copy_src - - - .segment "IP65ZP" : zeropage - -; checksum -ip_cksum_ptr: .res 2 ; pointer to data to be checksummed - +.endif + .importzp copy_src + + + .segment "IP65ZP" : zeropage + +; checksum +ip_cksum_ptr: .res 2 ; pointer to data to be checksummed + + +.bss + +ip_cksum_len: .res 2 ; length of data to be checksummed + +; ip packets start at ethernet packet + 14 +ip_inp = eth_inp + eth_data ;pointer to start of IP packet in input ethernet frame +ip_outp = eth_outp + eth_data ;pointer to start of IP packet in output ethernet frame + +; temp storage for size calculation +len: .res 2 + +; flag for incoming broadcast packets +ip_broadcast: .res 1 ;flag set when an incoming IP packet was sent to a broadcast address + +; ip packet offsets +ip_ver_ihl = 0 ;offset of 4 bit "version" field and 4 bit "header length" field in an IP packet header +ip_tos = 1 ;offset of "type of service" field in an IP packet header +ip_len = 2 ;offset of "length" field in an IP packet header +ip_id = 4 ;offset of "identification" field in an IP packet header +ip_frag = 6 ;offset of "fragmentation offset" field in an IP packet header +ip_ttl = 8 ;offset of "time to live" field in an IP packet header +ip_proto = 9 ;offset of "protocol number" field in an IP packet header +ip_header_cksum = 10 ;offset of "ip header checksum" field in an IP packet header +ip_src = 12 ;offset of "source address" field in an IP packet header +ip_dest = 16 ;offset of "destination address" field in an IP packet header +ip_data = 20 ;offset of data payload in an IP packet -.bss - -ip_cksum_len: .res 2 ; length of data to be checksummed - -; ip packets start at ethernet packet + 14 -ip_inp = eth_inp + eth_data ;pointer to start of IP packet in input ethernet frame -ip_outp = eth_outp + eth_data ;pointer to start of IP packet in output ethernet frame - -; temp storage for size calculation -len: .res 2 - -; flag for incoming broadcast packets -ip_broadcast: .res 1 ;flag set when an incoming IP packet was sent to a broadcast address - -; ip packet offsets -ip_ver_ihl = 0 ;offset of 4 bit "version" field and 4 bit "header length" field in an IP packet header -ip_tos = 1 ;offset of "type of service" field in an IP packet header -ip_len = 2 ;offset of "length" field in an IP packet header -ip_id = 4 ;offset of "identification" field in an IP packet header -ip_frag = 6 ;offset of "fragmentation offset" field in an IP packet header -ip_ttl = 8 ;offset of "time to live" field in an IP packet header -ip_proto = 9 ;offset of "protocol number" field in an IP packet header -ip_header_cksum = 10 ;offset of "ip header checksum" field in an IP packet header -ip_src = 12 ;offset of "source address" field in an IP packet header -ip_dest = 16 ;offset of "destination address" field in an IP packet header -ip_data = 20 ;offset of data payload in an IP packet - ; ip protocols - -ip_proto_icmp = 1 -ip_proto_tcp = 6 -ip_proto_udp = 17 - - -; temp for calculating checksum -cksum: .res 3 - -; bad packet counters -bad_header: .res 2 -bad_addr: .res 2 - - - .code - + +ip_proto_icmp = 1 +ip_proto_tcp = 6 +ip_proto_udp = 17 + + +; temp for calculating checksum +cksum: .res 3 + +; bad packet counters +bad_header: .res 2 +bad_addr: .res 2 + + + .code + ; initialize ip routines ; inputs: none -; outputs: none -ip_init: - lda #0 - sta bad_header - sta bad_header + 1 - sta bad_addr - sta bad_addr + 1 - +; outputs: none +ip_init: + lda #0 + sta bad_header + sta bad_header + 1 + sta bad_addr + sta bad_addr + 1 + jsr icmp_init .ifdef TCP jsr tcp_init -.endif - jsr udp_init - - rts +.endif + jsr udp_init + + rts + - ;process an incoming packet & call the appropriate protocol handler ;inputs: ; eth_inp: should point to the received ethernet packet ;outputs: ; carry flag - set on any error, clear if OK ; depending on the packet contents and the protocol handler, a response -; message may be generated and sent out (overwriting eth_outp buffer) -ip_process: - jsr verifyheader ; ver, ihl, len, frag, checksum - bcc @ok -@badpacket: - sec - rts -@ok: - jsr checkaddr ; make sure it's meant for us - bcs @badpacket - - lda ip_inp + ip_proto - cmp #ip_proto_icmp - bne :+ +; message may be generated and sent out (overwriting eth_outp buffer) +ip_process: + jsr verifyheader ; ver, ihl, len, frag, checksum + bcc @ok +@badpacket: + sec + rts +@ok: + jsr checkaddr ; make sure it's meant for us + bcs @badpacket + + lda ip_inp + ip_proto + cmp #ip_proto_icmp + bne :+ jmp icmp_process ; jump to icmp handler -.ifdef TCP -: cmp #ip_proto_tcp - bne :+ +.ifdef TCP +: cmp #ip_proto_tcp + bne :+ jmp tcp_process ; jump to tcp handler -.endif -: cmp #ip_proto_udp - bne :+ - jmp udp_process ; jump to udp handler -: -unknown_protocol: - sec ; unknown protocol - rts - - -; verify that header contains what we expect -verifyheader: - lda ip_inp + ip_ver_ihl ; IPv4 and no IP options - cmp #$45 - bne @badpacket - -; lda ip_inp + ip_tos ; ignore ToS - - lda ip_inp + ip_len + 1 ; ip + 14 bytes ethernet header - clc - adc #14 - sta len - lda ip_inp + ip_len - adc #0 - sta len + 1 - - lda eth_inp_len ; check if advertised length is shorter - sec ; than actual length - sbc len - lda eth_inp_len + 1 - sbc len + 1 - bmi @badpacket - - lda ip_inp + ip_frag ; check for fragmentation - beq :+ - cmp #$40 - bne @badpacket -: lda ip_inp + ip_frag + 1 - bne @badpacket - - ldax #ip_inp ; verify checksum - stax ip_cksum_ptr - ldax #20 - jsr ip_calc_cksum - cmp #0 - bne @badpacket - cpx #0 - bne @badpacket - - clc - rts -@badpacket: - inc bad_header - bne :+ - inc bad_header + 1 -: sec - rts - - -; check that this packet was addressed to us -checkaddr: - lda #0 - sta ip_broadcast - lda ip_inp + ip_dest ; compare ip address - cmp cfg_ip - bne @broadcast - lda ip_inp + ip_dest + 1 - cmp cfg_ip + 1 - bne @broadcast - lda ip_inp + ip_dest + 2 - cmp cfg_ip + 2 - bne @broadcast - lda ip_inp + ip_dest + 3 - cmp cfg_ip + 3 - bne @broadcast -@ok: clc - rts -@broadcast: - inc ip_broadcast - lda ip_inp + ip_dest ; check for broadcast - and ip_inp + ip_dest + 1 - and ip_inp + ip_dest + 2 - and ip_inp + ip_dest + 3 - cmp #$ff - beq @ok - inc bad_addr - bne :+ - inc bad_addr + 1 -: sec - rts - - +.endif +: cmp #ip_proto_udp + bne :+ + jmp udp_process ; jump to udp handler +: +unknown_protocol: + sec ; unknown protocol + rts + + +; verify that header contains what we expect +verifyheader: + lda ip_inp + ip_ver_ihl ; IPv4 and no IP options + cmp #$45 + bne @badpacket + +; lda ip_inp + ip_tos ; ignore ToS + + lda ip_inp + ip_len + 1 ; ip + 14 bytes ethernet header + clc + adc #14 + sta len + lda ip_inp + ip_len + adc #0 + sta len + 1 + + lda eth_inp_len ; check if advertised length is shorter + sec ; than actual length + sbc len + lda eth_inp_len + 1 + sbc len + 1 + bmi @badpacket + + lda ip_inp + ip_frag ; check for fragmentation + beq :+ + cmp #$40 + bne @badpacket +: lda ip_inp + ip_frag + 1 + bne @badpacket + + ldax #ip_inp ; verify checksum + stax ip_cksum_ptr + ldax #20 + jsr ip_calc_cksum + cmp #0 + bne @badpacket + cpx #0 + bne @badpacket + + clc + rts +@badpacket: + inc bad_header + bne :+ + inc bad_header + 1 +: sec + rts + + +; check that this packet was addressed to us +checkaddr: + lda #0 + sta ip_broadcast + lda ip_inp + ip_dest ; compare ip address + cmp cfg_ip + bne @broadcast + lda ip_inp + ip_dest + 1 + cmp cfg_ip + 1 + bne @broadcast + lda ip_inp + ip_dest + 2 + cmp cfg_ip + 2 + bne @broadcast + lda ip_inp + ip_dest + 3 + cmp cfg_ip + 3 + bne @broadcast +@ok: clc + rts +@broadcast: + inc ip_broadcast + lda ip_inp + ip_dest ; check for broadcast + and ip_inp + ip_dest + 1 + and ip_inp + ip_dest + 2 + and ip_inp + ip_dest + 3 + cmp #$ff + beq @ok + inc bad_addr + bne :+ + inc bad_addr + 1 +: sec + rts + + ; create an IP header (with all the appropriate flags and common fields set) inside an ; ethernet frame ;inputs: ; eth_outp: should point to a buffer in which the ethernet frame is being built ;outputs: ; eth_outp: contains an IP header with version, TTL, flags, src address & IP header -; checksum fields set. -ip_create_packet: - lda #$45 ; set IP version and header length - sta ip_outp + ip_ver_ihl - - lda #0 ; set type of service - sta ip_outp + ip_tos - - ; skip length - - ; skip ID - - lda #$40 ; don't fragment - or should we not care? - sta ip_outp + ip_frag - lda #0 - sta ip_outp + ip_frag + 1 - - lda #$40 ; set time to live - sta ip_outp + ip_ttl - - ; skip protocol - - lda #0 ; clear checksum - sta ip_outp + ip_header_cksum - sta ip_outp + ip_header_cksum + 1 - - ldx #3 ; copy source address -: lda cfg_ip,x - sta ip_outp + ip_src,x - dex - bpl :- - - ; skip destination address - - rts - - +; checksum fields set. +ip_create_packet: + lda #$45 ; set IP version and header length + sta ip_outp + ip_ver_ihl + + lda #0 ; set type of service + sta ip_outp + ip_tos + + ; skip length + + ; skip ID + + lda #$40 ; don't fragment - or should we not care? + sta ip_outp + ip_frag + lda #0 + sta ip_outp + ip_frag + 1 + + lda #$40 ; set time to live + sta ip_outp + ip_ttl + + ; skip protocol + + lda #0 ; clear checksum + sta ip_outp + ip_header_cksum + sta ip_outp + ip_header_cksum + 1 + + ldx #3 ; copy source address +: lda cfg_ip,x + sta ip_outp + ip_src,x + dex + bpl :- + + ; skip destination address + + rts + + ; send an IP packet ;inputs ; eth_outp: should point to an ethernet frame that has an IP header created (by -; calling ip_create_packet) -; ip_len: should contain length of IP packet (header + data) -; ip_id: should contain an ID that is unique for each packet -; ip_protocol: should contain protocol ID +; calling ip_create_packet) +; ip_len: should contain length of IP packet (header + data) +; ip_id: should contain an ID that is unique for each packet +; ip_protocol: should contain protocol ID ; ip_dest: should contain the destination IP address ;outputs: ; eth_outp: ethernet frame updated with correct IP header, then sent out over ; the wire -; carry flag - set on any error, clear if OK -ip_send: - ldx #3 ; get mac addr from ip -: lda ip_outp + ip_dest,x - sta arp_ip,x - dex - bpl :- - - jsr arp_lookup - bcc :+ - rts ; packet buffer nuked, fail -: - ldax #ip_outp ; calculate ip header checksum - stax ip_cksum_ptr - ldax #20 - jsr ip_calc_cksum - stax ip_outp + ip_header_cksum - - ldx #5 -: lda arp_mac,x ; copy destination mac address - sta eth_outp + eth_dest,x - lda cfg_mac,x ; copy my mac address - sta eth_outp + eth_src,x - dex - bpl :- - - lda #eth_proto_ip ; set type to IP - jsr eth_set_proto - - lda ip_outp + ip_len + 1 ; set packet length - lsr - bcc @dontpad - - rol ; pad with 0 - ;clc - adc #ip_outp - sta copy_src + 1 - ldy #0 - tya - sta (copy_src),y - - sec ; round up to even number -@dontpad: - lda ip_outp + ip_len + 1 - adc #eth_data - sta eth_outp_len - lda ip_outp + ip_len - adc #0 - sta eth_outp_len + 1 - - ;jsr dbg_dump_ip_header - - jmp eth_tx ; send packet and return status - - +; carry flag - set on any error, clear if OK +ip_send: + ldx #3 ; get mac addr from ip +: lda ip_outp + ip_dest,x + sta arp_ip,x + dex + bpl :- + + jsr arp_lookup + bcc :+ + rts ; packet buffer nuked, fail +: + ldax #ip_outp ; calculate ip header checksum + stax ip_cksum_ptr + ldax #20 + jsr ip_calc_cksum + stax ip_outp + ip_header_cksum + + ldx #5 +: lda arp_mac,x ; copy destination mac address + sta eth_outp + eth_dest,x + lda cfg_mac,x ; copy my mac address + sta eth_outp + eth_src,x + dex + bpl :- + + lda #eth_proto_ip ; set type to IP + jsr eth_set_proto + + lda ip_outp + ip_len + 1 ; set packet length + lsr + bcc @dontpad + + rol ; pad with 0 + ;clc + adc #ip_outp + sta copy_src + 1 + ldy #0 + tya + sta (copy_src),y + + sec ; round up to even number +@dontpad: + lda ip_outp + ip_len + 1 + adc #eth_data + sta eth_outp_len + lda ip_outp + ip_len + adc #0 + sta eth_outp_len + 1 + + ;jsr dbg_dump_ip_header + + jmp eth_tx ; send packet and return status + + ; calculate checksum for a buffer according to the standard IP checksum algorithm ; David Schmidt discovered errors in the original ip65 implementation, and he replaced ; this with an implementation from the contiki project (http://www.sics.se/contiki/) @@ -368,11 +368,11 @@ ip_send: ; ip_cksum_ptr: points at buffer to be checksummed ; AX: length of buffer to be checksumed ;outputs: -; AX: checkum of buffer -ip_calc_cksum: - sta ip_cksum_len ; save length - stx ip_cksum_len + 1 - +; AX: checkum of buffer +ip_calc_cksum: + sta ip_cksum_len ; save length + stx ip_cksum_len + 1 + lda #0 sta cksum sta cksum+1 @@ -462,3 +462,24 @@ chksum_endloop: eor #$ff rts + + + +;-- LICENSE FOR ip.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/ip65.s b/client/ip65/ip65.s index 1341ecd..0f4540b 100644 --- a/client/ip65/ip65.s +++ b/client/ip65/ip65.s @@ -1,50 +1,50 @@ -; ip65 main routines - -.include "../inc/common.i" +; ip65 main routines + +.include "../inc/common.i" .ifndef KPR_API_VERSION_NUMBER .define EQU = .include "../inc/kipper_constants.i" .endif - - .export ip65_init - .export ip65_process - .export ip65_random_word - .export ip65_ctr - .export ip65_ctr_arp + + .export ip65_init + .export ip65_process + .export ip65_random_word + .export ip65_ctr + .export ip65_ctr_arp .export ip65_ctr_ip .export ip65_error - + .import cfg_init - - .import eth_init - .import timer_init - .import arp_init - .import ip_init + + .import eth_init + .import timer_init + .import arp_init + .import ip_init .import timer_read - - .import eth_inp - .import eth_outp - .import eth_rx - - .import ip_process - .import arp_process - - .importzp eth_proto_arp - - .export ip65_random_word - - .bss - -ip65_ctr: .res 1 ; incremented for every incoming packet -ip65_ctr_arp: .res 1 ; incremented for every incoming arp packet -ip65_ctr_ip: .res 1 ; incremented for every incoming ip packet - + .import eth_inp + .import eth_outp + .import eth_rx + + .import ip_process + .import arp_process + + .importzp eth_proto_arp + + .export ip65_random_word + + .bss + + +ip65_ctr: .res 1 ; incremented for every incoming packet +ip65_ctr_arp: .res 1 ; incremented for every incoming arp packet +ip65_ctr_ip: .res 1 ; incremented for every incoming ip packet + ip65_error: .res 1 ;last error code - - .code + + .code ;generate a 'random' 16 bit word ;entropy comes from the last ethernet frame, counters, and timer @@ -68,30 +68,30 @@ ip65_random_word: adc ip65_ctr eor ip65_ctr_ip rts - + ; initialise the IP stack ; this calls the individual protocol & driver initialisations, so this is ; the only *_init routine that must be called by a user application, ; except for dhcp_init which must also be called if the application ; is using dhcp rather than hardcoded ip configuration ; inputs: none -; outputs: none +; outputs: none ip65_init: - jsr cfg_init ;copy default values (including MAC address) to RAM + jsr cfg_init ;copy default values (including MAC address) to RAM jsr eth_init ; initialize ethernet driver - + bcc @ok lda #KPR_ERROR_DEVICE_FAILURE sta ip65_error rts -@ok: - jsr timer_init ; initialize timer - jsr arp_init ; initialize arp - jsr ip_init ; initialize ip, icmp, udp, and tcp +@ok: + jsr timer_init ; initialize timer + jsr arp_init ; initialize arp + jsr ip_init ; initialize ip, icmp, udp, and tcp clc - rts - - + rts + + ;main ip polling loop ;this routine should be periodically called by an application at any time ;that an inbound packet needs to be handled. @@ -101,26 +101,47 @@ ip65_init: ;outputs: carry flag set if no packet was waiting, or packet handling caused error. ; since the inbound packet may trigger generation of an outbound, eth_outp ; and eth_outp_len may be overwriiten. -ip65_process: - jsr eth_rx ; check for incoming packets - bcs @done - - lda eth_inp + 12 ; type should be 08xx - cmp #8 - bne @done - - lda eth_inp + 13 -; cmp #eth_proto_ip ; ip = 00 - beq @ip - cmp #eth_proto_arp ; arp = 06 - beq @arp -@done: - rts - -@arp: - inc ip65_ctr_arp - jmp arp_process - -@ip: - inc ip65_ctr_ip - jmp ip_process +ip65_process: + jsr eth_rx ; check for incoming packets + bcs @done + + lda eth_inp + 12 ; type should be 08xx + cmp #8 + bne @done + + lda eth_inp + 13 +; cmp #eth_proto_ip ; ip = 00 + beq @ip + cmp #eth_proto_arp ; arp = 06 + beq @arp +@done: + rts + +@arp: + inc ip65_ctr_arp + jmp arp_process + +@ip: + inc ip65_ctr_ip + jmp ip_process + + + +;-- LICENSE FOR ip65.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/output_buffer.s b/client/ip65/output_buffer.s index e0ddb87..17e100b 100644 --- a/client/ip65/output_buffer.s +++ b/client/ip65/output_buffer.s @@ -4,4 +4,24 @@ ;you need to be careful if using this that you don't call a function that also uses it. ;if this is reserved for higher level protocols, the likelyhood of collision is low. .export output_buffer -output_buffer: .res 520 \ No newline at end of file +output_buffer: .res 520 + + +;-- LICENSE FOR output_buffer.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/parser.s b/client/ip65/parser.s index 14ede76..355926f 100644 --- a/client/ip65/parser.s +++ b/client/ip65/parser.s @@ -81,3 +81,24 @@ parser_skip_next: stax current_string_ptr sec rts + + + +;-- LICENSE FOR parser.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/printf.s b/client/ip65/printf.s index bef24c2..63e4a60 100644 --- a/client/ip65/printf.s +++ b/client/ip65/printf.s @@ -1,33 +1,33 @@ -.include "../inc/common.i" - - .export console_printf - - - .import console_out - .import console_strout - - - .segment "IP65ZP" : zeropage - -strptr: .res 2 -argptr: .res 2 -valptr: .res 2 - - - .bss - -ysave: .res 1 -arg: .res 1 -fieldwidth: .res 1 -fieldwcnt: .res 1 -leadzero: .res 1 -argtemp: .res 1 -int: .res 2 -num: .res 5 -ext: .res 2 - - - .code +.include "../inc/common.i" + + .export console_printf + + + .import console_out + .import console_strout + + + .segment "IP65ZP" : zeropage + +strptr: .res 2 +argptr: .res 2 +valptr: .res 2 + + + .bss + +ysave: .res 1 +arg: .res 1 +fieldwidth: .res 1 +fieldwcnt: .res 1 +leadzero: .res 1 +argtemp: .res 1 +int: .res 2 +num: .res 5 +ext: .res 2 + + + .code ;print a string to console, with (some) standard printf % codes converted ;inputs: AX = pointer to 'argument list' @@ -41,367 +41,388 @@ ext: .res 2 ; %d: decimal number (arguement interpreted as 16 bit number) ; %x: hex number (arguement interpreted as 16 bit number) ; %c: char (arguement interpreted as pointer to single ASCII char) -;"field width" modifiers are also supported, e.g "%02x" to print 2 hex digits -console_printf: - stax argptr - ldy #0 - lda (argptr),y - sta strptr - iny - lda (argptr),y - sta strptr + 1 - iny - sty arg - - ldy #0 -@nextchar: - lda (strptr),y - bne :+ - rts -: - cmp #'%' - beq @printarg - - cmp #'\' - beq @printescape - - jsr console_out - -@next: - iny - bne @nextchar - - inc strptr + 1 - jmp @nextchar - -@printescape: - iny - bne :+ - inc strptr + 1 -: lda (strptr),y - ldx #esc_count - 1 -: cmp esc_code,x - beq @escmatch - dex - bpl :- - bmi @next -@escmatch: - lda esc_char,x - jsr console_out - jmp @next - -@printarg: - lda #0 - sta fieldwidth - sta leadzero - lda #$ff - sta fieldwcnt -@argnext: - iny - bne :+ - inc strptr + 1 -: - tya - pha - - lda (strptr),y - - cmp #'0' ; check for field width - bcc @notdigit - cmp #'9'+1 - bcs @notdigit - and #$0f - bne :+ ; check for leading 0 - inc fieldwcnt - bne :+ - lda #$80 - sta leadzero - pla - tay - jmp @argnext -: - pha ; multiply old value by 10 - asl fieldwidth - lda fieldwidth - asl - asl - clc - adc fieldwidth - sta fieldwidth - pla - clc ; add new value - adc fieldwidth - sta fieldwidth - pla - tay - jmp @argnext - -@notdigit: - cmp #'s' - beq @argstr - - cmp #'d' - beq @argint - - cmp #'x' - beq @arghex - - cmp #'c' - beq @argchar - -@argdone: - pla - tay - jmp @next - -@argstr: - jsr @argax - jsr console_strout - - jmp @argdone - -@argint: - jsr @argax - stax valptr - jsr @valax - jsr printint - - jmp @argdone - -@arghex: - jsr @argax - stax valptr - jsr @valax - jsr printhex - - jmp @argdone - -@argchar: - jsr @argax - stax valptr - ldy #0 - lda (valptr),y - jsr console_out - - jmp @argdone - -@argax: - ldy arg - lda (argptr),y - pha - iny - lda (argptr),y - tax - iny - sty arg - pla - rts - -@valax: - ldy #0 - lda (valptr),y - pha - iny - lda (valptr),y - tax - pla - rts - -@printx: - txa - lsr - lsr - lsr - lsr - tay - lda hex2asc,y - jsr console_out - txa - and #$0f - tay - lda hex2asc,y - jmp console_out - - -; print 16-bit hexadecimal number -printhex: - tay - and #$0f - sta num + 3 - tya - lsr - lsr - lsr - lsr - sta num + 2 - - txa - and #$0f - sta num + 1 - txa - lsr - lsr - lsr - lsr - sta num - - lda #4 - sec - sbc fieldwidth - tax - bpl :+ - jsr printlong -: - cpx #4 - beq @nowidth - -@printlead: - lda num,x - bne @printrest - lda #' ' - bit leadzero - bpl :+ - lda #'0' -: jsr console_out - inx - cpx #3 - bne @printlead - -@nowidth: - ldx #0 -: lda num,x - bne @printrest - inx - cpx #4 - bne :- - lda #'0' - jsr console_out - rts - -@printrest: - lda num,x - tay - lda hex2asc,y - jsr console_out - inx - cpx #4 - bne @printrest - rts - - -printlong: - lda #' ' - bit leadzero - bpl :+ - lda #'0' -: jsr console_out - inx - bne :- - rts - - -; print a 16-bit integer -printint: - stax int - - ldx #4 -@next: - lda #0 - sta num,x - jsr div10 - lda ext - sta num,x - dex - bpl @next - - lda fieldwidth - beq @nowidth - lda #5 - sec - sbc fieldwidth - tax - bpl :+ - jsr printlong -: -@printlead: - lda num,x - bne @print - - lda #' ' - bit leadzero - bpl :+ - lda #'0' -: jsr console_out - inx - cpx #5 - bne @printlead - beq @printzero - -@nowidth: - inx - cpx #5 - beq @printzero - lda num,x - beq @nowidth - -@print: - clc - adc #'0' - jsr console_out - inx - cpx #5 - beq @done -@printall: - lda num,x - jmp @print - -@done: - rts - -@printzero: - lda #'0' - jmp console_out - - -; 16/16-bit division, from the fridge -; int/aux -> int, remainder in ext -div10: - lda #0 - sta ext+1 - ldy #$10 -@dloop: - asl int - rol int+1 - rol - rol ext+1 - pha - cmp #10 - lda ext+1 - sbc #0 ; is this a nop? - bcc @div2 - sta ext+1 - pla - sbc #10 - pha - inc int -@div2: - pla - dey - bne @dloop - sta ext - rts - - - .rodata - -msg_unimplemented: - .byte "",0 - -hex2asc: - .byte "0123456789abcdef" - -esc_code: - .byte "eabfnrt", '\' -esc_count = * - esc_code -esc_char: - .byte 27, 7, 8, 12, 10, 13, 9, '\' +;"field width" modifiers are also supported, e.g "%02x" to print 2 hex digits +console_printf: + stax argptr + ldy #0 + lda (argptr),y + sta strptr + iny + lda (argptr),y + sta strptr + 1 + iny + sty arg + + ldy #0 +@nextchar: + lda (strptr),y + bne :+ + rts +: + cmp #'%' + beq @printarg + + cmp #'\' + beq @printescape + + jsr console_out + +@next: + iny + bne @nextchar + + inc strptr + 1 + jmp @nextchar + +@printescape: + iny + bne :+ + inc strptr + 1 +: lda (strptr),y + ldx #esc_count - 1 +: cmp esc_code,x + beq @escmatch + dex + bpl :- + bmi @next +@escmatch: + lda esc_char,x + jsr console_out + jmp @next + +@printarg: + lda #0 + sta fieldwidth + sta leadzero + lda #$ff + sta fieldwcnt +@argnext: + iny + bne :+ + inc strptr + 1 +: + tya + pha + + lda (strptr),y + + cmp #'0' ; check for field width + bcc @notdigit + cmp #'9'+1 + bcs @notdigit + and #$0f + bne :+ ; check for leading 0 + inc fieldwcnt + bne :+ + lda #$80 + sta leadzero + pla + tay + jmp @argnext +: + pha ; multiply old value by 10 + asl fieldwidth + lda fieldwidth + asl + asl + clc + adc fieldwidth + sta fieldwidth + pla + clc ; add new value + adc fieldwidth + sta fieldwidth + pla + tay + jmp @argnext + +@notdigit: + cmp #'s' + beq @argstr + + cmp #'d' + beq @argint + + cmp #'x' + beq @arghex + + cmp #'c' + beq @argchar + +@argdone: + pla + tay + jmp @next + +@argstr: + jsr @argax + jsr console_strout + + jmp @argdone + +@argint: + jsr @argax + stax valptr + jsr @valax + jsr printint + + jmp @argdone + +@arghex: + jsr @argax + stax valptr + jsr @valax + jsr printhex + + jmp @argdone + +@argchar: + jsr @argax + stax valptr + ldy #0 + lda (valptr),y + jsr console_out + + jmp @argdone + +@argax: + ldy arg + lda (argptr),y + pha + iny + lda (argptr),y + tax + iny + sty arg + pla + rts + +@valax: + ldy #0 + lda (valptr),y + pha + iny + lda (valptr),y + tax + pla + rts + +@printx: + txa + lsr + lsr + lsr + lsr + tay + lda hex2asc,y + jsr console_out + txa + and #$0f + tay + lda hex2asc,y + jmp console_out + + +; print 16-bit hexadecimal number +printhex: + tay + and #$0f + sta num + 3 + tya + lsr + lsr + lsr + lsr + sta num + 2 + + txa + and #$0f + sta num + 1 + txa + lsr + lsr + lsr + lsr + sta num + + lda #4 + sec + sbc fieldwidth + tax + bpl :+ + jsr printlong +: + cpx #4 + beq @nowidth + +@printlead: + lda num,x + bne @printrest + lda #' ' + bit leadzero + bpl :+ + lda #'0' +: jsr console_out + inx + cpx #3 + bne @printlead + +@nowidth: + ldx #0 +: lda num,x + bne @printrest + inx + cpx #4 + bne :- + lda #'0' + jsr console_out + rts + +@printrest: + lda num,x + tay + lda hex2asc,y + jsr console_out + inx + cpx #4 + bne @printrest + rts + + +printlong: + lda #' ' + bit leadzero + bpl :+ + lda #'0' +: jsr console_out + inx + bne :- + rts + + +; print a 16-bit integer +printint: + stax int + + ldx #4 +@next: + lda #0 + sta num,x + jsr div10 + lda ext + sta num,x + dex + bpl @next + + lda fieldwidth + beq @nowidth + lda #5 + sec + sbc fieldwidth + tax + bpl :+ + jsr printlong +: +@printlead: + lda num,x + bne @print + + lda #' ' + bit leadzero + bpl :+ + lda #'0' +: jsr console_out + inx + cpx #5 + bne @printlead + beq @printzero + +@nowidth: + inx + cpx #5 + beq @printzero + lda num,x + beq @nowidth + +@print: + clc + adc #'0' + jsr console_out + inx + cpx #5 + beq @done +@printall: + lda num,x + jmp @print + +@done: + rts + +@printzero: + lda #'0' + jmp console_out + + +; 16/16-bit division, from the fridge +; int/aux -> int, remainder in ext +div10: + lda #0 + sta ext+1 + ldy #$10 +@dloop: + asl int + rol int+1 + rol + rol ext+1 + pha + cmp #10 + lda ext+1 + sbc #0 ; is this a nop? + bcc @div2 + sta ext+1 + pla + sbc #10 + pha + inc int +@div2: + pla + dey + bne @dloop + sta ext + rts + + + .rodata + +msg_unimplemented: + .byte "",0 + +hex2asc: + .byte "0123456789abcdef" + +esc_code: + .byte "eabfnrt", '\' +esc_count = * - esc_code +esc_char: + .byte 27, 7, 8, 12, 10, 13, 9, '\' + + + +;-- LICENSE FOR printf.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/sntp.s b/client/ip65/sntp.s index d06f47f..948f23d 100644 --- a/client/ip65/sntp.s +++ b/client/ip65/sntp.s @@ -187,4 +187,24 @@ sntp_in: inc sntp_break_polling_loop lda #sntp_completed sta sntp_state - rts \ No newline at end of file + rts + + +;-- LICENSE FOR sntp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/string_utils.s b/client/ip65/string_utils.s index ebcf875..9136a1a 100644 --- a/client/ip65/string_utils.s +++ b/client/ip65/string_utils.s @@ -1,6 +1,8 @@ ;text file parsing routines .export parse_integer +.export parse_hex_digits + .importzp copy_dest .import mul_8_16 @@ -12,7 +14,8 @@ target_string=copy_dest .include "../inc/common.i" .bss -int_value: .res 2 +temp_value: .res 2 + .code ;parses a string, returns integer (up to 16 bits) @@ -22,8 +25,8 @@ parse_integer: stax target_string lda #0 - sta int_value - sta int_value+1 + sta temp_value + sta temp_value+1 tay @parse_int: lda (target_string),y @@ -32,24 +35,80 @@ parse_integer: cmp #$39 bcs @end_of_int ;any non-decimal char should be treated as end of integer - ldax int_value + ldax temp_value stax acc16 lda #10 jsr mul_8_16 ldax acc16 - stax int_value + stax temp_value lda (target_string),y sec sbc #'0' clc - adc int_value - sta int_value + adc temp_value + sta temp_value bcc @no_rollover - inc int_value+1 + inc temp_value+1 @no_rollover: iny bne @parse_int @end_of_int: - ldax int_value + ldax temp_value clc rts + + +parse_hex_digits: +;parses 2 hex digits, returns a byte +;inputs: X contains high nibble char, A contains low nibble char +;outputs: A contains byte + pha + txa + jsr parse_1_digit + asl + asl + asl + asl + sta temp_value + + pla + jsr parse_1_digit + clc + adc temp_value + rts + +parse_1_digit: + cmp #$3A + + bcs @not_digit + sec + sbc #$30 + rts +@not_digit: + ora #$20 ;make lower case + sec + sbc #'a'-10 + rts + + + + + +;-- LICENSE FOR string_utils.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/tcp.s b/client/ip65/tcp.s index d65846b..ec2103d 100644 --- a/client/ip65/tcp.s +++ b/client/ip65/tcp.s @@ -303,6 +303,16 @@ tcp_close: ;outputs: ; carry flag is set if an error occured, clear otherwise + + lda tcp_state + cmp #tcp_cxn_state_established + beq :+ +@connection_closed: + lda #tcp_cxn_state_closed + sta tcp_state + clc + rts +: ;increment the expected sequence number for the SYN we are about to send ldax #tcp_connect_expected_ack_number stax acc32 @@ -356,9 +366,6 @@ tcp_close: cmp #MAX_TCP_PACKETS_SENT-1 bpl @too_many_messages_sent jmp @send_fin_loop -@connection_closed: - clc - rts @too_many_messages_sent: @failed: lda #tcp_cxn_state_closed @@ -1030,3 +1037,24 @@ tcp_process: jmp tcp_send_packet + + + +;-- LICENSE FOR tcp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/telnet.s b/client/ip65/telnet.s index e11c2bf..8d5ca95 100644 --- a/client/ip65/telnet.s +++ b/client/ip65/telnet.s @@ -360,4 +360,24 @@ buffer_length: .res 2 iac_response_buffer: .res 64 iac_response_buffer_length: .res 1 -scratch_buffer : .res 40 \ No newline at end of file +scratch_buffer : .res 40 + + +;-- LICENSE FOR telnet.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/tftp.s b/client/ip65/tftp.s index 15fdfe9..3bd3d41 100644 --- a/client/ip65/tftp.s +++ b/client/ip65/tftp.s @@ -578,4 +578,24 @@ tftp_callback_vector: jmp copy_tftp_block_to_ram ;vector for action to take when a data block received (default is to store block in RAM) -tftp_callback_address_set: .byte 0 \ No newline at end of file +tftp_callback_address_set: .byte 0 + + +;-- LICENSE FOR tftp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/timer.s b/client/ip65/timer.s index 5381319..d767b9f 100644 --- a/client/ip65/timer.s +++ b/client/ip65/timer.s @@ -1,38 +1,59 @@ -; timer routines -; -; the timer should be a 16-bit counter that's incremented by about -; 1000 units per second. it doesn't have to be particularly accurate, -; if you're working with e.g. a 60 Hz VBLANK IRQ, adding 17 to the -; counter every frame would be just fine. +; timer routines ; -; this is generic timer routines, machine specific code goes in drivers/timer.s - .include "../inc/common.i" - - - .export timer_timeout - .import timer_read - - .bss - -time: .res 2 - - - .code - +; the timer should be a 16-bit counter that's incremented by about +; 1000 units per second. it doesn't have to be particularly accurate, +; if you're working with e.g. a 60 Hz VBLANK IRQ, adding 17 to the +; counter every frame would be just fine. +; +; this is generic timer routines, machine specific code goes in drivers/timer.s + .include "../inc/common.i" + + + .export timer_timeout + .import timer_read + + .bss + +time: .res 2 + + + .code + ;check if specified period of time has passed yet ;inputs: AX - maximum number of milliseconds we are willing to wait for -;outputs: carry flag set if timeout occured, clear otherwise -timer_timeout: +;outputs: carry flag set if timeout occured, clear otherwise +timer_timeout: pha txa pha jsr timer_read stax time pla - tax - pla - sec ; subtract current value - sbc time - txa - sbc time + 1 - rts ; clc = timeout, sec = no timeout + tax + pla + sec ; subtract current value + sbc time + txa + sbc time + 1 + rts ; clc = timeout, sec = no timeout + + + +;-- LICENSE FOR timer.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/udp.s b/client/ip65/udp.s index 1e077f4..121eeb3 100644 --- a/client/ip65/udp.s +++ b/client/ip65/udp.s @@ -1,115 +1,115 @@ ;UDP (user datagram protocol) functions -.include "../inc/common.i" +.include "../inc/common.i" .ifndef KPR_API_VERSION_NUMBER .define EQU = .include "../inc/kipper_constants.i" .endif - - ;.import dbg_dump_udp_header - + + ;.import dbg_dump_udp_header + .import ip65_error - - .export udp_init - .export udp_process - .export udp_add_listener - .export udp_remove_listener - .export udp_send - - .export udp_callback - - .export udp_inp - .export udp_outp - - .exportzp udp_src_port - .exportzp udp_dest_port - .exportzp udp_len - .exportzp udp_cksum - .exportzp udp_data - - .export udp_send_dest - .export udp_send_src_port - .export udp_send_dest_port - .export udp_send_len - - - .import ip_calc_cksum - .import ip_send - .import ip_create_packet - .import ip_inp - .import ip_outp - .importzp ip_cksum_ptr - .importzp ip_header_cksum - .importzp ip_src - .importzp ip_dest - .importzp ip_data - .importzp ip_proto - .importzp ip_proto_udp - .importzp ip_id - .importzp ip_len - - .import copymem - .importzp copy_src - .importzp copy_dest - - .import cfg_ip + + .export udp_init + .export udp_process + .export udp_add_listener + .export udp_remove_listener + .export udp_send + + .export udp_callback + + .export udp_inp + .export udp_outp + + .exportzp udp_src_port + .exportzp udp_dest_port + .exportzp udp_len + .exportzp udp_cksum + .exportzp udp_data + + .export udp_send_dest + .export udp_send_src_port + .export udp_send_dest_port + .export udp_send_len + + + .import ip_calc_cksum + .import ip_send + .import ip_create_packet + .import ip_inp + .import ip_outp + .importzp ip_cksum_ptr + .importzp ip_header_cksum + .importzp ip_src + .importzp ip_dest + .importzp ip_data + .importzp ip_proto + .importzp ip_proto_udp + .importzp ip_id + .importzp ip_len + + .import copymem + .importzp copy_src + .importzp copy_dest + + .import cfg_ip .data udp_cbtmp: jmp $ffff ; temporary vector - gets filled in later - - - .bss - -; argument for udp_add_listener -udp_callback: .res 2 ;vector to routine to be called when a udp packet arrives - -; arguments for udp_send -udp_send_dest: .res 4 ;set to ip address that udp packet will be sent to -udp_send_src_port: .res 2 ;set to port that udp packet will be sent from -udp_send_dest_port: .res 2 ;set to port that udp packet will be sent to -udp_send_len: .res 2 ;set to length of data to be sent in udp packet (excluding ethernet,ip & udp headers) - -; udp listener callbacks -udp_cbmax = 4 -udp_cbveclo: .res udp_cbmax ; table of listener vectors (lsb) -udp_cbvechi: .res udp_cbmax ; table of listener vectors (msb) -udp_cbportlo: .res udp_cbmax ; table of ports (lsb) -udp_cbporthi: .res udp_cbmax ; table of ports (msb) -udp_cbcount: .res 1 ; number of active listeners - -; udp packet offsets -udp_inp = ip_inp + ip_data ;pointer to udp packet inside inbound ethernet frame -udp_outp = ip_outp + ip_data ;pointer to udp packet inside outbound ethernet frame -udp_src_port = 0 ;offset of source port field in udp packet -udp_dest_port = 2 ;offset of destination port field in udp packet -udp_len = 4 ;offset of length field in udp packet -udp_cksum = 6 ;offset of checksum field in udp packet -udp_data = 8 ;offset of data in udp packet - -; virtual header -udp_vh = udp_outp - 12 -udp_vh_src = 0 -udp_vh_dest = 4 -udp_vh_zero = 8 -udp_vh_proto = 9 -udp_vh_len = 10 - - -; temp for port comparison -port: .res 2 - - - .code - + + + .bss + +; argument for udp_add_listener +udp_callback: .res 2 ;vector to routine to be called when a udp packet arrives + +; arguments for udp_send +udp_send_dest: .res 4 ;set to ip address that udp packet will be sent to +udp_send_src_port: .res 2 ;set to port that udp packet will be sent from +udp_send_dest_port: .res 2 ;set to port that udp packet will be sent to +udp_send_len: .res 2 ;set to length of data to be sent in udp packet (excluding ethernet,ip & udp headers) + +; udp listener callbacks +udp_cbmax = 4 +udp_cbveclo: .res udp_cbmax ; table of listener vectors (lsb) +udp_cbvechi: .res udp_cbmax ; table of listener vectors (msb) +udp_cbportlo: .res udp_cbmax ; table of ports (lsb) +udp_cbporthi: .res udp_cbmax ; table of ports (msb) +udp_cbcount: .res 1 ; number of active listeners + +; udp packet offsets +udp_inp = ip_inp + ip_data ;pointer to udp packet inside inbound ethernet frame +udp_outp = ip_outp + ip_data ;pointer to udp packet inside outbound ethernet frame +udp_src_port = 0 ;offset of source port field in udp packet +udp_dest_port = 2 ;offset of destination port field in udp packet +udp_len = 4 ;offset of length field in udp packet +udp_cksum = 6 ;offset of checksum field in udp packet +udp_data = 8 ;offset of data in udp packet + +; virtual header +udp_vh = udp_outp - 12 +udp_vh_src = 0 +udp_vh_dest = 4 +udp_vh_zero = 8 +udp_vh_proto = 9 +udp_vh_len = 10 + + +; temp for port comparison +port: .res 2 + + + .code + ; initialize udp ; inputs: none -; outputs: none -udp_init: - lda #0 - sta udp_cbcount - rts - - +; outputs: none +udp_init: + lda #0 + sta udp_cbcount + rts + + ;process incoming udp packet ;inputs: ; eth_inp: should contain an ethernet frame encapsulating an inbound udp packet @@ -118,136 +118,136 @@ udp_init: ; was found) ; carry flag clear if no error ; if handler was found, an outbound message may be created, overwriting eth_outp - -udp_process: - lda udp_cbcount ; any installed udp listeners? - beq @drop - - tax ; check ports - dex -@checkport: - lda udp_cbportlo,x - cmp udp_inp + udp_dest_port + 1 - bne :+ - lda udp_cbporthi,x - cmp udp_inp + udp_dest_port - beq @handle -: dex - bpl @checkport - + +udp_process: + lda udp_cbcount ; any installed udp listeners? + beq @drop + + tax ; check ports + dex +@checkport: + lda udp_cbportlo,x + cmp udp_inp + udp_dest_port + 1 + bne :+ + lda udp_cbporthi,x + cmp udp_inp + udp_dest_port + beq @handle +: dex + bpl @checkport + @drop: lda #KPR_ERROR_NO_SUCH_LISTENER - sta ip65_error - sec - rts - -@handle: - lda udp_cbveclo,x ; copy vector - sta udp_cbtmp + 1 - lda udp_cbvechi,x - sta udp_cbtmp + 2 - jsr udp_cbtmp ; call listener - clc - rts - - + sta ip65_error + sec + rts + +@handle: + lda udp_cbveclo,x ; copy vector + sta udp_cbtmp + 1 + lda udp_cbvechi,x + sta udp_cbtmp + 2 + jsr udp_cbtmp ; call listener + clc + rts + + ;add a udp listener ;inputs: -; udp_callback: vector to call when udp packet arrives on specified port +; udp_callback: vector to call when udp packet arrives on specified port ; AX: set to udp port to listen on ;outputs: -; carry flag set if too may listeners already installed, clear otherwise -udp_add_listener: - sta port - stx port + 1 - - ldy udp_cbcount ; any listeners at all? - beq @add - cpy #udp_cbmax ; max? - beq @full - ldy #0 -@check: - lda udp_cbportlo,y ; check if port is already handled - cmp port - bne :+ - lda udp_cbporthi,y - cmp port + 1 - beq @busy -: iny - cpy udp_cbcount - bne @check -@add: - inc udp_cbcount ; increase counter - sta udp_cbportlo,y ; add port - txa - sta udp_cbporthi,y ; add port - lda udp_callback ; and vector - sta udp_cbveclo,y - lda udp_callback + 1 - sta udp_cbvechi,y - - clc - rts -@full: +; carry flag set if too may listeners already installed, clear otherwise +udp_add_listener: + sta port + stx port + 1 + + ldy udp_cbcount ; any listeners at all? + beq @add + cpy #udp_cbmax ; max? + beq @full + ldy #0 +@check: + lda udp_cbportlo,y ; check if port is already handled + cmp port + bne :+ + lda udp_cbporthi,y + cmp port + 1 + beq @busy +: iny + cpy udp_cbcount + bne @check +@add: + inc udp_cbcount ; increase counter + sta udp_cbportlo,y ; add port + txa + sta udp_cbporthi,y ; add port + lda udp_callback ; and vector + sta udp_cbveclo,y + lda udp_callback + 1 + sta udp_cbvechi,y + + clc + rts +@full: @busy: lda #KPR_ERROR_LISTENER_NOT_AVAILABLE sta ip65_error - sec - sec - rts - - + sec + sec + rts + + ; remove an udp listener ; inputs: ; AX = port to stop listening on ; outputs: -; carry flag clear of handler found and removed +; carry flag clear of handler found and removed ; carry flag set if handler for specified port not found -udp_remove_listener: - sta port - stx port + 1 - - ldy udp_cbcount ; any listeners installed? +udp_remove_listener: + sta port + stx port + 1 + + ldy udp_cbcount ; any listeners installed? beq @notfound - dey -@check: - lda udp_cbportlo,y ; check if port is handled - cmp port - bne :+ - lda udp_cbporthi,y - cmp port + 1 - beq @remove -: dey - bpl @check -@notfound: - sec - rts -@remove: - tya ; number of listeners below - eor #$ff - clc - adc udp_cbcount - beq @done -@move: - tax ; number of items to move -: lda udp_cbportlo + 1,y ; move ports - sta udp_cbportlo,y - lda udp_cbporthi + 1,y - sta udp_cbporthi,y - lda udp_cbveclo + 1,y ; move vectors - sta udp_cbveclo,y - lda udp_cbvechi + 1,y - sta udp_cbvechi,y - iny - dex - bne :- -@done: - dec udp_cbcount ; decrement counter - clc - rts - - -;send udp packet + dey +@check: + lda udp_cbportlo,y ; check if port is handled + cmp port + bne :+ + lda udp_cbporthi,y + cmp port + 1 + beq @remove +: dey + bpl @check +@notfound: + sec + rts +@remove: + tya ; number of listeners below + eor #$ff + clc + adc udp_cbcount + beq @done +@move: + tax ; number of items to move +: lda udp_cbportlo + 1,y ; move ports + sta udp_cbportlo,y + lda udp_cbporthi + 1,y + sta udp_cbporthi,y + lda udp_cbveclo + 1,y ; move vectors + sta udp_cbveclo,y + lda udp_cbvechi + 1,y + sta udp_cbvechi,y + iny + dex + bne :- +@done: + dec udp_cbcount ; decrement counter + clc + rts + + +;send udp packet ;inputs: ; udp_send_dest: destination ip address (4 bytes) ; udp_send_dest_port: destination port (2 bytes) @@ -255,88 +255,109 @@ udp_remove_listener: ; udp_send_len: length of data to send (exclusive of any headers) ; AX: pointer to buffer containing data to be sent ;outputs: -; carry flag is set if an error occured, clear otherwise -udp_send: - stax copy_src ; copy data to output buffer - ldax #udp_outp + udp_data - stax copy_dest - ldax udp_send_len - jsr copymem - - ldx #3 ; copy virtual header addresses -: lda udp_send_dest,x - sta udp_vh + udp_vh_dest,x ; set virtual header destination - lda cfg_ip,x - sta udp_vh + udp_vh_src,x ; set virtual header source - dex - bpl :- - - lda udp_send_src_port ; copy source port - sta udp_outp + udp_src_port + 1 - lda udp_send_src_port + 1 - sta udp_outp + udp_src_port - - lda udp_send_dest_port ; copy destination port - sta udp_outp + udp_dest_port + 1 - lda udp_send_dest_port + 1 - sta udp_outp + udp_dest_port - - lda #ip_proto_udp - sta udp_vh + udp_vh_proto - - lda #0 ; clear checksum - sta udp_outp + udp_cksum - sta udp_outp + udp_cksum + 1 - sta udp_vh + udp_vh_zero ; clear virtual header zero byte - - ldax #udp_vh ; checksum pointer to virtual header - stax ip_cksum_ptr - - lda udp_send_len ; copy length + 8 - clc - adc #8 - sta udp_outp + udp_len + 1 ; lsb for udp header - sta udp_vh + udp_vh_len + 1 ; lsb for virtual header - tay - lda udp_send_len + 1 - adc #0 - sta udp_outp + udp_len ; msb for udp header - sta udp_vh + udp_vh_len ; msb for virtual header - - tax ; length to A/X - tya - - clc ; add 12 bytes for virtual header - adc #12 - bcc :+ - inx -: - jsr ip_calc_cksum ; calculate checksum - stax udp_outp + udp_cksum - - ldx #3 ; copy addresses -: lda udp_send_dest,x - sta ip_outp + ip_dest,x ; set ip destination address - dex - bpl :- - - jsr ip_create_packet ; create ip packet template - - lda udp_outp + udp_len + 1 ; ip len = udp len + 20 - ldx udp_outp + udp_len - clc - adc #20 - bcc :+ - inx -: sta ip_outp + ip_len + 1 ; set length - stx ip_outp + ip_len - - ldax #$1234 ; set ID - stax ip_outp + ip_id - - lda #ip_proto_udp ; set protocol - sta ip_outp + ip_proto - - ;jsr dbg_dump_udp_header - - jmp ip_send ; send packet, sec on error +; carry flag is set if an error occured, clear otherwise +udp_send: + stax copy_src ; copy data to output buffer + ldax #udp_outp + udp_data + stax copy_dest + ldax udp_send_len + jsr copymem + + ldx #3 ; copy virtual header addresses +: lda udp_send_dest,x + sta udp_vh + udp_vh_dest,x ; set virtual header destination + lda cfg_ip,x + sta udp_vh + udp_vh_src,x ; set virtual header source + dex + bpl :- + + lda udp_send_src_port ; copy source port + sta udp_outp + udp_src_port + 1 + lda udp_send_src_port + 1 + sta udp_outp + udp_src_port + + lda udp_send_dest_port ; copy destination port + sta udp_outp + udp_dest_port + 1 + lda udp_send_dest_port + 1 + sta udp_outp + udp_dest_port + + lda #ip_proto_udp + sta udp_vh + udp_vh_proto + + lda #0 ; clear checksum + sta udp_outp + udp_cksum + sta udp_outp + udp_cksum + 1 + sta udp_vh + udp_vh_zero ; clear virtual header zero byte + + ldax #udp_vh ; checksum pointer to virtual header + stax ip_cksum_ptr + + lda udp_send_len ; copy length + 8 + clc + adc #8 + sta udp_outp + udp_len + 1 ; lsb for udp header + sta udp_vh + udp_vh_len + 1 ; lsb for virtual header + tay + lda udp_send_len + 1 + adc #0 + sta udp_outp + udp_len ; msb for udp header + sta udp_vh + udp_vh_len ; msb for virtual header + + tax ; length to A/X + tya + + clc ; add 12 bytes for virtual header + adc #12 + bcc :+ + inx +: + jsr ip_calc_cksum ; calculate checksum + stax udp_outp + udp_cksum + + ldx #3 ; copy addresses +: lda udp_send_dest,x + sta ip_outp + ip_dest,x ; set ip destination address + dex + bpl :- + + jsr ip_create_packet ; create ip packet template + + lda udp_outp + udp_len + 1 ; ip len = udp len + 20 + ldx udp_outp + udp_len + clc + adc #20 + bcc :+ + inx +: sta ip_outp + ip_len + 1 ; set length + stx ip_outp + ip_len + + ldax #$1234 ; set ID + stax ip_outp + ip_id + + lda #ip_proto_udp ; set protocol + sta ip_outp + ip_proto + + ;jsr dbg_dump_udp_header + + jmp ip_send ; send packet, sec on error + + + +;-- LICENSE FOR udp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Per Olofsson, +; MagerValp@gmail.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Per Olofsson. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/ip65/url.s b/client/ip65/url.s index c3f9eca..66d5b51 100644 --- a/client/ip65/url.s +++ b/client/ip65/url.s @@ -435,4 +435,24 @@ not_end_of_file: slash: .byte "/",0 colon: .byte ":",0 - \ No newline at end of file + + + +;-- LICENSE FOR url.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_cart_api.s b/client/test/test_cart_api.s index df75848..9c3d618 100644 --- a/client/test/test_cart_api.s +++ b/client/test/test_cart_api.s @@ -418,4 +418,24 @@ test_file: .byte "TESTFILE.BIN",0 kipper_signature: - .byte "KIPPER" ; API signature \ No newline at end of file + .byte "KIPPER" ; API signature + + +;-- LICENSE FOR test_cart_api.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_disk_io.s b/client/test/test_disk_io.s index c7c0ee0..28c14f1 100644 --- a/client/test/test_disk_io.s +++ b/client/test/test_disk_io.s @@ -426,3 +426,24 @@ bytes: bytes_to: .byte " BYTES TO $", 0 + + + +;-- LICENSE FOR test_disk_io.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_get_url.s b/client/test/test_get_url.s index ba8bec1..dd6d455 100644 --- a/client/test/test_get_url.s +++ b/client/test/test_get_url.s @@ -129,3 +129,24 @@ press_a_key: .byte "PRESS ANY KEY TO CONTINUE",13,0 .bss dl_buffer_length=8092 dl_buffer: .res dl_buffer_length + + + +;-- LICENSE FOR test_get_url.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_httpd.s b/client/test/test_httpd.s index 7f3e851..561b3e7 100644 --- a/client/test/test_httpd.s +++ b/client/test/test_httpd.s @@ -165,3 +165,24 @@ ok: initializing: .byte "INITIALIZING ",0 + + + +;-- LICENSE FOR test_httpd.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_parse_querystring.s b/client/test/test_parse_querystring.s index 0078c80..47f97c7 100644 --- a/client/test/test_parse_querystring.s +++ b/client/test/test_parse_querystring.s @@ -119,3 +119,24 @@ query_5: query_6: .byte $0d,$0a,0 ;this should also be a gopher path + + + +;-- LICENSE FOR test_parse_querystring.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_parser.s b/client/test/test_parser.s index e697f43..60d756b 100644 --- a/client/test/test_parser.s +++ b/client/test/test_parser.s @@ -213,4 +213,24 @@ atom_file: ;.incbin "atom_test.xml" -.byte 0 \ No newline at end of file +.byte 0 + + +;-- LICENSE FOR test_parser.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_ping.s b/client/test/test_ping.s index 360ab76..3da4806 100644 --- a/client/test/test_ping.s +++ b/client/test/test_ping.s @@ -3,7 +3,7 @@ .include "../inc/net.i" .import exit_to_basic - + .import cfg_get_configuration_ptr .import copymem .importzp copy_src @@ -12,30 +12,30 @@ .import icmp_echo_ip .import icmp_ping - + .import __CODE_LOAD__ .import __CODE_SIZE__ .import __RODATA_SIZE__ .import __DATA_SIZE__ - - .segment "STARTUP" ;this is what gets put at the start of the file on the C64 - - .word basicstub ; load address - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - -.code - + + .segment "STARTUP" ;this is what gets put at the start of the file on the C64 + + .word basicstub ; load address + +basicstub: + .word @nextline + .word 2003 + .byte $9e + .byte <(((init / 1000) .mod 10) + $30) + .byte <(((init / 100 ) .mod 10) + $30) + .byte <(((init / 10 ) .mod 10) + $30) + .byte <(((init ) .mod 10) + $30) + .byte 0 +@nextline: + .word 0 + +.code + init: jsr print_cr init_ip_via_dhcp @@ -65,10 +65,30 @@ init: jmp print_errorcode .rodata -ms: .byte " MS",13,0 +ms: .byte " MS",13,0 pinging: .byte "PINGING ",0 -.bss +.bss block_number: .res 1 block_length: .res 2 buffer1: .res 256 -buffer2: .res 256 \ No newline at end of file +buffer2: .res 256 + + +;-- LICENSE FOR test_ping.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_sntp.s b/client/test/test_sntp.s index 91af263..4281618 100644 --- a/client/test/test_sntp.s +++ b/client/test/test_sntp.s @@ -11,36 +11,36 @@ .import sntp_ip .import sntp_utc_timestamp .import sntp_get_time - + .import __CODE_LOAD__ .import __CODE_SIZE__ .import __RODATA_SIZE__ .import __DATA_SIZE__ - - .segment "STARTUP" ;this is what gets put at the start of the file on the C64 - - .word basicstub ; load address - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - + + .segment "STARTUP" ;this is what gets put at the start of the file on the C64 + + .word basicstub ; load address + +basicstub: + .word @nextline + .word 2003 + .byte $9e + .byte <(((init / 1000) .mod 10) + $30) + .byte <(((init / 100 ) .mod 10) + $30) + .byte <(((init / 10 ) .mod 10) + $30) + .byte <(((init ) .mod 10) + $30) + .byte 0 +@nextline: + .word 0 + .segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 .addr __CODE_LOAD__-$11 ; Start address .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size - jmp init + jmp init + +.code -.code - init: jsr test_vlb @@ -156,8 +156,8 @@ div_32_32: rol quotient+3 dex bpl @loop - rts - .rodata + rts + .rodata test_vlb: ldx #7 @@ -171,7 +171,7 @@ test_vlb: .byte $92 - + time_server_msg: .byte "TIME SERVER : ",0 @@ -192,4 +192,24 @@ dns_error: .byte $02,$30,$00,$00 .byte $05,$00,$00,$00 - \ No newline at end of file + + + +;-- LICENSE FOR test_sntp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/test_tcp.s b/client/test/test_tcp.s index 40b2007..5c2eabd 100644 --- a/client/test/test_tcp.s +++ b/client/test/test_tcp.s @@ -3,7 +3,7 @@ .include "../inc/net.i" .import exit_to_basic - .import ascii_to_native + .import ascii_to_native .import parse_dotted_quad .import dotted_quad_value @@ -20,7 +20,7 @@ .import tcp_send .import tcp_send_data_len - + .import __CODE_LOAD__ .import __CODE_SIZE__ .import __RODATA_SIZE__ @@ -38,27 +38,27 @@ .import mul_8_16 .import sub_16_16 - - .segment "STARTUP" ;this is what gets put at the start of the file on the C64 - - .word basicstub ; load address - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - + + .segment "STARTUP" ;this is what gets put at the start of the file on the C64 + + .word basicstub ; load address + +basicstub: + .word @nextline + .word 2003 + .byte $9e + .byte <(((init / 1000) .mod 10) + $30) + .byte <(((init / 100 ) .mod 10) + $30) + .byte <(((init / 10 ) .mod 10) + $30) + .byte <(((init ) .mod 10) + $30) + .byte 0 +@nextline: + .word 0 + .segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 .addr __CODE_LOAD__-$11 ; Start address .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size - jmp init + jmp init .bss cxn_closed: .res 1 @@ -69,8 +69,8 @@ get_next_byte: lda $ffff rts -.code - +.code + init: @@ -404,7 +404,7 @@ test_add_32_32: dey bpl :- jsr print_cr - rts + rts @@ -565,9 +565,9 @@ test_sub_16_16: .bss temp_ax: .res 2 - - .rodata - + + .rodata + .data number1: @@ -622,4 +622,24 @@ http_get_msg: http_get_msg_end: http_get_length=http_get_msg_end-http_get_msg - \ No newline at end of file + + + +;-- LICENSE FOR test_tcp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/testdns.s b/client/test/testdns.s index ece7a14..b0394bd 100644 --- a/client/test/testdns.s +++ b/client/test/testdns.s @@ -3,49 +3,49 @@ .include "../inc/net.i" .import exit_to_basic - + .import dns_set_hostname .import dns_resolve .import dns_ip .import dns_status .import cfg_get_configuration_ptr - + .import __CODE_LOAD__ .import __CODE_SIZE__ .import __RODATA_SIZE__ .import __DATA_SIZE__ - - .segment "STARTUP" ;this is what gets put at the start of the file on the C64 - - .word basicstub ; load address - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - + + .segment "STARTUP" ;this is what gets put at the start of the file on the C64 + + .word basicstub ; load address + +basicstub: + .word @nextline + .word 2003 + .byte $9e + .byte <(((init / 1000) .mod 10) + $30) + .byte <(((init / 100 ) .mod 10) + $30) + .byte <(((init / 10 ) .mod 10) + $30) + .byte <(((init ) .mod 10) + $30) + .byte 0 +@nextline: + .word 0 + .segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 .addr __CODE_LOAD__-$11 ; Start address .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size - jmp init + jmp init + +.code -.code - init: jsr print_cr jsr print_ip_config init_ip_via_dhcp -; jsr overwrite_with_hardcoded_dns_server +; jsr overwrite_with_hardcoded_dns_server jsr print_ip_config ldax #hostname_1 @@ -95,7 +95,7 @@ do_dns_query: lda dns_status+1 jsr print_hex jsr print_cr - rts + rts overwrite_with_hardcoded_dns_server: ldx #3 @@ -104,12 +104,12 @@ overwrite_with_hardcoded_dns_server: sta cfg_dns,x dex bpl :- - rts + rts - - .rodata - + + .rodata + buffer1: .res 256 hostname_1: @@ -135,3 +135,24 @@ hardcoded_dns_server: ;.byte 64,127,100,12 .byte 205,171,3,65 .byte 69,111,95,106 + + + +;-- LICENSE FOR testdns.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/testdottedquad.s b/client/test/testdottedquad.s index 85530d1..862edef 100644 --- a/client/test/testdottedquad.s +++ b/client/test/testdottedquad.s @@ -3,39 +3,39 @@ .include "../inc/net.i" .import exit_to_basic - + .import parse_dotted_quad .import dotted_quad_value - + .import __CODE_LOAD__ .import __CODE_SIZE__ .import __RODATA_SIZE__ .import __DATA_SIZE__ - - .segment "STARTUP" ;this is what gets put at the start of the file on the C64 - - .word basicstub ; load address - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - + + .segment "STARTUP" ;this is what gets put at the start of the file on the C64 + + .word basicstub ; load address + +basicstub: + .word @nextline + .word 2003 + .byte $9e + .byte <(((init / 1000) .mod 10) + $30) + .byte <(((init / 100 ) .mod 10) + $30) + .byte <(((init / 10 ) .mod 10) + $30) + .byte <(((init ) .mod 10) + $30) + .byte 0 +@nextline: + .word 0 + .segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 .addr __CODE_LOAD__-$11 ; Start address .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size - jmp init + jmp init + +.code -.code - init: jsr print_cr @@ -76,7 +76,7 @@ test_dotted_quad_string: ldax #dotted_quad_value jsr print_dotted_quad jsr print_cr - rts + rts @error: ldax #failed_msg @@ -86,9 +86,9 @@ test_dotted_quad_string: .bss temp_ax: .res 2 - - .rodata - + + .rodata + dotted_quad_1: .byte "1.1.1.1",0 ;should work @@ -111,3 +111,24 @@ dotted_quad_6: dotted_quad_7: .byte "3.4.5.6X",0 ; should fail + + + +;-- LICENSE FOR testdottedquad.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/test/testtftp.s b/client/test/testtftp.s index c324219..2f39252 100644 --- a/client/test/testtftp.s +++ b/client/test/testtftp.s @@ -3,13 +3,13 @@ .include "../inc/net.i" .import exit_to_basic - + .import cfg_get_configuration_ptr .import copymem .importzp copy_src .importzp copy_dest - + .import __CODE_LOAD__ .import __CODE_SIZE__ .import __RODATA_SIZE__ @@ -20,30 +20,30 @@ .import tftp_ip .import tftp_filesize .importzp tftp_filename - - .segment "STARTUP" ;this is what gets put at the start of the file on the C64 - - .word basicstub ; load address - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - + + .segment "STARTUP" ;this is what gets put at the start of the file on the C64 + + .word basicstub ; load address + +basicstub: + .word @nextline + .word 2003 + .byte $9e + .byte <(((init / 1000) .mod 10) + $30) + .byte <(((init / 100 ) .mod 10) + $30) + .byte <(((init / 10 ) .mod 10) + $30) + .byte <(((init ) .mod 10) + $30) + .byte 0 +@nextline: + .word 0 + .segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 .addr __CODE_LOAD__-$11 ; Start address .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size - jmp init + jmp init + +.code -.code - init: jsr print_cr init_ip_via_dhcp @@ -106,15 +106,35 @@ upload_callback: stax block_length jsr copymem ldax block_length - rts + rts .rodata - + test_file: .byte "TESTFILE.BIN",0 basic_file: .byte "CBMBASIC.BIN",0 sending_via_callback: .byte "SENDING VIA CALLBACK...",0 sending_ram: .byte "SENDING RAM...",0 -.bss +.bss block_number: .res 1 block_length: .res 2 buffer1: .res 256 -buffer2: .res 256 \ No newline at end of file +buffer2: .res 256 + + +;-- LICENSE FOR testtftp.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/uthernet/bankswitch_eeprom.s b/client/uthernet/bankswitch_eeprom.s index 6de6b95..9207238 100644 --- a/client/uthernet/bankswitch_eeprom.s +++ b/client/uthernet/bankswitch_eeprom.s @@ -28,3 +28,24 @@ .asciiz "BANK $0D" .segment "C800_E" .asciiz "BANK $0E" + + + +;-- LICENSE FOR bankswitch_eeprom.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/uthernet/c700_rom.s b/client/uthernet/c700_rom.s index 821a94a..c1bc679 100644 --- a/client/uthernet/c700_rom.s +++ b/client/uthernet/c700_rom.s @@ -46,3 +46,24 @@ hello_world: .byte "hello from autostart firmware land!",13,0 + + + +;-- LICENSE FOR c700_rom.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/uthernet/patch_applewin.rb b/client/uthernet/patch_applewin.rb index 40930ec..75007c7 100644 --- a/client/uthernet/patch_applewin.rb +++ b/client/uthernet/patch_applewin.rb @@ -29,4 +29,24 @@ filebytes[c700_rom_offset,c700_rom.length]=c700_rom filebytes[bankswitch_eeprom_offset,bankswitch_eeprom.length]=bankswitch_eeprom filehandle=File.open(patched_applewin_filename,"wb") filehandle<