3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 //===========================================================================
24 // This file contains the interface to the LPAR configuration data
25 // to determine which resources should be allocated to each partition.
27 //===========================================================================
29 #include <asm/iSeries/HvCallCfg.h>
30 #include <asm/iSeries/HvTypes.h>
31 #include <asm/iSeries/ItLpNaca.h>
32 #include <asm/iSeries/LparData.h>
34 //-------------------------------------------------------------------
36 //-------------------------------------------------------------------
38 extern HvLpIndex
HvLpConfig_getLpIndex_outline(void);
40 //===================================================================
41 static inline HvLpIndex
HvLpConfig_getLpIndex(void)
43 return itLpNaca
.xLpIndex
;
45 //===================================================================
46 static inline HvLpIndex
HvLpConfig_getPrimaryLpIndex(void)
48 return itLpNaca
.xPrimaryLpIndex
;
50 //=================================================================
51 static inline HvLpIndex
HvLpConfig_getLps(void)
53 return HvCallCfg_getLps();
55 //=================================================================
56 static inline HvLpIndexMap
HvLpConfig_getActiveLpMap(void)
58 return HvCallCfg_getActiveLpMap();
60 //=================================================================
61 static inline u64
HvLpConfig_getSystemMsMegs(void)
63 return HvCallCfg_getSystemMsChunks() / HVCHUNKSPERMEG
;
65 //=================================================================
66 static inline u64
HvLpConfig_getSystemMsChunks(void)
68 return HvCallCfg_getSystemMsChunks();
70 //=================================================================
71 static inline u64
HvLpConfig_getSystemMsPages(void)
73 return HvCallCfg_getSystemMsChunks() * HVPAGESPERCHUNK
;
75 //================================================================
76 static inline u64
HvLpConfig_getMsMegs(void)
78 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur
) / HVCHUNKSPERMEG
;
80 //================================================================
81 static inline u64
HvLpConfig_getMsChunks(void)
83 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur
);
85 //================================================================
86 static inline u64
HvLpConfig_getMsPages(void)
88 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur
) * HVPAGESPERCHUNK
;
90 //================================================================
91 static inline u64
HvLpConfig_getMinMsMegs(void)
93 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min
) / HVCHUNKSPERMEG
;
95 //================================================================
96 static inline u64
HvLpConfig_getMinMsChunks(void)
98 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min
);
100 //================================================================
101 static inline u64
HvLpConfig_getMinMsPages(void)
103 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min
) * HVPAGESPERCHUNK
;
105 //================================================================
106 static inline u64
HvLpConfig_getMinRuntimeMsMegs(void)
108 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex()) / HVCHUNKSPERMEG
;
110 //===============================================================
111 static inline u64
HvLpConfig_getMinRuntimeMsChunks(void)
113 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex());
115 //===============================================================
116 static inline u64
HvLpConfig_getMinRuntimeMsPages(void)
118 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex()) * HVPAGESPERCHUNK
;
120 //===============================================================
121 static inline u64
HvLpConfig_getMaxMsMegs(void)
123 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max
) / HVCHUNKSPERMEG
;
125 //===============================================================
126 static inline u64
HvLpConfig_getMaxMsChunks(void)
128 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max
);
130 //===============================================================
131 static inline u64
HvLpConfig_getMaxMsPages(void)
133 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max
) * HVPAGESPERCHUNK
;
135 //===============================================================
136 static inline u64
HvLpConfig_getInitMsMegs(void)
138 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init
) / HVCHUNKSPERMEG
;
140 //===============================================================
141 static inline u64
HvLpConfig_getInitMsChunks(void)
143 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init
);
145 //===============================================================
146 static inline u64
HvLpConfig_getInitMsPages(void)
147 { return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init
) * HVPAGESPERCHUNK
;
149 //===============================================================
150 static inline u64
HvLpConfig_getSystemPhysicalProcessors(void)
152 return HvCallCfg_getSystemPhysicalProcessors();
154 //===============================================================
155 static inline u64
HvLpConfig_getSystemLogicalProcessors(void)
157 return HvCallCfg_getSystemPhysicalProcessors() * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
159 //===============================================================
160 static inline u64
HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI
)
162 return HvCallCfg_getNumProcsInSharedPool(sPI
);
164 //===============================================================
165 static inline u64
HvLpConfig_getPhysicalProcessors(void)
167 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Cur
);
169 //===============================================================
170 static inline u64
HvLpConfig_getLogicalProcessors(void)
172 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Cur
) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
174 //===============================================================
175 static inline HvLpSharedPoolIndex
HvLpConfig_getSharedPoolIndex(void)
177 return HvCallCfg_getSharedPoolIndex(HvLpConfig_getLpIndex());
179 //===============================================================
180 static inline u64
HvLpConfig_getSharedProcUnits(void)
182 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Cur
);
184 //===============================================================
185 static inline u64
HvLpConfig_getMinSharedProcUnits(void)
187 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Min
);
189 //===============================================================
190 static inline u64
HvLpConfig_getMaxSharedProcUnits(void)
192 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Max
);
194 //===============================================================
195 static inline u64
HvLpConfig_getMinPhysicalProcessors(void)
197 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Min
);
199 //===============================================================
200 static inline u64
HvLpConfig_getMinLogicalProcessors(void)
202 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Min
) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
204 //===============================================================
205 static inline u64
HvLpConfig_getMaxPhysicalProcessors(void)
207 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Max
);
209 //===============================================================
210 static inline u64
HvLpConfig_getMaxLogicalProcessors(void)
212 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Max
) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
214 //===============================================================
215 static inline u64
HvLpConfig_getInitPhysicalProcessors(void)
217 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Init
);
219 //===============================================================
220 static inline u64
HvLpConfig_getInitLogicalProcessors(void)
222 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Init
) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
224 //================================================================
225 static inline HvLpVirtualLanIndexMap
HvLpConfig_getVirtualLanIndexMap(void)
227 return HvCallCfg_getVirtualLanIndexMap(HvLpConfig_getLpIndex_outline());
229 //===============================================================
230 static inline HvLpVirtualLanIndexMap
HvLpConfig_getVirtualLanIndexMapForLp(HvLpIndex lp
)
232 return HvCallCfg_getVirtualLanIndexMap(lp
);
234 //================================================================
235 static inline HvLpIndex
HvLpConfig_getBusOwner(HvBusNumber busNumber
)
237 return HvCallCfg_getBusOwner(busNumber
);
239 //===============================================================
240 static inline int HvLpConfig_isBusDedicated(HvBusNumber busNumber
)
242 return HvCallCfg_isBusDedicated(busNumber
);
244 //================================================================
245 static inline HvLpIndexMap
HvLpConfig_getBusAllocation(HvBusNumber busNumber
)
247 return HvCallCfg_getBusAllocation(busNumber
);
249 //================================================================
250 // returns the absolute real address of the load area
251 static inline u64
HvLpConfig_getLoadAddress(void)
253 return itLpNaca
.xLoadAreaAddr
& 0x7fffffffffffffff;
255 //================================================================
256 static inline u64
HvLpConfig_getLoadPages(void)
258 return itLpNaca
.xLoadAreaChunks
* HVPAGESPERCHUNK
;
260 //================================================================
261 static inline int HvLpConfig_isBusOwnedByThisLp(HvBusNumber busNumber
)
263 HvLpIndex busOwner
= HvLpConfig_getBusOwner(busNumber
);
264 return (busOwner
== HvLpConfig_getLpIndex());
266 //================================================================
267 static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1
, HvLpIndex lp2
)
269 HvLpVirtualLanIndexMap virtualLanIndexMap1
= HvCallCfg_getVirtualLanIndexMap( lp1
);
270 HvLpVirtualLanIndexMap virtualLanIndexMap2
= HvCallCfg_getVirtualLanIndexMap( lp2
);
271 return ((virtualLanIndexMap1
& virtualLanIndexMap2
) != 0);
273 //================================================================
274 static inline HvLpIndex
HvLpConfig_getHostingLpIndex(HvLpIndex lp
)
276 return HvCallCfg_getHostingLpIndex(lp
);
278 //================================================================
280 #endif /* _HVLPCONFIG_H */