Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / slof / fs / pci-bridge.fs
1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2008 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
8 \ *
9 \ * Contributors:
10 \ *     IBM Corporation - initial implementation
11 \ ****************************************************************************/
12
13 \ get the PUID from the node above
14 get-node CONSTANT my-phandle
15 s" my-puid" my-phandle parent $call-static CONSTANT my-puid
16
17 \ Save the bus number provided by this bridge
18 pci-bus-number 1+ CONSTANT my-bus
19
20 s" pci-config-bridge.fs" included
21 s" dma-function.fs" included
22
23 \ generate the rom-fs filename from the vendor and device ID "pci-bridge_VENDORID_DEVICEID.fs"
24 : filename ( -- str len )
25   s" pci-bridge_"
26   my-space pci-vendor@ 4 int2str $cat
27   s" _" $cat
28   my-space pci-device@ 4 int2str $cat
29   s" .fs" $cat
30 ;
31
32 \ Set up the Bridge with either default or special settings
33 : setup ( -- )
34         \ is there special handling for this device, given vendor and device id?
35         filename romfs-lookup ?dup
36                 IF
37                         \ give it a special treatment
38                         evaluate
39                 ELSE
40                         \ no special handling for this device, attempt autoconfiguration
41                         my-space pci-class-name type 2a emit cr
42                         my-space pci-bridge-generic-setup
43                         my-space pci-reset-2nd
44                 THEN
45 ;
46
47 \ Disable Bus Master, Memory Space and I/O Space for
48 \ this device and so for the scanning for the devices behind
49 pci-device-disable
50
51 \ Enalbe #PERR and #SERR reporting
52 pci-error-enable
53
54 \ Print out device information
55 my-space 42 pci-out     \ config-addr ascii('B')
56
57 \ and set up the bridge
58 setup
59
60 \ And enable Bus Master IO and MEM access again.
61 \ we need that on bridges so that the devices behind
62 \ can set their state on their own.
63 pci-master-enable
64 pci-mem-enable
65 pci-io-enable