Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: hotplugdetect.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: @(#)hotplugdetect.fth 1.1 06/04/05 15:50:27 | |
43 | copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved | |
44 | copyright: Use is subject to license terms. | |
45 | ||
46 | headerless | |
47 | ||
48 | \ Hot plug capability detection code to be used | |
49 | \ in pci bridge code. | |
50 | ||
51 | \ Called only if pcie capability is present. Called with the | |
52 | \ offset of pcie capability register. Check pcie capability | |
53 | \ for downstream port type, slot implemented and slot capability | |
54 | \ for hotplug capability of the slot. | |
55 | : pcie-hotplug-capable? ( offs -- flag ) | |
56 | >r r@ 2+ my-w@ ( pcie-cap ) ( R: offs ) | |
57 | dup 4 >> h# f and 6 = swap ( downstream? pcie-cap ) | |
58 | h# 100 and and if ( ) ( R: offs ) | |
59 | \ downstream port and slot implemented. | |
60 | \ check for hotplug capable bit in | |
61 | \ slot capability register | |
62 | r> d# 20 + my-l@ h# 40 and 0<> ( flag ) | |
63 | else | |
64 | \ upstream port or slot not implemented | |
65 | r> drop false ( false ) | |
66 | then | |
67 | ; | |
68 | ||
69 | \ Called only if pcie capability is present. Called with | |
70 | \ the offset of pcie capability register. Check pcie | |
71 | \ capability for downstream port type and slot implemented. | |
72 | : pcie-slot-implemented? ( offs -- flag ) | |
73 | 2+ my-w@ ( pcie-cap ) | |
74 | dup 4 >> h# f and 6 = swap ( downstream? pcie-cap ) | |
75 | h# 100 and and ( flag ) | |
76 | ; | |
77 | ||
78 | \ Identifying a "hotplug-capable" bridge. If capability | |
79 | \ ptr is implemented then we search for the existence of | |
80 | \ SHPC capability. If SHPC capability is present then we | |
81 | \ say that the bridge supports hotplug. If no SHPC, then | |
82 | \ if PCIE capability is present then we check the slot | |
83 | \ capability for the presence of hotplug capability. If | |
84 | \ present then it is hotplug capable. | |
85 | : hotplug-capability? ( -- flag ) | |
86 | shpc-capability-regs if true exit then | |
87 | pcie-capability-regs ?dup if ( offs ) | |
88 | pcie-hotplug-capable? ( flag ) | |
89 | else | |
90 | false ( false ) | |
91 | then | |
92 | ; | |
93 | ||
94 | \ Since there is no way to tell if a pcie-pcix bridge has | |
95 | \ physical slot underneath it, we resort to finding if | |
96 | \ the bridge is hotplug capable and hence has slot | |
97 | \ underneath. For a pcie port,it is possible to find if | |
98 | \ there is physical slot implemented by looking at pci | |
99 | \ express capability. | |
100 | : slot-implemented? ( -- flag ) | |
101 | \ SHPC Capability? | |
102 | shpc-capability-regs if true exit then | |
103 | pcie-capability-regs ?dup if ( offs ) | |
104 | pcie-slot-implemented? ( flag ) | |
105 | else ( ) | |
106 | false ( false ) | |
107 | then | |
108 | ; |