pal.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827
  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 s64
  867. ia64_pal_cache_summary (u64 *cache_levels, u64 *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 s64
  911. ia64_pal_debug_info (u64 *inst_regs, u64 *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 s64
  943. ia64_pal_freq_base (u64 *platform_base_freq)
  944. {
  945. struct ia64_pal_retval iprv;
  946. PAL_CALL(iprv, PAL_FREQ_BASE, 0, 0, 0);
  947. if (platform_base_freq)
  948. *platform_base_freq = iprv.v0;
  949. return iprv.status;
  950. }
  951. /*
  952. * Get the ratios for processor frequency, bus frequency and interval timer to
  953. * to base frequency of the platform
  954. */
  955. static inline s64
  956. ia64_pal_freq_ratios (struct pal_freq_ratio *proc_ratio, struct pal_freq_ratio *bus_ratio,
  957. struct pal_freq_ratio *itc_ratio)
  958. {
  959. struct ia64_pal_retval iprv;
  960. PAL_CALL(iprv, PAL_FREQ_RATIOS, 0, 0, 0);
  961. if (proc_ratio)
  962. *(u64 *)proc_ratio = iprv.v0;
  963. if (bus_ratio)
  964. *(u64 *)bus_ratio = iprv.v1;
  965. if (itc_ratio)
  966. *(u64 *)itc_ratio = iprv.v2;
  967. return iprv.status;
  968. }
  969. /*
  970. * Get the current hardware resource sharing policy of the processor
  971. */
  972. static inline s64
  973. ia64_pal_get_hw_policy (u64 proc_num, u64 *cur_policy, u64 *num_impacted,
  974. u64 *la)
  975. {
  976. struct ia64_pal_retval iprv;
  977. PAL_CALL(iprv, PAL_GET_HW_POLICY, proc_num, 0, 0);
  978. if (cur_policy)
  979. *cur_policy = iprv.v0;
  980. if (num_impacted)
  981. *num_impacted = iprv.v1;
  982. if (la)
  983. *la = iprv.v2;
  984. return iprv.status;
  985. }
  986. /* Make the processor enter HALT or one of the implementation dependent low
  987. * power states where prefetching and execution are suspended and cache and
  988. * TLB coherency is not maintained.
  989. */
  990. static inline s64
  991. ia64_pal_halt (u64 halt_state)
  992. {
  993. struct ia64_pal_retval iprv;
  994. PAL_CALL(iprv, PAL_HALT, halt_state, 0, 0);
  995. return iprv.status;
  996. }
  997. typedef union pal_power_mgmt_info_u {
  998. u64 ppmi_data;
  999. struct {
  1000. u64 exit_latency : 16,
  1001. entry_latency : 16,
  1002. power_consumption : 28,
  1003. im : 1,
  1004. co : 1,
  1005. reserved : 2;
  1006. } pal_power_mgmt_info_s;
  1007. } pal_power_mgmt_info_u_t;
  1008. /* Return information about processor's optional power management capabilities. */
  1009. static inline s64
  1010. ia64_pal_halt_info (pal_power_mgmt_info_u_t *power_buf)
  1011. {
  1012. struct ia64_pal_retval iprv;
  1013. PAL_CALL_STK(iprv, PAL_HALT_INFO, (unsigned long) power_buf, 0, 0);
  1014. return iprv.status;
  1015. }
  1016. /* Get the current P-state information */
  1017. static inline s64
  1018. ia64_pal_get_pstate (u64 *pstate_index, unsigned long type)
  1019. {
  1020. struct ia64_pal_retval iprv;
  1021. PAL_CALL_STK(iprv, PAL_GET_PSTATE, type, 0, 0);
  1022. *pstate_index = iprv.v0;
  1023. return iprv.status;
  1024. }
  1025. /* Set the P-state */
  1026. static inline s64
  1027. ia64_pal_set_pstate (u64 pstate_index)
  1028. {
  1029. struct ia64_pal_retval iprv;
  1030. PAL_CALL_STK(iprv, PAL_SET_PSTATE, pstate_index, 0, 0);
  1031. return iprv.status;
  1032. }
  1033. /* Processor branding information*/
  1034. static inline s64
  1035. ia64_pal_get_brand_info (char *brand_info)
  1036. {
  1037. struct ia64_pal_retval iprv;
  1038. PAL_CALL_STK(iprv, PAL_BRAND_INFO, 0, (u64)brand_info, 0);
  1039. return iprv.status;
  1040. }
  1041. /* Cause the processor to enter LIGHT HALT state, where prefetching and execution are
  1042. * suspended, but cache and TLB coherency is maintained.
  1043. */
  1044. static inline s64
  1045. ia64_pal_halt_light (void)
  1046. {
  1047. struct ia64_pal_retval iprv;
  1048. PAL_CALL(iprv, PAL_HALT_LIGHT, 0, 0, 0);
  1049. return iprv.status;
  1050. }
  1051. /* Clear all the processor error logging registers and reset the indicator that allows
  1052. * the error logging registers to be written. This procedure also checks the pending
  1053. * machine check bit and pending INIT bit and reports their states.
  1054. */
  1055. static inline s64
  1056. ia64_pal_mc_clear_log (u64 *pending_vector)
  1057. {
  1058. struct ia64_pal_retval iprv;
  1059. PAL_CALL(iprv, PAL_MC_CLEAR_LOG, 0, 0, 0);
  1060. if (pending_vector)
  1061. *pending_vector = iprv.v0;
  1062. return iprv.status;
  1063. }
  1064. /* Ensure that all outstanding transactions in a processor are completed or that any
  1065. * MCA due to thes outstanding transaction is taken.
  1066. */
  1067. static inline s64
  1068. ia64_pal_mc_drain (void)
  1069. {
  1070. struct ia64_pal_retval iprv;
  1071. PAL_CALL(iprv, PAL_MC_DRAIN, 0, 0, 0);
  1072. return iprv.status;
  1073. }
  1074. /* Return the machine check dynamic processor state */
  1075. static inline s64
  1076. ia64_pal_mc_dynamic_state (u64 info_type, u64 dy_buffer, u64 *size)
  1077. {
  1078. struct ia64_pal_retval iprv;
  1079. PAL_CALL(iprv, PAL_MC_DYNAMIC_STATE, info_type, dy_buffer, 0);
  1080. if (size)
  1081. *size = iprv.v0;
  1082. return iprv.status;
  1083. }
  1084. /* Return processor machine check information */
  1085. static inline s64
  1086. ia64_pal_mc_error_info (u64 info_index, u64 type_index, u64 *size, u64 *error_info)
  1087. {
  1088. struct ia64_pal_retval iprv;
  1089. PAL_CALL(iprv, PAL_MC_ERROR_INFO, info_index, type_index, 0);
  1090. if (size)
  1091. *size = iprv.v0;
  1092. if (error_info)
  1093. *error_info = iprv.v1;
  1094. return iprv.status;
  1095. }
  1096. /* Injects the requested processor error or returns info on
  1097. * supported injection capabilities for current processor implementation
  1098. */
  1099. static inline s64
  1100. ia64_pal_mc_error_inject_phys (u64 err_type_info, u64 err_struct_info,
  1101. u64 err_data_buffer, u64 *capabilities, u64 *resources)
  1102. {
  1103. struct ia64_pal_retval iprv;
  1104. PAL_CALL_PHYS_STK(iprv, PAL_MC_ERROR_INJECT, err_type_info,
  1105. err_struct_info, err_data_buffer);
  1106. if (capabilities)
  1107. *capabilities= iprv.v0;
  1108. if (resources)
  1109. *resources= iprv.v1;
  1110. return iprv.status;
  1111. }
  1112. static inline s64
  1113. ia64_pal_mc_error_inject_virt (u64 err_type_info, u64 err_struct_info,
  1114. u64 err_data_buffer, u64 *capabilities, u64 *resources)
  1115. {
  1116. struct ia64_pal_retval iprv;
  1117. PAL_CALL_STK(iprv, PAL_MC_ERROR_INJECT, err_type_info,
  1118. err_struct_info, err_data_buffer);
  1119. if (capabilities)
  1120. *capabilities= iprv.v0;
  1121. if (resources)
  1122. *resources= iprv.v1;
  1123. return iprv.status;
  1124. }
  1125. /* Inform PALE_CHECK whether a machine check is expected so that PALE_CHECK willnot
  1126. * attempt to correct any expected machine checks.
  1127. */
  1128. static inline s64
  1129. ia64_pal_mc_expected (u64 expected, u64 *previous)
  1130. {
  1131. struct ia64_pal_retval iprv;
  1132. PAL_CALL(iprv, PAL_MC_EXPECTED, expected, 0, 0);
  1133. if (previous)
  1134. *previous = iprv.v0;
  1135. return iprv.status;
  1136. }
  1137. typedef union pal_hw_tracking_u {
  1138. u64 pht_data;
  1139. struct {
  1140. u64 itc :4, /* Instruction cache tracking */
  1141. dct :4, /* Date cache tracking */
  1142. itt :4, /* Instruction TLB tracking */
  1143. ddt :4, /* Data TLB tracking */
  1144. reserved:48;
  1145. } pal_hw_tracking_s;
  1146. } pal_hw_tracking_u_t;
  1147. /*
  1148. * Hardware tracking status.
  1149. */
  1150. static inline s64
  1151. ia64_pal_mc_hw_tracking (u64 *status)
  1152. {
  1153. struct ia64_pal_retval iprv;
  1154. PAL_CALL(iprv, PAL_MC_HW_TRACKING, 0, 0, 0);
  1155. if (status)
  1156. *status = iprv.v0;
  1157. return iprv.status;
  1158. }
  1159. /* Register a platform dependent location with PAL to which it can save
  1160. * minimal processor state in the event of a machine check or initialization
  1161. * event.
  1162. */
  1163. static inline s64
  1164. ia64_pal_mc_register_mem (u64 physical_addr, u64 size, u64 *req_size)
  1165. {
  1166. struct ia64_pal_retval iprv;
  1167. PAL_CALL(iprv, PAL_MC_REGISTER_MEM, physical_addr, size, 0);
  1168. if (req_size)
  1169. *req_size = iprv.v0;
  1170. return iprv.status;
  1171. }
  1172. /* Restore minimal architectural processor state, set CMC interrupt if necessary
  1173. * and resume execution
  1174. */
  1175. static inline s64
  1176. ia64_pal_mc_resume (u64 set_cmci, u64 save_ptr)
  1177. {
  1178. struct ia64_pal_retval iprv;
  1179. PAL_CALL(iprv, PAL_MC_RESUME, set_cmci, save_ptr, 0);
  1180. return iprv.status;
  1181. }
  1182. /* Return the memory attributes implemented by the processor */
  1183. static inline s64
  1184. ia64_pal_mem_attrib (u64 *mem_attrib)
  1185. {
  1186. struct ia64_pal_retval iprv;
  1187. PAL_CALL(iprv, PAL_MEM_ATTRIB, 0, 0, 0);
  1188. if (mem_attrib)
  1189. *mem_attrib = iprv.v0 & 0xff;
  1190. return iprv.status;
  1191. }
  1192. /* Return the amount of memory needed for second phase of processor
  1193. * self-test and the required alignment of memory.
  1194. */
  1195. static inline s64
  1196. ia64_pal_mem_for_test (u64 *bytes_needed, u64 *alignment)
  1197. {
  1198. struct ia64_pal_retval iprv;
  1199. PAL_CALL(iprv, PAL_MEM_FOR_TEST, 0, 0, 0);
  1200. if (bytes_needed)
  1201. *bytes_needed = iprv.v0;
  1202. if (alignment)
  1203. *alignment = iprv.v1;
  1204. return iprv.status;
  1205. }
  1206. typedef union pal_perf_mon_info_u {
  1207. u64 ppmi_data;
  1208. struct {
  1209. u64 generic : 8,
  1210. width : 8,
  1211. cycles : 8,
  1212. retired : 8,
  1213. reserved : 32;
  1214. } pal_perf_mon_info_s;
  1215. } pal_perf_mon_info_u_t;
  1216. /* Return the performance monitor information about what can be counted
  1217. * and how to configure the monitors to count the desired events.
  1218. */
  1219. static inline s64
  1220. ia64_pal_perf_mon_info (u64 *pm_buffer, pal_perf_mon_info_u_t *pm_info)
  1221. {
  1222. struct ia64_pal_retval iprv;
  1223. PAL_CALL(iprv, PAL_PERF_MON_INFO, (unsigned long) pm_buffer, 0, 0);
  1224. if (pm_info)
  1225. pm_info->ppmi_data = iprv.v0;
  1226. return iprv.status;
  1227. }
  1228. /* Specifies the physical address of the processor interrupt block
  1229. * and I/O port space.
  1230. */
  1231. static inline s64
  1232. ia64_pal_platform_addr (u64 type, u64 physical_addr)
  1233. {
  1234. struct ia64_pal_retval iprv;
  1235. PAL_CALL(iprv, PAL_PLATFORM_ADDR, type, physical_addr, 0);
  1236. return iprv.status;
  1237. }
  1238. /* Set the SAL PMI entrypoint in memory */
  1239. static inline s64
  1240. ia64_pal_pmi_entrypoint (u64 sal_pmi_entry_addr)
  1241. {
  1242. struct ia64_pal_retval iprv;
  1243. PAL_CALL(iprv, PAL_PMI_ENTRYPOINT, sal_pmi_entry_addr, 0, 0);
  1244. return iprv.status;
  1245. }
  1246. struct pal_features_s;
  1247. /* Provide information about configurable processor features */
  1248. static inline s64
  1249. ia64_pal_proc_get_features (u64 *features_avail,
  1250. u64 *features_status,
  1251. u64 *features_control,
  1252. u64 features_set)
  1253. {
  1254. struct ia64_pal_retval iprv;
  1255. PAL_CALL_PHYS(iprv, PAL_PROC_GET_FEATURES, 0, features_set, 0);
  1256. if (iprv.status == 0) {
  1257. *features_avail = iprv.v0;
  1258. *features_status = iprv.v1;
  1259. *features_control = iprv.v2;
  1260. }
  1261. return iprv.status;
  1262. }
  1263. /* Enable/disable processor dependent features */
  1264. static inline s64
  1265. ia64_pal_proc_set_features (u64 feature_select)
  1266. {
  1267. struct ia64_pal_retval iprv;
  1268. PAL_CALL_PHYS(iprv, PAL_PROC_SET_FEATURES, feature_select, 0, 0);
  1269. return iprv.status;
  1270. }
  1271. /*
  1272. * Put everything in a struct so we avoid the global offset table whenever
  1273. * possible.
  1274. */
  1275. typedef struct ia64_ptce_info_s {
  1276. u64 base;
  1277. u32 count[2];
  1278. u32 stride[2];
  1279. } ia64_ptce_info_t;
  1280. /* Return the information required for the architected loop used to purge
  1281. * (initialize) the entire TC
  1282. */
  1283. static inline s64
  1284. ia64_get_ptce (ia64_ptce_info_t *ptce)
  1285. {
  1286. struct ia64_pal_retval iprv;
  1287. if (!ptce)
  1288. return -1;
  1289. PAL_CALL(iprv, PAL_PTCE_INFO, 0, 0, 0);
  1290. if (iprv.status == 0) {
  1291. ptce->base = iprv.v0;
  1292. ptce->count[0] = iprv.v1 >> 32;
  1293. ptce->count[1] = iprv.v1 & 0xffffffff;
  1294. ptce->stride[0] = iprv.v2 >> 32;
  1295. ptce->stride[1] = iprv.v2 & 0xffffffff;
  1296. }
  1297. return iprv.status;
  1298. }
  1299. /* Return info about implemented application and control registers. */
  1300. static inline s64
  1301. ia64_pal_register_info (u64 info_request, u64 *reg_info_1, u64 *reg_info_2)
  1302. {
  1303. struct ia64_pal_retval iprv;
  1304. PAL_CALL(iprv, PAL_REGISTER_INFO, info_request, 0, 0);
  1305. if (reg_info_1)
  1306. *reg_info_1 = iprv.v0;
  1307. if (reg_info_2)
  1308. *reg_info_2 = iprv.v1;
  1309. return iprv.status;
  1310. }
  1311. typedef union pal_hints_u {
  1312. u64 ph_data;
  1313. struct {
  1314. u64 si : 1,
  1315. li : 1,
  1316. reserved : 62;
  1317. } pal_hints_s;
  1318. } pal_hints_u_t;
  1319. /* Return information about the register stack and RSE for this processor
  1320. * implementation.
  1321. */
  1322. static inline s64
  1323. ia64_pal_rse_info (u64 *num_phys_stacked, pal_hints_u_t *hints)
  1324. {
  1325. struct ia64_pal_retval iprv;
  1326. PAL_CALL(iprv, PAL_RSE_INFO, 0, 0, 0);
  1327. if (num_phys_stacked)
  1328. *num_phys_stacked = iprv.v0;
  1329. if (hints)
  1330. hints->ph_data = iprv.v1;
  1331. return iprv.status;
  1332. }
  1333. /*
  1334. * Set the current hardware resource sharing policy of the processor
  1335. */
  1336. static inline s64
  1337. ia64_pal_set_hw_policy (u64 policy)
  1338. {
  1339. struct ia64_pal_retval iprv;
  1340. PAL_CALL(iprv, PAL_SET_HW_POLICY, policy, 0, 0);
  1341. return iprv.status;
  1342. }
  1343. /* Cause the processor to enter SHUTDOWN state, where prefetching and execution are
  1344. * suspended, but cause cache and TLB coherency to be maintained.
  1345. * This is usually called in IA-32 mode.
  1346. */
  1347. static inline s64
  1348. ia64_pal_shutdown (void)
  1349. {
  1350. struct ia64_pal_retval iprv;
  1351. PAL_CALL(iprv, PAL_SHUTDOWN, 0, 0, 0);
  1352. return iprv.status;
  1353. }
  1354. /* Perform the second phase of processor self-test. */
  1355. static inline s64
  1356. ia64_pal_test_proc (u64 test_addr, u64 test_size, u64 attributes, u64 *self_test_state)
  1357. {
  1358. struct ia64_pal_retval iprv;
  1359. PAL_CALL(iprv, PAL_TEST_PROC, test_addr, test_size, attributes);
  1360. if (self_test_state)
  1361. *self_test_state = iprv.v0;
  1362. return iprv.status;
  1363. }
  1364. typedef union pal_version_u {
  1365. u64 pal_version_val;
  1366. struct {
  1367. u64 pv_pal_b_rev : 8;
  1368. u64 pv_pal_b_model : 8;
  1369. u64 pv_reserved1 : 8;
  1370. u64 pv_pal_vendor : 8;
  1371. u64 pv_pal_a_rev : 8;
  1372. u64 pv_pal_a_model : 8;
  1373. u64 pv_reserved2 : 16;
  1374. } pal_version_s;
  1375. } pal_version_u_t;
  1376. /*
  1377. * Return PAL version information. While the documentation states that
  1378. * PAL_VERSION can be called in either physical or virtual mode, some
  1379. * implementations only allow physical calls. We don't call it very often,
  1380. * so the overhead isn't worth eliminating.
  1381. */
  1382. static inline s64
  1383. ia64_pal_version (pal_version_u_t *pal_min_version, pal_version_u_t *pal_cur_version)
  1384. {
  1385. struct ia64_pal_retval iprv;
  1386. PAL_CALL_PHYS(iprv, PAL_VERSION, 0, 0, 0);
  1387. if (pal_min_version)
  1388. pal_min_version->pal_version_val = iprv.v0;
  1389. if (pal_cur_version)
  1390. pal_cur_version->pal_version_val = iprv.v1;
  1391. return iprv.status;
  1392. }
  1393. typedef union pal_tc_info_u {
  1394. u64 pti_val;
  1395. struct {
  1396. u64 num_sets : 8,
  1397. associativity : 8,
  1398. num_entries : 16,
  1399. pf : 1,
  1400. unified : 1,
  1401. reduce_tr : 1,
  1402. reserved : 29;
  1403. } pal_tc_info_s;
  1404. } pal_tc_info_u_t;
  1405. #define tc_reduce_tr pal_tc_info_s.reduce_tr
  1406. #define tc_unified pal_tc_info_s.unified
  1407. #define tc_pf pal_tc_info_s.pf
  1408. #define tc_num_entries pal_tc_info_s.num_entries
  1409. #define tc_associativity pal_tc_info_s.associativity
  1410. #define tc_num_sets pal_tc_info_s.num_sets
  1411. /* Return information about the virtual memory characteristics of the processor
  1412. * implementation.
  1413. */
  1414. static inline s64
  1415. ia64_pal_vm_info (u64 tc_level, u64 tc_type, pal_tc_info_u_t *tc_info, u64 *tc_pages)
  1416. {
  1417. struct ia64_pal_retval iprv;
  1418. PAL_CALL(iprv, PAL_VM_INFO, tc_level, tc_type, 0);
  1419. if (tc_info)
  1420. tc_info->pti_val = iprv.v0;
  1421. if (tc_pages)
  1422. *tc_pages = iprv.v1;
  1423. return iprv.status;
  1424. }
  1425. /* Get page size information about the virtual memory characteristics of the processor
  1426. * implementation.
  1427. */
  1428. static inline s64
  1429. 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 infomation 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 */