pal.h 53 KB

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