!************************************************************************** !* !* Network driver interface for netboot bootrom !* !* Module: gethwinfo.S !* Purpose: Support routines to determine type of NIC hardware !* Entries: gethwinfo !* !************************************************************************** !* !* Copyright (C) 1998-2003 Gero Kuhlmann !* !* This program is free software; you can redistribute it and/or modify !* it under the terms of the GNU General Public License as published by !* the Free Software Foundation; either version 2 of the License, or !* any later version. !* !* This program is distributed in the hope that it will be useful, !* but WITHOUT ANY WARRANTY; without even the implied warranty of !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !* GNU General Public License for more details. !* !* You should have received a copy of the GNU General Public License !* along with this program; if not, write to the Free Software !* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. !* !* $Id: gethwinfo.S,v 1.5 2003/01/25 23:29:41 gkminix Exp $ !* ! !************************************************************************** ! ! Load assembler macros and other include files. ! #include #include #include ! !************************************************************************** ! ! Start BSS segment. ! .bss .lcomm infostruct,getnic_size ! structure holding NIC hardware info ! !************************************************************************** ! ! Start data segment. ! .data btypes: .byte UNDI_NIC_PNP ! array used to convert PXE bus types .byte UNDI_NIC_PNP ! into UNDI bus types .byte UNDI_NIC_PNP .byte UNDI_NIC_PCI .byte UNDI_NIC_PNP .byte UNDI_NIC_CB ! !************************************************************************** ! ! Start code segment. ! .text public gethwinfo extrn bustyp ! !************************************************************************** ! ! Determine hardware info ! Input: AX - PCI PFA ! BX - PnP CSN ! Output: DS:SI - pointer to hardware info structure ! Registers changed: AX, BX, CX, DX, SI, DI ! gethwinfo: mov si,#infostruct test byte ptr [si + o_ugnt_pnp_baseclass],#$FF jnz gethw9 ! First convert the bus type value to an UNDI compliant value. mov dx,bx #ifdef IS386 seg cs movzx bx,byte ptr [bustyp] #else seg cs mov bl,[bustyp] xor bh,bh #endif mov cl,[bx + btypes] mov [si + o_ugnt_nictype],cl ! Get information for PCI network card using PCI BIOS. For this we let the ! BIOS scan for the first network device (if not given already by a BBS ! compliant BIOS), and use its PFA to determine vendor and device IDs. ! Since the 86-version of the bootrom can also run on a 386, we have to ! use 386 instructions here. However, PCI cards are only available on ! 386 and above. USE386 ! switch to 386 instructions cmp cl,#UNDI_NIC_PCI jne gethw5 mov bx,ax cmp bx,#$FFFF jne gethw7 push si xor si,si mov ecx,#PCI_CLASS_ETHERNET << 8 mov ax,#PCI_FUNC_FIND_CLASS ! search for the first network int INT_PCI ! device using the BIOS if no PFN pop si ! given jc gethw6 gethw7: mov [si + o_ugnt_pci_busdevfunc],bx mov di,#PCI_REG_VENDOR_ID mov ax,#PCI_FUNC_READ_WORD int INT_PCI ! get vendor ID jc gethw1 mov [si + o_ugnt_pci_vendid],cx gethw1: mov di,#PCI_REG_DEVICE_ID mov ax,#PCI_FUNC_READ_WORD int INT_PCI ! get device ID jc gethw2 mov [si + o_ugnt_pci_devid],cx gethw2: mov di,#PCI_REG_REVISION mov ax,#PCI_FUNC_READ_BYTE int INT_PCI ! get hardware revision number jc gethw3 mov [si + o_ugnt_pci_revision],cl gethw3: mov di,#PCI_REG_SUBSYS_VEND mov ax,#PCI_FUNC_READ_WORD int INT_PCI ! get sub-vendor ID jc gethw4 mov [si + o_ugnt_pci_subvendid],cx gethw4: mov di,#PCI_REG_SUBSYS_ID mov ax,#PCI_FUNC_READ_WORD int INT_PCI ! get sub-device ID jc gethw6 mov [si + o_ugnt_pci_subdevid],cx jmp gethw6 USETYPE ! switch back to original instructions ! For PnP/EISA cards we just save the card select number. The class values ! are the same for both PnP and PCI, and are also at the same offsets. gethw5: mov word ptr [si + o_ugnt_pnp_cardselnum],dx gethw6: mov byte ptr [si + o_ugnt_pnp_baseclass],#PCI_BASE_NETWORK gethw9: ret ! !************************************************************************** ! end