From 641453ffe92106e81140ccca3a921d18c5e4c4fc Mon Sep 17 00:00:00 2001 From: jonnosan Date: Sun, 5 Apr 2009 11:34:20 +0000 Subject: [PATCH] NB65_GET_INPUT_PACKET_INFO is not quite working yet git-svn-id: http://svn.code.sf.net/p/netboot65/code@86 93682198-c243-4bdb-bd91-e943c89aac3b --- client/clients/rrnetboot.s | 2 +- client/inc/commonprint.i | 2 +- client/inc/nb65_constants.i | 8 +- client/ip65/function_dispatcher.s | 47 ++++++++++-- client/test/test_cart_api.s | 119 +++++++++++++++++++++++++----- 5 files changed, 148 insertions(+), 30 deletions(-) diff --git a/client/clients/rrnetboot.s b/client/clients/rrnetboot.s index ae1c015..b8e61fe 100644 --- a/client/clients/rrnetboot.s +++ b/client/clients/rrnetboot.s @@ -302,7 +302,7 @@ download: ;AX should point at filename to download rts cfg_get_configuration_ptr: - ldy #NB65_GET_IP_CONFIG_PTR + ldy #NB65_GET_IP_CONFIG ldax #nb65_param_buffer jmp NB65_DISPATCH_VECTOR diff --git a/client/inc/commonprint.i b/client/inc/commonprint.i index 3585ae7..9dc40cd 100644 --- a/client/inc/commonprint.i +++ b/client/inc/commonprint.i @@ -7,7 +7,7 @@ .export failed_msg .export init_msg .export print - + .export print_decimal .zeropage pptr: .res 2 .bss diff --git a/client/inc/nb65_constants.i b/client/inc/nb65_constants.i index ab9b331..719ebdd 100644 --- a/client/inc/nb65_constants.i +++ b/client/inc/nb65_constants.i @@ -49,8 +49,10 @@ NB65_PAYLOAD_POINTER =$0A ;2 byte pointer to payload of ; then JSR NB65_DISPATCH_VECTOR ; on return, carry flag is set if there is an error, or clear otherwise ; some functions return results in AX directly, others will update the parameter buffer they were called with. +; any register not specified in outputs will have an undefined value on exit + NB65_GET_DRIVER_NAME =$01 ;no inputs, outputs AX=pointer to asciiz driver name -NB65_GET_IP_CONFIG_PTR =$02 ;AX=pointer to buffer where IP configuration structure written, outputs AX=points to same buffer, which has now been written to +NB65_GET_IP_CONFIG =$02 ;AX=pointer to buffer where IP configuration structure written, outputs AX=points to same buffer, which has now been written to NB65_INIT_IP =$03 ;no inputs or outputs - also sets IRQ chain to call NB65_VBL_VECTOR at @ 60hz NB65_INIT_DHCP =$04 ;no inputs or outputs (NB65_INIT_IP should be called first NB65_TFTP_DIRECTORY_LISTING =$05 ;inputs: AX points to a TFTP parameter structure, outputs: none @@ -63,9 +65,9 @@ NB65_GET_INPUT_PACKET_INFO =$09 ;inputs: AX points to a UDP packet parameter NB65_UNHOOK_VBL_IRQ =$0A ;inputs: none, outputs: none (removes call to NB65_VBL_VECTOR on IRQ chain) NB65_PRINT_ASCIIZ =$80 ;inputs: AX= pointer to null terminated string to be printed to screen, outputs: none -NB65_PRINT_HEX_DIGIT =$81 ;inputs: A = hex digit to be printed (to screen) +NB65_PRINT_HEX =$81 ;inputs: A = byte digit to be displayed on screen as (zero padded) hex digit, outputs: none NB65_PRINT_DOTTED_QUAD =$82 ;inputs: AX= pointer to 4 bytes that will be displayed as a decimal dotted quad (e.g. 192.168.1.1) -NB65_PRINT_IP_CONFIG =$83 ;no inputs, no outputs, prints (to screen) current IP configuration +NB65_PRINT_IP_CONFIG =$83 ;no inputs, no outputs, prints to screen current IP configuration NB65_GET_LAST_ERROR =$FF ;no inputs, outputs A = error code (from last function that set the global error value, not necessarily the diff --git a/client/ip65/function_dispatcher.s b/client/ip65/function_dispatcher.s index b1f2c07..3f53d81 100644 --- a/client/ip65/function_dispatcher.s +++ b/client/ip65/function_dispatcher.s @@ -25,6 +25,7 @@ .import udp_callback .import udp_add_listener .import ip_inp +.import udp_inp .import copymem .import cfg_mac @@ -92,7 +93,7 @@ nb65_dispatcher: rts : - cpy #NB65_GET_IP_CONFIG_PTR + cpy #NB65_GET_IP_CONFIG bne :+ stax copy_dest ldax #cfg_mac @@ -192,10 +193,47 @@ irq_handler_installed: jmp udp_add_listener : - cpy #NB65_GET_INPUT_PACKET_INFO bne :+ -fixme: + ldy #3 +@copy_src_ip: + lda ip_inp+12,y ;src IP + sta (nb65_params),y + dey + bpl @copy_src_ip + + ldy #NB65_REMOTE_PORT + lda udp_inp+1 ;src port (lo byte) + sta (nb65_params),y + iny + lda udp_inp+0 ;src port (high byte) + sta (nb65_params),y + iny + lda udp_inp+3 ;dest port (lo byte) + sta (nb65_params),y + iny + lda udp_inp+2 ;dest port (high byte) + sta (nb65_params),y + + iny + sec + lda udp_inp+5 ;payload length (lo byte) + sbc #8 ;to remove length of header + sta (nb65_params),y + + iny + lda udp_inp+4 ;payload length (hi byte) + sbc #0 ;in case there was a carry from the lo byte + sta (nb65_params),y + + iny + lda #udp_inp+8 ;payload ptr (hi byte) + sta (nb65_params),y + clc rts : @@ -218,7 +256,7 @@ fixme: rts : - cpy #NB65_PRINT_HEX_DIGIT + cpy #NB65_PRINT_HEX bne :+ jsr print_hex clc @@ -240,7 +278,6 @@ fixme: : - cpy #NB65_GET_LAST_ERROR bne :+ lda ip65_error diff --git a/client/test/test_cart_api.s b/client/test/test_cart_api.s index 8a6e993..3d61465 100644 --- a/client/test/test_cart_api.s +++ b/client/test/test_cart_api.s @@ -1,8 +1,7 @@ ;test the "NETBOOT65 Cartridge API" - .include "../inc/nb65_constants.i" +.include "../inc/nb65_constants.i" - ; load A/X macro .macro ldax arg .if (.match (.left (1, arg), #)) ; immediate mode @@ -23,11 +22,12 @@ print_a = $ffd2 - .bss - nb65_param_buffer: .res $10 - .zeropage - buffer_ptr: .res 2 +temp_ptr: .res 2 + + .bss + nb65_param_buffer: .res $20 + .segment "STARTUP" ;this is what gets put at the start of the file on the C64 @@ -70,11 +70,7 @@ init: lda #$01 sta $de00 ;turns on RR cartridge (since it will have been banked out when exiting to BASIC) - - print_cr - ldy #NB65_PRINT_IP_CONFIG - jsr NB65_DISPATCH_VECTOR - + ldy #NB65_INIT_IP jsr NB65_DISPATCH_VECTOR bcc :+ @@ -82,7 +78,19 @@ init: jsr print_errorcode jmp bad_boot : - + + ldy #NB65_GET_DRIVER_NAME + jsr NB65_DISPATCH_VECTOR + + ldy #NB65_PRINT_ASCIIZ + jsr NB65_DISPATCH_VECTOR + + ldax #initialized + ldy #NB65_PRINT_ASCIIZ + jsr NB65_DISPATCH_VECTOR + + print_cr + ldy #NB65_INIT_DHCP jsr NB65_DISPATCH_VECTOR @@ -95,8 +103,7 @@ init: ldy #NB65_PRINT_IP_CONFIG jsr NB65_DISPATCH_VECTOR - - ;jmp callback_test + jmp callback_test ldax #hostname_1 jsr do_dns_query @@ -117,8 +124,6 @@ init: jsr do_dns_query - - callback_test: ldax #64 @@ -145,15 +150,77 @@ callback_test: jmp $a7ae ;exit to basic udp_callback: + + ldax #nb65_param_buffer + ldy #NB65_GET_INPUT_PACKET_INFO + jsr NB65_DISPATCH_VECTOR + + ldax #port + ldy #NB65_PRINT_ASCIIZ + jsr NB65_DISPATCH_VECTOR + + lda nb65_param_buffer+NB65_LOCAL_PORT+1 + ldy #NB65_PRINT_HEX + jsr NB65_DISPATCH_VECTOR + + lda nb65_param_buffer+NB65_LOCAL_PORT + ldy #NB65_PRINT_HEX + jsr NB65_DISPATCH_VECTOR + + print_cr + ldax #recv_from ldy #NB65_PRINT_ASCIIZ jsr NB65_DISPATCH_VECTOR - ldy #NB65_GET_INPUT_PACKET_INFO + + ldax #nb65_param_buffer+NB65_REMOTE_IP + ldy #NB65_PRINT_DOTTED_QUAD jsr NB65_DISPATCH_VECTOR - stax buffer_ptr - rts + lda #' ' + jsr print_a + ldax #port + ldy #NB65_PRINT_ASCIIZ + jsr NB65_DISPATCH_VECTOR + lda nb65_param_buffer+NB65_REMOTE_PORT+1 + ldy #NB65_PRINT_HEX + jsr NB65_DISPATCH_VECTOR + lda nb65_param_buffer+NB65_REMOTE_PORT + ldy #NB65_PRINT_HEX + jsr NB65_DISPATCH_VECTOR + + print_cr + + ldax #length + ldy #NB65_PRINT_ASCIIZ + jsr NB65_DISPATCH_VECTOR + + lda nb65_param_buffer+NB65_PAYLOAD_LENGTH+1 + ldy #NB65_PRINT_HEX + jsr NB65_DISPATCH_VECTOR + lda nb65_param_buffer+NB65_PAYLOAD_LENGTH + ldy #NB65_PRINT_HEX + jsr NB65_DISPATCH_VECTOR + + ldax #data + ldy #NB65_PRINT_ASCIIZ + jsr NB65_DISPATCH_VECTOR + + ldax nb65_param_buffer+NB65_PAYLOAD_POINTER + stax temp_ptr + ldx nb65_param_buffer+NB65_PAYLOAD_LENGTH ;assumes length is < 255 + ldy #0 +: + lda (temp_ptr),y + jsr print_a + iny + dex + bne :- + + print_cr + + rts do_dns_query: ;AX points at the hostname on entry stax nb65_param_buffer+NB65_DNS_HOSTNAME @@ -197,7 +264,7 @@ print_errorcode: jsr NB65_DISPATCH_VECTOR ldy #NB65_GET_LAST_ERROR jsr NB65_DISPATCH_VECTOR - ldy #NB65_PRINT_HEX_DIGIT + ldy #NB65_PRINT_HEX jsr NB65_DISPATCH_VECTOR print_cr rts @@ -242,6 +309,18 @@ recv_from: listening: .byte "LISTENING.",13,0 + +initialized: + .byte " INITIALIZED.",13,0 + +port: + .byte "PORT: ",0 + +length: + .byte "LENGTH: ",0 +data: + .byte "DATA: ",0 + error_code: .asciiz "ERROR CODE: " press_a_key_to_continue: