openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

mirror.asm (2213B)


      1 ;
      2 ;
      3 ;
      4 ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5 ; 
      6 ; Copyright 2007-2019 Broadcom Inc. All rights reserved.
      7 ; 
      8 ;
      9 ; This LED program simply mirrors bits from the LED data area directly to
     10 ; the LED scan chain, effectively allowing the host CPU to write directly
     11 ; to the LEDs as memory-mapped bits.
     12 ;
     13 ;
     14 ; After this program is downloaded and starts executing, it increments
     15 ; the byte at address 0x80 once per frame.  This may help the host
     16 ; synchronize writes to frame updates, if needed.
     17 ;
     18 ; Next, the user program should write the length of the scan chain in
     19 ; bits to location 0x81.  This only needs to be done once.
     20 ;
     21 ; Next, the actual LED bits may be updated by writing to bytes to
     22 ; addresses 0x82 and above:
     23 ;
     24 ;	Byte 0x82 bits 7:0 are the first 8 bits on the scan chain
     25 ;	Byte 0x83 bits 7:0 are the second 8 bits on the scan chain
     26 ;	Etc.
     27 ;
     28 ; Remember that:
     29 ;	LED Data address 0x80 corresponds to PCI offset 0x1e00 (word write).
     30 ;	LED Data address 0x81 corresponds to PCI offset 0x1e04 (word write).
     31 ;	Etc.
     32 ;
     33 
     34 BYTE_PTR	equ	0x7f
     35 
     36 FRAME_COUNT	equ	0x80
     37 BIT_COUNT	equ	0x81
     38 BIT_DATA	equ	0x82
     39 
     40 ;
     41 ; Main Update Routine
     42 ;
     43 ;  This routine is called once per tick.
     44 ;
     45 
     46 update:
     47 	inc	(FRAME_COUNT)
     48 
     49 	ld	a,BIT_DATA
     50 	ld	(BYTE_PTR),a
     51 
     52 	ld	b,(BIT_COUNT)
     53 
     54 loop:
     55 	ld	a,(BYTE_PTR)
     56 	inc	(BYTE_PTR)
     57 	ld	a,(a)
     58 
     59 	call	shift_bit
     60 	call	shift_bit
     61 	call	shift_bit
     62 	call	shift_bit
     63 	call	shift_bit
     64 	call	shift_bit
     65 	call	shift_bit
     66 	call	shift_bit
     67 
     68 	cmp	b,0
     69 	jnz	loop
     70 
     71 	ld	b,(BIT_COUNT)
     72 	send	b
     73 
     74 ;
     75 ; shift_bit
     76 ;	A: current byte
     77 ;	B: number of bits remaining
     78 ;
     79 ; Never shifts more than 'B' bits.
     80 ;
     81 
     82 shift_bit:
     83 	cmp	b,0
     84 	jnz	sb1
     85 	ret
     86 sb1:
     87 	dec	b
     88 	tst	a,7
     89 	ror	a
     90 	jnc	sb2
     91 	pushst	ZERO
     92 	pack
     93 	ret
     94 sb2:
     95 	pushst	ONE
     96 	pack
     97 	ret
     98 
     99 ;
    100 ; Symbolic names for the bits of the port status fields
    101 ;
    102 
    103 RX		equ	0x0	; received packet
    104 TX		equ	0x1	; transmitted packet
    105 COLL		equ	0x2	; collision indicator
    106 SPEED_C		equ	0x3	; 100 Mbps
    107 SPEED_M		equ	0x4	; 1000 Mbps
    108 DUPLEX		equ	0x5	; half/full duplex
    109 FLOW		equ	0x6	; flow control capable
    110 LINKUP		equ	0x7	; link down/up status
    111 LINKEN		equ	0x8	; link disabled/enabled status
    112 ZERO		equ	0xE	; always 0
    113 ONE		equ	0xF	; always 1