diff --git a/client/basic/Makefile b/client/basic/Makefile index 6e6ddab..e676dab 100644 --- a/client/basic/Makefile +++ b/client/basic/Makefile @@ -11,11 +11,8 @@ INCFILES=\ ../inc/kipper_constants.i\ ../inc/version.i\ -#IP65LIB=../ip65/ip65.lib IP65LIB=../ip65/ip65_tcp.lib -#IP65TCPLIB=../ip65/ip65_tcp.lib - -C64PROGLIB=../drivers/c64prog.lib +C64RRNETLIB=../drivers/c64rrnet.lib all: ip65 kipperbas.d64 bails.d64 @@ -25,8 +22,8 @@ ip65: %.o: %.s $(INCFILES) $(AS) $(AFLAGS) $< -%.prg: %.o $(IP65LIB) $(C64PROGLIB) $(INCFILES) ../cfg/kipperbas.cfg - $(LD) -m $*.map -vm -C ../cfg/kipperbas.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64PROGLIB) +%.prg: %.o $(IP65LIB) $(C64RRNETLIB) $(INCFILES) ../cfg/kipperbas.cfg + $(LD) -m $*.map -vm -C ../cfg/kipperbas.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64RRNETLIB) bails.d64: bails.prg diff --git a/client/basic/bails.d64 b/client/basic/bails.d64 index 5996533..e3bee18 100644 Binary files a/client/basic/bails.d64 and b/client/basic/bails.d64 differ diff --git a/client/basic/bails.s b/client/basic/bails.s index 69babfc..647b0d2 100644 --- a/client/basic/bails.s +++ b/client/basic/bails.s @@ -77,7 +77,7 @@ crunched_line = $0200 ;Input buffer .import dhcp_server .import cfg_mac .import cfg_mac_default -.import cs_driver_name +.import eth_driver_name .import get_key_if_available .import timer_read .import native_to_ascii @@ -216,10 +216,9 @@ install_new_vectors_loop: .byte "NO RR-NET FOUND - UNINSTALLING",0 @init_ok: - lda CHAIN_FLAG - jsr $A644 ;do a "NEW" - jmp $A474 ;"READY" prompt +; jsr $A644 ;do a "NEW" +; jmp $A474 ;"READY" prompt rts ;so BASIC will LOAD & RUN INDEX.BAS welcome_banner: @@ -714,7 +713,7 @@ ipcfg_keyword: ldax #interface_type jsr print - ldax #cs_driver_name + ldax #eth_driver_name jsr print jsr print_cr diff --git a/client/basic/kipperbas.d64 b/client/basic/kipperbas.d64 index 96de627..42f5ede 100644 Binary files a/client/basic/kipperbas.d64 and b/client/basic/kipperbas.d64 differ diff --git a/client/basic/kipperbas.s b/client/basic/kipperbas.s index d6334df..d7c2441 100644 --- a/client/basic/kipperbas.s +++ b/client/basic/kipperbas.s @@ -80,7 +80,7 @@ crunched_line = $0200 ;Input buffer .import dhcp_server .import cfg_mac .import cfg_mac_default -.import cs_driver_name +.import eth_driver_name .importzp tftp_filename .import tftp_ip .import tftp_download @@ -727,7 +727,7 @@ ipcfg_keyword: ldax #interface_type jsr print - ldax #cs_driver_name + ldax #eth_driver_name jsr print jsr print_cr diff --git a/client/carts/Makefile b/client/carts/Makefile index edc0750..7237ab0 100644 --- a/client/carts/Makefile +++ b/client/carts/Makefile @@ -15,8 +15,7 @@ IP65LIB=../ip65/ip65.lib IP65TCPLIB=../ip65/ip65_tcp.lib -C64PROGLIB=../drivers/c64prog.lib -#C64NB65LIB=../drivers/c64nb65.lib +C64RRNETLIB=../drivers/c64rrnet.lib all: kipperkart.bin kipperkart_rr.bin netboot.bin kipperterm.bin kipperkart.prg kipperterm.prg kipperterm_rr.bin kippergo.bin kipperkart.prg kippergo.prg kippergo_rr.bin kipperdisk.d64 @@ -41,21 +40,21 @@ kipperterm.prg: kipperterm.bin c64_cart_ram_header.prg kippergo.prg: kippergo.bin c64_cart_ram_header.prg cat c64_cart_ram_header.prg kippergo.bin > kippergo.prg -%.prg: %.o $(IP65LIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m $*.map -vm -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64PROGLIB) +%.prg: %.o $(IP65LIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m $*.map -vm -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64RRNETLIB) -netboot.bin: netboot.o $(IP65LIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64_8kcart.cfg - $(LD) -m netboot.map -vm -C ../cfg/c64_8kcart.cfg -o $@ $< $(IP65LIB) $(C64PROGLIB) +netboot.bin: netboot.o $(IP65LIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_8kcart.cfg + $(LD) -m netboot.map -vm -C ../cfg/c64_8kcart.cfg -o $@ $< $(IP65LIB) $(C64RRNETLIB) ruby fix_cart.rb $@ 8192 -kipperkart.bin: kipperkart.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64_16kcart.cfg - $(LD) -m kipperkart.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64PROGLIB) +kipperkart.bin: kipperkart.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_16kcart.cfg + $(LD) -m kipperkart.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64RRNETLIB) ruby fix_cart.rb $@ 16384 ruby set_ip_config.rb $@ mac auto ruby dupe_cart.rb kipperkart.bin kipperkart_29c040.bin 32 -kipperterm.bin: kipperterm.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64_16kcart.cfg - $(LD) -m kipperterm.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64PROGLIB) +kipperterm.bin: kipperterm.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_16kcart.cfg + $(LD) -m kipperterm.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64RRNETLIB) ruby fix_cart.rb $@ 16384 ruby dupe_cart.rb kipperterm.bin kipperterm_29c040.bin 32 @@ -65,8 +64,8 @@ kipperterm_rr.bin: kipperterm.bin ruby fix_cart.rb $@ 32768 -kippergo.bin: kippergo.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64_16kcart.cfg - $(LD) -m kippergo.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64PROGLIB) +kippergo.bin: kippergo.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_16kcart.cfg + $(LD) -m kippergo.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64RRNETLIB) ruby fix_cart.rb $@ 16384 ruby dupe_cart.rb kippergo.bin kippergo_29c040.bin 32 diff --git a/client/drivers/Makefile b/client/drivers/Makefile index b401116..1f17bcb 100644 --- a/client/drivers/Makefile +++ b/client/drivers/Makefile @@ -13,8 +13,8 @@ AFLAGS= DRIVERS=\ apple2prog.lib \ - c64prog.lib \ -# c64nb65.lib \ + c64rrnet.lib \ + c64wiznet.lib \ all: $(DRIVERS) @@ -23,16 +23,13 @@ all: $(DRIVERS) apple2prog.lib: a2print.o uthernet.o a2timer.o a2kernal.o a2input.o a2charconv.o cs8900a.o ar65 a $@ $^ -c64prog.lib: c64print.o rr-net.o c64timer.o c64kernal.o c64inputs.o c64_disk_access.o c64charconv.o c64_vt100.o cs8900a.o +c64rrnet.lib: c64print.o rr-net.o c64timer.o c64kernal.o c64inputs.o c64_disk_access.o c64charconv.o c64_vt100.o cs8900a.o ar65 a $@ $^ -c64wiznet.lib: c64print.o wiznet.o c64timer.o c64kernal.o c64inputs.o c64_disk_access.o c64charconv.o c64_vt100.o +c64wiznet.lib: w5100.o c64print.o c64timer.o c64kernal.o c64inputs.o c64_disk_access.o c64charconv.o c64_vt100.o ar65 a $@ $^ - -#c64nb65.lib: c64print.o rr-net.o c64timer_nb65.o c64kernal.o c64inputs.o c64_disk_access.o c64charconv.o - # ar65 a $@ $^ diff --git a/client/drivers/c64timer.s b/client/drivers/c64timer.s index 37049e5..b1919e4 100644 --- a/client/drivers/c64timer.s +++ b/client/drivers/c64timer.s @@ -5,7 +5,6 @@ .include "../inc/common.i" - .export timer_init .export timer_read diff --git a/client/drivers/cs8900a.s b/client/drivers/cs8900a.s index 0bd314e..cfddf23 100644 --- a/client/drivers/cs8900a.s +++ b/client/drivers/cs8900a.s @@ -15,15 +15,15 @@ .export eth_rx .export eth_tx - .export eth_inp - .export eth_inp_len - .export eth_outp - .export eth_outp_len + .import eth_inp + .import eth_inp_len + .import eth_outp + .import eth_outp_len - .exportzp eth_dest - .exportzp eth_src - .exportzp eth_type - .exportzp eth_data + .importzp eth_dest + .importzp eth_src + .importzp eth_type + .importzp eth_data .import cs_init .import cs_packet_page @@ -49,21 +49,7 @@ 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 diff --git a/client/drivers/rr-net.s b/client/drivers/rr-net.s index 11dd36d..8e21a99 100644 --- a/client/drivers/rr-net.s +++ b/client/drivers/rr-net.s @@ -8,7 +8,7 @@ .export cs_rxtx_data .export cs_tx_cmd .export cs_tx_len - .export cs_driver_name + .export eth_driver_name rr_ctl = $de01 ;address of 'control' port on Retro-Replay cs_packet_page = $de02 ;address of 'packet page' port on RR-Net @@ -30,7 +30,7 @@ cs_init: rts .rodata -cs_driver_name: +eth_driver_name: .asciiz "RR-NET" diff --git a/client/drivers/uthernet.s b/client/drivers/uthernet.s index b56492f..8bd9b6b 100644 --- a/client/drivers/uthernet.s +++ b/client/drivers/uthernet.s @@ -9,7 +9,7 @@ .export cs_rxtx_data .export cs_tx_cmd .export cs_tx_len - .export cs_driver_name + .export eth_driver_name cs_rxtx_data = $c0b0 ;address of 'recieve/transmit data' port on Uthernet cs_tx_cmd = $c0b4;address of 'transmit command' port on Uthernet @@ -25,7 +25,7 @@ cs_init: rts .rodata -cs_driver_name: +eth_driver_name: .byte "UTHERNET",0 diff --git a/client/drivers/w5100.i b/client/drivers/w5100.i new file mode 100644 index 0000000..cf562b6 --- /dev/null +++ b/client/drivers/w5100.i @@ -0,0 +1,213 @@ + +W5100_MR = $0000 ;Mode Register + +W5100_GAR0 = $0001 ;Gateway Address Byte 0 +W5100_GAR1 = $0002 ;Gateway Address Byte 1 +W5100_GAR2 = $0003 ;Gateway Address Byte 2 +W5100_GAR3 = $0004 ;Gateway Address Byte 3 + +W5100_SUBR0 = $0005 ;Subnet Mask Address 0 +W5100_SUBR1 = $0006 ;Subnet Mask Address 1 +W5100_SUBR2 = $0007 ;Subnet Mask Address 2 +W5100_SUBR3 = $0008 ;Subnet Mask Address 3 + +W5100_SHAR0 = $0009 ;Local MAC Address 0 +W5100_SHAR1 = $000A ;Local MAC Address 1 +W5100_SHAR2 = $000B ;Local MAC Address 2 +W5100_SHAR3 = $000C ;Local MAC Address 3 +W5100_SHAR4 = $000D ;Local MAC Address 4 +W5100_SHAR5 = $000E ;Local MAC Address 5 + +W5100_SIPR0 = $000F ;Source IP Address 0 +W5100_SIPR1 = $0010 ;Source IP Address 0 +W5100_SIPR2 = $0011 ;Source IP Address 0 +W5100_SIPR3 = $0012 ;Source IP Address 0 + +W5100_IR = $0015 ;Interrupt +W5100_IMR = $0016 ;Interrupt Mask + +W5100_RTR0 = $0017 ;Retry Time High Byte +W5100_RTR1 = $0018 ;Retry Time Low Byte + +W5100_RCR = $0019 ;Retry Count + +W5100_RMSR = $001A ;RX Memory Size (per socket) +W5100_TMSR = $001B ;TX Memory Size (per socket) + +W5100_PATR0 = $001C ;PPPoE Auth Type High +W5100_PART1 = $001D ;PPPoE Auth Type Low + +W5100_PTIMER = $0028 ;PPP LCP Request Timer +W5100_PMAGIC = $0029 ;PPP LCP Magic Number + +W5100_UIPR0 = $002A ;Unreachable IP Address 0 +W5100_UIPR1 = $002B ;Unreachable IP Address 1 +W5100_UIPR2 = $002C ;Unreachable IP Address 2 +W5100_UIPR3 = $002D ;Unreachable IP Address 3 + +W5100_UPORT0 = $002E ;Unreachable Port High +W5100_UPORT1 = $002F ;Unreachable Port Low + + +;Socket Registers +W5100_S0_BASE = $0400 ;Base for socket 0 +W5100_S0_MR = $0400 ;Socket 0 Mode +W5100_S0_CR = $0401 ;Socket 0 Command +W5100_S0_IR = $0402 ;Socket 0 Interrupt +W5100_S0_SR = $0403 ;Socket 0 Status +W5100_S0_PORT0 = $0404 ;Socket 0 Source Port High +W5100_S0_PORT1 = $0405 ;Socket 0 Source Port Low +W5100_S0_DHAR0 = $0406 ;Socket 0 Dest Mac 0 +W5100_S0_DHAR1 = $0407 ;Socket 0 Dest Mac 1 +W5100_S0_DHAR2 = $0408 ;Socket 0 Dest Mac 2 +W5100_S0_DHAR3 = $0409 ;Socket 0 Dest Mac 3 +W5100_S0_DHAR4 = $040A ;Socket 0 Dest Mac 4 +W5100_S0_DHAR5 = $040B ;Socket 0 Dest Mac 5 +W5100_S0_DIPR0 = $040C ;Socket 0 Dest IP 0 +W5100_S0_DIPR1 = $040D ;Socket 0 Dest IP 1 +W5100_S0_DIPR2 = $040E ;Socket 0 Dest IP 2 +W5100_S0_DIPR3 = $040F ;Socket 0 Dest IP 3 +W5100_S0_DPORT0 = $0410 ;Socket 0 Dest Port High +W5100_S0_DPORT1 = $0411 ;Socket 0 Dest Port Low +W5100_S0_MSSR0 = $0412 ;Socket 0 Max Segment High +W5100_S0_MSSR1 = $0413 ;Socket 0 Max Segment Low +W5100_S0_PROTO = $0414 ;Socket 0 Protocol (Raw Mode) +W5100_S0_TOS = $0415 ;Socket 0 IP TOS +W5100_S0_TTL = $0416 ;Socket 0 IP TTL +W5100_S0_TX_FSR0 = $0420 ;Socket 0 TX Free Size High +W5100_S0_TX_FSR1 = $0421 ;Socket 0 TX Free Size Low +W5100_S0_TX_RD0 = $0422 ;Socket 0 TX Read Pointer High +W5100_S0_TX_RD1 = $0423 ;Socket 0 TX Read Pointer Low +W5100_S0_TX_WR0 = $0424 ;Socket 0 TX Write Pointer High +W5100_S0_TX_WR1 = $0425 ;Socket 0 TX Write Pointer Low +W5100_S0_RX_RSR0 = $0426 ;Socket 0 RX Received Size High +W5100_S0_RX_RSR1 = $0427 ;Socket 0 RX Received Size Low +W5100_S0_RX_RD0 = $0428 ;Socket 0 RX Read Pointer High +W5100_S0_RX_RD1 = $0429 ;Socket 0 RX Read Pointer Low + +W5100_S1_BASE = $0500 ;Base for socket 1 +W5100_S1_MR = $0500 ;Socket 1 Mode +W5100_S1_CR = $0501 ;Socket 1 Command +W5100_S1_IR = $0502 ;Socket 1 Interrupt +W5100_S1_SR = $0503 ;Socket 1 Status +W5100_S1_PORT0 = $0504 ;Socket 1 Source Port High +W5100_S1_PORT1 = $0505 ;Socket 1 Source Port Low +W5100_S1_DHAR0 = $0506 ;Socket 1 Dest Mac 0 +W5100_S1_DHAR1 = $0507 ;Socket 1 Dest Mac 1 +W5100_S1_DHAR2 = $0508 ;Socket 1 Dest Mac 2 +W5100_S1_DHAR3 = $0509 ;Socket 1 Dest Mac 3 +W5100_S1_DHAR4 = $050A ;Socket 1 Dest Mac 4 +W5100_S1_DHAR5 = $050B ;Socket 1 Dest Mac 5 +W5100_S1_DIPR0 = $050C ;Socket 1 Dest IP 0 +W5100_S1_DIPR1 = $050D ;Socket 1 Dest IP 1 +W5100_S1_DIPR2 = $050E ;Socket 1 Dest IP 2 +W5100_S1_DIPR3 = $050F ;Socket 1 Dest IP 3 +W5100_S1_DPORT0 = $0510 ;Socket 1 Dest Port High +W5100_S1_DPORT1 = $0511 ;Socket 1 Dest Port Low +W5100_S1_MSSR0 = $0512 ;Socket 1 Max Segment High +W5100_S1_MSSR1 = $0513 ;Socket 1 Max Segment Low +W5100_S1_PROTO = $0514 ;Socket 1 Protocol (Raw Mode) +W5100_S1_TOS = $0515 ;Socket 1 IP TOS +W5100_S1_TTL = $0516 ;Socket 1 IP TTL +W5100_S1_TX_FSR0 = $0520 ;Socket 1 TX Free Size High +W5100_S1_TX_FSR1 = $0521 ;Socket 1 TX Free Size Low +W5100_S1_TX_RD0 = $0522 ;Socket 1 TX Read Pointer High +W5100_S1_TX_RD1 = $0523 ;Socket 1 TX Read Pointer Low +W5100_S1_TX_WR0 = $0524 ;Socket 1 TX Write Pointer High +W5100_S1_TX_WR1 = $0525 ;Socket 1 TX Write Pointer Low +W5100_S1_RX_RSR0 = $0526 ;Socket 1 RX Received Size High +W5100_S1_RX_RSR1 = $0527 ;Socket 1 RX Received Size Low +W5100_S1_RX_RD0 = $0528 ;Socket 1 RX Read Pointer High +W5100_S1_RX_RD1 = $0529 ;Socket 1 RX Read Pointer Low + +W5100_S2_BASE = $0600 ;Base for socket 2 +W5100_S2_MR = $0600 ;Socket 2 Mode +W5100_S2_CR = $0601 ;Socket 2 Command +W5100_S2_IR = $0602 ;Socket 2 Interrupt +W5100_S2_SR = $0603 ;Socket 2 Status +W5100_S2_PORT0 = $0604 ;Socket 2 Source Port High +W5100_S2_PORT1 = $0605 ;Socket 2 Source Port Low +W5100_S2_DHAR0 = $0606 ;Socket 2 Dest Mac 0 +W5100_S2_DHAR1 = $0607 ;Socket 2 Dest Mac 1 +W5100_S2_DHAR2 = $0608 ;Socket 2 Dest Mac 2 +W5100_S2_DHAR3 = $0609 ;Socket 2 Dest Mac 3 +W5100_S2_DHAR4 = $060A ;Socket 2 Dest Mac 4 +W5100_S2_DHAR5 = $060B ;Socket 2 Dest Mac 5 +W5100_S2_DIPR0 = $060C ;Socket 2 Dest IP 0 +W5100_S2_DIPR1 = $060D ;Socket 2 Dest IP 1 +W5100_S2_DIPR2 = $060E ;Socket 2 Dest IP 2 +W5100_S2_DIPR3 = $060F ;Socket 2 Dest IP 3 +W5100_S2_DPORT0 = $0610 ;Socket 2 Dest Port High +W5100_S2_DPORT1 = $0611 ;Socket 2 Dest Port Low +W5100_S2_MSSR0 = $0612 ;Socket 2 Max Segment High +W5100_S2_MSSR1 = $0613 ;Socket 2 Max Segment Low +W5100_S2_PROTO = $0614 ;Socket 2 Protocol (Raw Mode) +W5100_S2_TOS = $0615 ;Socket 2 IP TOS +W5100_S2_TTL = $0616 ;Socket 2 IP TTL +W5100_S2_TX_FSR0 = $0620 ;Socket 2 TX Free Size High +W5100_S2_TX_FSR1 = $0621 ;Socket 2 TX Free Size Low +W5100_S2_TX_RD0 = $0622 ;Socket 2 TX Read Pointer High +W5100_S2_TX_RD1 = $0623 ;Socket 2 TX Read Pointer Low +W5100_S2_TX_WR0 = $0624 ;Socket 2 TX Write Pointer High +W5100_S2_TX_WR1 = $0625 ;Socket 2 TX Write Pointer Low +W5100_S2_RX_RSR0 = $0626 ;Socket 2 RX Received Size High +W5100_S2_RX_RSR1 = $0627 ;Socket 2 RX Received Size Low +W5100_S2_RX_RD0 = $0628 ;Socket 2 RX Read Pointer High +W5100_S2_RX_RD1 = $0629 ;Socket 2 RX Read Pointer Low + +W5100_S3_BASE = $0700 ;Base for socket 3 +W5100_S3_MR = $0700 ;Socket 3 Mode +W5100_S3_CR = $0701 ;Socket 3 Command +W5100_S3_IR = $0702 ;Socket 3 Interrupt +W5100_S3_SR = $0703 ;Socket 3 Status +W5100_S3_PORT0 = $0704 ;Socket 3 Source Port High +W5100_S3_PORT1 = $0705 ;Socket 3 Source Port Low +W5100_S3_DHAR0 = $0706 ;Socket 3 Dest Mac 0 +W5100_S3_DHAR1 = $0707 ;Socket 3 Dest Mac 1 +W5100_S3_DHAR2 = $0708 ;Socket 3 Dest Mac 2 +W5100_S3_DHAR3 = $0709 ;Socket 3 Dest Mac 3 +W5100_S3_DHAR4 = $070A ;Socket 3 Dest Mac 4 +W5100_S3_DHAR5 = $070B ;Socket 3 Dest Mac 5 +W5100_S3_DIPR0 = $070C ;Socket 3 Dest IP 0 +W5100_S3_DIPR1 = $070D ;Socket 3 Dest IP 1 +W5100_S3_DIPR2 = $070E ;Socket 3 Dest IP 2 +W5100_S3_DIPR3 = $070F ;Socket 3 Dest IP 3 +W5100_S3_DPORT0 = $0710 ;Socket 3 Dest Port High +W5100_S3_DPORT1 = $0711 ;Socket 3 Dest Port Low +W5100_S3_MSSR0 = $0712 ;Socket 3 Max Segment High +W5100_S3_MSSR1 = $0713 ;Socket 3 Max Segment Low +W5100_S3_PROTO = $0714 ;Socket 3 Protocol (Raw Mode) +W5100_S3_TOS = $0715 ;Socket 3 IP TOS +W5100_S3_TTL = $0716 ;Socket 3 IP TTL +W5100_S3_TX_FSR0 = $0720 ;Socket 3 TX Free Size High +W5100_S3_TX_FSR1 = $0721 ;Socket 3 TX Free Size Low +W5100_S3_TX_RD0 = $0722 ;Socket 3 TX Read Pointer High +W5100_S3_TX_RD1 = $0723 ;Socket 3 TX Read Pointer Low +W5100_S3_TX_WR0 = $0724 ;Socket 3 TX Write Pointer High +W5100_S3_TX_WR1 = $0725 ;Socket 3 TX Write Pointer Low +W5100_S3_RX_RSR0 = $0726 ;Socket 3 RX Received Size High +W5100_S3_RX_RSR1 = $0727 ;Socket 3 RX Received Size Low +W5100_S3_RX_RD0 = $0728 ;Socket 3 RX Read Pointer High +W5100_S3_RX_RD1 = $0729 ;Socket 3 RX Read Pointer Low + + +;commands +W5100_CMD_OPEN = $01 +W5100_CMD_LISTEN = $02 +W5100_CMD_CONNECT = $04 +W5100_CMD_DISCONNECT = $08 +W5100_CMD_CLOSE = $10 +W5100_CMD_SEND = $20 +W5100_CMD_SEND_MAC = $21 +W5100_CMD_SEND_KEEP = $22 +W5100_CMD_RECV = $40 + +;modes +W5100_MODE_CLOSED = $00 +W5100_MODE_TCP = $01 +W5100_MODE_UDP = $02 +W5100_MODE_IP_RAW = $03 +W5100_MODE_MAC_RAW = $04 +W5100_MODE_PPPOE = $05 + + diff --git a/client/drivers/w5100.s b/client/drivers/w5100.s new file mode 100644 index 0000000..f2a9f37 --- /dev/null +++ b/client/drivers/w5100.s @@ -0,0 +1,169 @@ +; Ethernet driver for W5100 W5100 chip +; + +.ifndef KPR_API_VERSION_NUMBER + .define EQU = + .include "../inc/kipper_constants.i" +.endif + +.include "../inc/common.i" + +.include "w5100.i" + + .export eth_init + .export eth_rx + .export eth_tx + .export eth_driver_name + .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 + + .export w5100_read_reg + .export w5100_write_reg + + .import cfg_mac + + .import ip65_error + + + .segment "IP65ZP" : zeropage + +W5100_BASE = $DF20 +W5100_ADDR_HI = W5100_BASE+1 +W5100_ADDR_LO = W5100_BASE+2 +W5100_DATA = W5100_BASE+3 + + + + .code + +;initialize the ethernet adaptor +;inputs: none +;outputs: carry flag is set if there was an error, clear otherwise +eth_init: + lda #$80 ;reset + sta W5100_BASE + lda W5100_BASE + bne @error ;writing a byte to the MODE register with bit 7 set should reset. + ;after a reset, mode register is zero + ;therefore, if there is a real W5100 at the specified address, + ;we should be able to write a $80 and read back a $00 + lda #$03 ;set indirect + autoincrement + sta W5100_BASE + lda W5100_BASE + cmp #$03 + bne @error ;make sure if we write to mode register without bit 7 set, + ;the value persists. + lda #$00 + sta W5100_ADDR_HI + lda #$16 + sta W5100_ADDR_LO + ldx #$00 ;start writing to reg $0016 - Interrupt Mask Register +@loop: + lda w5100_config_data,x + sta W5100_DATA + inx + cpx #$06 + bne @loop + + lda #$09 + sta W5100_ADDR_LO + ldx #$00 ;start writing to reg $0009 - MAC address +@mac_loop: + lda cfg_mac,x + sta W5100_DATA + inx + cpx #$06 + bne @mac_loop + + ;set up socket 0 for MAC RAW mode + ldax #W5100_S0_MR + ldy #W5100_MODE_MAC_RAW + jsr w5100_write_reg + + ;open socket 0 + ldax #W5100_S0_CR + ldy #W5100_CMD_OPEN + jsr w5100_write_reg + + clc + rts +@error: + 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: + + +; 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: + + sec + rts + +; read one of the W5100 registers +; inputs: AX = register number to read +; outputs: A = value of nominated register +w5100_read_reg: + stx W5100_ADDR_HI + sta W5100_ADDR_LO + lda W5100_DATA + rts + +; write to one of the W5100 registers +; inputs: AX = register number to read +; Y = value to write to register +; outputs: none +w5100_write_reg: + stx W5100_ADDR_HI + sta W5100_ADDR_LO + sty W5100_DATA + rts + +.rodata +eth_driver_name: + .asciiz "W5100 5100" +w5100_config_data: + .byte $00 ;no interrupts + .byte $0f ;400ms retry (default) + .byte $a0 + .byte $08 ;# of timeouts + .byte $55 ;4 sockets @2K each, tx/rx + .byte $55 + +;-- LICENSE FOR w5100a.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 is Copyright (C) 2010 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/client/examples/Makefile b/client/examples/Makefile index 826a985..9acb5ec 100644 --- a/client/examples/Makefile +++ b/client/examples/Makefile @@ -10,7 +10,7 @@ AFLAGS= IP65TCPLIB=../ip65/ip65_tcp.lib -C64PROGLIB=../drivers/c64prog.lib +C64RRNETLIB=../drivers/c64rrnet.lib #NT2PLAY=nt2play.o @@ -39,18 +39,18 @@ webnoter.o: webnoter.s form.html $(AS) $(AFLAGS) $< -webnoter.prg: webnoter.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m webnoter.map -vm -C ../cfg/c64prg.cfg -o webnoter.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) $(NT2PLAY) +webnoter.prg: webnoter.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m webnoter.map -vm -C ../cfg/c64prg.cfg -o webnoter.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) $(NT2PLAY) -upnatom.prg: upnatom.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m upnatom.map -vm -C ../cfg/c64prg.cfg -o upnatom.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) $(NT2PLAY) +upnatom.prg: upnatom.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m upnatom.map -vm -C ../cfg/c64prg.cfg -o upnatom.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) $(NT2PLAY) # cp upnatom.prg ../../server/boot/ -%.prg: %.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m $*.map -vm -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) +%.prg: %.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m $*.map -vm -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) diff --git a/client/inc/commonprint.i b/client/inc/commonprint.i index d449c13..8ae2be1 100644 --- a/client/inc/commonprint.i +++ b/client/inc/commonprint.i @@ -26,7 +26,7 @@ .import ascii_to_native -.import cs_driver_name +.import eth_driver_name .importzp copy_src .import cfg_tftp_server ;reuse the copy_src zero page var @@ -38,7 +38,7 @@ temp_bcd: .res 3 temp_ptr: .res 2 .code .macro print_driver_init - ldax #cs_driver_name + ldax #eth_driver_name jsr print_ascii_as_native ldax #init_msg jsr print_ascii_as_native @@ -69,13 +69,13 @@ temp_ptr: .res 2 .import print_a .import print_cr -.import cs_driver_name +.import eth_driver_name print_ip_config: ldax #interface_type jsr print_ascii_as_native - ldax #cs_driver_name + ldax #eth_driver_name jsr print_ascii_as_native jsr print_cr diff --git a/client/ip65/Makefile b/client/ip65/Makefile index 770bea3..b6c9db9 100644 --- a/client/ip65/Makefile +++ b/client/ip65/Makefile @@ -39,23 +39,15 @@ ETHOBJS= \ all: ip65.lib ip65_tcp.lib ip65.lib: $(ETHOBJS) function_dispatcher.s ip.s icmp.s - $(AS) $(AFLAGS) function_dispatcher.s - $(AS) $(AFLAGS) ip.s - $(AS) $(AFLAGS) icmp.s ar65 a ip65.lib $(ETHOBJS) function_dispatcher.o ip.o icmp.o - -ip65_tcp.lib: tcp.o $(ETHOBJS) function_dispatcher.s ip.s tcp.s icmp.s - +ip65_tcp.lib: tcp.o $(ETHOBJS) function_dispatcher.s ip.s tcp.s icmp.s $(AS) $(AFLAGS) function_dispatcher.s -DTCP -DAPI_VERSION=2 - $(AS) $(AFLAGS) ip.s -DTCP - $(AS) $(AFLAGS) icmp.s -DTCP - ar65 a ip65_tcp.lib $(ETHOBJS) function_dispatcher.o ip.o tcp.o icmp.o clean: diff --git a/client/ip65/eth.s b/client/ip65/eth.s index 0976974..aab21bb 100644 --- a/client/ip65/eth.s +++ b/client/ip65/eth.s @@ -8,11 +8,27 @@ .exportzp eth_proto_ip .exportzp eth_proto_arp + .exportzp eth_dest + .exportzp eth_src + .exportzp eth_type + .exportzp eth_data - .import eth_outp + .export eth_outp + .export eth_outp_len + .export eth_inp + .export eth_inp_len .import cfg_mac + .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 address in ethernet packet diff --git a/client/kipperterm2/Makefile b/client/kipperterm2/Makefile index 99238fe..2066aab 100644 --- a/client/kipperterm2/Makefile +++ b/client/kipperterm2/Makefile @@ -15,8 +15,7 @@ IP65LIB=../ip65/ip65.lib IP65TCPLIB=../ip65/ip65_tcp.lib -C64PROGLIB=../drivers/c64prog.lib -#C64NB65LIB=../drivers/c64nb65.lib +C64RRNETLIB=../drivers/c64rrnet.lib all: kipperterm2.prg kipperterm2.d64 @@ -26,8 +25,8 @@ kipperterm2.o: kipperterm2.s $(INCFILES) ../inc/telnet.i ../inc/config_menu.i .. %.o: %.s $(INCFILES) $(AS) $(AFLAGS) $< -%.prg: %.o $(IP65LIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64fullprg.cfg - $(LD) -m $*.map -vm -C ../cfg/c64fullprg.cfg -o $*.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) +%.prg: %.o $(IP65LIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64fullprg.cfg + $(LD) -m $*.map -vm -C ../cfg/c64fullprg.cfg -o $*.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) ruby ../carts/set_ip_config.rb $@ mac auto kipperterm2.d64: kipperterm2.prg addresses.txt abe.bas diff --git a/client/test/Makefile b/client/test/Makefile index 18d1a7f..3389c5d 100644 --- a/client/test/Makefile +++ b/client/test/Makefile @@ -4,99 +4,124 @@ LD=ld65 CFLAGS=-Oirs -t $(TARGET) AFLAGS= - -IP65LIB=../ip65/ip65.lib - -IP65TCPLIB=../ip65/ip65_tcp.lib - -C64PROGLIB=../drivers/c64prog.lib -C64PNB65LIB=../drivers/c64nb65.lib -APPLE2PROGLIB=../drivers/apple2prog.lib - -INCFILES=\ - ../inc/common.i\ - ../inc/commonprint.i\ - ../inc/net.i\ - -all: \ - test_getc.prg \ - testdns.prg \ - test_disk_io.prg \ - testdns.pg2 \ - testtftp.prg \ - testtftp.pg2\ - test_cart_api.prg\ - test_vt100.prg\ - testdottedquad.pg2\ - testdottedquad.prg\ - test_tcp.prg \ - test_xmodem.prg \ - test_xmodem.d64 \ - test_httpd.prg \ - test_parser.prg \ - test_ping.prg \ - test_sntp.prg \ - test_get_url.prg \ - test_parse_querystring.prg \ -# httpd_test.d64 \ -# ip65test.dsk \ -# test_disk_io.d64 \ + + +IP65LIB=../ip65/ip65.lib + +IP65TCPLIB=../ip65/ip65_tcp.lib + +C64RRNETLIB=../drivers/c64rrnet.lib + +C64WIZNETLIB=../drivers/c64wiznet.lib + +APPLE2PROGLIB=../drivers/apple2prog.lib + + +INCFILES=\ + ../inc/common.i\ + ../inc/commonprint.i\ + ../inc/net.i\ + +all: \ + test_getc.prg \ + testdns.prg \ + test_disk_io.prg \ + testdns.pg2 \ + testtftp.prg \ + testtftp.pg2\ + test_cart_api.prg\ + test_vt100.prg\ + testdottedquad.pg2\ + testdottedquad.prg\ + test_tcp.prg \ + test_xmodem.prg \ + test_xmodem.d64 \ + test_httpd.prg \ + test_parser.prg \ + test_ping.prg \ + test_sntp.prg \ + test_get_url.prg \ + test_wiznet.prg \ + test_parse_querystring.prg \ +# httpd_test.d64 \ +# ip65test.dsk \ +# test_disk_io.d64 \ + %.o: %.c $(CC) -c $(CFLAGS) $< %.o: %.s $(AS) $(AFLAGS) $< - -%.prg: %.o $(IP65LIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m $*.map -vm -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64PROGLIB) - -test_tcp.prg: test_tcp.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m test_tcp.map -vm -C ../cfg/c64prg.cfg -o test_tcp.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) - -test_xmodem.o: test_xmodem.s ../ip65/xmodem.s - $(AS) $(AFLAGS) $< - -test_xmodem.prg: test_xmodem.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m test_xmodem.map -vm -C ../cfg/c64prg.cfg -o test_xmodem.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) - -test_parser.prg: test_parser.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m test_parser.map -vm -C ../cfg/c64prg.cfg -o test_parser.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) - -test_get_url.prg: test_get_url.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m test_get_url.map -vm -C ../cfg/c64prg.cfg -o test_get_url.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) - -test_ping.prg: test_ping.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m test_ping.map -vm -C ../cfg/c64prg.cfg -o test_ping.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) - -%.pg2: %.o $(IP65LIB) $(APPLE2PROGLIB) $(INCFILES) ../cfg/a2bin.cfg - $(LD) -C ../cfg/a2bin.cfg -o $*.pg2 $(AFLAGS) $< $(IP65LIB) $(APPLE2PROGLIB) - - -httpd_test.d64: test_httpd.prg index.html file1.html - cp test_httpd.prg autoexec.prg - ripxplore.rb --init CbmDos httpd_test.d64 -a autoexec.prg - ripxplore.rb httpd_test.d64 -a index.html -t C64Seq - ripxplore.rb httpd_test.d64 -a file1.html -t C64Seq - -ip65test.dsk: testdns.pg2 testdottedquad.pg2 testtftp.pg2 - ripxplore.rb --init BeautifulBoot ip65test.dsk -a testdns.pg2 -t AppleBinary - ripxplore.rb ip65test.dsk -a testdns.pg2 -t AppleBinary - ripxplore.rb ip65test.dsk -a testtftp.pg2 -t AppleBinary - ripxplore.rb ip65test.dsk -a testdottedquad.pg2 -t AppleBinary - ripxplore.rb ip65test.dsk -a testdns.pg2 -t AppleBinary - -test_disk_io.d64: test_disk_io.prg - ripxplore.rb --init CbmDos test_disk_io.d64 -a test_disk_io.prg - cp screen_prg.bin screen.prg - ripxplore.rb test_disk_io.d64 -a screen.prg - -test_xmodem.d64: test_xmodem.prg - ripxplore.rb --init CbmDos test_xmodem.d64 -a test_xmodem.prg + + +%.prg: %.o $(IP65LIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m $*.map -vm -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64RRNETLIB) + + + +test_tcp.prg: test_tcp.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m test_tcp.map -vm -C ../cfg/c64prg.cfg -o test_tcp.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) + +test_xmodem.o: test_xmodem.s ../ip65/xmodem.s + $(AS) $(AFLAGS) $< + + + +test_xmodem.prg: test_xmodem.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m test_xmodem.map -vm -C ../cfg/c64prg.cfg -o test_xmodem.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) + +test_parser.prg: test_parser.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m test_parser.map -vm -C ../cfg/c64prg.cfg -o test_parser.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) + + +test_get_url.prg: test_get_url.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m test_get_url.map -vm -C ../cfg/c64prg.cfg -o test_get_url.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) + + +test_ping.prg: test_ping.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m test_ping.map -vm -C ../cfg/c64prg.cfg -o test_ping.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64RRNETLIB) + +test_wiznet.prg: test_wiznet.o $(C64WIZNETLIB) $(IP65TCPLIB) $(INCFILES) ../cfg/c64prg.cfg + $(LD) -m test_wiznet.map -vm -C ../cfg/c64prg.cfg -o test_wiznet.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64WIZNETLIB) + cp test_wiznet.prg ../../server/boot/autoexec.prg + + +%.pg2: %.o $(IP65LIB) $(APPLE2PROGLIB) $(INCFILES) ../cfg/a2bin.cfg + $(LD) -C ../cfg/a2bin.cfg -o $*.pg2 $(AFLAGS) $< $(IP65LIB) $(APPLE2PROGLIB) + + + + +httpd_test.d64: test_httpd.prg index.html file1.html + cp test_httpd.prg autoexec.prg + ripxplore.rb --init CbmDos httpd_test.d64 -a autoexec.prg + ripxplore.rb httpd_test.d64 -a index.html -t C64Seq + ripxplore.rb httpd_test.d64 -a file1.html -t C64Seq + + +ip65test.dsk: testdns.pg2 testdottedquad.pg2 testtftp.pg2 + ripxplore.rb --init BeautifulBoot ip65test.dsk -a testdns.pg2 -t AppleBinary + ripxplore.rb ip65test.dsk -a testdns.pg2 -t AppleBinary + ripxplore.rb ip65test.dsk -a testtftp.pg2 -t AppleBinary + ripxplore.rb ip65test.dsk -a testdottedquad.pg2 -t AppleBinary + ripxplore.rb ip65test.dsk -a testdns.pg2 -t AppleBinary + + +test_disk_io.d64: test_disk_io.prg + + ripxplore.rb --init CbmDos test_disk_io.d64 -a test_disk_io.prg + cp screen_prg.bin screen.prg + ripxplore.rb test_disk_io.d64 -a screen.prg + + +test_xmodem.d64: test_xmodem.prg + ripxplore.rb --init CbmDos test_xmodem.d64 -a test_xmodem.prg clean: rm -f *.o *.pg2 *.prg - rm -f ip65test.dsk + rm -f ip65test.dsk + distclean: clean rm -f *~ diff --git a/client/test/test_wiznet.s b/client/test/test_wiznet.s new file mode 100644 index 0000000..a975158 --- /dev/null +++ b/client/test/test_wiznet.s @@ -0,0 +1,153 @@ + .include "../inc/common.i" + .include "../inc/commonprint.i" + .include "../inc/net.i" + + .import exit_to_basic + + .import cfg_get_configuration_ptr + .import copymem + .importzp copy_src + .importzp copy_dest + + .import icmp_echo_ip + .import icmp_ping + .import get_key + .import w5100_read_reg + .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 + +init: + jsr print_cr + init_ip_via_dhcp + jsr print_ip_config + jsr print_cr + lda #0 + sta register_page + jsr dump_wiznet_register_page + lda #$4 + sta register_page + jsr dump_wiznet_register_page + + ;our default gateway is probably a safe thing to ping + ldx #$3 +: + lda cfg_gateway,x + sta icmp_echo_ip,x + dex + bpl :- + ldax #pinging + jsr print + + ldax #icmp_echo_ip + jsr print_dotted_quad + jsr print_cr + jsr icmp_ping + bcs @error + jsr print_integer + ldax #ms + jsr print + rts +@error: + jmp print_errorcode + + +dump_wiznet_register_page: + sta register_page + lda #0 + sta current_register + jsr print_cr + +@one_row: + lda current_register + cmp #$20 + beq @done + lda register_page + jsr print_hex + lda current_register + jsr print_hex + lda #':' + jsr print_a + lda #' ' + jsr print_a + + lda #0 + sta current_byte_in_row + +@dump_byte: + lda current_register + ldx register_page + jsr w5100_read_reg + jsr print_hex + lda #' ' + jsr print_a + inc current_register + inc current_byte_in_row + lda current_byte_in_row + cmp #08 + bne @dump_byte + + jsr print_cr + jmp @one_row +@done: + jsr print_cr + jsr wait_for_keypress + rts + +wait_for_keypress: + lda #0 + sta $c6 ;set the keyboard buffer to be empty + ldax #press_a_key_to_continue + jsr print + jsr get_key + rts + +.rodata +ms: .byte " MS",13,0 +pinging: .byte "PINGING ",0 + +hello: .byte "HELLO WORLD!",13,10,0 +.bss +block_number: .res 1 +block_length: .res 2 +current_register:.res 1 +current_byte_in_row: .res 1 +register_page: .res 1 + +;-- 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 --