⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3c59x.inc

📁 国外 Menuet OS 内核(包括各种驱动TCP UDP VGA Ethernet等)
💻 INC
📖 第 1 页 / 共 5 页
字号:
        "3c592 EISA 10Mbps Demon/Vortex", \        "3c597 EISA Fast Demon/Vortex", \        "3c595 Vortex 100baseTx", \        "3c595 Vortex 100baseT4", \        "3c595 Vortex 100base-MII", \        "3c900 Boomerang 10baseT", \        "3c900 Boomerang 10Mbps Combo", \        "3c900 Cyclone 10Mbps TPO", \        "3c900 Cyclone 10Mbps Combo", \        "3c900 Cyclone 10Mbps TPC", \        "3c900B-FL Cyclone 10base-FL", \        "3c905 Boomerang 100baseTx", \        "3c905 Boomerang 100baseT4", \        "3c905B Cyclone 100baseTx", \        "3c905B Cyclone 10/100/BNC", \        "3c905B-FX Cyclone 100baseFx", \        "3c905C Tornado", \        "3c980 Cyclone", \        "3c982 Dual Port Server Cyclone", \        "3cSOHO100-TX Hurricane", \        "3c555 Laptop Hurricane", \        "3c556 Laptop Tornado", \        "3c556B Laptop Hurricane", \        "3c575 [Megahertz] 10/100 LAN CardBus", \        "3c575 Boomerang CardBus", \        "3CCFE575BT Cyclone CardBus", \        "3CCFE575CT Tornado CardBus", \        "3CCFE656 Cyclone CardBus", \        "3CCFEM656B Cyclone+Winmodem CardBus", \        "3CXFEM656C Tornado+Winmodem CardBus", \        "3c450 HomePNA Tornado", \        "3c920 Tornado", \        "3c982 Hydra Dual Port A", \        "3c982 Hydra Dual Port B", \        "3c905B-T4", \        "3c920B-EMB-WNM Tornado"end if ; defined E3C59X_DEBUG;***************************************************************************;   Function;      e3c59x_debug;   Description;      prints debug info to the debug board;   Parameters;      ebp - io_addr;   Return value;   Destroyed registers;      eax, ebx, ecx, edx, edi, esi;;***************************************************************************if defined E3C59X_DEBUG        align 4e3c59x_debug:        pushad; print device type        mov     esi, e3c59x_hw_type_str        call    sys_msg_board_str        movzx   ecx, byte [e3c59x_ver_id]        mov     esi, [e3c59x_hw_str+ecx*4]        call    sys_msg_board_str        mov     esi, e3c59x_boomerang_str        cmp     dword [e3c59x_transmit_function], e3c59x_boomerang_transmit        jz      .boomerang        mov     esi, e3c59x_vortex_str.boomerang:        call    sys_msg_board_str; print device/vendor        mov     ax, [pci_data+2]        mov     cl, 2        mov     ebx, e3c59x_device_id_str        call    e3c59x_print_hex        mov     esi, e3c59x_device_str        call    sys_msg_board_str        mov     ax, [pci_data]        mov     cl, 2        mov     ebx, e3c59x_vendor_id_str        call    e3c59x_print_hex        mov     esi, e3c59x_vendor_str        call    sys_msg_board_str; print io address        mov     ax, [io_addr]        mov     ebx, e3c59x_io_addr_str        mov     cl, 2        call    e3c59x_print_hex        mov     esi, e3c59x_io_info_str        call    sys_msg_board_str; print MAC address        mov     ebx, e3c59x_mac_addr_str        xor     ecx, ecx.mac_loop:        push    ecx        mov     al, [node_addr+ecx]        mov     cl, 1        call    e3c59x_print_hex        inc     ebx        pop     ecx        inc     cl        cmp     cl, 6        jne     .mac_loop        mov     esi, e3c59x_mac_info_str        call    sys_msg_board_str; print link type        mov     esi, e3c59x_link_type_str        call    sys_msg_board_str        xor     eax, eax        bsr     ax, word [e3c59x_link_type]        jz      @f        sub     ax, 4@@:        mov     esi, [e3c59x_link_str+eax*4]        call    sys_msg_board_str        mov     esi, e3c59x_new_line_str        call    sys_msg_board_str        popad        ret;***************************************************************************;   Function;      e3c59x_print_hex;   Description;      prints a hexadecimal value;   Parameters;      eax - value to be printed out;      ebx - where to print;       cl - value size (1, 2, 4);   Return value;      ebx - end address after the print;   Destroyed registers;      eax, ebx;;***************************************************************************        align 4e3c59x_print_hex:        cmp     cl, 1        je      .print_byte        cmp     cl, 2        jz      .print_word.print_dword:        push    eax        bswap   eax        xchg    ah, al        call    .print_word        pop     eax.print_word:        push    eax        xchg    ah, al        call    .print_byte        pop     eax.print_byte:        movzx   eax, al        push    eax        and     al, 0xf0        shr     al, 4        mov     al, byte [eax+e3c59x_charset]        mov     [ebx], al        inc     ebx        pop     eax        and     al, 0x0f        mov     al, byte [eax+e3c59x_charset]        mov     [ebx], al        inc     ebx        retend if ; defined E3C59X_DEBUG;***************************************************************************;   Function;      e3c59x_try_link_detect;   Description;      e3c59x_try_link_detect checks if link exists;   Parameters;      ebp - io_addr;   Return value;      al - 0 ; no link detected;      al - 1 ; link detected;   Destroyed registers;      eax, ebx, ecx, edx, edi, esi;;***************************************************************************        align 4e3c59x_try_link_detect:; download self-directed packet        mov     edi, node_addr        mov     bx, 0x0608 ; packet type        mov     esi, e3c59x_self_directed_packet        mov     ecx, 6 ; 6 + 6 + 2 + 6 = 20 bytes        call    dword [e3c59x_transmit_function]; switch to register window 5        lea     edx, [ebp+E3C59X_REG_COMMAND]        mov     ax, E3C59X_SELECT_REGISTER_WINDOW+5        out     dx, ax; program RxFilter for promiscuous operation        mov     ax, (10000b shl 11)        lea     edx, [ebp+E3C59X_REG_RX_FILTER]        in      al, dx        or      al, 1111b        lea     edx, [ebp+E3C59X_REG_COMMAND]        out     dx, ax; switch to register window 4        mov     ax, E3C59X_SELECT_REGISTER_WINDOW+4        out     dx, ax; check loop        xor     ebx, ebx        mov     ecx, 0xffff ; 65535 tries.loop:        push    ecx ebx        call    dword [e3c59x_receive_function]        pop     ebx ecx        test    al, al        jnz     .finish.no_packet_received:; switch to register window 4        lea     edx, [ebp+E3C59X_REG_COMMAND]        mov     ax, E3C59X_SELECT_REGISTER_WINDOW+4        out     dx, ax; read linkbeatdetect        lea     edx, [ebp+E3C59X_REG_MEDIA_STATUS]        in      ax, dx        test    ah, 1000b ; test linkBeatDetect        jnz     .link_detected        xor     al, al        jmp     .finish.link_detected:; test carrierSense        test    al, 100000b        jz      .no_carrier_sense        inc     ebx.no_carrier_sense:        dec     ecx        jns     .loop; assume the link is good if 0 < ebx < 25 %        test    ebx, ebx        setnz   al        jz      .finish        cmp     ebx, 16384 ; 25%        setb    al.finish:if defined E3C59X_DEBUG        test    al, al        jz      @f        or      byte [e3c59x_link_type+1], 100b@@:end if ; defined E3C59X_DEBUG        ret;***************************************************************************;   Function;      e3c59x_try_phy;   Description;      e3c59x_try_phy checks the auto-negotiation function;      in the PHY at PHY index. It can also be extended to;      include link detection for non-IEEE 802.3u;      auto-negotiation devices, for instance the BCM5000.;   Parameters;       ah - PHY index;      ebp - io_addr;   Return value;      al - 0 link is auto-negotiated;      al - 1 no link is auto-negotiated;   Destroyed registers;       eax, ebx, ecx, edx, esi;;***************************************************************************        align 4e3c59x_try_phy:        mov     al, E3C59X_REG_MII_BMCR        push    eax        call    e3c59x_mdio_read ; returns with window #4        or      ah, 0x80 ; software reset        mov     ebx, eax        pop     eax        push    eax        call    e3c59x_mdio_write ; returns with window #4; wait for reset to complete        mov     esi, 2000 ; 2000ms = 2s        call    delay_ms        pop     eax        push    eax        call    e3c59x_mdio_read ; returns with window #4        test    ah, 0x80        jnz     .fail_finish        pop     eax        push    eax; wait for a while after reset        mov     esi, 20 ; 20ms        call    delay_ms        pop     eax        push    eax        mov     al, E3C59X_REG_MII_BMSR        call    e3c59x_mdio_read ; returns with window #4        test    al, 1 ; extended capability supported?        jz      .no_ext_cap; auto-neg capable?        test    al, 1000b        jz      .fail_finish ; not auto-negotiation capable; auto-neg complete?        test    al, 100000b        jnz     .auto_neg_ok; restart auto-negotiation        pop     eax        push    eax        mov     al, E3C59X_REG_MII_ANAR        push    eax        call    e3c59x_mdio_read ; returns with window #4        or      ax, (1111b shl 5) ; advertise only 10base-T and 100base-TX        mov     ebx, eax        pop     eax        call    e3c59x_mdio_write ; returns with window #4        pop     eax        push    eax        call    e3c59x_mdio_read ; returns with window #4        mov     ebx, eax        or      bh, 10010b ; restart auto-negotiation        pop     eax        push    eax        call    e3c59x_mdio_write ; returns with window #4        mov     esi, 4000 ; 4000ms = 4 seconds        call    delay_ms        pop     eax        push    eax        mov     al, E3C59X_REG_MII_BMSR        call    e3c59x_mdio_read ; returns with window #4        test    al, 100000b ; auto-neg complete?        jnz     .auto_neg_ok        jmp     .fail_finish.auto_neg_ok:; compare advertisement and link partner ability registers        pop     eax        push    eax        mov     al, E3C59X_REG_MII_ANAR        call    e3c59x_mdio_read ; returns with window #4        xchg    eax, [esp]        mov     al, E3C59X_REG_MII_ANLPAR        call    e3c59x_mdio_read ; returns with window #4        pop     ebx        and     eax, ebx        and     eax, 1111100000b        push    eaxif defined E3C59X_DEBUG        mov     word [e3c59x_link_type], axend if ; defined E3C59X_DEBUG; switch to register window 3        lea     edx, [ebp+E3C59X_REG_COMMAND]        mov     ax, E3C59X_SELECT_REGISTER_WINDOW+3        out     dx, ax; set full-duplex mode        lea     edx, [ebp+E3C59X_REG_MAC_CONTROL]        in      ax, dx        and     ax, not 0x120 ; clear full duplex and flow control        pop     ebx        test    ebx, (1010b shl 5) ; check for full-duplex        jz      .half_duplex        or      ax, 0x120 ; set full duplex and flow control.half_duplex:        out     dx, ax        mov     al, 1        ret.no_ext_cap:; not yet implemented BCM5000.fail_finish:        pop     eax        xor     al, al        ret;***************************************************************************;   Function;      e3c59x_try_mii;   Description;      e3c59x_try_MII checks the on-chip auto-negotiation logic;      or an off-chip MII PHY, depending upon what is set in;      xcvrSelect by the caller.;      It exits when it finds the first device with a good link.;   Parameters;      ebp - io_addr;   Return value;      al - 0;      al - 1;   Destroyed registers;      eax, ebx, ecx, edx, esi;;***************************************************************************        align 4e3c59x_try_mii:; switch to register window 3        lea     edx, [ebp+E3C59X_REG_COMMAND]        mov     ax, E3C59X_SELECT_REGISTER_WINDOW+3        out     dx, ax        lea     edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]        in      eax, dx        and     eax, (1111b shl 20)        cmp     eax, (1000b shl 20) ; is auto-negotiation set?        jne     .mii_device

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -