1 /************************************************************************/
2 /* Provides the Hypervisor PCI calls for iSeries Linux Parition. */
3 /* Copyright (C) 20yy <Wayne G Holm> <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: */
17 /* Free Software Foundation, Inc., */
18 /* 59 Temple Place, Suite 330, */
19 /* Boston, MA 02111-1307 USA */
20 /************************************************************************/
21 /* Change Activity: */
22 /* Created, Jan 9, 2001 */
23 /************************************************************************/
24 //============================================================================
26 // Name______________: HvCallPci.H
28 // Description_______:
30 // This file contains the "hypervisor call" interface which is used to
31 // drive the hypervisor from SLIC.
33 //============================================================================
35 //-------------------------------------------------------------------
36 // Forward declarations
37 //-------------------------------------------------------------------
39 //-------------------------------------------------------------------
41 //-------------------------------------------------------------------
47 #include <asm/iSeries/HvTypes.h>
50 //-------------------------------------------------------------------
52 //-------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
57 //-----------------------------------------------------------------------------
61 struct HvCallPci_DsaAddr { // make sure this struct size is 64-bits total
70 struct HvCallPci_DsaAddr Dsa;
73 struct HvCallPci_LoadReturn {
78 enum HvCallPci_DeviceType {HvCallPci_NodeDevice = 1,
79 HvCallPci_SpDevice = 2,
80 HvCallPci_IopDevice = 3,
81 HvCallPci_BridgeDevice = 4,
82 HvCallPci_MultiFunctionDevice = 5,
83 HvCallPci_IoaDevice = 6
87 struct HvCallPci_DeviceInfo {
88 u32 deviceType; // See DeviceType enum for values
91 struct HvCallPci_BusUnitInfo {
92 u32 sizeReturned; // length of data returned
93 u32 deviceType; // see DeviceType enum for values
96 struct HvCallPci_BridgeInfo {
97 struct HvCallPci_BusUnitInfo busUnitInfo; // Generic bus unit info
98 u8 subBusNumber; // Bus number of secondary bus
99 u8 maxAgents; // Max idsels on secondary bus
100 u8 maxSubBusNumber; // Max Sub Bus
101 u8 logicalSlotNumber; // Logical Slot Number for IOA
105 // Maximum BusUnitInfo buffer size. Provided for clients so they can allocate
106 // a buffer big enough for any type of bus unit. Increase as needed.
107 enum {HvCallPci_MaxBusUnitInfoSize = 128};
109 struct HvCallPci_BarParms {
115 u64 relocationOffset;
120 enum HvCallPci_VpdType {
121 HvCallPci_BusVpd = 1,
122 HvCallPci_BusAdapterVpd = 2
125 #define HvCallPciConfigLoad8 HvCallPci + 0
126 #define HvCallPciConfigLoad16 HvCallPci + 1
127 #define HvCallPciConfigLoad32 HvCallPci + 2
128 #define HvCallPciConfigStore8 HvCallPci + 3
129 #define HvCallPciConfigStore16 HvCallPci + 4
130 #define HvCallPciConfigStore32 HvCallPci + 5
131 #define HvCallPciEoi HvCallPci + 16
132 #define HvCallPciGetBarParms HvCallPci + 18
133 #define HvCallPciMaskFisr HvCallPci + 20
134 #define HvCallPciUnmaskFisr HvCallPci + 21
135 #define HvCallPciSetSlotReset HvCallPci + 25
136 #define HvCallPciGetDeviceInfo HvCallPci + 27
137 #define HvCallPciGetCardVpd HvCallPci + 28
138 #define HvCallPciBarLoad8 HvCallPci + 40
139 #define HvCallPciBarLoad16 HvCallPci + 41
140 #define HvCallPciBarLoad32 HvCallPci + 42
141 #define HvCallPciBarLoad64 HvCallPci + 43
142 #define HvCallPciBarStore8 HvCallPci + 44
143 #define HvCallPciBarStore16 HvCallPci + 45
144 #define HvCallPciBarStore32 HvCallPci + 46
145 #define HvCallPciBarStore64 HvCallPci + 47
146 #define HvCallPciMaskInterrupts HvCallPci + 48
147 #define HvCallPciUnmaskInterrupts HvCallPci + 49
148 #define HvCallPciGetBusUnitInfo HvCallPci + 50
150 //============================================================================
151 static inline u64 HvCallPci_configLoad8(u16 busNumber, u8 subBusNumber,
152 u8 deviceId, u32 offset,
155 struct HvCallPci_DsaAddr dsa;
156 struct HvCallPci_LoadReturn retVal;
160 dsa.busNumber = busNumber;
161 dsa.subBusNumber = subBusNumber;
162 dsa.deviceId = deviceId;
164 HvCall3Ret16(HvCallPciConfigLoad8, &retVal, *(u64 *)&dsa, offset, 0);
166 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
168 *value = retVal.value;
172 //============================================================================
173 static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,
174 u8 deviceId, u32 offset,
177 struct HvCallPci_DsaAddr dsa;
178 struct HvCallPci_LoadReturn retVal;
182 dsa.busNumber = busNumber;
183 dsa.subBusNumber = subBusNumber;
184 dsa.deviceId = deviceId;
186 HvCall3Ret16(HvCallPciConfigLoad16, &retVal, *(u64 *)&dsa, offset, 0);
188 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
190 *value = retVal.value;
194 //============================================================================
195 static inline u64 HvCallPci_configLoad32(u16 busNumber, u8 subBusNumber,
196 u8 deviceId, u32 offset,
199 struct HvCallPci_DsaAddr dsa;
200 struct HvCallPci_LoadReturn retVal;
204 dsa.busNumber = busNumber;
205 dsa.subBusNumber = subBusNumber;
206 dsa.deviceId = deviceId;
208 HvCall3Ret16(HvCallPciConfigLoad32, &retVal, *(u64 *)&dsa, offset, 0);
210 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
212 *value = retVal.value;
216 //============================================================================
217 static inline u64 HvCallPci_configStore8(u16 busNumber, u8 subBusNumber,
218 u8 deviceId, u32 offset,
221 struct HvCallPci_DsaAddr dsa;
226 dsa.busNumber = busNumber;
227 dsa.subBusNumber = subBusNumber;
228 dsa.deviceId = deviceId;
230 retVal = HvCall4(HvCallPciConfigStore8, *(u64 *)&dsa, offset, value, 0);
232 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
236 //============================================================================
237 static inline u64 HvCallPci_configStore16(u16 busNumber, u8 subBusNumber,
238 u8 deviceId, u32 offset,
241 struct HvCallPci_DsaAddr dsa;
246 dsa.busNumber = busNumber;
247 dsa.subBusNumber = subBusNumber;
248 dsa.deviceId = deviceId;
250 retVal = HvCall4(HvCallPciConfigStore16, *(u64 *)&dsa, offset, value, 0);
252 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
256 //============================================================================
257 static inline u64 HvCallPci_configStore32(u16 busNumber, u8 subBusNumber,
258 u8 deviceId, u32 offset,
261 struct HvCallPci_DsaAddr dsa;
266 dsa.busNumber = busNumber;
267 dsa.subBusNumber = subBusNumber;
268 dsa.deviceId = deviceId;
270 retVal = HvCall4(HvCallPciConfigStore32, *(u64 *)&dsa, offset, value, 0);
272 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
276 //============================================================================
277 static inline u64 HvCallPci_barLoad8(u16 busNumberParm,
284 struct HvCallPci_DsaAddr dsa;
285 struct HvCallPci_LoadReturn retVal;
289 dsa.busNumber = busNumberParm;
290 dsa.subBusNumber = subBusParm;
291 dsa.deviceId = deviceIdParm;
292 dsa.barNumber = barNumberParm;
294 HvCall3Ret16(HvCallPciBarLoad8, &retVal, *(u64 *)&dsa, offsetParm, 0);
296 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
298 *valueParm = retVal.value;
302 //============================================================================
303 static inline u64 HvCallPci_barLoad16(u16 busNumberParm,
310 struct HvCallPci_DsaAddr dsa;
311 struct HvCallPci_LoadReturn retVal;
315 dsa.busNumber = busNumberParm;
316 dsa.subBusNumber = subBusParm;
317 dsa.deviceId = deviceIdParm;
318 dsa.barNumber = barNumberParm;
320 HvCall3Ret16(HvCallPciBarLoad16, &retVal, *(u64 *)&dsa, offsetParm, 0);
322 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
324 *valueParm = retVal.value;
328 //============================================================================
329 static inline u64 HvCallPci_barLoad32(u16 busNumberParm,
336 struct HvCallPci_DsaAddr dsa;
337 struct HvCallPci_LoadReturn retVal;
341 dsa.busNumber = busNumberParm;
342 dsa.subBusNumber = subBusParm;
343 dsa.deviceId = deviceIdParm;
344 dsa.barNumber = barNumberParm;
346 HvCall3Ret16(HvCallPciBarLoad32, &retVal, *(u64 *)&dsa, offsetParm, 0);
348 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
350 *valueParm = retVal.value;
354 //============================================================================
355 static inline u64 HvCallPci_barLoad64(u16 busNumberParm,
362 struct HvCallPci_DsaAddr dsa;
363 struct HvCallPci_LoadReturn retVal;
367 dsa.busNumber = busNumberParm;
368 dsa.subBusNumber = subBusParm;
369 dsa.deviceId = deviceIdParm;
370 dsa.barNumber = barNumberParm;
372 HvCall3Ret16(HvCallPciBarLoad64, &retVal, *(u64 *)&dsa, offsetParm, 0);
374 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
376 *valueParm = retVal.value;
380 //============================================================================
381 static inline u64 HvCallPci_barStore8(u16 busNumberParm,
388 struct HvCallPci_DsaAddr dsa;
393 dsa.busNumber = busNumberParm;
394 dsa.subBusNumber = subBusParm;
395 dsa.deviceId = deviceIdParm;
396 dsa.barNumber = barNumberParm;
398 retVal = HvCall4(HvCallPciBarStore8, *(u64 *)&dsa, offsetParm, valueParm, 0);
400 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
404 //============================================================================
405 static inline u64 HvCallPci_barStore16(u16 busNumberParm,
412 struct HvCallPci_DsaAddr dsa;
417 dsa.busNumber = busNumberParm;
418 dsa.subBusNumber = subBusParm;
419 dsa.deviceId = deviceIdParm;
420 dsa.barNumber = barNumberParm;
422 retVal = HvCall4(HvCallPciBarStore16, *(u64 *)&dsa, offsetParm, valueParm, 0);
424 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
428 //============================================================================
429 static inline u64 HvCallPci_barStore32(u16 busNumberParm,
436 struct HvCallPci_DsaAddr dsa;
441 dsa.busNumber = busNumberParm;
442 dsa.subBusNumber = subBusParm;
443 dsa.deviceId = deviceIdParm;
444 dsa.barNumber = barNumberParm;
446 retVal = HvCall4(HvCallPciBarStore32, *(u64 *)&dsa, offsetParm, valueParm, 0);
448 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
452 //============================================================================
453 static inline u64 HvCallPci_barStore64(u16 busNumberParm,
460 struct HvCallPci_DsaAddr dsa;
465 dsa.busNumber = busNumberParm;
466 dsa.subBusNumber = subBusParm;
467 dsa.deviceId = deviceIdParm;
468 dsa.barNumber = barNumberParm;
470 retVal = HvCall4(HvCallPciBarStore64, *(u64 *)&dsa, offsetParm, valueParm, 0);
472 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
476 //============================================================================
477 static inline u64 HvCallPci_eoi(u16 busNumberParm,
481 struct HvCallPci_DsaAddr dsa;
482 struct HvCallPci_LoadReturn retVal;
486 dsa.busNumber = busNumberParm;
487 dsa.subBusNumber = subBusParm;
488 dsa.deviceId = deviceIdParm;
490 HvCall1Ret16(HvCallPciEoi, &retVal, *(u64*)&dsa);
492 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
496 //============================================================================
497 static inline u64 HvCallPci_getBarParms(u16 busNumberParm,
504 struct HvCallPci_DsaAddr dsa;
509 dsa.busNumber = busNumberParm;
510 dsa.subBusNumber = subBusParm;
511 dsa.deviceId = deviceIdParm;
512 dsa.barNumber = barNumberParm;
514 retVal = HvCall3(HvCallPciGetBarParms, *(u64*)&dsa, parms, sizeofParms);
516 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
520 //============================================================================
521 static inline u64 HvCallPci_maskFisr(u16 busNumberParm,
526 struct HvCallPci_DsaAddr dsa;
531 dsa.busNumber = busNumberParm;
532 dsa.subBusNumber = subBusParm;
533 dsa.deviceId = deviceIdParm;
535 retVal = HvCall2(HvCallPciMaskFisr, *(u64*)&dsa, fisrMask);
537 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
541 //============================================================================
542 static inline u64 HvCallPci_unmaskFisr(u16 busNumberParm,
547 struct HvCallPci_DsaAddr dsa;
552 dsa.busNumber = busNumberParm;
553 dsa.subBusNumber = subBusParm;
554 dsa.deviceId = deviceIdParm;
556 retVal = HvCall2(HvCallPciUnmaskFisr, *(u64*)&dsa, fisrMask);
558 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
562 //============================================================================
563 static inline u64 HvCallPci_setSlotReset(u16 busNumberParm,
568 struct HvCallPci_DsaAddr dsa;
573 dsa.busNumber = busNumberParm;
574 dsa.subBusNumber = subBusParm;
575 dsa.deviceId = deviceIdParm;
577 retVal = HvCall2(HvCallPciSetSlotReset, *(u64*)&dsa, onNotOff);
579 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
583 //============================================================================
584 static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm,
590 struct HvCallPci_DsaAddr dsa;
595 dsa.busNumber = busNumberParm;
596 dsa.subBusNumber = subBusParm;
597 dsa.deviceId = deviceNumberParm << 4;
599 retVal = HvCall3(HvCallPciGetDeviceInfo, *(u64*)&dsa, parms, sizeofParms);
601 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
605 //============================================================================
606 static inline u64 HvCallPci_maskInterrupts(u16 busNumberParm,
611 struct HvCallPci_DsaAddr dsa;
616 dsa.busNumber = busNumberParm;
617 dsa.subBusNumber = subBusParm;
618 dsa.deviceId = deviceIdParm;
620 retVal = HvCall2(HvCallPciMaskInterrupts, *(u64*)&dsa, interruptMask);
622 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
626 //============================================================================
627 static inline u64 HvCallPci_unmaskInterrupts(u16 busNumberParm,
632 struct HvCallPci_DsaAddr dsa;
637 dsa.busNumber = busNumberParm;
638 dsa.subBusNumber = subBusParm;
639 dsa.deviceId = deviceIdParm;
641 retVal = HvCall2(HvCallPciUnmaskInterrupts, *(u64*)&dsa, interruptMask);
643 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
647 //============================================================================
649 static inline u64 HvCallPci_getBusUnitInfo(u16 busNumberParm,
655 struct HvCallPci_DsaAddr dsa;
660 dsa.busNumber = busNumberParm;
661 dsa.subBusNumber = subBusParm;
662 dsa.deviceId = deviceIdParm;
664 retVal = HvCall3(HvCallPciGetBusUnitInfo, *(u64*)&dsa, parms, sizeofParms);
666 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
670 //============================================================================
672 static inline int HvCallPci_getBusVpd(u16 busNumParm, u64 destParm, u16 sizeParm)
675 u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm, sizeParm, HvCallPci_BusVpd);
676 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
680 xRetSize = xRc & 0xFFFF;
683 //============================================================================
685 static inline int HvCallPci_getBusAdapterVpd(u16 busNumParm, u64 destParm, u16 sizeParm)
688 u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm, sizeParm, HvCallPci_BusAdapterVpd);
689 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
693 xRetSize = xRc & 0xFFFF;
696 //============================================================================
697 #endif // _HVCALLPCI_H