?? sis900.inc
字號:
jne .get_mac_loop ; Enable packet filtering ;lea edx,[ebp+SIS900_rfcr] ;mov eax,edi ;or eax,SIS900_RFEN ;out dx, eax ;*******Debug Print MAC ID to debug window**********************if defined SIS900_DEBUG mov esi,SIS900_Debug_Str_GetMac_Address call sys_msg_board_str mov edx, node_addr call Create_Mac_Stringend if ret;***************************************************************************;* Function: sis900_read_eeprom;*;* Description: reads and returns a given location from EEPROM;*;* Arguments: eax - location: requested EEPROM location;*;* Returns: eax : contents of requested EEPROM location;*; Read Serial EEPROM through EEPROM Access Register, Note that location is; in word (16 bits) unit */;done+;***************************************************************************sis900_read_eeprom: push esi push edx push ecx push ebx mov ebp,[io_addr] mov ebx, eax ;location of Mac byte to read or ebx, SIS900_EEread ; lea edx,[ebp+SIS900_mear] ; Eeprom access register xor eax, eax ; start send out dx,eax call SIS900_Eeprom_Delay_1 mov eax, SIS900_EECLK out dx, eax call SIS900_Eeprom_Delay_1 ;************ Shift the read command (9) bits out. ********* mov cl, 8 ;sis900_read_eeprom_Send: mov eax, 1 shl eax, cl and eax, ebx jz SIS900_Read_Eeprom_8 mov eax, 9 jmp SIS900_Read_Eeprom_9SIS900_Read_Eeprom_8: mov eax, 8SIS900_Read_Eeprom_9: out dx, eax call SIS900_Eeprom_Delay_1 or eax, SIS900_EECLK out dx, eax call SIS900_Eeprom_Delay_1 cmp cl, 0 je sis900_read_eeprom_Send_Done dec cl jmp sis900_read_eeprom_Send ;*********************sis900_read_eeprom_Send_Done: mov eax, SIS900_EECS ; out dx, eax call SIS900_Eeprom_Delay_1 ;********** Read 16-bits of data in *************** mov cx, 16 ;16 bits to readsis900_read_eeprom_Send2: mov eax, SIS900_EECS out dx, eax call SIS900_Eeprom_Delay_1 or eax, SIS900_EECLK out dx, eax call SIS900_Eeprom_Delay_1 in eax, dx shl ebx, 1 and eax, SIS900_EEDO jz SIS900_Read_Eeprom_0 or ebx, 1SIS900_Read_Eeprom_0: dec cx jnz sis900_read_eeprom_Send2 ;************** Terminate the EEPROM access. ************** xor eax, eax out dx, eax call SIS900_Eeprom_Delay_1 mov eax, SIS900_EECLK out dx, eax mov eax, ebx and eax, 0x0000ffff ;return only 16 bits pop ebx pop ecx pop edx pop esi ret;***************************************************************************; Function; SIS900_Eeprom_Delay_1; Description;;;;;***************************************************************************SIS900_Eeprom_Delay_1: push eax in eax, dx pop eax ret;***************************************************************************; Function; SIS900_poll; Description; polls card to see if there is a packet waiting;; Currently only supports one descriptor per packet, if packet is fragmented; between multiple descriptors you will lose part of the packet;***************************************************************************if defined SIS900_DEBUGSIS900_Debug_Pull_Packet_good db 'Good Packet Waiting: ',13,10,0SIS900_Debug_Pull_Bad_Packet_Status db 'Bad Packet Waiting: Status',13,10,0SIS900_Debug_Pull_Bad_Packet_Size db 'Bad Packet Waiting: Size',13,10,0end ifSIS900_poll: ;**************Get Status ************** xor eax, eax ;get RX_Status mov [eth_rx_data_len], ax mov al, [cur_rx] ;find current discriptor imul eax, 12 ; mov ecx, [rxd+eax+4] ; get receive status ;**************Check Status ************** mov ebx, ecx ;move status ;Check RX_Status to see if packet is waiting and ebx, 0x80000000 jnz SIS900_poll_IS_packet ret ;**********There is a packet waiting check it for errors**************SIS900_poll_IS_packet: mov ebx, ecx ;move status and ebx, 0x67C0000 ;see if there are any errors jnz SIS900_Poll_Error_Status ;**************Check size of packet************* and ecx, SIS900_DSIZE ;get packet size minus CRC cmp cx, SIS900_CRC_SIZE ;make sure packet contains data jle SIS900_Poll_Error_Size ;*******Copy Good Packet to receive buffer****** sub cx, SIS900_CRC_SIZE ;dont want crc mov word [eth_rx_data_len], cx ;save size of packet ;**********Continue copying packet**************** push ecx ; first copy dword-wise, divide size by 4 shr ecx, 2 mov esi, [rxd+eax+8] ; set source mov edi, Ether_buffer ; set destination cld ; clear direction rep movsd ; copy the dwords pop ecx and ecx, 3 ; rep movsb ;********Debug, tell user we have a good packet*************if defined SIS900_DEBUG mov esi, SIS900_Debug_Pull_Packet_good call sys_msg_board_strend if jmp SIS900_Poll_Cnt ; ;*************Error occured let user know through debug window***********SIS900_Poll_Error_Status:if defined SIS900_DEBUG mov esi, SIS900_Debug_Pull_Bad_Packet_Status call sys_msg_board_strend if jmp SIS900_Poll_CntSIS900_Poll_Error_Size:if defined SIS900_DEBUG mov esi, SIS900_Debug_Pull_Bad_Packet_Size call sys_msg_board_strend if ;*************Increment to next available descriptor**************SIS900_Poll_Cnt: ;Reset status, allow ethernet card access to descriptor mov ecx, RX_BUFF_SZ mov [rxd+eax+4], ecx ; inc [cur_rx] ;get next descriptor and [cur_rx],3 ;only 4 descriptors 0-3 ;******Enable Receiver************ mov ebp, [io_addr] ; Base Address lea edx,[ebp+SIS900_cr] ; Command Register offset in eax, dx ; Get current Command Register or eax, SIS900_RxENA ;Enable Receive out dx, eax ret;***************************************************************************; Function; SIS900_transmit; Description; Transmits a packet of data via the ethernet card; Pointer to 48 bit destination address in edi; Type of packet in bx; size of packet in ecx; pointer to packet data in esi;; only one transmit descriptor is used;;***************************************************************************if defined SIS900_DEBUGSIS900_Debug_Transmit_Packet db 'Transmitting Packet: ',13,10,0SIS900_Debug_Transmit_Packet_Err db 'Transmitting Packet Error: ',13,10,0end ifSIS900_transmit: mov ebp, [io_addr] ; Base Address ;******** Stop the transmitter ******** lea edx,[ebp+SIS900_cr] ; Command Register offset in eax, dx ; Get current Command Register or eax, SIS900_TxDIS ; Disable Transmitter out dx, eax ;*******load Transmit Descriptor Register ******* lea edx,[ebp+SIS900_txdp] mov eax, txd out dx, eax ;******* copy packet to descriptor******* push esi mov esi, edi ;copy destination addess mov edi, txb cld movsd movsw mov esi, node_addr ;copy my mac address movsd movsw mov [edi], bx ;copy packet type add edi, 2 pop esi ;restore pointer to source of packet push ecx ;save packet size shr ecx, 2 ;divide by 4, size in bytes send in dwords rep movsd ;copy data to decriptor pop ecx ;restore packet size push ecx ;save packet size and ecx, 3 ;last three bytes if not a multiple of 4 rep movsb ;**************set length tag************** pop ecx ;restore packet size add ecx, SIS900_ETH_HLEN ;add header to length and ecx, SIS900_DSIZE ; ;**************pad to minimum packet size **************not needed ;cmp ecx, SIS900_ETH_ZLEN ;jge SIS900_transmit_Size_Ok ;push ecx ;mov ebx, SIS900_ETH_ZLEN ;sub ebx, ecx ;mov ecx, ebx ;rep movsb ;pop ecxSIS900_transmit_Size_Ok: mov [txd+4], dword 0x80000000 ;card owns descriptor or [txd+4], ecx ;set size of packetif defined SIS900_DEBUG mov esi, SIS900_Debug_Transmit_Packet call sys_msg_board_strend if ;***************restart the transmitter ******** lea edx,[ebp+SIS900_cr] in eax, dx ; Get current Command Register or eax, SIS900_TxENA ; Enable Transmitter out dx, eax ;****make sure packet transmitted successfully**** mov esi,10 call delay_ms mov eax, [txd+4] and eax, 0x6200000 jz SIS900_transmit_OK ;**************Tell user there was an error through debug windowif defined SIS900_DEBUG mov esi, SIS900_Debug_Transmit_Packet_Err call sys_msg_board_strend ifSIS900_transmit_OK: ;******** Disable interrupts by clearing the interrupt mask. ******** lea edx,[ebp+SIS900_imr] ; Interupt Mask Register xor eax, eax out dx,eax ret ;***************************************************************************;* Function: Create_Mac_String;*;* Description: Converts the 48 bit value to a string for display;*;* String Format: XX:XX:XX:XX:XX:XX;*;* Arguments: node_addr is location of 48 bit MAC ID;*;* Returns: Prints string to general debug window;*;*;done;***************************************************************************if defined SIS900_DEBUGSIS900_Char_String db '0','1','2','3','4','5','6','7','8','9' db 'A','B','C','D','E','F'Mac_str_build: times 20 db 0Create_Mac_String: pusha xor ecx, ecxCreate_Mac_String_loop: mov al,byte [edx+ecx];[node_addr+ecx] push eax shr eax, 4 and eax, 0x0f mov bl, byte [SIS900_Char_String+eax] mov [Mac_str_build+ecx*3], bl pop eax and eax, 0x0f mov bl, byte [SIS900_Char_String+eax] mov [Mac_str_build+1+ecx*3], bl cmp ecx, 5 je Create_Mac_String_done mov bl, ':' mov [Mac_str_build+2+ecx*3], bl inc ecx jmp Create_Mac_String_loopCreate_Mac_String_done: ;Insert CR and Zero Terminate mov [Mac_str_build+2+ecx*3],byte 13 mov [Mac_str_build+3+ecx*3],byte 10 mov [Mac_str_build+4+ecx*3],byte 0 mov esi, Mac_str_build call sys_msg_board_str ;Print String to message board popa retend if;***************************************************************************;* Set device to be a busmaster in case BIOS neglected to do so.;* Also adjust PCI latency timer to a reasonable value, 64.;***************************************************************************SIS900_adjust_pci_device: ;*******Get current setting************************ mov al, 2 ;read a word mov bh, [pci_dev] mov ah, [pci_bus] mov bl, 0x04 ;from command Register call pci_read_reg ;******see if its already set as bus master******** mov bx, ax and bx,5 cmp bx,5 je SIS900_adjust_pci_device_Latency ;******Make card a bus master******* mov cx, ax ;value to write mov bh, [pci_dev] mov al, 2 ;write a word or cx,5 mov ah, [pci_bus] mov bl, 0x04 ;to command register call pci_write_reg ;******Check latency setting***********SIS900_adjust_pci_device_Latency: ;*******Get current latency setting************************ mov al, 1 ;read a byte mov bh, [pci_dev] mov ah, [pci_bus] mov bl, 0x0D ;from Lantency Timer Register call pci_read_reg ;******see if its aat least 64 clocks******** cmp ax,64 jge SIS900_adjust_pci_device_Done ;******Set latency to 32 clocks******* mov cx, 64 ;value to write mov bh, [pci_dev] mov al, 1 ;write a byte mov ah, [pci_bus] mov bl, 0x0D ;to Lantency Timer Register call pci_write_reg ;******Check latency setting***********SIS900_adjust_pci_device_Done: ret
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -