Subversion Repositories Spectranet

[/] [branches/] [gnubinutils/] [rom/] [w5100_ifconfig.asm] - Diff between revs 371 and 384

Show entire file | Details | Blame | View Log

Rev 371 Rev 384
Line 21... Line 21...
;THE SOFTWARE.
;THE SOFTWARE.
;
;
; Interface configuration functions - to abstract the W5100 away from
; Interface configuration functions - to abstract the W5100 away from
; software that needs to configure the interface.
; software that needs to configure the interface.
;
;
 
.include        "w5100_defs.inc"
 
.include        "sysvars.inc"
 
 
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
; F_ifconfig_ routines: F_ifconfig_inet, F_ifconfig_gw, F_ifconfig_netmask
; F_ifconfig_ routines: F_ifconfig_inet, F_ifconfig_gw, F_ifconfig_netmask
; Configures the basic settings needed for the W5100.
; Configures the basic settings needed for the W5100.
; Parameters: HL - pointer to the 4 byte block of memory with the IPv4
; Parameters: HL - pointer to the 4 byte block of memory with the IPv4
; info.
; info.
; DE is incremented by 4.
; DE is incremented by 4.
F_ifconfig_gw
.text
 
.globl F_ifconfig_gw
 
F_ifconfig_gw:
        call F_regpage
        call F_regpage
        ld de, GAR0     ; gateway address register
        ld de, GAR0     ; gateway address register
        jr J_copy_cfg
        jr J_copy_cfg
 
 
F_ifconfig_inet
.globl F_ifconfig_inet
 
F_ifconfig_inet:
        call F_regpage
        call F_regpage
        ld de, SIPR0
        ld de, SIPR0
        jr J_copy_cfg
        jr J_copy_cfg
 
 
F_ifconfig_netmask
.globl F_ifconfig_netmask
 
F_ifconfig_netmask:
        call F_regpage
        call F_regpage
        ld de, SUBR0
        ld de, SUBR0
        jr J_copy_cfg
        jr J_copy_cfg
 
 
J_copy_cfg
J_copy_cfg:
        ld bc, 4
        ld bc, 4
        ldir
        ldir
        jp J_leavesockfn
        jp J_leavesockfn
 
 
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
; F_get_ifconfig routines: F_get_ifconfig_inet, gw, netmask:
; F_get_ifconfig routines: F_get_ifconfig_inet, gw, netmask:
; Returns the inet settings into a 4-byte buffer pointed to by DE
; Returns the inet settings into a 4-byte buffer pointed to by DE
; in big-endian format.
; in big-endian format.
F_get_ifconfig_gw
.globl F_get_ifconfig_gw
 
F_get_ifconfig_gw:
        call F_regpage
        call F_regpage
        ld hl, GAR0
        ld hl, GAR0
        jr J_copy_cfg
        jr J_copy_cfg
 
 
F_get_ifconfig_inet
.globl F_get_ifconfig_inet
 
F_get_ifconfig_inet:
        call F_regpage
        call F_regpage
        ld hl, SIPR0
        ld hl, SIPR0
        jr J_copy_cfg
        jr J_copy_cfg
 
 
F_get_ifconfig_netmask
.globl F_get_ifconfig_netmask
 
F_get_ifconfig_netmask:
        call F_regpage
        call F_regpage
        ld hl, SUBR0
        ld hl, SUBR0
        jr J_copy_cfg
        jr J_copy_cfg
 
 
F_regpage
.globl F_regpage
 
F_regpage:
        ld a, (v_pga)           ; copy original page A value
        ld a, (v_pga)           ; copy original page A value
        ld (v_buf_pga), a
        ld (v_buf_pga), a
        ld a, REGPAGE
        ld a, REGPAGE
        call F_setpageA
        call F_setpageA
        ret
        ret
Line 79... Line 89...
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
; F_sethwaddr
; F_sethwaddr
; Configures the W5100 hardware (MAC) address.
; Configures the W5100 hardware (MAC) address.
; Parameters: HL - pointer to a 6 byte buffer containing the hardware addr.
; Parameters: HL - pointer to a 6 byte buffer containing the hardware addr.
; Returns with carry set if the readback fails to give the same result.
; Returns with carry set if the readback fails to give the same result.
F_sethwaddr
.globl F_sethwaddr
 
F_sethwaddr:
        call F_regpage
        call F_regpage
        push hl         ; preserve buffer pointer
        push hl         ; preserve buffer pointer
        ld de, SHAR0    ; hardware address register
        ld de, SHAR0    ; hardware address register
        ld bc, 6        ; is 6 bytes long
        ld bc, 6        ; is 6 bytes long
        ldir
        ldir
 
 
        pop hl
        pop hl
        ld de, SHAR0    ; readback
        ld de, SHAR0    ; readback
        ld bc, 6        ; check 6 bytes
        ld bc, 6        ; check 6 bytes
.readback
.readback8:
        ld a, (de)
        ld a, (de)
        cpi
        cpi
        jr nz, .readbackerr
        jr nz, .readbackerr8
        inc de
        inc de
        jp pe, .readback ; keep going till BC=0
        jp pe, .readback8 ; keep going till BC=0
        or 0            ; ensure carry is cleared
        or 0            ; ensure carry is cleared
        jp J_leavesockfn
        jp J_leavesockfn
.readbackerr
.readbackerr8:
        scf
        scf
        jp J_leavesockfn
        jp J_leavesockfn
 
 
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; F_gethwaddr
; F_gethwaddr
; Read the hardware address and fill a 6 byte buffer.
; Read the hardware address and fill a 6 byte buffer.
; Parameters: DE = pointer to buffer to fill.
; Parameters: DE = pointer to buffer to fill.
F_gethwaddr
.globl F_gethwaddr
 
F_gethwaddr:
        call F_regpage
        call F_regpage
        ld hl, SHAR0
        ld hl, SHAR0
        ld bc, 6
        ld bc, 6
        ldir
        ldir
        jp J_leavesockfn
        jp J_leavesockfn
 
 
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; F_deconfig
; F_deconfig
; Deconfigure the interface (reset the inet, gateway and netmask fields).
; Deconfigure the interface (reset the inet, gateway and netmask fields).
; Parameters: None.
; Parameters: None.
F_deconfig
.globl F_deconfig
 
F_deconfig:
        call F_regpage
        call F_regpage
        ld hl, GAR0
        ld hl, GAR0
        ld de, GAR1
        ld de, GAR1
        ld bc, 7
        ld bc, 7
        ld (hl), 0
        ld (hl), 0