From 36aa80fe2a06735c1ac2aaab4c9fb9acd348ac6c Mon Sep 17 00:00:00 2001 From: jonnosan Date: Sun, 29 May 2011 06:10:13 +0000 Subject: [PATCH] stresstest the w5100 autoinc mode git-svn-id: http://svn.code.sf.net/p/netboot65/code@312 93682198-c243-4bdb-bd91-e943c89aac3b --- client/wiznet/Makefile | 6 +- client/wiznet/wiztest.s | 345 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 349 insertions(+), 2 deletions(-) create mode 100644 client/wiznet/wiztest.s diff --git a/client/wiznet/Makefile b/client/wiznet/Makefile index d91ba93..7dbe29e 100644 --- a/client/wiznet/Makefile +++ b/client/wiznet/Makefile @@ -21,9 +21,10 @@ IP65WIZNETLIB=../ip65/ip65_wiznet.lib all: ip65 drivers\ wizboot.bin \ wizboot2.prg \ - bootc64.prg \ cartheader.prg \ + wiztest.prg \ wizboot.prg \ + bootc64.prg \ %.o: %.s $(INCFILES) $(AS) $(AFLAGS) $< @@ -61,4 +62,5 @@ drivers: make -C ../drivers all bootc64.prg: - cp wizboot.prg ../../server/boot/bootc64.prg \ No newline at end of file +# cp wizboot.prg ../../server/boot/bootc64.prg + cp wiztest.prg ../../server/boot/bootc64.prg \ No newline at end of file diff --git a/client/wiznet/wiztest.s b/client/wiznet/wiztest.s new file mode 100644 index 0000000..1ba9f14 --- /dev/null +++ b/client/wiznet/wiztest.s @@ -0,0 +1,345 @@ + +;.include "../inc/common.i" +;.import cfg_get_configuration_ptr +;.include "../inc/commonprint.i" +; +;.include "../drivers/w5100.i" + + + +WIZNET_MODE_REG = $DE04 +WIZNET_ADDR_HI = $DE05 +WIZNET_ADDR_LO = $DE06 +WIZNET_DATA_REG = $DE07 + +TEST_LOOPS=$1F + +TX_BUFFER_START_PAGE=$40 + + +; 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 + + +.zeropage +pptr: .res 2 + +.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 + +init: + + lda $de01 + eor #$01 + sta $de01 ;enable clock port + + + lda #147 ;cls + jsr print_a + lda #142 ;go to upper case mode + jsr print_a + lda #$80 ;reset + sta WIZNET_MODE_REG + lda WIZNET_MODE_REG + beq @reset_ok + jmp @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 +@reset_ok: + lda #$13 ;set indirect mode, with autoinc, no auto PING + sta WIZNET_MODE_REG + lda WIZNET_MODE_REG + cmp #$13 + beq @mode_persists + ;make sure if we write to mode register without bit 7 set, + ;the value persists. + jmp @error +@mode_persists: + + ldax #w5100_found + jsr print + jsr print_base_address + + lda #0 + sta intersperse_address_reads +@reset_test_loops: + + lda #0 + sta loop_count + +@next_loop: + lda loop_count + and #$1f + clc + adc #TX_BUFFER_START_PAGE + sta test_page + + lda test_page + sta WIZNET_ADDR_HI + + lda #$00 + sta WIZNET_ADDR_LO + + + +; jmp @exit + + ldax #loop + jsr print + lda loop_count + jsr print_hex + + lda #':' + jsr print_a + jsr print_wiz_address + + + lda intersperse_address_reads + beq @without + ldax #with_address_reads + jsr print + jmp :+ +@without: + ldax #without + jsr print + ldax #address_reads + jsr print +: + lda #0 + sta byte_counter +@write_one_byte: + lda byte_counter + sta WIZNET_DATA_REG + lda intersperse_address_reads + beq :+ + lda WIZNET_ADDR_LO ;see if we can force a glitch! +: + + inc byte_counter + bne @write_one_byte + + ;reset the pointer to start of this page + + lda test_page + sta WIZNET_ADDR_HI + + lda #$00 + sta WIZNET_ADDR_LO + + + + ldx #0 +@test_one_byte: + lda WIZNET_DATA_REG + sta last_byte + cpx last_byte + beq @ok + txa + pha + ldax #error_offset + jsr print + pla + jsr print_hex + ldax #was + jsr print + lda last_byte + jsr print_hex + + jsr print_cr + + + lda test_page + sta WIZNET_ADDR_HI + + ldy #$00 ;# of bytes to print + jsr dump_wiznet_register_page + + jmp @exit + +@ok: + inx + bne @test_one_byte + +@after_test: + jsr print_cr + inc loop_count + lda loop_count + cmp #<(TEST_LOOPS+1) + beq :+ + jmp @next_loop +: + + lda intersperse_address_reads + bne @exit + inc intersperse_address_reads + jmp @reset_test_loops + +@exit: + + jmp $e37b + +@error: + ldax #not_found + jsr print + jsr print_base_address + + jmp @exit + +print_base_address: + lda #>WIZNET_MODE_REG + jsr print_hex + lda #