!************************************************************************** !* !* Network driver interface for netboot bootrom !* !* Module: pci.S !* Purpose: PCI handling routines !* Entries: setmaster !* !************************************************************************** !* !* Copyright (C) 2002-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: pci.S,v 1.2 2003/01/25 23:29:41 gkminix Exp $ !* ! !************************************************************************** ! ! Load assembler macros and other include files. ! #include #include #include ! !************************************************************************** ! ! Start code segment. ! .text public setmaster ! !************************************************************************** ! ! Set latency timer of PCI network card, if its a bus master card. Some ! BIOS and network drivers dont set this timer causing it be zero. ! Input: DS:SI - Pointer to UNDI info structure ! Output: None ! Registers changed: AX, BX, CX ! setmaster: push si push di ! Check that we have a PCI network card and get its PFN number. Then check ! that its a bus master device. or si,si ! have an info struct pointer? jz setma9 mov al,[si + o_ugnt_nictype] cmp al,#UNDI_NIC_PCI ! check network card type jne setma9 mov bx,[si + o_ugnt_pci_busdevfunc] cmp bx,#$FFFF ! we must have a PCI PFN je setma9 mov di,#PCI_REG_COMMAND mov ax,#PCI_FUNC_READ_WORD int INT_PCI ! get command word jc setma9 test cx,#PCI_CMD_MASTER ! check that its a bus master jz setma9 ! Now read the PCI latency timer and check that its above 16. If not, we ! set it to a fixed value of 32. This is similar to the way the Linux ! kernel is doing it. mov di,#PCI_REG_LATENCY_TIMER mov ax,#PCI_FUNC_READ_BYTE int INT_PCI ! get value of latency timer cmp cl,#16 ! it has to be greater than 16 jae setma9 mov cx,#32 ! if not, set it to 32 as a default mov di,#PCI_REG_LATENCY_TIMER mov ax,#PCI_FUNC_WRITE_BYTE int INT_PCI setma9: pop di pop si ret ! !************************************************************************** ! end