HvCallPci.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /*
  2. * Provides the Hypervisor PCI calls for iSeries Linux Parition.
  3. * Copyright (C) 2001 <Wayne G Holm> <IBM Corporation>
  4. *
  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.
  9. *
  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.
  14. *
  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. #ifndef _HVCALLPCI_H
  25. #define _HVCALLPCI_H
  26. #include <asm/iSeries/HvCallSc.h>
  27. #include <asm/iSeries/HvTypes.h>
  28. /*
  29. * DSA == Direct Select Address
  30. * this struct must be 64 bits in total
  31. */
  32. struct HvCallPci_DsaAddr {
  33. u16 busNumber; /* PHB index? */
  34. u8 subBusNumber; /* PCI bus number? */
  35. u8 deviceId; /* device and function? */
  36. u8 barNumber;
  37. u8 reserved[3];
  38. };
  39. union HvDsaMap {
  40. u64 DsaAddr;
  41. struct HvCallPci_DsaAddr Dsa;
  42. };
  43. struct HvCallPci_LoadReturn {
  44. u64 rc;
  45. u64 value;
  46. };
  47. enum HvCallPci_DeviceType {
  48. HvCallPci_NodeDevice = 1,
  49. HvCallPci_SpDevice = 2,
  50. HvCallPci_IopDevice = 3,
  51. HvCallPci_BridgeDevice = 4,
  52. HvCallPci_MultiFunctionDevice = 5,
  53. HvCallPci_IoaDevice = 6
  54. };
  55. struct HvCallPci_DeviceInfo {
  56. u32 deviceType; /* See DeviceType enum for values */
  57. };
  58. struct HvCallPci_BusUnitInfo {
  59. u32 sizeReturned; /* length of data returned */
  60. u32 deviceType; /* see DeviceType enum for values */
  61. };
  62. struct HvCallPci_BridgeInfo {
  63. struct HvCallPci_BusUnitInfo busUnitInfo; /* Generic bus unit info */
  64. u8 subBusNumber; /* Bus number of secondary bus */
  65. u8 maxAgents; /* Max idsels on secondary bus */
  66. u8 maxSubBusNumber; /* Max Sub Bus */
  67. u8 logicalSlotNumber; /* Logical Slot Number for IOA */
  68. };
  69. /*
  70. * Maximum BusUnitInfo buffer size. Provided for clients so
  71. * they can allocate a buffer big enough for any type of bus
  72. * unit. Increase as needed.
  73. */
  74. enum {HvCallPci_MaxBusUnitInfoSize = 128};
  75. struct HvCallPci_BarParms {
  76. u64 vaddr;
  77. u64 raddr;
  78. u64 size;
  79. u64 protectStart;
  80. u64 protectEnd;
  81. u64 relocationOffset;
  82. u64 pciAddress;
  83. u64 reserved[3];
  84. };
  85. enum HvCallPci_VpdType {
  86. HvCallPci_BusVpd = 1,
  87. HvCallPci_BusAdapterVpd = 2
  88. };
  89. #define HvCallPciConfigLoad8 HvCallPci + 0
  90. #define HvCallPciConfigLoad16 HvCallPci + 1
  91. #define HvCallPciConfigLoad32 HvCallPci + 2
  92. #define HvCallPciConfigStore8 HvCallPci + 3
  93. #define HvCallPciConfigStore16 HvCallPci + 4
  94. #define HvCallPciConfigStore32 HvCallPci + 5
  95. #define HvCallPciEoi HvCallPci + 16
  96. #define HvCallPciGetBarParms HvCallPci + 18
  97. #define HvCallPciMaskFisr HvCallPci + 20
  98. #define HvCallPciUnmaskFisr HvCallPci + 21
  99. #define HvCallPciSetSlotReset HvCallPci + 25
  100. #define HvCallPciGetDeviceInfo HvCallPci + 27
  101. #define HvCallPciGetCardVpd HvCallPci + 28
  102. #define HvCallPciBarLoad8 HvCallPci + 40
  103. #define HvCallPciBarLoad16 HvCallPci + 41
  104. #define HvCallPciBarLoad32 HvCallPci + 42
  105. #define HvCallPciBarLoad64 HvCallPci + 43
  106. #define HvCallPciBarStore8 HvCallPci + 44
  107. #define HvCallPciBarStore16 HvCallPci + 45
  108. #define HvCallPciBarStore32 HvCallPci + 46
  109. #define HvCallPciBarStore64 HvCallPci + 47
  110. #define HvCallPciMaskInterrupts HvCallPci + 48
  111. #define HvCallPciUnmaskInterrupts HvCallPci + 49
  112. #define HvCallPciGetBusUnitInfo HvCallPci + 50
  113. static inline u64 HvCallPci_configLoad8(u16 busNumber, u8 subBusNumber,
  114. u8 deviceId, u32 offset, u8 *value)
  115. {
  116. struct HvCallPci_DsaAddr dsa;
  117. struct HvCallPci_LoadReturn retVal;
  118. *((u64*)&dsa) = 0;
  119. dsa.busNumber = busNumber;
  120. dsa.subBusNumber = subBusNumber;
  121. dsa.deviceId = deviceId;
  122. HvCall3Ret16(HvCallPciConfigLoad8, &retVal, *(u64 *)&dsa, offset, 0);
  123. *value = retVal.value;
  124. return retVal.rc;
  125. }
  126. static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,
  127. u8 deviceId, u32 offset, u16 *value)
  128. {
  129. struct HvCallPci_DsaAddr dsa;
  130. struct HvCallPci_LoadReturn retVal;
  131. *((u64*)&dsa) = 0;
  132. dsa.busNumber = busNumber;
  133. dsa.subBusNumber = subBusNumber;
  134. dsa.deviceId = deviceId;
  135. HvCall3Ret16(HvCallPciConfigLoad16, &retVal, *(u64 *)&dsa, offset, 0);
  136. *value = retVal.value;
  137. return retVal.rc;
  138. }
  139. static inline u64 HvCallPci_configLoad32(u16 busNumber, u8 subBusNumber,
  140. u8 deviceId, u32 offset, u32 *value)
  141. {
  142. struct HvCallPci_DsaAddr dsa;
  143. struct HvCallPci_LoadReturn retVal;
  144. *((u64*)&dsa) = 0;
  145. dsa.busNumber = busNumber;
  146. dsa.subBusNumber = subBusNumber;
  147. dsa.deviceId = deviceId;
  148. HvCall3Ret16(HvCallPciConfigLoad32, &retVal, *(u64 *)&dsa, offset, 0);
  149. *value = retVal.value;
  150. return retVal.rc;
  151. }
  152. static inline u64 HvCallPci_configStore8(u16 busNumber, u8 subBusNumber,
  153. u8 deviceId, u32 offset, u8 value)
  154. {
  155. struct HvCallPci_DsaAddr dsa;
  156. *((u64*)&dsa) = 0;
  157. dsa.busNumber = busNumber;
  158. dsa.subBusNumber = subBusNumber;
  159. dsa.deviceId = deviceId;
  160. return HvCall4(HvCallPciConfigStore8, *(u64 *)&dsa, offset, value, 0);
  161. }
  162. static inline u64 HvCallPci_configStore16(u16 busNumber, u8 subBusNumber,
  163. u8 deviceId, u32 offset, u16 value)
  164. {
  165. struct HvCallPci_DsaAddr dsa;
  166. *((u64*)&dsa) = 0;
  167. dsa.busNumber = busNumber;
  168. dsa.subBusNumber = subBusNumber;
  169. dsa.deviceId = deviceId;
  170. return HvCall4(HvCallPciConfigStore16, *(u64 *)&dsa, offset, value, 0);
  171. }
  172. static inline u64 HvCallPci_configStore32(u16 busNumber, u8 subBusNumber,
  173. u8 deviceId, u32 offset, u32 value)
  174. {
  175. struct HvCallPci_DsaAddr dsa;
  176. *((u64*)&dsa) = 0;
  177. dsa.busNumber = busNumber;
  178. dsa.subBusNumber = subBusNumber;
  179. dsa.deviceId = deviceId;
  180. return HvCall4(HvCallPciConfigStore32, *(u64 *)&dsa, offset, value, 0);
  181. }
  182. static inline u64 HvCallPci_barLoad8(u16 busNumberParm, u8 subBusParm,
  183. u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
  184. u8 *valueParm)
  185. {
  186. struct HvCallPci_DsaAddr dsa;
  187. struct HvCallPci_LoadReturn retVal;
  188. *((u64*)&dsa) = 0;
  189. dsa.busNumber = busNumberParm;
  190. dsa.subBusNumber = subBusParm;
  191. dsa.deviceId = deviceIdParm;
  192. dsa.barNumber = barNumberParm;
  193. HvCall3Ret16(HvCallPciBarLoad8, &retVal, *(u64 *)&dsa, offsetParm, 0);
  194. *valueParm = retVal.value;
  195. return retVal.rc;
  196. }
  197. static inline u64 HvCallPci_barLoad16(u16 busNumberParm, u8 subBusParm,
  198. u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
  199. u16 *valueParm)
  200. {
  201. struct HvCallPci_DsaAddr dsa;
  202. struct HvCallPci_LoadReturn retVal;
  203. *((u64*)&dsa) = 0;
  204. dsa.busNumber = busNumberParm;
  205. dsa.subBusNumber = subBusParm;
  206. dsa.deviceId = deviceIdParm;
  207. dsa.barNumber = barNumberParm;
  208. HvCall3Ret16(HvCallPciBarLoad16, &retVal, *(u64 *)&dsa, offsetParm, 0);
  209. *valueParm = retVal.value;
  210. return retVal.rc;
  211. }
  212. static inline u64 HvCallPci_barLoad32(u16 busNumberParm, u8 subBusParm,
  213. u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
  214. u32 *valueParm)
  215. {
  216. struct HvCallPci_DsaAddr dsa;
  217. struct HvCallPci_LoadReturn retVal;
  218. *((u64*)&dsa) = 0;
  219. dsa.busNumber = busNumberParm;
  220. dsa.subBusNumber = subBusParm;
  221. dsa.deviceId = deviceIdParm;
  222. dsa.barNumber = barNumberParm;
  223. HvCall3Ret16(HvCallPciBarLoad32, &retVal, *(u64 *)&dsa, offsetParm, 0);
  224. *valueParm = retVal.value;
  225. return retVal.rc;
  226. }
  227. static inline u64 HvCallPci_barLoad64(u16 busNumberParm, u8 subBusParm,
  228. u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
  229. u64 *valueParm)
  230. {
  231. struct HvCallPci_DsaAddr dsa;
  232. struct HvCallPci_LoadReturn retVal;
  233. *((u64*)&dsa) = 0;
  234. dsa.busNumber = busNumberParm;
  235. dsa.subBusNumber = subBusParm;
  236. dsa.deviceId = deviceIdParm;
  237. dsa.barNumber = barNumberParm;
  238. HvCall3Ret16(HvCallPciBarLoad64, &retVal, *(u64 *)&dsa, offsetParm, 0);
  239. *valueParm = retVal.value;
  240. return retVal.rc;
  241. }
  242. static inline u64 HvCallPci_barStore8(u16 busNumberParm, u8 subBusParm,
  243. u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
  244. u8 valueParm)
  245. {
  246. struct HvCallPci_DsaAddr dsa;
  247. *((u64*)&dsa) = 0;
  248. dsa.busNumber = busNumberParm;
  249. dsa.subBusNumber = subBusParm;
  250. dsa.deviceId = deviceIdParm;
  251. dsa.barNumber = barNumberParm;
  252. return HvCall4(HvCallPciBarStore8, *(u64 *)&dsa, offsetParm,
  253. valueParm, 0);
  254. }
  255. static inline u64 HvCallPci_barStore16(u16 busNumberParm, u8 subBusParm,
  256. u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
  257. u16 valueParm)
  258. {
  259. struct HvCallPci_DsaAddr dsa;
  260. *((u64*)&dsa) = 0;
  261. dsa.busNumber = busNumberParm;
  262. dsa.subBusNumber = subBusParm;
  263. dsa.deviceId = deviceIdParm;
  264. dsa.barNumber = barNumberParm;
  265. return HvCall4(HvCallPciBarStore16, *(u64 *)&dsa, offsetParm,
  266. valueParm, 0);
  267. }
  268. static inline u64 HvCallPci_barStore32(u16 busNumberParm, u8 subBusParm,
  269. u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
  270. u32 valueParm)
  271. {
  272. struct HvCallPci_DsaAddr dsa;
  273. *((u64*)&dsa) = 0;
  274. dsa.busNumber = busNumberParm;
  275. dsa.subBusNumber = subBusParm;
  276. dsa.deviceId = deviceIdParm;
  277. dsa.barNumber = barNumberParm;
  278. return HvCall4(HvCallPciBarStore32, *(u64 *)&dsa, offsetParm,
  279. valueParm, 0);
  280. }
  281. static inline u64 HvCallPci_barStore64(u16 busNumberParm, u8 subBusParm,
  282. u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
  283. u64 valueParm)
  284. {
  285. struct HvCallPci_DsaAddr dsa;
  286. *((u64*)&dsa) = 0;
  287. dsa.busNumber = busNumberParm;
  288. dsa.subBusNumber = subBusParm;
  289. dsa.deviceId = deviceIdParm;
  290. dsa.barNumber = barNumberParm;
  291. return HvCall4(HvCallPciBarStore64, *(u64 *)&dsa, offsetParm,
  292. valueParm, 0);
  293. }
  294. static inline u64 HvCallPci_eoi(u16 busNumberParm, u8 subBusParm,
  295. u8 deviceIdParm)
  296. {
  297. struct HvCallPci_DsaAddr dsa;
  298. struct HvCallPci_LoadReturn retVal;
  299. *((u64*)&dsa) = 0;
  300. dsa.busNumber = busNumberParm;
  301. dsa.subBusNumber = subBusParm;
  302. dsa.deviceId = deviceIdParm;
  303. HvCall1Ret16(HvCallPciEoi, &retVal, *(u64*)&dsa);
  304. return retVal.rc;
  305. }
  306. static inline u64 HvCallPci_getBarParms(u16 busNumberParm, u8 subBusParm,
  307. u8 deviceIdParm, u8 barNumberParm, u64 parms, u32 sizeofParms)
  308. {
  309. struct HvCallPci_DsaAddr dsa;
  310. *((u64*)&dsa) = 0;
  311. dsa.busNumber = busNumberParm;
  312. dsa.subBusNumber = subBusParm;
  313. dsa.deviceId = deviceIdParm;
  314. dsa.barNumber = barNumberParm;
  315. return HvCall3(HvCallPciGetBarParms, *(u64*)&dsa, parms, sizeofParms);
  316. }
  317. static inline u64 HvCallPci_maskFisr(u16 busNumberParm, u8 subBusParm,
  318. u8 deviceIdParm, u64 fisrMask)
  319. {
  320. struct HvCallPci_DsaAddr dsa;
  321. *((u64*)&dsa) = 0;
  322. dsa.busNumber = busNumberParm;
  323. dsa.subBusNumber = subBusParm;
  324. dsa.deviceId = deviceIdParm;
  325. return HvCall2(HvCallPciMaskFisr, *(u64*)&dsa, fisrMask);
  326. }
  327. static inline u64 HvCallPci_unmaskFisr(u16 busNumberParm, u8 subBusParm,
  328. u8 deviceIdParm, u64 fisrMask)
  329. {
  330. struct HvCallPci_DsaAddr dsa;
  331. *((u64*)&dsa) = 0;
  332. dsa.busNumber = busNumberParm;
  333. dsa.subBusNumber = subBusParm;
  334. dsa.deviceId = deviceIdParm;
  335. return HvCall2(HvCallPciUnmaskFisr, *(u64*)&dsa, fisrMask);
  336. }
  337. static inline u64 HvCallPci_setSlotReset(u16 busNumberParm, u8 subBusParm,
  338. u8 deviceIdParm, u64 onNotOff)
  339. {
  340. struct HvCallPci_DsaAddr dsa;
  341. *((u64*)&dsa) = 0;
  342. dsa.busNumber = busNumberParm;
  343. dsa.subBusNumber = subBusParm;
  344. dsa.deviceId = deviceIdParm;
  345. return HvCall2(HvCallPciSetSlotReset, *(u64*)&dsa, onNotOff);
  346. }
  347. static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm, u8 subBusParm,
  348. u8 deviceNumberParm, u64 parms, u32 sizeofParms)
  349. {
  350. struct HvCallPci_DsaAddr dsa;
  351. *((u64*)&dsa) = 0;
  352. dsa.busNumber = busNumberParm;
  353. dsa.subBusNumber = subBusParm;
  354. dsa.deviceId = deviceNumberParm << 4;
  355. return HvCall3(HvCallPciGetDeviceInfo, *(u64*)&dsa, parms, sizeofParms);
  356. }
  357. static inline u64 HvCallPci_maskInterrupts(u16 busNumberParm, u8 subBusParm,
  358. u8 deviceIdParm, u64 interruptMask)
  359. {
  360. struct HvCallPci_DsaAddr dsa;
  361. *((u64*)&dsa) = 0;
  362. dsa.busNumber = busNumberParm;
  363. dsa.subBusNumber = subBusParm;
  364. dsa.deviceId = deviceIdParm;
  365. return HvCall2(HvCallPciMaskInterrupts, *(u64*)&dsa, interruptMask);
  366. }
  367. static inline u64 HvCallPci_unmaskInterrupts(u16 busNumberParm, u8 subBusParm,
  368. u8 deviceIdParm, u64 interruptMask)
  369. {
  370. struct HvCallPci_DsaAddr dsa;
  371. *((u64*)&dsa) = 0;
  372. dsa.busNumber = busNumberParm;
  373. dsa.subBusNumber = subBusParm;
  374. dsa.deviceId = deviceIdParm;
  375. return HvCall2(HvCallPciUnmaskInterrupts, *(u64*)&dsa, interruptMask);
  376. }
  377. static inline u64 HvCallPci_getBusUnitInfo(u16 busNumberParm, u8 subBusParm,
  378. u8 deviceIdParm, u64 parms, u32 sizeofParms)
  379. {
  380. struct HvCallPci_DsaAddr dsa;
  381. *((u64*)&dsa) = 0;
  382. dsa.busNumber = busNumberParm;
  383. dsa.subBusNumber = subBusParm;
  384. dsa.deviceId = deviceIdParm;
  385. return HvCall3(HvCallPciGetBusUnitInfo, *(u64*)&dsa, parms,
  386. sizeofParms);
  387. }
  388. static inline int HvCallPci_getBusVpd(u16 busNumParm, u64 destParm,
  389. u16 sizeParm)
  390. {
  391. u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm,
  392. sizeParm, HvCallPci_BusVpd);
  393. if (xRc == -1)
  394. return -1;
  395. else
  396. return xRc & 0xFFFF;
  397. }
  398. static inline int HvCallPci_getBusAdapterVpd(u16 busNumParm, u64 destParm,
  399. u16 sizeParm)
  400. {
  401. u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm,
  402. sizeParm, HvCallPci_BusAdapterVpd);
  403. if (xRc == -1)
  404. return -1;
  405. else
  406. return xRc & 0xFFFF;
  407. }
  408. #endif /* _HVCALLPCI_H */