simplified NB65 - this is now release candidate for 1.0 of the API definition (although not necessarily the implementation)

git-svn-id: http://svn.code.sf.net/p/netboot65/code@92 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
jonnosan 2009-04-10 01:19:42 +00:00
parent ae8a98f8a1
commit 3ffe25098b
7 changed files with 65 additions and 115 deletions

View File

@ -4,8 +4,8 @@
MEMORY {
ZP: start = $02, size = $1A, type = rw, define = yes;
IP65ZP: start = $5f, size = $10, type = rw, define = yes;
HEADER: start = $8000, size = $16, file = %O;
ROM: start = $8016, size = $1F00, define = yes, file = %O;
HEADER: start = $8000, size = $18, file = %O;
ROM: start = $8018, size = $1F00, define = yes, file = %O;
RAM: start = $C080, size = $0f80, define = yes;

View File

@ -38,7 +38,6 @@
.import print_hex
.import print_ip_config
.import dhcp_msg
.import ok_msg
.import failed_msg
.import init_msg
@ -72,6 +71,8 @@ nb65_param_buffer: .res $20
.word $FE47 ;warm start vector
.byte $C3,$C2,$CD,$38,$30 ; "CBM80"
.byte $4E,$42,$36,$35 ; "NB65" - API signature
.byte $01 ;NB65_API_VERSION
.byte $02 ;NB65_BANKSWITCH_SUPPORT
jmp nb65_dispatcher ; NB65_DISPATCH_VECTOR : entry point for NB65 functions
jmp ip65_process ;NB65_PERIODIC_PROCESSING_VECTOR : routine to be periodically called to check for arrival of ethernet packects
jmp timer_vbl_handler ;NB65_VBL_VECTOR : routine to be called during each vertical blank interrupt
@ -133,13 +134,10 @@ init:
@tftp_boot:
ldy #NB65_GET_DRIVER_NAME
jsr NB65_DISPATCH_VECTOR
jsr print
ldax #init_msg
jsr print
ldy #NB65_INIT_IP
ldy #NB65_INITIALIZE
jsr NB65_DISPATCH_VECTOR
bcc :+
@ -150,20 +148,6 @@ init:
print_ok
ldax #dhcp_msg
jsr print
ldax #init_msg
jsr print
ldy #NB65_INIT_DHCP
jsr NB65_DISPATCH_VECTOR
bcc :+
print_failed
jsr print_errorcode
jmp bad_boot
:
print_ok
jsr print_ip_config
ldax #press_a_key_to_continue
@ -226,8 +210,8 @@ init:
@file_downloaded_ok:
;remove the IP timer code from IRQ chain
ldy #NB65_UNHOOK_VBL_IRQ
;get ready to bank out
ldy #NB65_DEACTIVATE
jsr NB65_DISPATCH_VECTOR
;check whether the file we just downloaded was a BASIC prg

View File

@ -7,7 +7,9 @@
.export failed_msg
.export init_msg
.export print
.export print_decimal
.export print_decimal
.import cs_driver_name
.zeropage
pptr: .res 2
.bss
@ -49,8 +51,14 @@ temp_bcd: .res 2
.import print_cr
.import cs_driver_name
print_ip_config:
ldax #interface_type
jsr print
ldax #cs_driver_name
jsr print
jsr print_cr
ldax #mac_address_msg
jsr print
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
@ -245,29 +253,32 @@ print_hex:
hexdigits:
.byte "0123456789ABCDEF"
interface_type:
.byte "INTERFACE : ",0
mac_address_msg:
.byte "MAC ADDRESS: ", 0
.byte "MAC ADDRESS : ", 0
ip_address_msg:
.byte "IP ADDRESS: ", 0
.byte "IP ADDRESS : ", 0
netmask_msg:
.byte "NETMASK: ", 0
.byte "NETMASK : ", 0
gateway_msg:
.byte "GATEWAY: ", 0
.byte "GATEWAY : ", 0
dns_server_msg:
.byte "DNS SERVER: ", 0
.byte "DNS SERVER : ", 0
dhcp_server_msg:
.byte "DHCP SERVER:", 0
.byte "DHCP SERVER : ", 0
dhcp_msg:
.byte "DHCP",0
init_msg:
.byte " INIT ",0
.byte "INIT ",0
failed_msg:
.byte "FAILED", 0

View File

@ -1,12 +1,14 @@
.ifndef NB65_API_VERSION
.ifndef NB65_API_VERSION_NUMBER
NB65_API_VERSION=$0001
NB65_API_VERSION_NUMBER=$01
NB65_CART_SIGNATURE = $8009
NB65_DISPATCH_VECTOR = $800d
NB65_PERIODIC_PROCESSING_VECTOR = $8010
NB65_VBL_VECTOR = $8013
NB65_API_VERSION = $800d
NB65_BANKSWITCH_SUPPORT = $800e
NB65_DISPATCH_VECTOR = $800f
NB65_PERIODIC_PROCESSING_VECTOR = $8012
NB65_VBL_VECTOR = $8015
NB65_RAM_STUB_SIGNATURE = $C000
NB65_RAM_STUB_ACTIVATE = $C004
@ -19,20 +21,17 @@ NB65_RAM_STUB_ACTIVATE = $C004
; 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 =$02 ;AX=pointer to buffer where IP configuration structure written, outputs AX=points to same buffer, which has now been written to
NB65_SET_IP_CONFIG =$03 ;AX=pointer to buffer where IP configuration structure written, outputs AX=points to same buffer, which has now been written to
NB65_INIT_IP =$04 ;no inputs or outputs - also sets IRQ chain to call NB65_VBL_VECTOR at @ 60hz
NB65_INIT_DHCP =$05 ;no inputs or outputs (NB65_INIT_IP should be called first
NB65_TFTP_DIRECTORY_LISTING =$06 ;inputs: AX points to a TFTP parameter structure, outputs: none
NB65_TFTP_DOWNLOAD =$07 ;inputs: AX points to a TFTP parameter structure, outputs: TFTP param structure updated with
NB65_INITIALIZE =$01 ;no inputs or outputs - initializes IP stack, also sets IRQ chain to call NB65_VBL_VECTOR at @ 60hz
NB65_GET_IP_CONFIG =$02 ;no inputs, outputs AX=pointer to IP configuration structure
NB65_TFTP_DIRECTORY_LISTING =$03 ;inputs: AX points to a TFTP parameter structure, outputs: none
NB65_TFTP_DOWNLOAD =$04 ;inputs: AX points to a TFTP parameter structure, outputs: TFTP param structure updated with
;NB65_TFTP_POINTER updated to reflect actual load address (if load address $0000 originally passed in)
NB65_DNS_RESOLVE_HOSTNAME =$08 ;inputs: AX points to a DNS parameter structure, outputs: DNS param structure updated with
NB65_DNS_RESOLVE =$05 ;inputs: AX points to a DNS parameter structure, outputs: DNS param structure updated with
;NB65_DNS_HOSTNAME_IP updated with IP address corresponding to hostname.
NB65_UDP_ADD_LISTENER =$09 ;inputs: AX points to a UDP listener parameter structure, outputs: none
NB65_GET_INPUT_PACKET_INFO =$0A ;inputs: AX points to a UDP packet parameter structure, outputs: UDP packet structure filled in
NB65_SEND_UDP_PACKET =$0B ;inputs: AX points to a UDP packet parameter structure, outputs: none packet is sent
NB65_UNHOOK_VBL_IRQ =$0C ;inputs: none, outputs: none (removes call to NB65_VBL_VECTOR on IRQ chain)
NB65_UDP_ADD_LISTENER =$06 ;inputs: AX points to a UDP listener parameter structure, outputs: none
NB65_GET_INPUT_PACKET_INFO =$07 ;inputs: AX points to a UDP packet parameter structure, outputs: UDP packet structure filled in
NB65_SEND_UDP_PACKET =$08 ;inputs: AX points to a UDP packet parameter structure, outputs: none packet is sent
NB65_DEACTIVATE =$09 ;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 =$81 ;inputs: A = byte digit to be displayed on screen as (zero padded) hex digit, outputs: none
@ -43,20 +42,21 @@ NB65_PRINT_IP_CONFIG =$83 ;no inputs, no outputs, prints to screen curr
NB65_GET_LAST_ERROR =$FF ;no inputs, outputs A = error code (from last function that set the global error value, not necessarily the
;last function that was called)
;offsets in NB65 configuration structure
;offsets in IP configuration structure (used by NB65_GET_IP_CONFIG)
NB65_CFG_MAC = $00 ;6 byte MAC address
NB65_CFG_IP = $06 ;4 byte local IP address (will be overwritten by DHCP)
NB65_CFG_NETMASK = $0A ;4 byte local netmask (will be overwritten by DHCP)
NB65_CFG_GATEWAY = $0D ;4 byte local gateway (will be overwritten by DHCP)
NB65_CFG_DNS_SERVER = $12 ;4 byte IP address of DNS server (will be overwritten by DHCP)
NB65_CFG_DHCP_SERVER = $16 ;4 byte IP address of DHCP server (will only be set by DHCP initialisation)
NB65_DRIVER_NAME = $1A ;2 byte pointer to name of driver
;offsets in TFTP parameter structure
;offsets in TFTP parameter structure (used by NB65_TFTP_DIRECTORY_LISTING & NB65_TFTP_DOWNLOAD)
NB65_TFTP_IP = $00 ;4 byte IP address of TFTP server
NB65_TFTP_FILENAME = $04 ;2 byte pointer to asciiz filename (or filemask in case of NB65_TFTP_DIRECTORY_LISTING)
NB65_TFTP_POINTER = $06 ;2 byte pointer to memory location data to be stored in OR address of tftp callback
NB65_TFTP_POINTER = $06 ;2 byte pointer to memory location data to be stored in
;offsets in TFTP parameter structure
;offsets in DNS parameter structure (used by NB65_DNS_RESOLVE)
NB65_DNS_HOSTNAME = $00 ;2 byte pointer to asciiz hostname to resolve (can also be a dotted quad string)
NB65_DNS_HOSTNAME_IP= $00 ;4 byte IP address (filled in on succesful resolution of hostname)
@ -77,6 +77,7 @@ NB65_ERROR_TIMEOUT_ON_RECEIVE = $81
NB65_ERROR_TRANSMIT_FAILED = $82
NB65_ERROR_TRANSMISSION_REJECTED_BY_PEER = $83
NB65_ERROR_INPUT_TOO_LARGE = $84
NB65_ERROR_DEVICE_FAILURE = $85
NB65_ERROR_OPTION_NOT_SUPPORTED = $FE
NB65_ERROR_FUNCTION_NOT_SUPPORTED = $FF

View File

@ -10,7 +10,6 @@
.import ip65_init
.import dhcp_init
.import cs_driver_name
.import cfg_get_configuration_ptr
.import tftp_load_address
.importzp tftp_filename
@ -91,38 +90,8 @@ nb65_dispatcher:
stax nb65_params
cpy #NB65_GET_DRIVER_NAME
bne :+
ldax #cs_driver_name
clc
rts
:
cpy #NB65_GET_IP_CONFIG
bne :+
stax copy_dest
ldax #cfg_mac
stax copy_src
ldax #NB65_CFG_DHCP_SERVER+4 ;bytes to copy
jsr copymem
clc
ldax nb65_params
rts
:
cpy #NB65_SET_IP_CONFIG
bne :+
stax copy_src
ldax #cfg_mac
stax copy_dest
ldax #NB65_CFG_DHCP_SERVER+4 ;bytes to copy
jsr copymem
clc
ldax nb65_params
rts
:
cpy #NB65_INIT_IP
cpy #NB65_INITIALIZE
bne :+
lda irq_handler_installed_flag
bne irq_handler_installed
@ -135,14 +104,19 @@ nb65_dispatcher:
cli
sta irq_handler_installed_flag
irq_handler_installed:
jmp ip65_init
:
cpy #NB65_INIT_DHCP
bne :+
jsr ip65_init
jmp dhcp_init
:
cpy #NB65_GET_IP_CONFIG
bne :+
ldax #cfg_mac
clc
rts
:
cpy #NB65_TFTP_DIRECTORY_LISTING
bne :+
jsr set_tftp_params
@ -171,7 +145,7 @@ irq_handler_installed:
jmp @after_tftp_call
:
cpy #NB65_DNS_RESOLVE_HOSTNAME
cpy #NB65_DNS_RESOLVE
bne :+
ldy #NB65_DNS_HOSTNAME+1
lda (nb65_params),y
@ -297,7 +271,7 @@ irq_handler_installed:
jmp udp_send
:
cpy #NB65_UNHOOK_VBL_IRQ
cpy #NB65_DEACTIVATE
bne :+
ldax jmp_old_irq+1
sei ;don't want any interrupts while we fiddle with the vector

View File

@ -94,14 +94,10 @@ init:
jsr NB65_RAM_STUB_ACTIVATE ;we need to turn on NB65 cartridge
@found_nb65_signature:
call #NB65_GET_DRIVER_NAME
call #NB65_PRINT_ASCIIZ
print #initializing
ldy #NB65_INIT_IP
ldy #NB65_INITIALIZE
jsr NB65_DISPATCH_VECTOR
bcc :+
print #failed
@ -112,19 +108,6 @@ init:
print #ok
print_cr
print #dhcp
print #initializing
call #NB65_INIT_DHCP
bcc :+
print #failed
jsr print_errorcode
jmp bad_boot
:
print #ok
print_cr
call #NB65_PRINT_IP_CONFIG
;DNS resolution test
@ -139,7 +122,7 @@ init:
cout #' '
ldax #nb65_param_buffer
call #NB65_DNS_RESOLVE_HOSTNAME
call #NB65_DNS_RESOLVE
bcc :+
print #dns_lookup_failed_msg
print_cr
@ -289,10 +272,7 @@ reply_sent:
initializing:
.byte " INITIALIZING ",0
dhcp:
.byte "DHCP",0
.byte "INITIALIZING ",0
port:
.byte "PORT: $",0

Binary file not shown.