1 /* $NetBSD: bios_pci.S,v 1.6 2005/12/11 12:17:48 christos Exp $ */
5 * Matthias Drochner. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 /* minimal calls to PCI BIOS */
31 #include <machine/asm.h>
33 #define addr32 .byte 0x67
34 #define data32 .byte 0x66
36 #define PCI_FUNCTION_ID 0xb1
37 #define PCI_BIOS_PRESENT 0x01
38 #define FIND_PCI_DEVICE 0x02
39 #define READ_CONFIG_DWORD 0x0a
40 #define WRITE_CONFIG_DWORD 0x0d
42 /* int pcibios_present(int *signature)
43 return: AX from BIOS call, -1 on error
44 var param: EDX from BIOS call, must be signature "PCI "
46 ENTRY(pcibios_present)
53 call _C_LABEL(prot_to_real) # enter real mode
56 movb $PCI_FUNCTION_ID, %ah
57 movb $PCI_BIOS_PRESENT, %al
68 calll _C_LABEL(real_to_prot) # back to protected mode
74 movl %ebx, %eax # return value in %eax
82 /* int pcibios_finddev(int vendor, int device, int index, int *busdevfcn)
83 return: AH from BIOS call, -1 on error
84 var param: BX from BIOS call, contains bus/device/function
86 ENTRY(pcibios_finddev)
98 call _C_LABEL(prot_to_real) # enter real mode
101 movb $PCI_FUNCTION_ID, %ah
102 movb $FIND_PCI_DEVICE, %al
113 calll _C_LABEL(real_to_prot) # back to protected mode
119 movl %edx, %eax # return value in %eax
128 /* int pcibios_cfgread(int busdevfcn, int offset, int *value)
129 return: AH from BIOS call, -1 on error
130 var param: ECX from BIOS call, contains value read
132 ENTRY(pcibios_cfgread)
143 call _C_LABEL(prot_to_real) # enter real mode
146 movb $PCI_FUNCTION_ID, %ah
147 movb $READ_CONFIG_DWORD, %al
158 calll _C_LABEL(real_to_prot) # back to protected mode
164 movl %edx, %eax # return value in %eax
173 /* int pcibios_cfgwrite(int busdevfcn, int offset, int value)
174 return: AH from BIOS call, -1 on error
175 var param: ECX from BIOS call, contains value read
177 ENTRY(pcibios_cfgwrite)
189 call _C_LABEL(prot_to_real) # enter real mode
192 movb $PCI_FUNCTION_ID, %ah
193 movb $WRITE_CONFIG_DWORD, %al
204 calll _C_LABEL(real_to_prot) # back to protected mode
207 movl %edx, %eax # return value in %eax