Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: make-device.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)make-device.fth 1.7 05/10/12 | |
43 | purpose: PCI bus package | |
44 | copyright: Copyright 1994 FirmWorks All Rights Reserved | |
45 | copyright: Copyright 2005 Sun Microsystems, Inc. All Rights Reserved | |
46 | copyright: Use is subject to license terms. | |
47 | ||
48 | ||
49 | \ --------------------------------------------------------------------- | |
50 | \ All routines loaded from here assume we are executing in the child | |
51 | \ node of a pci bus device. | |
52 | \ any references to my-space are only valid for such children. | |
53 | \ and all routines executing in this context will use the parent-X words. | |
54 | \ | |
55 | \ Routines that are used in both contexts will leave phys.hi on the | |
56 | \ data stack and won't do $call-<anything> the routine not-relocatable? | |
57 | \ is an example of such a routine. | |
58 | \ | |
59 | ||
60 | : parent-l! ( l phys.hi -- ) my-space + $config-l! $call-parent ; | |
61 | : parent-b@ ( phys.hi -- b ) my-space + $config-b@ $call-parent ; | |
62 | : parent-b! ( b phys.hi -- ) my-space + $config-b! $call-parent ; | |
63 | : parent-w@ ( phys.hi -- b ) my-space + $config-w@ $call-parent ; | |
64 | : parent-w! ( w phys.hi -- ) my-space + $config-w! $call-parent ; | |
65 | : parent-l@ ( phys.hi -- l ) my-space + $config-l@ $call-parent ; | |
66 | : parent-l! ( l phys.hi -- ) my-space + $config-l! $call-parent ; | |
67 | ||
68 | : not-relocatable? ( phys.hi -- flag ) h# 80 ss#>cfg and 0<> ; | |
69 | ||
70 | : header-type ( -- type ) h# 0e parent-b@ h# 7f and ; | |
71 | ||
72 | \ True if the header type indicates that the function is a PCI-PCI bridge | |
73 | : bridge? ( -- flag ) | |
74 | header-type h# 1 = h# 0a parent-w@ h# 0609 = or | |
75 | ; | |
76 | ||
77 | \ True if the header type indicates that the funtion is a PCI-Cardbus | |
78 | : card-bus? ( -- flag ) header-type h# 2 = ; | |
79 | ||
80 | : expansion-rom ( -- offset ) | |
81 | header-type h# 1 = if h# 38 else h# 30 then | |
82 | ; | |
83 | ||
84 | : subsystem-base ( -- offset ) | |
85 | card-bus? if h# 40 else h# 2c then | |
86 | ; | |
87 | ||
88 | : base-register-bounds ( -- high low ) | |
89 | bridge? if h# 18 else | |
90 | card-bus? if h# 14 else h# 28 then | |
91 | then | |
92 | h# 10 | |
93 | ; | |
94 | ||
95 | : io? ( phys.hi -- flag ) cfg>ss# 1 = ; | |
96 | ||
97 | false value pci-express? \ Set by each call to populate-device-node | |
98 | ||
99 | fload ${BP}/dev/pci/probe-reg.fth | |
100 | fload ${BP}/dev/pci/device-props.fth | |
101 | fload ${BP}/dev/pci/fcode-rom.fth | |
102 | ||
103 | : load-fcode ( adr len -- ) | |
104 | >r >r r@ 1 byte-load r> r> free-mem | |
105 | ; | |
106 | ||
107 | : populate-device-node ( -- ) | |
108 | pcie-capability-regs 0<> to pci-express? | |
109 | pci-make-function-properties | |
110 | assign-addresses ( ) | |
111 | find-fcode? if ( adr len ) | |
112 | load-fcode true ( ) | |
113 | else ( ) | |
114 | no-builtin-fcode? if | |
115 | make-std-fcode-properties false ( false ) | |
116 | else ( ) | |
117 | true ( true ) | |
118 | then ( flag ) | |
119 | then ( flag ) | |
120 | make-assigned-property ( ) | |
121 | ||
122 | device-enabled? 0= bridge? 0= and if | |
123 | \ Disables all card response | |
124 | 0 4 parent-w! | |
125 | then | |
126 | ; |