git-svn-id: http://svn.code.sf.net/p/netboot65/code@304 93682198-c243-4bdb-bd91-e943c89aac3b

This commit is contained in:
jonnosan 2011-01-08 11:48:24 +00:00
parent 268979d8b2
commit 1061221a54
7 changed files with 264 additions and 61 deletions

Binary file not shown.

Binary file not shown.

View File

@ -15,7 +15,8 @@
.bss .bss
current_time_value: .res 2 current_time_value: .res 2
current_seconds: .res 1
current_jiffies: .res 1
.data .data
jmp_old_handler: jmp_old_handler:
.byte $4c ;JMP .byte $4c ;JMP
@ -35,8 +36,11 @@ timer_init:
ldax #timer_vbl_handler ldax #timer_vbl_handler
stax IRQ_VECTOR stax IRQ_VECTOR
@handler_installed: @handler_installed:
ldax #0 lda #0
stax current_time_value sta current_time_value
sta current_time_value+1
sta current_seconds
sta current_jiffies
rts rts
;read the current timer value ;read the current timer value
@ -57,11 +61,47 @@ timer_vbl_handler:
bcc :+ bcc :+
inc current_time_value+1 inc current_time_value+1
: :
inc current_jiffies
lda current_jiffies
cmp #60
bne @done
lda #0
sta current_jiffies
inc current_seconds
;we don't want to mess around with decimal mode in an IRQ handler
lda current_seconds
cmp #$0a
bne :+
lda #$10
:
cmp #$1a
bne :+
lda #$20
:
cmp #$2a
bne :+
lda #$30
:
cmp #$3a
bne :+
lda #$40
:
cmp #$4a
bne :+
lda #$50
:
cmp #$5a
bne :+
lda #$00
:
sta current_seconds
@done:
pla pla
jmp jmp_old_handler jmp jmp_old_handler
timer_seconds: timer_seconds:
lda #0 lda current_seconds
rts rts
;-- LICENSE FOR c64timer_nb65.s -- ;-- LICENSE FOR c64timer_nb65.s --

View File

@ -10,7 +10,7 @@
.include "../inc/kipper_constants.i" .include "../inc/kipper_constants.i"
.endif .endif
DEFAULT_CIFS_CMD_BUFFER = $2800 DEFAULT_CIFS_CMD_BUFFER = $6800
.export cifs_l1_encode .export cifs_l1_encode
.export cifs_l1_decode .export cifs_l1_decode
.export cifs_start .export cifs_start
@ -32,10 +32,14 @@ DEFAULT_CIFS_CMD_BUFFER = $2800
.importzp ip_src .importzp ip_src
.import ip_data .import ip_data
.import ip_inp .import ip_inp
.import tcp_close
.import tcp_listen .import tcp_listen
.import tcp_callback .import tcp_callback
.import tcp_inbound_data_length .import tcp_inbound_data_length
.import tcp_inbound_data_ptr .import tcp_inbound_data_ptr
.import tcp_send
.import tcp_send_data_len
.import ip65_process .import ip65_process
.import udp_add_listener .import udp_add_listener
.import udp_callback .import udp_callback
@ -208,28 +212,17 @@ cifs_start:
;broadcast a Name Registration Request message to the local LAN ;broadcast a Name Registration Request message to the local LAN
cifs_advertise_hostname: cifs_advertise_hostname:
;start with a template registration request message
ldx #nbns_registration_message_length
@copy_message_loop:
lda workgroup_registration_request,x
sta output_buffer,x
dex
bpl @copy_message_loop
; advertise the 'server' service for own hostname ; advertise the 'server' service for own hostname
;overwrite the hostname in 'DNS compressed form' ;overwrite the hostname in 'DNS compressed form'
;we assume this hostname ends with <20> ;we assume this hostname ends with <20>
lda #$20 ;indicates what follows is a netbios name lda #$20 ;indicates what follows is a netbios name
sta output_buffer+nbns_question_name sta output_buffer+nbns_question_name
ldx #0 ldx #0
@copy_hostname_loop: @copy_hostname_loop:
lda local_hostname,x lda local_hostname,x
sta output_buffer+nbns_question_name+1,x sta registration_request_servername+1,x
inx inx
cpx #$21 cpx #$21
bmi @copy_hostname_loop bmi @copy_hostname_loop
@ -237,19 +230,10 @@ cifs_advertise_hostname:
jsr @send_nbns_message jsr @send_nbns_message
;now send the host announcement
ldax #host_announce_message
stax copy_src
ldax #output_buffer
stax copy_dest
ldax #host_announce_message_length
jsr copymem
;copy our encode hostname to the host announcment ;copy our encode hostname to the host announcment
ldax #local_hostname ldax #local_hostname
stax copy_src stax copy_src
ldax # output_buffer+host_announce_hostname ldax #host_announce_hostname
stax copy_dest stax copy_dest
ldax #$20 ldax #$20
jsr copymem jsr copymem
@ -257,7 +241,7 @@ cifs_advertise_hostname:
;copy our encode hostname to the host announcment ;copy our encode hostname to the host announcment
ldax #raw_local_hostname ldax #raw_local_hostname
stax copy_src stax copy_src
ldax # output_buffer+host_announce_servername ldax #host_announce_servername
stax copy_dest stax copy_dest
ldax #$10 ldax #$10
jsr copymem jsr copymem
@ -267,7 +251,7 @@ cifs_advertise_hostname:
ldx #03 ldx #03
@copy_sending_address_loop: @copy_sending_address_loop:
lda cfg_ip,x lda cfg_ip,x
sta output_buffer+host_announce_my_ip,x sta host_announce_my_ip,x
dex dex
bpl @copy_sending_address_loop bpl @copy_sending_address_loop
@ -279,7 +263,7 @@ cifs_advertise_hostname:
ldax #host_announce_message_length ldax #host_announce_message_length
stax udp_send_len stax udp_send_len
ldax #output_buffer ldax #host_announce_message
jsr udp_send jsr udp_send
rts rts
@ -289,7 +273,7 @@ cifs_advertise_hostname:
ldx #03 ldx #03
@copy_my_address_loop: @copy_my_address_loop:
lda cfg_ip,x lda cfg_ip,x
sta output_buffer+nbns_my_ip,x sta nbns_my_ip,x
dex dex
bpl @copy_my_address_loop bpl @copy_my_address_loop
@ -308,7 +292,7 @@ cifs_advertise_hostname:
ldax #nbns_registration_message_length ldax #nbns_registration_message_length
stax udp_send_len stax udp_send_len
ldax #output_buffer ldax #registration_request
jsr udp_send jsr udp_send
@ -394,6 +378,7 @@ nb_session_callback:
lda tcp_inbound_data_length+1 lda tcp_inbound_data_length+1
cmp #$ff cmp #$ff
bne @not_eof bne @not_eof
@eof:
inc connection_closed inc connection_closed
@done: @done:
rts rts
@ -438,7 +423,53 @@ nb_session_callback:
bne @not_got_full_message bne @not_got_full_message
;we have a complete message! ;we have a complete message!
inc $d020 ldy #0
lda (copy_src),y ;get the message type
cmp #$81 ;is it a session request?
bne @not_session_request
ldax #positive_session_response_packet_length
stax tcp_send_data_len
ldax #positive_session_response_packet
jsr tcp_send
jmp @message_handled
@not_session_request:
cmp #$00 ;is it a session message?
bne @not_session_message
;this SHOULD be a SMB - best check the header
ldy #4
lda (copy_src),y ;get the message data
cmp #$FF ;start of SMB header
bne @not_smb
iny
lda (copy_src),y ;get the message data
cmp #'S' ;start of SMB header
bne @not_smb
jsr smb_handler
jmp @message_handled
;this doesn't look like a NBT session message or SMB, so give up
@not_session_message:
@not_smb:
jsr tcp_close
jmp @eof
@message_handled:
;reset ready for next message on this connection
ldax #-4 ;start at -4, to skip the NBT header length
stax cifs_cmd_length
ldax cifs_cmd_buffer
stax cifs_cmd_buffer_ptr
@not_got_full_message: @not_got_full_message:
.import print_hex .import print_hex
lda cifs_cmd_length+1 lda cifs_cmd_length+1
@ -448,19 +479,136 @@ nb_session_callback:
rts rts
.rodata smb_handler:
; at this point, copy_src points to an SMB block encapsulated in an NBT session header
ldy #8
lda (copy_src),y ;get the SMB type
cmp #$72
beq @negotiate_protcol
;unknown SMB
rts
@negotiate_protcol:
;copy the request TID,PID,UID,MID into the response
ldy #28 ;offset of TID from start of message
ldx #0
:
lda (copy_src),y
sta negotiate_protocol_response_tid,x
inx
iny
cpx #8
bne :-
lda #$ff
sta dialect_index
sta dialect_index+1
clc
lda cifs_cmd_buffer
adc #$26
sta copy_src
lda cifs_cmd_buffer+1
adc #$00
sta copy_src+1
ldy #$0
@dialect_scan_loop:
iny
bmi @end_of_dialects ;if we go to offset $80, we have gone too far
lda dialect_index
cmp #$10 ;if we've scanned more than $10 dialects, something is wrong
beq @end_of_dialects
lda (copy_src),y
cmp #$02
bne @test_dialect
inc dialect_index
jmp @dialect_scan_loop
@test_dialect:
tya
clc
adc copy_src
sta copy_src
bcc :+
inc copy_src+1
:
ldy #0
@test_dialect_loop:
lda (copy_src),y
cmp preferred_dialect_id,y
bne @dialect_scan_loop
iny
cpy #preferred_dialect_id_length
bne @test_dialect_loop
inc dialect_index+1
jmp @found_preferred_dialect
@end_of_dialects:
lda #$ff
sta dialect_index
@found_preferred_dialect:
ldax #negotiate_protocol_response_message_length
stax tcp_send_data_len
ldax #negotiate_protocol_response_message
jsr tcp_send
rts
.data
negotiate_protocol_response_message:
.byte $00 ;message type = session message
.byte $00,$00,negotiate_protocol_response_message_length-4 ;NBT header
.byte $FF,"SMB" ;SMB header
.byte $72 ;command = negotiate protocol
.byte $00,$00,$00,$00 ;status = OK
.byte $82 ;flags : oplocks not supported, paths are case sensitive
.byte $01,$00 ;flags 2 - long file names allowed
.byte $00, $00 ;PID HIGH
.byte $00,$00,$00,$00,$00,$00,$00,$00 ; signature
.byte $00, $00 ;reserved
negotiate_protocol_response_tid:
.byte $00,$00 ;tree ID
.byte $98,$76 ;PID - to be overwritten
.byte $65,$64 ;USER ID - to be overwritten
.byte $ab,$cd ;multiplex ID - to be overwritten
.byte $11 ;word count
dialect_index: .res 2 ;index of selected dialect
.byte $00 ;security mode: share, no encryption
.byte $01,$00 ;Max MPX count
.byte $01,$00 ;Max VCs count
.byte $00,$08,$00,$00 ;max buffer size
.byte $00,$08,$00,$00 ;max raw size
.byte $12,$34,$56,$78 ;session key
.byte $00,$00,$00,$00 ;capabilities
.byte $00,$00,$00,$00 ;server time low
.byte $00,$00,$00,$00 ;server time high
.byte $00,$00 ;server GMT offset
.byte $00 ;encryption key length
.word negotiate_protocol_response_message_data_length ;data length
negotiate_protocol_response_message_data:
.byte "WORKGROUP",0
.byte "SERVERNAME",0
negotiate_protocol_response_message_length=*-negotiate_protocol_response_message
negotiate_protocol_response_message_data_length=*-negotiate_protocol_response_message_data
host_announce_message: host_announce_message:
.byte $11 ;message type = direct group datagram .byte $11 ;message type = direct group datagram
.byte $02 ;no more fragments, this is first fragment, node type = B .byte $02 ;no more fragments, this is first fragment, node type = B
.byte $ab,$cd ;txn id .byte $ab,$cd ;txn id
host_announce_my_ip=*- host_announce_message host_announce_my_ip:
.byte $0,0,0,0 ;source IP .byte $0,0,0,0 ;source IP
.byte $0,138 ;source port .byte $0,138 ;source port
.byte $00,<(host_announce_message_length-4) ;datagram length .byte $00,<(host_announce_message_length-4) ;datagram length
.byte $00,$00 ;packet offset .byte $00,$00 ;packet offset
.byte $20 ;hostname length .byte $20 ;hostname length
host_announce_hostname=*- host_announce_message host_announce_hostname:
.res 32 ;hostname .res 32 ;hostname
.byte $0 ;nul at end of hostname .byte $0 ;nul at end of hostname
;now WORKGROUP<1D> encoded ;now WORKGROUP<1D> encoded
@ -507,7 +655,7 @@ host_announce_hostname=*- host_announce_message
.byte $01 ;command - HOST ANNOUNCEMENT .byte $01 ;command - HOST ANNOUNCEMENT
.byte $0 ;update count 0 .byte $0 ;update count 0
.byte $80,$fc,03,00 ;update period .byte $80,$fc,03,00 ;update period
host_announce_servername =*-host_announce_message host_announce_servername:
.res 16 .res 16
.byte $01 ;OS major version .byte $01 ;OS major version
.byte $64 ;OS minor version .byte $64 ;OS minor version
@ -519,7 +667,7 @@ host_announce_hostname=*- host_announce_message
host_announce_message_length=*-host_announce_message host_announce_message_length=*-host_announce_message
workgroup_registration_request: registration_request:
.byte $0c, $64 ;txn ID .byte $0c, $64 ;txn ID
.byte $29,$10 ;Registration Request opcode & flags .byte $29,$10 ;Registration Request opcode & flags
@ -527,6 +675,7 @@ workgroup_registration_request:
.byte $00,$00 ;answers = 0 .byte $00,$00 ;answers = 0
.byte $00,$00 ;authority records = 0 .byte $00,$00 ;authority records = 0
.byte $00,$01 ;additional records = 1 .byte $00,$01 ;additional records = 1
registration_request_servername:
;now WORKGROUP<00> encoded ;now WORKGROUP<00> encoded
.byte $20, $46, $48, $45, $50, $46, $43, $45, $4c, $45, $48, $46, $43, $45, $50, $46 .byte $20, $46, $48, $45, $50, $46, $43, $45, $4c, $45, $48, $46, $43, $45, $50, $46
.byte $46, $46, $41, $43, $41, $43, $41, $43, $41, $43, $41, $43, $41, $43, $41, $41, $41, $00 .byte $46, $46, $41, $43, $41, $43, $41, $43, $41, $43, $41, $43, $41, $43, $41, $41, $41, $00
@ -540,14 +689,22 @@ nbns_ttl_etc:
.byte $00,$00,$01,$40 ; TTL = 64 seconds .byte $00,$00,$01,$40 ; TTL = 64 seconds
.byte $00,$06 ;data length .byte $00,$06 ;data length
.byte $00,$00 ;FLAGS = B-NODE, UNIQUE NAME .byte $00,$00 ;FLAGS = B-NODE, UNIQUE NAME
.rodata
preferred_dialect_id: .byte "NT LM 0.12"
preferred_dialect_id_length=*-preferred_dialect_id
positive_session_response_packet:
.byte $82 ;packet type = Positive session response
.byte $00 ;flags
.byte $00, $00 ;message length
positive_session_response_packet_length=*-positive_session_response_packet
.bss .bss
hostname_buffer: hostname_buffer: .res 33
.res 33
local_hostname: local_hostname: .res 33
.res 33
raw_local_hostname: raw_local_hostname:
.res 16 .res 16
@ -558,6 +715,7 @@ connection_closed: .res 1
cifs_cmd_buffer_ptr: .res 2 cifs_cmd_buffer_ptr: .res 2
cifs_cmd_length: .res 2 cifs_cmd_length: .res 2
.data .data
cifs_cmd_buffer: .word DEFAULT_CIFS_CMD_BUFFER cifs_cmd_buffer: .word DEFAULT_CIFS_CMD_BUFFER

View File

@ -10,7 +10,6 @@
HTTPD_TIMEOUT_SECONDS=5 ;what's the maximum time we let 1 connection be open for? HTTPD_TIMEOUT_SECONDS=5 ;what's the maximum time we let 1 connection be open for?
;DEBUG=1
.export httpd_start .export httpd_start
@ -36,6 +35,7 @@ HTTPD_TIMEOUT_SECONDS=5 ;what's the maximum time we let 1 connection be open for
.import io_read_file_with_callback .import io_read_file_with_callback
.import io_filename .import io_filename
.import io_callback .import io_callback
.import timer_seconds
.import __HTTP_VARS_LOAD__ .import __HTTP_VARS_LOAD__
.import __HTTP_VARS_RUN__ .import __HTTP_VARS_RUN__
.import __HTTP_VARS_SIZE__ .import __HTTP_VARS_SIZE__
@ -144,14 +144,12 @@ httpd_start:
bcc @connect_ok bcc @connect_ok
rts rts
@connect_ok: @connect_ok:
.ifdef DEBUG
inc $d020
.endif
lda #0 lda #0
sta connection_closed sta connection_closed
sta found_eol sta found_eol
clc clc
lda $dc09 ;time of day clock: seconds (in BCD) jsr timer_seconds ;time of day clock: seconds (in BCD)
sed sed
adc #HTTPD_TIMEOUT_SECONDS adc #HTTPD_TIMEOUT_SECONDS
cmp #$60 cmp #$60
@ -173,7 +171,7 @@ httpd_start:
lda found_eol lda found_eol
bne @got_eol bne @got_eol
lda $dc09 ;time of day clock: seconds jsr timer_seconds ;time of day clock: seconds
cmp connection_timeout_seconds cmp connection_timeout_seconds
beq @connection_timed_out beq @connection_timed_out
@ -192,9 +190,6 @@ httpd_start:
jsr send_response jsr send_response
: :
.ifdef DEBUG
dec $d020
.endif
jmp @listen ;go listen for the next request jmp @listen ;go listen for the next request

View File

@ -37,6 +37,7 @@ PAD = $1A ;padding added to end of file
.import print_cr .import print_cr
.import print_ascii_as_native .import print_ascii_as_native
.import print_hex .import print_hex
.import timer_seconds
.segment "SELF_MODIFIED_CODE" .segment "SELF_MODIFIED_CODE"
got_byte: got_byte:
@ -513,7 +514,7 @@ getc:
sta getc_timeout_seconds sta getc_timeout_seconds
clc clc
lda $dc09 ;time of day clock: seconds (in BCD) jsr timer_seconds ;time of day clock: seconds (in BCD)
sed sed
adc getc_timeout_seconds adc getc_timeout_seconds
cmp #$60 cmp #$60
@ -537,7 +538,7 @@ getc:
rts rts
@no_abort: @no_abort:
jsr ip65_process jsr ip65_process
lda $dc09 ;time of day clock: seconds jsr timer_seconds ;time of day clock: seconds
cmp getc_timeout_end cmp getc_timeout_end
bne @poll_loop bne @poll_loop
lda #00 lda #00

View File

@ -9,8 +9,8 @@
.import timer_init .import timer_init
.import timer_read .import timer_read
.import timer_seconds
.import beep
.segment "STARTUP" ;this is what gets put at the start of the file on the C64 .segment "STARTUP" ;this is what gets put at the start of the file on the C64
.word basicstub ; load address .word basicstub ; load address
@ -38,7 +38,15 @@ init:
init_ip_via_dhcp init_ip_via_dhcp
jsr print jsr print
jsr print_ip_config jsr print_ip_config
jsr beep
@loop:
jsr timer_seconds
cmp last_seconds
beq @loop
sta last_seconds
jsr print_hex
jmp @loop
rts rts
@ -49,7 +57,8 @@ print_ax:
pla pla
jmp print_hex jmp print_hex
.data
last_seconds: .byte 0
;-- LICENSE FOR test_tcp.s -- ;-- LICENSE FOR test_tcp.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License