pal.h 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825
  1. #ifndef _ASM_IA64_PAL_H
  2. #define _ASM_IA64_PAL_H
  3. /*
  4. * Processor Abstraction Layer definitions.
  5. *
  6. * This is based on Intel IA-64 Architecture Software Developer's Manual rev 1.0
  7. * chapter 11 IA-64 Processor Abstraction Layer
  8. *
  9. * Copyright (C) 1998-2001 Hewlett-Packard Co
  10. * David Mosberger-Tang <davidm@hpl.hp.com>
  11. * Stephane Eranian <eranian@hpl.hp.com>
  12. * Copyright (C) 1999 VA Linux Systems
  13. * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
  14. * Copyright (C) 1999 Srinivasa Prasad Thirumalachar <sprasad@sprasad.engr.sgi.com>
  15. * Copyright (C) 2008 Silicon Graphics, Inc. (SGI)
  16. *
  17. * 99/10/01 davidm Make sure we pass zero for reserved parameters.
  18. * 00/03/07 davidm Updated pal_cache_flush() to be in sync with PAL v2.6.
  19. * 00/03/23 cfleck Modified processor min-state save area to match updated PAL & SAL info
  20. * 00/05/24 eranian Updated to latest PAL spec, fix structures bugs, added
  21. * 00/05/25 eranian Support for stack calls, and static physical calls
  22. * 00/06/18 eranian Support for stacked physical calls
  23. * 06/10/26 rja Support for Intel Itanium Architecture Software Developer's
  24. * Manual Rev 2.2 (Jan 2006)
  25. */
  26. /*
  27. * Note that some of these calls use a static-register only calling
  28. * convention which has nothing to do with the regular calling
  29. * convention.
  30. */
  31. #define PAL_CACHE_FLUSH 1 /* flush i/d cache */
  32. #define PAL_CACHE_INFO 2 /* get detailed i/d cache info */
  33. #define PAL_CACHE_INIT 3 /* initialize i/d cache */
  34. #define PAL_CACHE_SUMMARY 4 /* get summary of cache hierarchy */
  35. #define PAL_MEM_ATTRIB 5 /* list supported memory attributes */
  36. #define PAL_PTCE_INFO 6 /* purge TLB info */
  37. #define PAL_VM_INFO 7 /* return supported virtual memory features */
  38. #define PAL_VM_SUMMARY 8 /* return summary on supported vm features */
  39. #define PAL_BUS_GET_FEATURES 9 /* return processor bus interface features settings */
  40. #define PAL_BUS_SET_FEATURES 10 /* set processor bus features */
  41. #define PAL_DEBUG_INFO 11 /* get number of debug registers */
  42. #define PAL_FIXED_ADDR 12 /* get fixed component of processors's directed address */
  43. #define PAL_FREQ_BASE 13 /* base frequency of the platform */
  44. #define PAL_FREQ_RATIOS 14 /* ratio of processor, bus and ITC frequency */
  45. #define PAL_PERF_MON_INFO 15 /* return performance monitor info */
  46. #define PAL_PLATFORM_ADDR 16 /* set processor interrupt block and IO port space addr */
  47. #define PAL_PROC_GET_FEATURES 17 /* get configurable processor features & settings */
  48. #define PAL_PROC_SET_FEATURES 18 /* enable/disable configurable processor features */
  49. #define PAL_RSE_INFO 19 /* return rse information */
  50. #define PAL_VERSION 20 /* return version of PAL code */
  51. #define PAL_MC_CLEAR_LOG 21 /* clear all processor log info */
  52. #define PAL_MC_DRAIN 22 /* drain operations which could result in an MCA */
  53. #define PAL_MC_EXPECTED 23 /* set/reset expected MCA indicator */
  54. #define PAL_MC_DYNAMIC_STATE 24 /* get processor dynamic state */
  55. #define PAL_MC_ERROR_INFO 25 /* get processor MCA info and static state */
  56. #define PAL_MC_RESUME 26 /* Return to interrupted process */
  57. #define PAL_MC_REGISTER_MEM 27 /* Register memory for PAL to use during MCAs and inits */
  58. #define PAL_HALT 28 /* enter the low power HALT state */
  59. #define PAL_HALT_LIGHT 29 /* enter the low power light halt state*/
  60. #define PAL_COPY_INFO 30 /* returns info needed to relocate PAL */
  61. #define PAL_CACHE_LINE_INIT 31 /* init tags & data of cache line */
  62. #define PAL_PMI_ENTRYPOINT 32 /* register PMI memory entry points with the processor */
  63. #define PAL_ENTER_IA_32_ENV 33 /* enter IA-32 system environment */
  64. #define PAL_VM_PAGE_SIZE 34 /* return vm TC and page walker page sizes */
  65. #define PAL_MEM_FOR_TEST 37 /* get amount of memory needed for late processor test */
  66. #define PAL_CACHE_PROT_INFO 38 /* get i/d cache protection info */
  67. #define PAL_REGISTER_INFO 39 /* return AR and CR register information*/
  68. #define PAL_SHUTDOWN 40 /* enter processor shutdown state */
  69. #define PAL_PREFETCH_VISIBILITY 41 /* Make Processor Prefetches Visible */
  70. #define PAL_LOGICAL_TO_PHYSICAL 42 /* returns information on logical to physical processor mapping */
  71. #define PAL_CACHE_SHARED_INFO 43 /* returns information on caches shared by logical processor */
  72. #define PAL_GET_HW_POLICY 48 /* Get current hardware resource sharing policy */
  73. #define PAL_SET_HW_POLICY 49 /* Set current hardware resource sharing policy */
  74. #define PAL_VP_INFO 50 /* Information about virtual processor features */
  75. #define PAL_MC_HW_TRACKING 51 /* Hardware tracking status */
  76. #define PAL_COPY_PAL 256 /* relocate PAL procedures and PAL PMI */
  77. #define PAL_HALT_INFO 257 /* return the low power capabilities of processor */
  78. #define PAL_TEST_PROC 258 /* perform late processor self-test */
  79. #define PAL_CACHE_READ 259 /* read tag & data of cacheline for diagnostic testing */
  80. #define PAL_CACHE_WRITE 260 /* write tag & data of cacheline for diagnostic testing */
  81. #define PAL_VM_TR_READ 261 /* read contents of translation register */
  82. #define PAL_GET_PSTATE 262 /* get the current P-state */
  83. #define PAL_SET_PSTATE 263 /* set the P-state */
  84. #define PAL_BRAND_INFO 274 /* Processor branding information */
  85. #define PAL_GET_PSTATE_TYPE_LASTSET 0
  86. #define PAL_GET_PSTATE_TYPE_AVGANDRESET 1
  87. #define PAL_GET_PSTATE_TYPE_AVGNORESET 2
  88. #define PAL_GET_PSTATE_TYPE_INSTANT 3
  89. #define PAL_MC_ERROR_INJECT 276 /* Injects processor error or returns injection capabilities */
  90. #ifndef __ASSEMBLY__
  91. #include <linux/types.h>
  92. #include <asm/fpu.h>
  93. /*
  94. * Data types needed to pass information into PAL procedures and
  95. * interpret information returned by them.
  96. */
  97. /* Return status from the PAL procedure */
  98. typedef s64 pal_status_t;
  99. #define PAL_STATUS_SUCCESS 0 /* No error */
  100. #define PAL_STATUS_UNIMPLEMENTED (-1) /* Unimplemented procedure */
  101. #define PAL_STATUS_EINVAL (-2) /* Invalid argument */
  102. #define PAL_STATUS_ERROR (-3) /* Error */
  103. #define PAL_STATUS_CACHE_INIT_FAIL (-4) /* Could not initialize the
  104. * specified level and type of
  105. * cache without sideeffects
  106. * and "restrict" was 1
  107. */
  108. #define PAL_STATUS_REQUIRES_MEMORY (-9) /* Call requires PAL memory buffer */
  109. /* Processor cache level in the hierarchy */
  110. typedef u64 pal_cache_level_t;
  111. #define PAL_CACHE_LEVEL_L0 0 /* L0 */
  112. #define PAL_CACHE_LEVEL_L1 1 /* L1 */
  113. #define PAL_CACHE_LEVEL_L2 2 /* L2 */
  114. /* Processor cache type at a particular level in the hierarchy */
  115. typedef u64 pal_cache_type_t;
  116. #define PAL_CACHE_TYPE_INSTRUCTION 1 /* Instruction cache */
  117. #define PAL_CACHE_TYPE_DATA 2 /* Data or unified cache */
  118. #define PAL_CACHE_TYPE_INSTRUCTION_DATA 3 /* Both Data & Instruction */
  119. #define PAL_CACHE_FLUSH_INVALIDATE 1 /* Invalidate clean lines */
  120. #define PAL_CACHE_FLUSH_CHK_INTRS 2 /* check for interrupts/mc while flushing */
  121. /* Processor cache line size in bytes */
  122. typedef int pal_cache_line_size_t;
  123. /* Processor cache line state */
  124. typedef u64 pal_cache_line_state_t;
  125. #define PAL_CACHE_LINE_STATE_INVALID 0 /* Invalid */
  126. #define PAL_CACHE_LINE_STATE_SHARED 1 /* Shared */
  127. #define PAL_CACHE_LINE_STATE_EXCLUSIVE 2 /* Exclusive */
  128. #define PAL_CACHE_LINE_STATE_MODIFIED 3 /* Modified */
  129. typedef struct pal_freq_ratio {
  130. u32 den, num; /* numerator & denominator */
  131. } itc_ratio, proc_ratio;
  132. typedef union pal_cache_config_info_1_s {
  133. struct {
  134. u64 u : 1, /* 0 Unified cache ? */
  135. at : 2, /* 2-1 Cache mem attr*/
  136. reserved : 5, /* 7-3 Reserved */
  137. associativity : 8, /* 16-8 Associativity*/
  138. line_size : 8, /* 23-17 Line size */
  139. stride : 8, /* 31-24 Stride */
  140. store_latency : 8, /*39-32 Store latency*/
  141. load_latency : 8, /* 47-40 Load latency*/
  142. store_hints : 8, /* 55-48 Store hints*/
  143. load_hints : 8; /* 63-56 Load hints */
  144. } pcci1_bits;
  145. u64 pcci1_data;
  146. } pal_cache_config_info_1_t;
  147. typedef union pal_cache_config_info_2_s {
  148. struct {
  149. u32 cache_size; /*cache size in bytes*/
  150. u32 alias_boundary : 8, /* 39-32 aliased addr
  151. * separation for max
  152. * performance.
  153. */
  154. tag_ls_bit : 8, /* 47-40 LSb of addr*/
  155. tag_ms_bit : 8, /* 55-48 MSb of addr*/
  156. reserved : 8; /* 63-56 Reserved */
  157. } pcci2_bits;
  158. u64 pcci2_data;
  159. } pal_cache_config_info_2_t;
  160. typedef struct pal_cache_config_info_s {
  161. pal_status_t pcci_status;
  162. pal_cache_config_info_1_t pcci_info_1;
  163. pal_cache_config_info_2_t pcci_info_2;
  164. u64 pcci_reserved;
  165. } pal_cache_config_info_t;
  166. #define pcci_ld_hints pcci_info_1.pcci1_bits.load_hints
  167. #define pcci_st_hints pcci_info_1.pcci1_bits.store_hints
  168. #define pcci_ld_latency pcci_info_1.pcci1_bits.load_latency
  169. #define pcci_st_latency pcci_info_1.pcci1_bits.store_latency
  170. #define pcci_stride pcci_info_1.pcci1_bits.stride
  171. #define pcci_line_size pcci_info_1.pcci1_bits.line_size
  172. #define pcci_assoc pcci_info_1.pcci1_bits.associativity
  173. #define pcci_cache_attr pcci_info_1.pcci1_bits.at
  174. #define pcci_unified pcci_info_1.pcci1_bits.u
  175. #define pcci_tag_msb pcci_info_2.pcci2_bits.tag_ms_bit
  176. #define pcci_tag_lsb pcci_info_2.pcci2_bits.tag_ls_bit
  177. #define pcci_alias_boundary pcci_info_2.pcci2_bits.alias_boundary
  178. #define pcci_cache_size pcci_info_2.pcci2_bits.cache_size
  179. /* Possible values for cache attributes */
  180. #define PAL_CACHE_ATTR_WT 0 /* Write through cache */
  181. #define PAL_CACHE_ATTR_WB 1 /* Write back cache */
  182. #define PAL_CACHE_ATTR_WT_OR_WB 2 /* Either write thru or write
  183. * back depending on TLB
  184. * memory attributes
  185. */
  186. /* Possible values for cache hints */
  187. #define PAL_CACHE_HINT_TEMP_1 0 /* Temporal level 1 */
  188. #define PAL_CACHE_HINT_NTEMP_1 1 /* Non-temporal level 1 */
  189. #define PAL_CACHE_HINT_NTEMP_ALL 3 /* Non-temporal all levels */
  190. /* Processor cache protection information */
  191. typedef union pal_cache_protection_element_u {
  192. u32 pcpi_data;
  193. struct {
  194. u32 data_bits : 8, /* # data bits covered by
  195. * each unit of protection
  196. */
  197. tagprot_lsb : 6, /* Least -do- */
  198. tagprot_msb : 6, /* Most Sig. tag address
  199. * bit that this
  200. * protection covers.
  201. */
  202. prot_bits : 6, /* # of protection bits */
  203. method : 4, /* Protection method */
  204. t_d : 2; /* Indicates which part
  205. * of the cache this
  206. * protection encoding
  207. * applies.
  208. */
  209. } pcp_info;
  210. } pal_cache_protection_element_t;
  211. #define pcpi_cache_prot_part pcp_info.t_d
  212. #define pcpi_prot_method pcp_info.method
  213. #define pcpi_prot_bits pcp_info.prot_bits
  214. #define pcpi_tagprot_msb pcp_info.tagprot_msb
  215. #define pcpi_tagprot_lsb pcp_info.tagprot_lsb
  216. #define pcpi_data_bits pcp_info.data_bits
  217. /* Processor cache part encodings */
  218. #define PAL_CACHE_PROT_PART_DATA 0 /* Data protection */
  219. #define PAL_CACHE_PROT_PART_TAG 1 /* Tag protection */
  220. #define PAL_CACHE_PROT_PART_TAG_DATA 2 /* Tag+data protection (tag is
  221. * more significant )
  222. */
  223. #define PAL_CACHE_PROT_PART_DATA_TAG 3 /* Data+tag protection (data is
  224. * more significant )
  225. */
  226. #define PAL_CACHE_PROT_PART_MAX 6
  227. typedef struct pal_cache_protection_info_s {
  228. pal_status_t pcpi_status;
  229. pal_cache_protection_element_t pcp_info[PAL_CACHE_PROT_PART_MAX];
  230. } pal_cache_protection_info_t;
  231. /* Processor cache protection method encodings */
  232. #define PAL_CACHE_PROT_METHOD_NONE 0 /* No protection */
  233. #define PAL_CACHE_PROT_METHOD_ODD_PARITY 1 /* Odd parity */
  234. #define PAL_CACHE_PROT_METHOD_EVEN_PARITY 2 /* Even parity */
  235. #define PAL_CACHE_PROT_METHOD_ECC 3 /* ECC protection */
  236. /* Processor cache line identification in the hierarchy */
  237. typedef union pal_cache_line_id_u {
  238. u64 pclid_data;
  239. struct {
  240. u64 cache_type : 8, /* 7-0 cache type */
  241. level : 8, /* 15-8 level of the
  242. * cache in the
  243. * hierarchy.
  244. */
  245. way : 8, /* 23-16 way in the set
  246. */
  247. part : 8, /* 31-24 part of the
  248. * cache
  249. */
  250. reserved : 32; /* 63-32 is reserved*/
  251. } pclid_info_read;
  252. struct {
  253. u64 cache_type : 8, /* 7-0 cache type */
  254. level : 8, /* 15-8 level of the
  255. * cache in the
  256. * hierarchy.
  257. */
  258. way : 8, /* 23-16 way in the set
  259. */
  260. part : 8, /* 31-24 part of the
  261. * cache
  262. */
  263. mesi : 8, /* 39-32 cache line
  264. * state
  265. */
  266. start : 8, /* 47-40 lsb of data to
  267. * invert
  268. */
  269. length : 8, /* 55-48 #bits to
  270. * invert
  271. */
  272. trigger : 8; /* 63-56 Trigger error
  273. * by doing a load
  274. * after the write
  275. */
  276. } pclid_info_write;
  277. } pal_cache_line_id_u_t;
  278. #define pclid_read_part pclid_info_read.part
  279. #define pclid_read_way pclid_info_read.way
  280. #define pclid_read_level pclid_info_read.level
  281. #define pclid_read_cache_type pclid_info_read.cache_type
  282. #define pclid_write_trigger pclid_info_write.trigger
  283. #define pclid_write_length pclid_info_write.length
  284. #define pclid_write_start pclid_info_write.start
  285. #define pclid_write_mesi pclid_info_write.mesi
  286. #define pclid_write_part pclid_info_write.part
  287. #define pclid_write_way pclid_info_write.way
  288. #define pclid_write_level pclid_info_write.level
  289. #define pclid_write_cache_type pclid_info_write.cache_type
  290. /* Processor cache line part encodings */
  291. #define PAL_CACHE_LINE_ID_PART_DATA 0 /* Data */
  292. #define PAL_CACHE_LINE_ID_PART_TAG 1 /* Tag */
  293. #define PAL_CACHE_LINE_ID_PART_DATA_PROT 2 /* Data protection */
  294. #define PAL_CACHE_LINE_ID_PART_TAG_PROT 3 /* Tag protection */
  295. #define PAL_CACHE_LINE_ID_PART_DATA_TAG_PROT 4 /* Data+tag
  296. * protection
  297. */
  298. typedef struct pal_cache_line_info_s {
  299. pal_status_t pcli_status; /* Return status of the read cache line
  300. * info call.
  301. */
  302. u64 pcli_data; /* 64-bit data, tag, protection bits .. */
  303. u64 pcli_data_len; /* data length in bits */
  304. pal_cache_line_state_t pcli_cache_line_state; /* mesi state */
  305. } pal_cache_line_info_t;
  306. /* Machine Check related crap */
  307. /* Pending event status bits */
  308. typedef u64 pal_mc_pending_events_t;
  309. #define PAL_MC_PENDING_MCA (1 << 0)
  310. #define PAL_MC_PENDING_INIT (1 << 1)
  311. /* Error information type */
  312. typedef u64 pal_mc_info_index_t;
  313. #define PAL_MC_INFO_PROCESSOR 0 /* Processor */
  314. #define PAL_MC_INFO_CACHE_CHECK 1 /* Cache check */
  315. #define PAL_MC_INFO_TLB_CHECK 2 /* Tlb check */
  316. #define PAL_MC_INFO_BUS_CHECK 3 /* Bus check */
  317. #define PAL_MC_INFO_REQ_ADDR 4 /* Requestor address */
  318. #define PAL_MC_INFO_RESP_ADDR 5 /* Responder address */
  319. #define PAL_MC_INFO_TARGET_ADDR 6 /* Target address */
  320. #define PAL_MC_INFO_IMPL_DEP 7 /* Implementation
  321. * dependent
  322. */
  323. #define PAL_TLB_CHECK_OP_PURGE 8
  324. typedef struct pal_process_state_info_s {
  325. u64 reserved1 : 2,
  326. rz : 1, /* PAL_CHECK processor
  327. * rendezvous
  328. * successful.
  329. */
  330. ra : 1, /* PAL_CHECK attempted
  331. * a rendezvous.
  332. */
  333. me : 1, /* Distinct multiple
  334. * errors occurred
  335. */
  336. mn : 1, /* Min. state save
  337. * area has been
  338. * registered with PAL
  339. */
  340. sy : 1, /* Storage integrity
  341. * synched
  342. */
  343. co : 1, /* Continuable */
  344. ci : 1, /* MC isolated */
  345. us : 1, /* Uncontained storage
  346. * damage.
  347. */
  348. hd : 1, /* Non-essential hw
  349. * lost (no loss of
  350. * functionality)
  351. * causing the
  352. * processor to run in
  353. * degraded mode.
  354. */
  355. tl : 1, /* 1 => MC occurred
  356. * after an instr was
  357. * executed but before
  358. * the trap that
  359. * resulted from instr
  360. * execution was
  361. * generated.
  362. * (Trap Lost )
  363. */
  364. mi : 1, /* More information available
  365. * call PAL_MC_ERROR_INFO
  366. */
  367. pi : 1, /* Precise instruction pointer */
  368. pm : 1, /* Precise min-state save area */
  369. dy : 1, /* Processor dynamic
  370. * state valid
  371. */
  372. in : 1, /* 0 = MC, 1 = INIT */
  373. rs : 1, /* RSE valid */
  374. cm : 1, /* MC corrected */
  375. ex : 1, /* MC is expected */
  376. cr : 1, /* Control regs valid*/
  377. pc : 1, /* Perf cntrs valid */
  378. dr : 1, /* Debug regs valid */
  379. tr : 1, /* Translation regs
  380. * valid
  381. */
  382. rr : 1, /* Region regs valid */
  383. ar : 1, /* App regs valid */
  384. br : 1, /* Branch regs valid */
  385. pr : 1, /* Predicate registers
  386. * valid
  387. */
  388. fp : 1, /* fp registers valid*/
  389. b1 : 1, /* Preserved bank one
  390. * general registers
  391. * are valid
  392. */
  393. b0 : 1, /* Preserved bank zero
  394. * general registers
  395. * are valid
  396. */
  397. gr : 1, /* General registers
  398. * are valid
  399. * (excl. banked regs)
  400. */
  401. dsize : 16, /* size of dynamic
  402. * state returned
  403. * by the processor
  404. */
  405. se : 1, /* Shared error. MCA in a
  406. shared structure */
  407. reserved2 : 10,
  408. cc : 1, /* Cache check */
  409. tc : 1, /* TLB check */
  410. bc : 1, /* Bus check */
  411. rc : 1, /* Register file check */
  412. uc : 1; /* Uarch check */
  413. } pal_processor_state_info_t;
  414. typedef struct pal_cache_check_info_s {
  415. u64 op : 4, /* Type of cache
  416. * operation that
  417. * caused the machine
  418. * check.
  419. */
  420. level : 2, /* Cache level */
  421. reserved1 : 2,
  422. dl : 1, /* Failure in data part
  423. * of cache line
  424. */
  425. tl : 1, /* Failure in tag part
  426. * of cache line
  427. */
  428. dc : 1, /* Failure in dcache */
  429. ic : 1, /* Failure in icache */
  430. mesi : 3, /* Cache line state */
  431. mv : 1, /* mesi valid */
  432. way : 5, /* Way in which the
  433. * error occurred
  434. */
  435. wiv : 1, /* Way field valid */
  436. reserved2 : 1,
  437. dp : 1, /* Data poisoned on MBE */
  438. reserved3 : 6,
  439. hlth : 2, /* Health indicator */
  440. index : 20, /* Cache line index */
  441. reserved4 : 2,
  442. is : 1, /* instruction set (1 == ia32) */
  443. iv : 1, /* instruction set field valid */
  444. pl : 2, /* privilege level */
  445. pv : 1, /* privilege level field valid */
  446. mcc : 1, /* Machine check corrected */
  447. tv : 1, /* Target address
  448. * structure is valid
  449. */
  450. rq : 1, /* Requester identifier
  451. * structure is valid
  452. */
  453. rp : 1, /* Responder identifier
  454. * structure is valid
  455. */
  456. pi : 1; /* Precise instruction pointer
  457. * structure is valid
  458. */
  459. } pal_cache_check_info_t;
  460. typedef struct pal_tlb_check_info_s {
  461. u64 tr_slot : 8, /* Slot# of TR where
  462. * error occurred
  463. */
  464. trv : 1, /* tr_slot field is valid */
  465. reserved1 : 1,
  466. level : 2, /* TLB level where failure occurred */
  467. reserved2 : 4,
  468. dtr : 1, /* Fail in data TR */
  469. itr : 1, /* Fail in inst TR */
  470. dtc : 1, /* Fail in data TC */
  471. itc : 1, /* Fail in inst. TC */
  472. op : 4, /* Cache operation */
  473. reserved3 : 6,
  474. hlth : 2, /* Health indicator */
  475. reserved4 : 22,
  476. is : 1, /* instruction set (1 == ia32) */
  477. iv : 1, /* instruction set field valid */
  478. pl : 2, /* privilege level */
  479. pv : 1, /* privilege level field valid */
  480. mcc : 1, /* Machine check corrected */
  481. tv : 1, /* Target address
  482. * structure is valid
  483. */
  484. rq : 1, /* Requester identifier
  485. * structure is valid
  486. */
  487. rp : 1, /* Responder identifier
  488. * structure is valid
  489. */
  490. pi : 1; /* Precise instruction pointer
  491. * structure is valid
  492. */
  493. } pal_tlb_check_info_t;
  494. typedef struct pal_bus_check_info_s {
  495. u64 size : 5, /* Xaction size */
  496. ib : 1, /* Internal bus error */
  497. eb : 1, /* External bus error */
  498. cc : 1, /* Error occurred
  499. * during cache-cache
  500. * transfer.
  501. */
  502. type : 8, /* Bus xaction type*/
  503. sev : 5, /* Bus error severity*/
  504. hier : 2, /* Bus hierarchy level */
  505. dp : 1, /* Data poisoned on MBE */
  506. bsi : 8, /* Bus error status
  507. * info
  508. */
  509. reserved2 : 22,
  510. is : 1, /* instruction set (1 == ia32) */
  511. iv : 1, /* instruction set field valid */
  512. pl : 2, /* privilege level */
  513. pv : 1, /* privilege level field valid */
  514. mcc : 1, /* Machine check corrected */
  515. tv : 1, /* Target address
  516. * structure is valid
  517. */
  518. rq : 1, /* Requester identifier
  519. * structure is valid
  520. */
  521. rp : 1, /* Responder identifier
  522. * structure is valid
  523. */
  524. pi : 1; /* Precise instruction pointer
  525. * structure is valid
  526. */
  527. } pal_bus_check_info_t;
  528. typedef struct pal_reg_file_check_info_s {
  529. u64 id : 4, /* Register file identifier */
  530. op : 4, /* Type of register
  531. * operation that
  532. * caused the machine
  533. * check.
  534. */
  535. reg_num : 7, /* Register number */
  536. rnv : 1, /* reg_num valid */
  537. reserved2 : 38,
  538. is : 1, /* instruction set (1 == ia32) */
  539. iv : 1, /* instruction set field valid */
  540. pl : 2, /* privilege level */
  541. pv : 1, /* privilege level field valid */
  542. mcc : 1, /* Machine check corrected */
  543. reserved3 : 3,
  544. pi : 1; /* Precise instruction pointer
  545. * structure is valid
  546. */
  547. } pal_reg_file_check_info_t;
  548. typedef struct pal_uarch_check_info_s {
  549. u64 sid : 5, /* Structure identification */
  550. level : 3, /* Level of failure */
  551. array_id : 4, /* Array identification */
  552. op : 4, /* Type of
  553. * operation that
  554. * caused the machine
  555. * check.
  556. */
  557. way : 6, /* Way of structure */
  558. wv : 1, /* way valid */
  559. xv : 1, /* index valid */
  560. reserved1 : 6,
  561. hlth : 2, /* Health indicator */
  562. index : 8, /* Index or set of the uarch
  563. * structure that failed.
  564. */
  565. reserved2 : 24,
  566. is : 1, /* instruction set (1 == ia32) */
  567. iv : 1, /* instruction set field valid */
  568. pl : 2, /* privilege level */
  569. pv : 1, /* privilege level field valid */
  570. mcc : 1, /* Machine check corrected */
  571. tv : 1, /* Target address
  572. * structure is valid
  573. */
  574. rq : 1, /* Requester identifier
  575. * structure is valid
  576. */
  577. rp : 1, /* Responder identifier
  578. * structure is valid
  579. */
  580. pi : 1; /* Precise instruction pointer
  581. * structure is valid
  582. */
  583. } pal_uarch_check_info_t;
  584. typedef union pal_mc_error_info_u {
  585. u64 pmei_data;
  586. pal_processor_state_info_t pme_processor;
  587. pal_cache_check_info_t pme_cache;
  588. pal_tlb_check_info_t pme_tlb;
  589. pal_bus_check_info_t pme_bus;
  590. pal_reg_file_check_info_t pme_reg_file;
  591. pal_uarch_check_info_t pme_uarch;
  592. } pal_mc_error_info_t;
  593. #define pmci_proc_unknown_check pme_processor.uc
  594. #define pmci_proc_bus_check pme_processor.bc
  595. #define pmci_proc_tlb_check pme_processor.tc
  596. #define pmci_proc_cache_check pme_processor.cc
  597. #define pmci_proc_dynamic_state_size pme_processor.dsize
  598. #define pmci_proc_gpr_valid pme_processor.gr
  599. #define pmci_proc_preserved_bank0_gpr_valid pme_processor.b0
  600. #define pmci_proc_preserved_bank1_gpr_valid pme_processor.b1
  601. #define pmci_proc_fp_valid pme_processor.fp
  602. #define pmci_proc_predicate_regs_valid pme_processor.pr
  603. #define pmci_proc_branch_regs_valid pme_processor.br
  604. #define pmci_proc_app_regs_valid pme_processor.ar
  605. #define pmci_proc_region_regs_valid pme_processor.rr
  606. #define pmci_proc_translation_regs_valid pme_processor.tr
  607. #define pmci_proc_debug_regs_valid pme_processor.dr
  608. #define pmci_proc_perf_counters_valid pme_processor.pc
  609. #define pmci_proc_control_regs_valid pme_processor.cr
  610. #define pmci_proc_machine_check_expected pme_processor.ex
  611. #define pmci_proc_machine_check_corrected pme_processor.cm
  612. #define pmci_proc_rse_valid pme_processor.rs
  613. #define pmci_proc_machine_check_or_init pme_processor.in
  614. #define pmci_proc_dynamic_state_valid pme_processor.dy
  615. #define pmci_proc_operation pme_processor.op
  616. #define pmci_proc_trap_lost pme_processor.tl
  617. #define pmci_proc_hardware_damage pme_processor.hd
  618. #define pmci_proc_uncontained_storage_damage pme_processor.us
  619. #define pmci_proc_machine_check_isolated pme_processor.ci
  620. #define pmci_proc_continuable pme_processor.co
  621. #define pmci_proc_storage_intergrity_synced pme_processor.sy
  622. #define pmci_proc_min_state_save_area_regd pme_processor.mn
  623. #define pmci_proc_distinct_multiple_errors pme_processor.me
  624. #define pmci_proc_pal_attempted_rendezvous pme_processor.ra
  625. #define pmci_proc_pal_rendezvous_complete pme_processor.rz
  626. #define pmci_cache_level pme_cache.level
  627. #define pmci_cache_line_state pme_cache.mesi
  628. #define pmci_cache_line_state_valid pme_cache.mv
  629. #define pmci_cache_line_index pme_cache.index
  630. #define pmci_cache_instr_cache_fail pme_cache.ic
  631. #define pmci_cache_data_cache_fail pme_cache.dc
  632. #define pmci_cache_line_tag_fail pme_cache.tl
  633. #define pmci_cache_line_data_fail pme_cache.dl
  634. #define pmci_cache_operation pme_cache.op
  635. #define pmci_cache_way_valid pme_cache.wv
  636. #define pmci_cache_target_address_valid pme_cache.tv
  637. #define pmci_cache_way pme_cache.way
  638. #define pmci_cache_mc pme_cache.mc
  639. #define pmci_tlb_instr_translation_cache_fail pme_tlb.itc
  640. #define pmci_tlb_data_translation_cache_fail pme_tlb.dtc
  641. #define pmci_tlb_instr_translation_reg_fail pme_tlb.itr
  642. #define pmci_tlb_data_translation_reg_fail pme_tlb.dtr
  643. #define pmci_tlb_translation_reg_slot pme_tlb.tr_slot
  644. #define pmci_tlb_mc pme_tlb.mc
  645. #define pmci_bus_status_info pme_bus.bsi
  646. #define pmci_bus_req_address_valid pme_bus.rq
  647. #define pmci_bus_resp_address_valid pme_bus.rp
  648. #define pmci_bus_target_address_valid pme_bus.tv
  649. #define pmci_bus_error_severity pme_bus.sev
  650. #define pmci_bus_transaction_type pme_bus.type
  651. #define pmci_bus_cache_cache_transfer pme_bus.cc
  652. #define pmci_bus_transaction_size pme_bus.size
  653. #define pmci_bus_internal_error pme_bus.ib
  654. #define pmci_bus_external_error pme_bus.eb
  655. #define pmci_bus_mc pme_bus.mc
  656. /*
  657. * NOTE: this min_state_save area struct only includes the 1KB
  658. * architectural state save area. The other 3 KB is scratch space
  659. * for PAL.
  660. */
  661. typedef struct pal_min_state_area_s {
  662. u64 pmsa_nat_bits; /* nat bits for saved GRs */
  663. u64 pmsa_gr[15]; /* GR1 - GR15 */
  664. u64 pmsa_bank0_gr[16]; /* GR16 - GR31 */
  665. u64 pmsa_bank1_gr[16]; /* GR16 - GR31 */
  666. u64 pmsa_pr; /* predicate registers */
  667. u64 pmsa_br0; /* branch register 0 */
  668. u64 pmsa_rsc; /* ar.rsc */
  669. u64 pmsa_iip; /* cr.iip */
  670. u64 pmsa_ipsr; /* cr.ipsr */
  671. u64 pmsa_ifs; /* cr.ifs */
  672. u64 pmsa_xip; /* previous iip */
  673. u64 pmsa_xpsr; /* previous psr */
  674. u64 pmsa_xfs; /* previous ifs */
  675. u64 pmsa_br1; /* branch register 1 */
  676. u64 pmsa_reserved[70]; /* pal_min_state_area should total to 1KB */
  677. } pal_min_state_area_t;
  678. struct ia64_pal_retval {
  679. /*
  680. * A zero status value indicates call completed without error.
  681. * A negative status value indicates reason of call failure.
  682. * A positive status value indicates success but an
  683. * informational value should be printed (e.g., "reboot for
  684. * change to take effect").
  685. */
  686. s64 status;
  687. u64 v0;
  688. u64 v1;
  689. u64 v2;
  690. };
  691. /*
  692. * Note: Currently unused PAL arguments are generally labeled
  693. * "reserved" so the value specified in the PAL documentation
  694. * (generally 0) MUST be passed. Reserved parameters are not optional
  695. * parameters.
  696. */
  697. extern struct ia64_pal_retval ia64_pal_call_static (u64, u64, u64, u64);
  698. extern struct ia64_pal_retval ia64_pal_call_stacked (u64, u64, u64, u64);
  699. extern struct ia64_pal_retval ia64_pal_call_phys_static (u64, u64, u64, u64);
  700. extern struct ia64_pal_retval ia64_pal_call_phys_stacked (u64, u64, u64, u64);
  701. extern void ia64_save_scratch_fpregs (struct ia64_fpreg *);
  702. extern void ia64_load_scratch_fpregs (struct ia64_fpreg *);
  703. #define PAL_CALL(iprv,a0,a1,a2,a3) do { \
  704. struct ia64_fpreg fr[6]; \
  705. ia64_save_scratch_fpregs(fr); \
  706. iprv = ia64_pal_call_static(a0, a1, a2, a3); \
  707. ia64_load_scratch_fpregs(fr); \
  708. } while (0)
  709. #define PAL_CALL_STK(iprv,a0,a1,a2,a3) do { \
  710. struct ia64_fpreg fr[6]; \
  711. ia64_save_scratch_fpregs(fr); \
  712. iprv = ia64_pal_call_stacked(a0, a1, a2, a3); \
  713. ia64_load_scratch_fpregs(fr); \
  714. } while (0)
  715. #define PAL_CALL_PHYS(iprv,a0,a1,a2,a3) do { \
  716. struct ia64_fpreg fr[6]; \
  717. ia64_save_scratch_fpregs(fr); \
  718. iprv = ia64_pal_call_phys_static(a0, a1, a2, a3); \
  719. ia64_load_scratch_fpregs(fr); \
  720. } while (0)
  721. #define PAL_CALL_PHYS_STK(iprv,a0,a1,a2,a3) do { \
  722. struct ia64_fpreg fr[6]; \
  723. ia64_save_scratch_fpregs(fr); \
  724. iprv = ia64_pal_call_phys_stacked(a0, a1, a2, a3); \
  725. ia64_load_scratch_fpregs(fr); \
  726. } while (0)
  727. typedef int (*ia64_pal_handler) (u64, ...);
  728. extern ia64_pal_handler ia64_pal;
  729. extern void ia64_pal_handler_init (void *);
  730. extern ia64_pal_handler ia64_pal;
  731. extern pal_cache_config_info_t l0d_cache_config_info;
  732. extern pal_cache_config_info_t l0i_cache_config_info;
  733. extern pal_cache_config_info_t l1_cache_config_info;
  734. extern pal_cache_config_info_t l2_cache_config_info;
  735. extern pal_cache_protection_info_t l0d_cache_protection_info;
  736. extern pal_cache_protection_info_t l0i_cache_protection_info;
  737. extern pal_cache_protection_info_t l1_cache_protection_info;
  738. extern pal_cache_protection_info_t l2_cache_protection_info;
  739. extern pal_cache_config_info_t pal_cache_config_info_get(pal_cache_level_t,
  740. pal_cache_type_t);
  741. extern pal_cache_protection_info_t pal_cache_protection_info_get(pal_cache_level_t,
  742. pal_cache_type_t);
  743. extern void pal_error(int);
  744. /* Useful wrappers for the current list of pal procedures */
  745. typedef union pal_bus_features_u {
  746. u64 pal_bus_features_val;
  747. struct {
  748. u64 pbf_reserved1 : 29;
  749. u64 pbf_req_bus_parking : 1;
  750. u64 pbf_bus_lock_mask : 1;
  751. u64 pbf_enable_half_xfer_rate : 1;
  752. u64 pbf_reserved2 : 20;
  753. u64 pbf_enable_shared_line_replace : 1;
  754. u64 pbf_enable_exclusive_line_replace : 1;
  755. u64 pbf_disable_xaction_queueing : 1;
  756. u64 pbf_disable_resp_err_check : 1;
  757. u64 pbf_disable_berr_check : 1;
  758. u64 pbf_disable_bus_req_internal_err_signal : 1;
  759. u64 pbf_disable_bus_req_berr_signal : 1;
  760. u64 pbf_disable_bus_init_event_check : 1;
  761. u64 pbf_disable_bus_init_event_signal : 1;
  762. u64 pbf_disable_bus_addr_err_check : 1;
  763. u64 pbf_disable_bus_addr_err_signal : 1;
  764. u64 pbf_disable_bus_data_err_check : 1;
  765. } pal_bus_features_s;
  766. } pal_bus_features_u_t;
  767. extern void pal_bus_features_print (u64);
  768. /* Provide information about configurable processor bus features */
  769. static inline s64
  770. ia64_pal_bus_get_features (pal_bus_features_u_t *features_avail,
  771. pal_bus_features_u_t *features_status,
  772. pal_bus_features_u_t *features_control)
  773. {
  774. struct ia64_pal_retval iprv;
  775. PAL_CALL_PHYS(iprv, PAL_BUS_GET_FEATURES, 0, 0, 0);
  776. if (features_avail)
  777. features_avail->pal_bus_features_val = iprv.v0;
  778. if (features_status)
  779. features_status->pal_bus_features_val = iprv.v1;
  780. if (features_control)
  781. features_control->pal_bus_features_val = iprv.v2;
  782. return iprv.status;
  783. }
  784. /* Enables/disables specific processor bus features */
  785. static inline s64
  786. ia64_pal_bus_set_features (pal_bus_features_u_t feature_select)
  787. {
  788. struct ia64_pal_retval iprv;
  789. PAL_CALL_PHYS(iprv, PAL_BUS_SET_FEATURES, feature_select.pal_bus_features_val, 0, 0);
  790. return iprv.status;
  791. }
  792. /* Get detailed cache information */
  793. static inline s64
  794. ia64_pal_cache_config_info (u64 cache_level, u64 cache_type, pal_cache_config_info_t *conf)
  795. {
  796. struct ia64_pal_retval iprv;
  797. PAL_CALL(iprv, PAL_CACHE_INFO, cache_level, cache_type, 0);
  798. if (iprv.status == 0) {
  799. conf->pcci_status = iprv.status;
  800. conf->pcci_info_1.pcci1_data = iprv.v0;
  801. conf->pcci_info_2.pcci2_data = iprv.v1;
  802. conf->pcci_reserved = iprv.v2;
  803. }
  804. return iprv.status;
  805. }
  806. /* Get detailed cche protection information */
  807. static inline s64
  808. ia64_pal_cache_prot_info (u64 cache_level, u64 cache_type, pal_cache_protection_info_t *prot)
  809. {
  810. struct ia64_pal_retval iprv;
  811. PAL_CALL(iprv, PAL_CACHE_PROT_INFO, cache_level, cache_type, 0);
  812. if (iprv.status == 0) {
  813. prot->pcpi_status = iprv.status;
  814. prot->pcp_info[0].pcpi_data = iprv.v0 & 0xffffffff;
  815. prot->pcp_info[1].pcpi_data = iprv.v0 >> 32;
  816. prot->pcp_info[2].pcpi_data = iprv.v1 & 0xffffffff;
  817. prot->pcp_info[3].pcpi_data = iprv.v1 >> 32;
  818. prot->pcp_info[4].pcpi_data = iprv.v2 & 0xffffffff;
  819. prot->pcp_info[5].pcpi_data = iprv.v2 >> 32;
  820. }
  821. return iprv.status;
  822. }
  823. /*
  824. * Flush the processor instruction or data caches. *PROGRESS must be
  825. * initialized to zero before calling this for the first time..
  826. */
  827. static inline s64
  828. ia64_pal_cache_flush (u64 cache_type, u64 invalidate, u64 *progress, u64 *vector)
  829. {
  830. struct ia64_pal_retval iprv;
  831. PAL_CALL(iprv, PAL_CACHE_FLUSH, cache_type, invalidate, *progress);
  832. if (vector)
  833. *vector = iprv.v0;
  834. *progress = iprv.v1;
  835. return iprv.status;
  836. }
  837. /* Initialize the processor controlled caches */
  838. static inline s64
  839. ia64_pal_cache_init (u64 level, u64 cache_type, u64 rest)
  840. {
  841. struct ia64_pal_retval iprv;
  842. PAL_CALL(iprv, PAL_CACHE_INIT, level, cache_type, rest);
  843. return iprv.status;
  844. }
  845. /* Initialize the tags and data of a data or unified cache line of
  846. * processor controlled cache to known values without the availability
  847. * of backing memory.
  848. */
  849. static inline s64
  850. ia64_pal_cache_line_init (u64 physical_addr, u64 data_value)
  851. {
  852. struct ia64_pal_retval iprv;
  853. PAL_CALL(iprv, PAL_CACHE_LINE_INIT, physical_addr, data_value, 0);
  854. return iprv.status;
  855. }
  856. /* Read the data and tag of a processor controlled cache line for diags */
  857. static inline s64
  858. ia64_pal_cache_read (pal_cache_line_id_u_t line_id, u64 physical_addr)
  859. {
  860. struct ia64_pal_retval iprv;
  861. PAL_CALL_PHYS_STK(iprv, PAL_CACHE_READ, line_id.pclid_data,
  862. physical_addr, 0);
  863. return iprv.status;
  864. }
  865. /* Return summary information about the hierarchy of caches controlled by the processor */
  866. static inline long ia64_pal_cache_summary(unsigned long *cache_levels,
  867. unsigned long *unique_caches)
  868. {
  869. struct ia64_pal_retval iprv;
  870. PAL_CALL(iprv, PAL_CACHE_SUMMARY, 0, 0, 0);
  871. if (cache_levels)
  872. *cache_levels = iprv.v0;
  873. if (unique_caches)
  874. *unique_caches = iprv.v1;
  875. return iprv.status;
  876. }
  877. /* Write the data and tag of a processor-controlled cache line for diags */
  878. static inline s64
  879. ia64_pal_cache_write (pal_cache_line_id_u_t line_id, u64 physical_addr, u64 data)
  880. {
  881. struct ia64_pal_retval iprv;
  882. PAL_CALL_PHYS_STK(iprv, PAL_CACHE_WRITE, line_id.pclid_data,
  883. physical_addr, data);
  884. return iprv.status;
  885. }
  886. /* Return the parameters needed to copy relocatable PAL procedures from ROM to memory */
  887. static inline s64
  888. ia64_pal_copy_info (u64 copy_type, u64 num_procs, u64 num_iopics,
  889. u64 *buffer_size, u64 *buffer_align)
  890. {
  891. struct ia64_pal_retval iprv;
  892. PAL_CALL(iprv, PAL_COPY_INFO, copy_type, num_procs, num_iopics);
  893. if (buffer_size)
  894. *buffer_size = iprv.v0;
  895. if (buffer_align)
  896. *buffer_align = iprv.v1;
  897. return iprv.status;
  898. }
  899. /* Copy relocatable PAL procedures from ROM to memory */
  900. static inline s64
  901. ia64_pal_copy_pal (u64 target_addr, u64 alloc_size, u64 processor, u64 *pal_proc_offset)
  902. {
  903. struct ia64_pal_retval iprv;
  904. PAL_CALL(iprv, PAL_COPY_PAL, target_addr, alloc_size, processor);
  905. if (pal_proc_offset)
  906. *pal_proc_offset = iprv.v0;
  907. return iprv.status;
  908. }
  909. /* Return the number of instruction and data debug register pairs */
  910. static inline long ia64_pal_debug_info(unsigned long *inst_regs,
  911. unsigned long *data_regs)
  912. {
  913. struct ia64_pal_retval iprv;
  914. PAL_CALL(iprv, PAL_DEBUG_INFO, 0, 0, 0);
  915. if (inst_regs)
  916. *inst_regs = iprv.v0;
  917. if (data_regs)
  918. *data_regs = iprv.v1;
  919. return iprv.status;
  920. }
  921. #ifdef TBD
  922. /* Switch from IA64-system environment to IA-32 system environment */
  923. static inline s64
  924. ia64_pal_enter_ia32_env (ia32_env1, ia32_env2, ia32_env3)
  925. {
  926. struct ia64_pal_retval iprv;
  927. PAL_CALL(iprv, PAL_ENTER_IA_32_ENV, ia32_env1, ia32_env2, ia32_env3);
  928. return iprv.status;
  929. }
  930. #endif
  931. /* Get unique geographical address of this processor on its bus */
  932. static inline s64
  933. ia64_pal_fixed_addr (u64 *global_unique_addr)
  934. {
  935. struct ia64_pal_retval iprv;
  936. PAL_CALL(iprv, PAL_FIXED_ADDR, 0, 0, 0);
  937. if (global_unique_addr)
  938. *global_unique_addr = iprv.v0;
  939. return iprv.status;
  940. }
  941. /* Get base frequency of the platform if generated by the processor */
  942. static inline long ia64_pal_freq_base(unsigned long *platform_base_freq)
  943. {
  944. struct ia64_pal_retval iprv;
  945. PAL_CALL(iprv, PAL_FREQ_BASE, 0, 0, 0);
  946. if (platform_base_freq)
  947. *platform_base_freq = iprv.v0;
  948. return iprv.status;
  949. }
  950. /*
  951. * Get the ratios for processor frequency, bus frequency and interval timer to
  952. * to base frequency of the platform
  953. */
  954. static inline s64
  955. ia64_pal_freq_ratios (struct pal_freq_ratio *proc_ratio, struct pal_freq_ratio *bus_ratio,
  956. struct pal_freq_ratio *itc_ratio)
  957. {
  958. struct ia64_pal_retval iprv;
  959. PAL_CALL(iprv, PAL_FREQ_RATIOS, 0, 0, 0);
  960. if (proc_ratio)
  961. *(u64 *)proc_ratio = iprv.v0;
  962. if (bus_ratio)
  963. *(u64 *)bus_ratio = iprv.v1;
  964. if (itc_ratio)
  965. *(u64 *)itc_ratio = iprv.v2;
  966. return iprv.status;
  967. }
  968. /*
  969. * Get the current hardware resource sharing policy of the processor
  970. */
  971. static inline s64
  972. ia64_pal_get_hw_policy (u64 proc_num, u64 *cur_policy, u64 *num_impacted,
  973. u64 *la)
  974. {
  975. struct ia64_pal_retval iprv;
  976. PAL_CALL(iprv, PAL_GET_HW_POLICY, proc_num, 0, 0);
  977. if (cur_policy)
  978. *cur_policy = iprv.v0;
  979. if (num_impacted)
  980. *num_impacted = iprv.v1;
  981. if (la)
  982. *la = iprv.v2;
  983. return iprv.status;
  984. }
  985. /* Make the processor enter HALT or one of the implementation dependent low
  986. * power states where prefetching and execution are suspended and cache and
  987. * TLB coherency is not maintained.
  988. */
  989. static inline s64
  990. ia64_pal_halt (u64 halt_state)
  991. {
  992. struct ia64_pal_retval iprv;
  993. PAL_CALL(iprv, PAL_HALT, halt_state, 0, 0);
  994. return iprv.status;
  995. }
  996. typedef union pal_power_mgmt_info_u {
  997. u64 ppmi_data;
  998. struct {
  999. u64 exit_latency : 16,
  1000. entry_latency : 16,
  1001. power_consumption : 28,
  1002. im : 1,
  1003. co : 1,
  1004. reserved : 2;
  1005. } pal_power_mgmt_info_s;
  1006. } pal_power_mgmt_info_u_t;
  1007. /* Return information about processor's optional power management capabilities. */
  1008. static inline s64
  1009. ia64_pal_halt_info (pal_power_mgmt_info_u_t *power_buf)
  1010. {
  1011. struct ia64_pal_retval iprv;
  1012. PAL_CALL_STK(iprv, PAL_HALT_INFO, (unsigned long) power_buf, 0, 0);
  1013. return iprv.status;
  1014. }
  1015. /* Get the current P-state information */
  1016. static inline s64
  1017. ia64_pal_get_pstate (u64 *pstate_index, unsigned long type)
  1018. {
  1019. struct ia64_pal_retval iprv;
  1020. PAL_CALL_STK(iprv, PAL_GET_PSTATE, type, 0, 0);
  1021. *pstate_index = iprv.v0;
  1022. return iprv.status;
  1023. }
  1024. /* Set the P-state */
  1025. static inline s64
  1026. ia64_pal_set_pstate (u64 pstate_index)
  1027. {
  1028. struct ia64_pal_retval iprv;
  1029. PAL_CALL_STK(iprv, PAL_SET_PSTATE, pstate_index, 0, 0);
  1030. return iprv.status;
  1031. }
  1032. /* Processor branding information*/
  1033. static inline s64
  1034. ia64_pal_get_brand_info (char *brand_info)
  1035. {
  1036. struct ia64_pal_retval iprv;
  1037. PAL_CALL_STK(iprv, PAL_BRAND_INFO, 0, (u64)brand_info, 0);
  1038. return iprv.status;
  1039. }
  1040. /* Cause the processor to enter LIGHT HALT state, where prefetching and execution are
  1041. * suspended, but cache and TLB coherency is maintained.
  1042. */
  1043. static inline s64
  1044. ia64_pal_halt_light (void)
  1045. {
  1046. struct ia64_pal_retval iprv;
  1047. PAL_CALL(iprv, PAL_HALT_LIGHT, 0, 0, 0);
  1048. return iprv.status;
  1049. }
  1050. /* Clear all the processor error logging registers and reset the indicator that allows
  1051. * the error logging registers to be written. This procedure also checks the pending
  1052. * machine check bit and pending INIT bit and reports their states.
  1053. */
  1054. static inline s64
  1055. ia64_pal_mc_clear_log (u64 *pending_vector)
  1056. {
  1057. struct ia64_pal_retval iprv;
  1058. PAL_CALL(iprv, PAL_MC_CLEAR_LOG, 0, 0, 0);
  1059. if (pending_vector)
  1060. *pending_vector = iprv.v0;
  1061. return iprv.status;
  1062. }
  1063. /* Ensure that all outstanding transactions in a processor are completed or that any
  1064. * MCA due to thes outstanding transaction is taken.
  1065. */
  1066. static inline s64
  1067. ia64_pal_mc_drain (void)
  1068. {
  1069. struct ia64_pal_retval iprv;
  1070. PAL_CALL(iprv, PAL_MC_DRAIN, 0, 0, 0);
  1071. return iprv.status;
  1072. }
  1073. /* Return the machine check dynamic processor state */
  1074. static inline s64
  1075. ia64_pal_mc_dynamic_state (u64 info_type, u64 dy_buffer, u64 *size)
  1076. {
  1077. struct ia64_pal_retval iprv;
  1078. PAL_CALL(iprv, PAL_MC_DYNAMIC_STATE, info_type, dy_buffer, 0);
  1079. if (size)
  1080. *size = iprv.v0;
  1081. return iprv.status;
  1082. }
  1083. /* Return processor machine check information */
  1084. static inline s64
  1085. ia64_pal_mc_error_info (u64 info_index, u64 type_index, u64 *size, u64 *error_info)
  1086. {
  1087. struct ia64_pal_retval iprv;
  1088. PAL_CALL(iprv, PAL_MC_ERROR_INFO, info_index, type_index, 0);
  1089. if (size)
  1090. *size = iprv.v0;
  1091. if (error_info)
  1092. *error_info = iprv.v1;
  1093. return iprv.status;
  1094. }
  1095. /* Injects the requested processor error or returns info on
  1096. * supported injection capabilities for current processor implementation
  1097. */
  1098. static inline s64
  1099. ia64_pal_mc_error_inject_phys (u64 err_type_info, u64 err_struct_info,
  1100. u64 err_data_buffer, u64 *capabilities, u64 *resources)
  1101. {
  1102. struct ia64_pal_retval iprv;
  1103. PAL_CALL_PHYS_STK(iprv, PAL_MC_ERROR_INJECT, err_type_info,
  1104. err_struct_info, err_data_buffer);
  1105. if (capabilities)
  1106. *capabilities= iprv.v0;
  1107. if (resources)
  1108. *resources= iprv.v1;
  1109. return iprv.status;
  1110. }
  1111. static inline s64
  1112. ia64_pal_mc_error_inject_virt (u64 err_type_info, u64 err_struct_info,
  1113. u64 err_data_buffer, u64 *capabilities, u64 *resources)
  1114. {
  1115. struct ia64_pal_retval iprv;
  1116. PAL_CALL_STK(iprv, PAL_MC_ERROR_INJECT, err_type_info,
  1117. err_struct_info, err_data_buffer);
  1118. if (capabilities)
  1119. *capabilities= iprv.v0;
  1120. if (resources)
  1121. *resources= iprv.v1;
  1122. return iprv.status;
  1123. }
  1124. /* Inform PALE_CHECK whether a machine check is expected so that PALE_CHECK willnot
  1125. * attempt to correct any expected machine checks.
  1126. */
  1127. static inline s64
  1128. ia64_pal_mc_expected (u64 expected, u64 *previous)
  1129. {
  1130. struct ia64_pal_retval iprv;
  1131. PAL_CALL(iprv, PAL_MC_EXPECTED, expected, 0, 0);
  1132. if (previous)
  1133. *previous = iprv.v0;
  1134. return iprv.status;
  1135. }
  1136. typedef union pal_hw_tracking_u {
  1137. u64 pht_data;
  1138. struct {
  1139. u64 itc :4, /* Instruction cache tracking */
  1140. dct :4, /* Date cache tracking */
  1141. itt :4, /* Instruction TLB tracking */
  1142. ddt :4, /* Data TLB tracking */
  1143. reserved:48;
  1144. } pal_hw_tracking_s;
  1145. } pal_hw_tracking_u_t;
  1146. /*
  1147. * Hardware tracking status.
  1148. */
  1149. static inline s64
  1150. ia64_pal_mc_hw_tracking (u64 *status)
  1151. {
  1152. struct ia64_pal_retval iprv;
  1153. PAL_CALL(iprv, PAL_MC_HW_TRACKING, 0, 0, 0);
  1154. if (status)
  1155. *status = iprv.v0;
  1156. return iprv.status;
  1157. }
  1158. /* Register a platform dependent location with PAL to which it can save
  1159. * minimal processor state in the event of a machine check or initialization
  1160. * event.
  1161. */
  1162. static inline s64
  1163. ia64_pal_mc_register_mem (u64 physical_addr, u64 size, u64 *req_size)
  1164. {
  1165. struct ia64_pal_retval iprv;
  1166. PAL_CALL(iprv, PAL_MC_REGISTER_MEM, physical_addr, size, 0);
  1167. if (req_size)
  1168. *req_size = iprv.v0;
  1169. return iprv.status;
  1170. }
  1171. /* Restore minimal architectural processor state, set CMC interrupt if necessary
  1172. * and resume execution
  1173. */
  1174. static inline s64
  1175. ia64_pal_mc_resume (u64 set_cmci, u64 save_ptr)
  1176. {
  1177. struct ia64_pal_retval iprv;
  1178. PAL_CALL(iprv, PAL_MC_RESUME, set_cmci, save_ptr, 0);
  1179. return iprv.status;
  1180. }
  1181. /* Return the memory attributes implemented by the processor */
  1182. static inline s64
  1183. ia64_pal_mem_attrib (u64 *mem_attrib)
  1184. {
  1185. struct ia64_pal_retval iprv;
  1186. PAL_CALL(iprv, PAL_MEM_ATTRIB, 0, 0, 0);
  1187. if (mem_attrib)
  1188. *mem_attrib = iprv.v0 & 0xff;
  1189. return iprv.status;
  1190. }
  1191. /* Return the amount of memory needed for second phase of processor
  1192. * self-test and the required alignment of memory.
  1193. */
  1194. static inline s64
  1195. ia64_pal_mem_for_test (u64 *bytes_needed, u64 *alignment)
  1196. {
  1197. struct ia64_pal_retval iprv;
  1198. PAL_CALL(iprv, PAL_MEM_FOR_TEST, 0, 0, 0);
  1199. if (bytes_needed)
  1200. *bytes_needed = iprv.v0;
  1201. if (alignment)
  1202. *alignment = iprv.v1;
  1203. return iprv.status;
  1204. }
  1205. typedef union pal_perf_mon_info_u {
  1206. u64 ppmi_data;
  1207. struct {
  1208. u64 generic : 8,
  1209. width : 8,
  1210. cycles : 8,
  1211. retired : 8,
  1212. reserved : 32;
  1213. } pal_perf_mon_info_s;
  1214. } pal_perf_mon_info_u_t;
  1215. /* Return the performance monitor information about what can be counted
  1216. * and how to configure the monitors to count the desired events.
  1217. */
  1218. static inline s64
  1219. ia64_pal_perf_mon_info (u64 *pm_buffer, pal_perf_mon_info_u_t *pm_info)
  1220. {
  1221. struct ia64_pal_retval iprv;
  1222. PAL_CALL(iprv, PAL_PERF_MON_INFO, (unsigned long) pm_buffer, 0, 0);
  1223. if (pm_info)
  1224. pm_info->ppmi_data = iprv.v0;
  1225. return iprv.status;
  1226. }
  1227. /* Specifies the physical address of the processor interrupt block
  1228. * and I/O port space.
  1229. */
  1230. static inline s64
  1231. ia64_pal_platform_addr (u64 type, u64 physical_addr)
  1232. {
  1233. struct ia64_pal_retval iprv;
  1234. PAL_CALL(iprv, PAL_PLATFORM_ADDR, type, physical_addr, 0);
  1235. return iprv.status;
  1236. }
  1237. /* Set the SAL PMI entrypoint in memory */
  1238. static inline s64
  1239. ia64_pal_pmi_entrypoint (u64 sal_pmi_entry_addr)
  1240. {
  1241. struct ia64_pal_retval iprv;
  1242. PAL_CALL(iprv, PAL_PMI_ENTRYPOINT, sal_pmi_entry_addr, 0, 0);
  1243. return iprv.status;
  1244. }
  1245. struct pal_features_s;
  1246. /* Provide information about configurable processor features */
  1247. static inline s64
  1248. ia64_pal_proc_get_features (u64 *features_avail,
  1249. u64 *features_status,
  1250. u64 *features_control,
  1251. u64 features_set)
  1252. {
  1253. struct ia64_pal_retval iprv;
  1254. PAL_CALL_PHYS(iprv, PAL_PROC_GET_FEATURES, 0, features_set, 0);
  1255. if (iprv.status == 0) {
  1256. *features_avail = iprv.v0;
  1257. *features_status = iprv.v1;
  1258. *features_control = iprv.v2;
  1259. }
  1260. return iprv.status;
  1261. }
  1262. /* Enable/disable processor dependent features */
  1263. static inline s64
  1264. ia64_pal_proc_set_features (u64 feature_select)
  1265. {
  1266. struct ia64_pal_retval iprv;
  1267. PAL_CALL_PHYS(iprv, PAL_PROC_SET_FEATURES, feature_select, 0, 0);
  1268. return iprv.status;
  1269. }
  1270. /*
  1271. * Put everything in a struct so we avoid the global offset table whenever
  1272. * possible.
  1273. */
  1274. typedef struct ia64_ptce_info_s {
  1275. unsigned long base;
  1276. u32 count[2];
  1277. u32 stride[2];
  1278. } ia64_ptce_info_t;
  1279. /* Return the information required for the architected loop used to purge
  1280. * (initialize) the entire TC
  1281. */
  1282. static inline s64
  1283. ia64_get_ptce (ia64_ptce_info_t *ptce)
  1284. {
  1285. struct ia64_pal_retval iprv;
  1286. if (!ptce)
  1287. return -1;
  1288. PAL_CALL(iprv, PAL_PTCE_INFO, 0, 0, 0);
  1289. if (iprv.status == 0) {
  1290. ptce->base = iprv.v0;
  1291. ptce->count[0] = iprv.v1 >> 32;
  1292. ptce->count[1] = iprv.v1 & 0xffffffff;
  1293. ptce->stride[0] = iprv.v2 >> 32;
  1294. ptce->stride[1] = iprv.v2 & 0xffffffff;
  1295. }
  1296. return iprv.status;
  1297. }
  1298. /* Return info about implemented application and control registers. */
  1299. static inline s64
  1300. ia64_pal_register_info (u64 info_request, u64 *reg_info_1, u64 *reg_info_2)
  1301. {
  1302. struct ia64_pal_retval iprv;
  1303. PAL_CALL(iprv, PAL_REGISTER_INFO, info_request, 0, 0);
  1304. if (reg_info_1)
  1305. *reg_info_1 = iprv.v0;
  1306. if (reg_info_2)
  1307. *reg_info_2 = iprv.v1;
  1308. return iprv.status;
  1309. }
  1310. typedef union pal_hints_u {
  1311. unsigned long ph_data;
  1312. struct {
  1313. unsigned long si : 1,
  1314. li : 1,
  1315. reserved : 62;
  1316. } pal_hints_s;
  1317. } pal_hints_u_t;
  1318. /* Return information about the register stack and RSE for this processor
  1319. * implementation.
  1320. */
  1321. static inline long ia64_pal_rse_info(unsigned long *num_phys_stacked,
  1322. pal_hints_u_t *hints)
  1323. {
  1324. struct ia64_pal_retval iprv;
  1325. PAL_CALL(iprv, PAL_RSE_INFO, 0, 0, 0);
  1326. if (num_phys_stacked)
  1327. *num_phys_stacked = iprv.v0;
  1328. if (hints)
  1329. hints->ph_data = iprv.v1;
  1330. return iprv.status;
  1331. }
  1332. /*
  1333. * Set the current hardware resource sharing policy of the processor
  1334. */
  1335. static inline s64
  1336. ia64_pal_set_hw_policy (u64 policy)
  1337. {
  1338. struct ia64_pal_retval iprv;
  1339. PAL_CALL(iprv, PAL_SET_HW_POLICY, policy, 0, 0);
  1340. return iprv.status;
  1341. }
  1342. /* Cause the processor to enter SHUTDOWN state, where prefetching and execution are
  1343. * suspended, but cause cache and TLB coherency to be maintained.
  1344. * This is usually called in IA-32 mode.
  1345. */
  1346. static inline s64
  1347. ia64_pal_shutdown (void)
  1348. {
  1349. struct ia64_pal_retval iprv;
  1350. PAL_CALL(iprv, PAL_SHUTDOWN, 0, 0, 0);
  1351. return iprv.status;
  1352. }
  1353. /* Perform the second phase of processor self-test. */
  1354. static inline s64
  1355. ia64_pal_test_proc (u64 test_addr, u64 test_size, u64 attributes, u64 *self_test_state)
  1356. {
  1357. struct ia64_pal_retval iprv;
  1358. PAL_CALL(iprv, PAL_TEST_PROC, test_addr, test_size, attributes);
  1359. if (self_test_state)
  1360. *self_test_state = iprv.v0;
  1361. return iprv.status;
  1362. }
  1363. typedef union pal_version_u {
  1364. u64 pal_version_val;
  1365. struct {
  1366. u64 pv_pal_b_rev : 8;
  1367. u64 pv_pal_b_model : 8;
  1368. u64 pv_reserved1 : 8;
  1369. u64 pv_pal_vendor : 8;
  1370. u64 pv_pal_a_rev : 8;
  1371. u64 pv_pal_a_model : 8;
  1372. u64 pv_reserved2 : 16;
  1373. } pal_version_s;
  1374. } pal_version_u_t;
  1375. /*
  1376. * Return PAL version information. While the documentation states that
  1377. * PAL_VERSION can be called in either physical or virtual mode, some
  1378. * implementations only allow physical calls. We don't call it very often,
  1379. * so the overhead isn't worth eliminating.
  1380. */
  1381. static inline s64
  1382. ia64_pal_version (pal_version_u_t *pal_min_version, pal_version_u_t *pal_cur_version)
  1383. {
  1384. struct ia64_pal_retval iprv;
  1385. PAL_CALL_PHYS(iprv, PAL_VERSION, 0, 0, 0);
  1386. if (pal_min_version)
  1387. pal_min_version->pal_version_val = iprv.v0;
  1388. if (pal_cur_version)
  1389. pal_cur_version->pal_version_val = iprv.v1;
  1390. return iprv.status;
  1391. }
  1392. typedef union pal_tc_info_u {
  1393. u64 pti_val;
  1394. struct {
  1395. u64 num_sets : 8,
  1396. associativity : 8,
  1397. num_entries : 16,
  1398. pf : 1,
  1399. unified : 1,
  1400. reduce_tr : 1,
  1401. reserved : 29;
  1402. } pal_tc_info_s;
  1403. } pal_tc_info_u_t;
  1404. #define tc_reduce_tr pal_tc_info_s.reduce_tr
  1405. #define tc_unified pal_tc_info_s.unified
  1406. #define tc_pf pal_tc_info_s.pf
  1407. #define tc_num_entries pal_tc_info_s.num_entries
  1408. #define tc_associativity pal_tc_info_s.associativity
  1409. #define tc_num_sets pal_tc_info_s.num_sets
  1410. /* Return information about the virtual memory characteristics of the processor
  1411. * implementation.
  1412. */
  1413. static inline s64
  1414. ia64_pal_vm_info (u64 tc_level, u64 tc_type, pal_tc_info_u_t *tc_info, u64 *tc_pages)
  1415. {
  1416. struct ia64_pal_retval iprv;
  1417. PAL_CALL(iprv, PAL_VM_INFO, tc_level, tc_type, 0);
  1418. if (tc_info)
  1419. tc_info->pti_val = iprv.v0;
  1420. if (tc_pages)
  1421. *tc_pages = iprv.v1;
  1422. return iprv.status;
  1423. }
  1424. /* Get page size information about the virtual memory characteristics of the processor
  1425. * implementation.
  1426. */
  1427. static inline s64 ia64_pal_vm_page_size(u64 *tr_pages, u64 *vw_pages)
  1428. {
  1429. struct ia64_pal_retval iprv;
  1430. PAL_CALL(iprv, PAL_VM_PAGE_SIZE, 0, 0, 0);
  1431. if (tr_pages)
  1432. *tr_pages = iprv.v0;
  1433. if (vw_pages)
  1434. *vw_pages = iprv.v1;
  1435. return iprv.status;
  1436. }
  1437. typedef union pal_vm_info_1_u {
  1438. u64 pvi1_val;
  1439. struct {
  1440. u64 vw : 1,
  1441. phys_add_size : 7,
  1442. key_size : 8,
  1443. max_pkr : 8,
  1444. hash_tag_id : 8,
  1445. max_dtr_entry : 8,
  1446. max_itr_entry : 8,
  1447. max_unique_tcs : 8,
  1448. num_tc_levels : 8;
  1449. } pal_vm_info_1_s;
  1450. } pal_vm_info_1_u_t;
  1451. #define PAL_MAX_PURGES 0xFFFF /* all ones is means unlimited */
  1452. typedef union pal_vm_info_2_u {
  1453. u64 pvi2_val;
  1454. struct {
  1455. u64 impl_va_msb : 8,
  1456. rid_size : 8,
  1457. max_purges : 16,
  1458. reserved : 32;
  1459. } pal_vm_info_2_s;
  1460. } pal_vm_info_2_u_t;
  1461. /* Get summary information about the virtual memory characteristics of the processor
  1462. * implementation.
  1463. */
  1464. static inline s64
  1465. ia64_pal_vm_summary (pal_vm_info_1_u_t *vm_info_1, pal_vm_info_2_u_t *vm_info_2)
  1466. {
  1467. struct ia64_pal_retval iprv;
  1468. PAL_CALL(iprv, PAL_VM_SUMMARY, 0, 0, 0);
  1469. if (vm_info_1)
  1470. vm_info_1->pvi1_val = iprv.v0;
  1471. if (vm_info_2)
  1472. vm_info_2->pvi2_val = iprv.v1;
  1473. return iprv.status;
  1474. }
  1475. typedef union pal_vp_info_u {
  1476. u64 pvi_val;
  1477. struct {
  1478. u64 index: 48, /* virtual feature set info */
  1479. vmm_id: 16; /* feature set id */
  1480. } pal_vp_info_s;
  1481. } pal_vp_info_u_t;
  1482. /*
  1483. * Returns information about virtual processor features
  1484. */
  1485. static inline s64
  1486. ia64_pal_vp_info (u64 feature_set, u64 vp_buffer, u64 *vp_info, u64 *vmm_id)
  1487. {
  1488. struct ia64_pal_retval iprv;
  1489. PAL_CALL(iprv, PAL_VP_INFO, feature_set, vp_buffer, 0);
  1490. if (vp_info)
  1491. *vp_info = iprv.v0;
  1492. if (vmm_id)
  1493. *vmm_id = iprv.v1;
  1494. return iprv.status;
  1495. }
  1496. typedef union pal_itr_valid_u {
  1497. u64 piv_val;
  1498. struct {
  1499. u64 access_rights_valid : 1,
  1500. priv_level_valid : 1,
  1501. dirty_bit_valid : 1,
  1502. mem_attr_valid : 1,
  1503. reserved : 60;
  1504. } pal_tr_valid_s;
  1505. } pal_tr_valid_u_t;
  1506. /* Read a translation register */
  1507. static inline s64
  1508. ia64_pal_tr_read (u64 reg_num, u64 tr_type, u64 *tr_buffer, pal_tr_valid_u_t *tr_valid)
  1509. {
  1510. struct ia64_pal_retval iprv;
  1511. PAL_CALL_PHYS_STK(iprv, PAL_VM_TR_READ, reg_num, tr_type,(u64)ia64_tpa(tr_buffer));
  1512. if (tr_valid)
  1513. tr_valid->piv_val = iprv.v0;
  1514. return iprv.status;
  1515. }
  1516. /*
  1517. * PAL_PREFETCH_VISIBILITY transaction types
  1518. */
  1519. #define PAL_VISIBILITY_VIRTUAL 0
  1520. #define PAL_VISIBILITY_PHYSICAL 1
  1521. /*
  1522. * PAL_PREFETCH_VISIBILITY return codes
  1523. */
  1524. #define PAL_VISIBILITY_OK 1
  1525. #define PAL_VISIBILITY_OK_REMOTE_NEEDED 0
  1526. #define PAL_VISIBILITY_INVAL_ARG -2
  1527. #define PAL_VISIBILITY_ERROR -3
  1528. static inline s64
  1529. ia64_pal_prefetch_visibility (s64 trans_type)
  1530. {
  1531. struct ia64_pal_retval iprv;
  1532. PAL_CALL(iprv, PAL_PREFETCH_VISIBILITY, trans_type, 0, 0);
  1533. return iprv.status;
  1534. }
  1535. /* data structure for getting information on logical to physical mappings */
  1536. typedef union pal_log_overview_u {
  1537. struct {
  1538. u64 num_log :16, /* Total number of logical
  1539. * processors on this die
  1540. */
  1541. tpc :8, /* Threads per core */
  1542. reserved3 :8, /* Reserved */
  1543. cpp :8, /* Cores per processor */
  1544. reserved2 :8, /* Reserved */
  1545. ppid :8, /* Physical processor ID */
  1546. reserved1 :8; /* Reserved */
  1547. } overview_bits;
  1548. u64 overview_data;
  1549. } pal_log_overview_t;
  1550. typedef union pal_proc_n_log_info1_u{
  1551. struct {
  1552. u64 tid :16, /* Thread id */
  1553. reserved2 :16, /* Reserved */
  1554. cid :16, /* Core id */
  1555. reserved1 :16; /* Reserved */
  1556. } ppli1_bits;
  1557. u64 ppli1_data;
  1558. } pal_proc_n_log_info1_t;
  1559. typedef union pal_proc_n_log_info2_u {
  1560. struct {
  1561. u64 la :16, /* Logical address */
  1562. reserved :48; /* Reserved */
  1563. } ppli2_bits;
  1564. u64 ppli2_data;
  1565. } pal_proc_n_log_info2_t;
  1566. typedef struct pal_logical_to_physical_s
  1567. {
  1568. pal_log_overview_t overview;
  1569. pal_proc_n_log_info1_t ppli1;
  1570. pal_proc_n_log_info2_t ppli2;
  1571. } pal_logical_to_physical_t;
  1572. #define overview_num_log overview.overview_bits.num_log
  1573. #define overview_tpc overview.overview_bits.tpc
  1574. #define overview_cpp overview.overview_bits.cpp
  1575. #define overview_ppid overview.overview_bits.ppid
  1576. #define log1_tid ppli1.ppli1_bits.tid
  1577. #define log1_cid ppli1.ppli1_bits.cid
  1578. #define log2_la ppli2.ppli2_bits.la
  1579. /* Get information on logical to physical processor mappings. */
  1580. static inline s64
  1581. ia64_pal_logical_to_phys(u64 proc_number, pal_logical_to_physical_t *mapping)
  1582. {
  1583. struct ia64_pal_retval iprv;
  1584. PAL_CALL(iprv, PAL_LOGICAL_TO_PHYSICAL, proc_number, 0, 0);
  1585. if (iprv.status == PAL_STATUS_SUCCESS)
  1586. {
  1587. mapping->overview.overview_data = iprv.v0;
  1588. mapping->ppli1.ppli1_data = iprv.v1;
  1589. mapping->ppli2.ppli2_data = iprv.v2;
  1590. }
  1591. return iprv.status;
  1592. }
  1593. typedef struct pal_cache_shared_info_s
  1594. {
  1595. u64 num_shared;
  1596. pal_proc_n_log_info1_t ppli1;
  1597. pal_proc_n_log_info2_t ppli2;
  1598. } pal_cache_shared_info_t;
  1599. /* Get information on logical to physical processor mappings. */
  1600. static inline s64
  1601. ia64_pal_cache_shared_info(u64 level,
  1602. u64 type,
  1603. u64 proc_number,
  1604. pal_cache_shared_info_t *info)
  1605. {
  1606. struct ia64_pal_retval iprv;
  1607. PAL_CALL(iprv, PAL_CACHE_SHARED_INFO, level, type, proc_number);
  1608. if (iprv.status == PAL_STATUS_SUCCESS) {
  1609. info->num_shared = iprv.v0;
  1610. info->ppli1.ppli1_data = iprv.v1;
  1611. info->ppli2.ppli2_data = iprv.v2;
  1612. }
  1613. return iprv.status;
  1614. }
  1615. #endif /* __ASSEMBLY__ */
  1616. #endif /* _ASM_IA64_PAL_H */