2 * This software and ancillary information (herein called SOFTWARE )
3 * called LinuxBIOS is made available under the terms described
4 * here. The SOFTWARE has been approved for release with associated
5 * LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
6 * been authored by an employee or employees of the University of
7 * California, operator of the Los Alamos National Laboratory under
8 * Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
9 * U.S. Government has rights to use, reproduce, and distribute this
10 * SOFTWARE. The public may copy, distribute, prepare derivative works
11 * and publicly display this SOFTWARE without charge, provided that this
12 * Notice and any statement of authorship are reproduced on all copies.
13 * Neither the Government nor the University makes any warranty, express
14 * or implied, or assumes any liability or responsibility for the use of
15 * this SOFTWARE. If SOFTWARE is modified to produce derivative works,
16 * such modified SOFTWARE should be clearly marked, so as not to confuse
17 * it with the version available from LANL.
20 * This file is part of the coreboot project.
22 * (c) Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
27 * (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 #ifdef CONFIG_COREBOOT_V2
39 #include <console/console.h>
43 #include <device/device.h>
44 #include <device/pci.h>
45 #include <device/pci_ids.h>
46 #include <device/pci_ops.h>
47 #include <x86emu/x86emu.h>
51 int pcibios_handler(void)
54 struct device *dev = 0;
57 case PCI_BIOS_PRESENT:
58 X86_AH = 0x00; /* no config space/special cycle support */
59 X86_AL = 0x01; /* config mechanism 1 */
60 X86_EDX = 'P' | 'C' << 8 | 'I' << 16 | ' ' << 24;
61 X86_EBX = 0x0210; /* Version 2.10 */
62 X86_ECX = 0xFF00; /* FixME: Max bus number */
63 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
67 /* FixME: support SI != 0 */
68 #ifdef CONFIG_COREBOOT_V2
69 dev = dev_find_device(X86_DX, X86_CX, dev);
71 dev = dev_find_pci_device(X86_DX, X86_CX, dev);
74 X86_BH = dev->bus->secondary;
75 X86_BL = dev->path.pci.devfn;
77 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
80 X86_AH = DEVICE_NOT_FOUND;
81 X86_EFLAGS |= FB_CF; /* set carry flag */
85 case FIND_PCI_CLASS_CODE:
86 /* FixME: support SI != 0 */
87 dev = dev_find_class(X86_ECX, dev);
89 X86_BH = dev->bus->secondary;
90 X86_BL = dev->path.pci.devfn;
92 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
95 X86_AH = DEVICE_NOT_FOUND;
96 X86_EFLAGS |= FB_CF; /* set carry flag */
100 case READ_CONFIG_BYTE:
101 dev = dev_find_slot(X86_BH, X86_BL);
103 X86_CL = pci_read_config8(dev, X86_DI);
105 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
108 X86_AH = DEVICE_NOT_FOUND;
109 X86_EFLAGS |= FB_CF; /* set carry flag */
113 case READ_CONFIG_WORD:
114 dev = dev_find_slot(X86_BH, X86_BL);
116 X86_CX = pci_read_config16(dev, X86_DI);
118 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
121 X86_AH = DEVICE_NOT_FOUND;
122 X86_EFLAGS |= FB_CF; /* set carry flag */
126 case READ_CONFIG_DWORD:
127 dev = dev_find_slot(X86_BH, X86_BL);
129 X86_ECX = pci_read_config32(dev, X86_DI);
131 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
134 X86_AH = DEVICE_NOT_FOUND;
135 X86_EFLAGS |= FB_CF; /* set carry flag */
139 case WRITE_CONFIG_BYTE:
140 dev = dev_find_slot(X86_BH, X86_BL);
142 pci_write_config8(dev, X86_DI, X86_CL);
144 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
147 X86_AH = DEVICE_NOT_FOUND;
148 X86_EFLAGS |= FB_CF; /* set carry flag */
152 case WRITE_CONFIG_WORD:
153 dev = dev_find_slot(X86_BH, X86_BL);
155 pci_write_config16(dev, X86_DI, X86_CX);
157 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
160 X86_AH = DEVICE_NOT_FOUND;
161 X86_EFLAGS |= FB_CF; /* set carry flag */
165 case WRITE_CONFIG_DWORD:
166 dev = dev_find_slot(X86_BH, X86_BL);
168 pci_write_config16(dev, X86_DI, X86_ECX);
170 X86_EFLAGS &= ~FB_CF; /* clear carry flag */
173 X86_AH = DEVICE_NOT_FOUND;
174 X86_EFLAGS |= FB_CF; /* set carry flag */
179 X86_AH = FUNC_NOT_SUPPORTED;