pal.h 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826
  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 <davidm@hpl.hp.com>
  12. * Stephane Eranian <eranian@hpl.hp.com>
  13. * Copyright (C) 1999 VA Linux Systems
  14. * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
  15. * Copyright (C) 1999 Srinivasa Prasad Thirumalachar <sprasad@sprasad.engr.sgi.com>
  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. /*
  95. * Data types needed to pass information into PAL procedures and
  96. * interpret information returned by them.
  97. */
  98. /* Return status from the PAL procedure */
  99. typedef s64 pal_status_t;
  100. #define PAL_STATUS_SUCCESS 0 /* No error */
  101. #define PAL_STATUS_UNIMPLEMENTED (-1) /* Unimplemented procedure */
  102. #define PAL_STATUS_EINVAL (-2) /* Invalid argument */
  103. #define PAL_STATUS_ERROR (-3) /* Error */
  104. #define PAL_STATUS_CACHE_INIT_FAIL (-4) /* Could not initialize the
  105. * specified level and type of
  106. * cache without sideeffects
  107. * and "restrict" was 1
  108. */
  109. #define PAL_STATUS_REQUIRES_MEMORY (-9) /* Call requires PAL memory buffer */
  110. /* Processor cache level in the hierarchy */
  111. typedef u64 pal_cache_level_t;
  112. #define PAL_CACHE_LEVEL_L0 0 /* L0 */
  113. #define PAL_CACHE_LEVEL_L1 1 /* L1 */
  114. #define PAL_CACHE_LEVEL_L2 2 /* L2 */
  115. /* Processor cache type at a particular level in the hierarchy */
  116. typedef u64 pal_cache_type_t;
  117. #define PAL_CACHE_TYPE_INSTRUCTION 1 /* Instruction cache */
  118. #define PAL_CACHE_TYPE_DATA 2 /* Data or unified cache */
  119. #define PAL_CACHE_TYPE_INSTRUCTION_DATA 3 /* Both Data & Instruction */
  120. #define PAL_CACHE_FLUSH_INVALIDATE 1 /* Invalidate clean lines */
  121. #define PAL_CACHE_FLUSH_CHK_INTRS 2 /* check for interrupts/mc while flushing */
  122. /* Processor cache line size in bytes */
  123. typedef int pal_cache_line_size_t;
  124. /* Processor cache line state */
  125. typedef u64 pal_cache_line_state_t;
  126. #define PAL_CACHE_LINE_STATE_INVALID 0 /* Invalid */
  127. #define PAL_CACHE_LINE_STATE_SHARED 1 /* Shared */
  128. #define PAL_CACHE_LINE_STATE_EXCLUSIVE 2 /* Exclusive */
  129. #define PAL_CACHE_LINE_STATE_MODIFIED 3 /* Modified */
  130. typedef struct pal_freq_ratio {
  131. u32 den, num; /* numerator & denominator */
  132. } itc_ratio, proc_ratio;
  133. typedef union pal_cache_config_info_1_s {
  134. struct {
  135. u64 u : 1, /* 0 Unified cache ? */
  136. at : 2, /* 2-1 Cache mem attr*/
  137. reserved : 5, /* 7-3 Reserved */
  138. associativity : 8, /* 16-8 Associativity*/
  139. line_size : 8, /* 23-17 Line size */
  140. stride : 8, /* 31-24 Stride */
  141. store_latency : 8, /*39-32 Store latency*/
  142. load_latency : 8, /* 47-40 Load latency*/
  143. store_hints : 8, /* 55-48 Store hints*/
  144. load_hints : 8; /* 63-56 Load hints */
  145. } pcci1_bits;
  146. u64 pcci1_data;
  147. } pal_cache_config_info_1_t;
  148. typedef union pal_cache_config_info_2_s {
  149. struct {
  150. u32 cache_size; /*cache size in bytes*/
  151. u32 alias_boundary : 8, /* 39-32 aliased addr
  152. * separation for max
  153. * performance.
  154. */
  155. tag_ls_bit : 8, /* 47-40 LSb of addr*/
  156. tag_ms_bit : 8, /* 55-48 MSb of addr*/
  157. reserved : 8; /* 63-56 Reserved */
  158. } pcci2_bits;
  159. u64 pcci2_data;
  160. } pal_cache_config_info_2_t;
  161. typedef struct pal_cache_config_info_s {
  162. pal_status_t pcci_status;
  163. pal_cache_config_info_1_t pcci_info_1;
  164. pal_cache_config_info_2_t pcci_info_2;
  165. u64 pcci_reserved;
  166. } pal_cache_config_info_t;
  167. #define pcci_ld_hints pcci_info_1.pcci1_bits.load_hints
  168. #define pcci_st_hints pcci_info_1.pcci1_bits.store_hints
  169. #define pcci_ld_latency pcci_info_1.pcci1_bits.load_latency
  170. #define pcci_st_latency pcci_info_1.pcci1_bits.store_latency
  171. #define pcci_stride pcci_info_1.pcci1_bits.stride
  172. #define pcci_line_size pcci_info_1.pcci1_bits.line_size
  173. #define pcci_assoc pcci_info_1.pcci1_bits.associativity
  174. #define pcci_cache_attr pcci_info_1.pcci1_bits.at
  175. #define pcci_unified pcci_info_1.pcci1_bits.u
  176. #define pcci_tag_msb pcci_info_2.pcci2_bits.tag_ms_bit
  177. #define pcci_tag_lsb pcci_info_2.pcci2_bits.tag_ls_bit
  178. #define pcci_alias_boundary pcci_info_2.pcci2_bits.alias_boundary
  179. #define pcci_cache_size pcci_info_2.pcci2_bits.cache_size
  180. /* Possible values for cache attributes */
  181. #define PAL_CACHE_ATTR_WT 0 /* Write through cache */
  182. #define PAL_CACHE_ATTR_WB 1 /* Write back cache */
  183. #define PAL_CACHE_ATTR_WT_OR_WB 2 /* Either write thru or write
  184. * back depending on TLB
  185. * memory attributes
  186. */
  187. /* Possible values for cache hints */
  188. #define PAL_CACHE_HINT_TEMP_1 0 /* Temporal level 1 */
  189. #define PAL_CACHE_HINT_NTEMP_1 1 /* Non-temporal level 1 */
  190. #define PAL_CACHE_HINT_NTEMP_ALL 3 /* Non-temporal all levels */
  191. /* Processor cache protection information */
  192. typedef union pal_cache_protection_element_u {
  193. u32 pcpi_data;
  194. struct {
  195. u32 data_bits : 8, /* # data bits covered by
  196. * each unit of protection
  197. */
  198. tagprot_lsb : 6, /* Least -do- */
  199. tagprot_msb : 6, /* Most Sig. tag address
  200. * bit that this
  201. * protection covers.
  202. */
  203. prot_bits : 6, /* # of protection bits */
  204. method : 4, /* Protection method */
  205. t_d : 2; /* Indicates which part
  206. * of the cache this
  207. * protection encoding
  208. * applies.
  209. */
  210. } pcp_info;
  211. } pal_cache_protection_element_t;
  212. #define pcpi_cache_prot_part pcp_info.t_d
  213. #define pcpi_prot_method pcp_info.method
  214. #define pcpi_prot_bits pcp_info.prot_bits
  215. #define pcpi_tagprot_msb pcp_info.tagprot_msb
  216. #define pcpi_tagprot_lsb pcp_info.tagprot_lsb
  217. #define pcpi_data_bits pcp_info.data_bits
  218. /* Processor cache part encodings */
  219. #define PAL_CACHE_PROT_PART_DATA 0 /* Data protection */
  220. #define PAL_CACHE_PROT_PART_TAG 1 /* Tag protection */
  221. #define PAL_CACHE_PROT_PART_TAG_DATA 2 /* Tag+data protection (tag is
  222. * more significant )
  223. */
  224. #define PAL_CACHE_PROT_PART_DATA_TAG 3 /* Data+tag protection (data is
  225. * more significant )
  226. */
  227. #define PAL_CACHE_PROT_PART_MAX 6
  228. typedef struct pal_cache_protection_info_s {
  229. pal_status_t pcpi_status;
  230. pal_cache_protection_element_t pcp_info[PAL_CACHE_PROT_PART_MAX];
  231. } pal_cache_protection_info_t;
  232. /* Processor cache protection method encodings */
  233. #define PAL_CACHE_PROT_METHOD_NONE 0 /* No protection */
  234. #define PAL_CACHE_PROT_METHOD_ODD_PARITY 1 /* Odd parity */
  235. #define PAL_CACHE_PROT_METHOD_EVEN_PARITY 2 /* Even parity */
  236. #define PAL_CACHE_PROT_METHOD_ECC 3 /* ECC protection */
  237. /* Processor cache line identification in the hierarchy */
  238. typedef union pal_cache_line_id_u {
  239. u64 pclid_data;
  240. struct {
  241. u64 cache_type : 8, /* 7-0 cache type */
  242. level : 8, /* 15-8 level of the
  243. * cache in the
  244. * hierarchy.
  245. */
  246. way : 8, /* 23-16 way in the set
  247. */
  248. part : 8, /* 31-24 part of the
  249. * cache
  250. */
  251. reserved : 32; /* 63-32 is reserved*/
  252. } pclid_info_read;
  253. struct {
  254. u64 cache_type : 8, /* 7-0 cache type */
  255. level : 8, /* 15-8 level of the
  256. * cache in the
  257. * hierarchy.
  258. */
  259. way : 8, /* 23-16 way in the set
  260. */
  261. part : 8, /* 31-24 part of the
  262. * cache
  263. */
  264. mesi : 8, /* 39-32 cache line
  265. * state
  266. */
  267. start : 8, /* 47-40 lsb of data to
  268. * invert
  269. */
  270. length : 8, /* 55-48 #bits to
  271. * invert
  272. */
  273. trigger : 8; /* 63-56 Trigger error
  274. * by doing a load
  275. * after the write
  276. */
  277. } pclid_info_write;
  278. } pal_cache_line_id_u_t;
  279. #define pclid_read_part pclid_info_read.part
  280. #define pclid_read_way pclid_info_read.way
  281. #define pclid_read_level pclid_info_read.level
  282. #define pclid_read_cache_type pclid_info_read.cache_type
  283. #define pclid_write_trigger pclid_info_write.trigger
  284. #define pclid_write_length pclid_info_write.length
  285. #define pclid_write_start pclid_info_write.start
  286. #define pclid_write_mesi pclid_info_write.mesi
  287. #define pclid_write_part pclid_info_write.part
  288. #define pclid_write_way pclid_info_write.way
  289. #define pclid_write_level pclid_info_write.level
  290. #define pclid_write_cache_type pclid_info_write.cache_type
  291. /* Processor cache line part encodings */
  292. #define PAL_CACHE_LINE_ID_PART_DATA 0 /* Data */
  293. #define PAL_CACHE_LINE_ID_PART_TAG 1 /* Tag */
  294. #define PAL_CACHE_LINE_ID_PART_DATA_PROT 2 /* Data protection */
  295. #define PAL_CACHE_LINE_ID_PART_TAG_PROT 3 /* Tag protection */
  296. #define PAL_CACHE_LINE_ID_PART_DATA_TAG_PROT 4 /* Data+tag
  297. * protection
  298. */
  299. typedef struct pal_cache_line_info_s {
  300. pal_status_t pcli_status; /* Return status of the read cache line
  301. * info call.
  302. */
  303. u64 pcli_data; /* 64-bit data, tag, protection bits .. */
  304. u64 pcli_data_len; /* data length in bits */
  305. pal_cache_line_state_t pcli_cache_line_state; /* mesi state */
  306. } pal_cache_line_info_t;
  307. /* Machine Check related crap */
  308. /* Pending event status bits */
  309. typedef u64 pal_mc_pending_events_t;
  310. #define PAL_MC_PENDING_MCA (1 << 0)
  311. #define PAL_MC_PENDING_INIT (1 << 1)
  312. /* Error information type */
  313. typedef u64 pal_mc_info_index_t;
  314. #define PAL_MC_INFO_PROCESSOR 0 /* Processor */
  315. #define PAL_MC_INFO_CACHE_CHECK 1 /* Cache check */
  316. #define PAL_MC_INFO_TLB_CHECK 2 /* Tlb check */
  317. #define PAL_MC_INFO_BUS_CHECK 3 /* Bus check */
  318. #define PAL_MC_INFO_REQ_ADDR 4 /* Requestor address */
  319. #define PAL_MC_INFO_RESP_ADDR 5 /* Responder address */
  320. #define PAL_MC_INFO_TARGET_ADDR 6 /* Target address */
  321. #define PAL_MC_INFO_IMPL_DEP 7 /* Implementation
  322. * dependent
  323. */
  324. #define PAL_TLB_CHECK_OP_PURGE 8
  325. typedef struct pal_process_state_info_s {
  326. u64 reserved1 : 2,
  327. rz : 1, /* PAL_CHECK processor
  328. * rendezvous
  329. * successful.
  330. */
  331. ra : 1, /* PAL_CHECK attempted
  332. * a rendezvous.
  333. */
  334. me : 1, /* Distinct multiple
  335. * errors occurred
  336. */
  337. mn : 1, /* Min. state save
  338. * area has been
  339. * registered with PAL
  340. */
  341. sy : 1, /* Storage integrity
  342. * synched
  343. */
  344. co : 1, /* Continuable */
  345. ci : 1, /* MC isolated */
  346. us : 1, /* Uncontained storage
  347. * damage.
  348. */
  349. hd : 1, /* Non-essential hw
  350. * lost (no loss of
  351. * functionality)
  352. * causing the
  353. * processor to run in
  354. * degraded mode.
  355. */
  356. tl : 1, /* 1 => MC occurred
  357. * after an instr was
  358. * executed but before
  359. * the trap that
  360. * resulted from instr
  361. * execution was
  362. * generated.
  363. * (Trap Lost )
  364. */
  365. mi : 1, /* More information available
  366. * call PAL_MC_ERROR_INFO
  367. */
  368. pi : 1, /* Precise instruction pointer */
  369. pm : 1, /* Precise min-state save area */
  370. dy : 1, /* Processor dynamic
  371. * state valid
  372. */
  373. in : 1, /* 0 = MC, 1 = INIT */
  374. rs : 1, /* RSE valid */
  375. cm : 1, /* MC corrected */
  376. ex : 1, /* MC is expected */
  377. cr : 1, /* Control regs valid*/
  378. pc : 1, /* Perf cntrs valid */
  379. dr : 1, /* Debug regs valid */
  380. tr : 1, /* Translation regs
  381. * valid
  382. */
  383. rr : 1, /* Region regs valid */
  384. ar : 1, /* App regs valid */
  385. br : 1, /* Branch regs valid */
  386. pr : 1, /* Predicate registers
  387. * valid
  388. */
  389. fp : 1, /* fp registers valid*/
  390. b1 : 1, /* Preserved bank one
  391. * general registers
  392. * are valid
  393. */
  394. b0 : 1, /* Preserved bank zero
  395. * general registers
  396. * are valid
  397. */
  398. gr : 1, /* General registers
  399. * are valid
  400. * (excl. banked regs)
  401. */
  402. dsize : 16, /* size of dynamic
  403. * state returned
  404. * by the processor
  405. */
  406. se : 1, /* Shared error. MCA in a
  407. shared structure */
  408. reserved2 : 10,
  409. cc : 1, /* Cache check */
  410. tc : 1, /* TLB check */
  411. bc : 1, /* Bus check */
  412. rc : 1, /* Register file check */
  413. uc : 1; /* Uarch check */
  414. } pal_processor_state_info_t;
  415. typedef struct pal_cache_check_info_s {
  416. u64 op : 4, /* Type of cache
  417. * operation that
  418. * caused the machine
  419. * check.
  420. */
  421. level : 2, /* Cache level */
  422. reserved1 : 2,
  423. dl : 1, /* Failure in data part
  424. * of cache line
  425. */
  426. tl : 1, /* Failure in tag part
  427. * of cache line
  428. */
  429. dc : 1, /* Failure in dcache */
  430. ic : 1, /* Failure in icache */
  431. mesi : 3, /* Cache line state */
  432. mv : 1, /* mesi valid */
  433. way : 5, /* Way in which the
  434. * error occurred
  435. */
  436. wiv : 1, /* Way field valid */
  437. reserved2 : 1,
  438. dp : 1, /* Data poisoned on MBE */
  439. reserved3 : 6,
  440. hlth : 2, /* Health indicator */
  441. index : 20, /* Cache line index */
  442. reserved4 : 2,
  443. is : 1, /* instruction set (1 == ia32) */
  444. iv : 1, /* instruction set field valid */
  445. pl : 2, /* privilege level */
  446. pv : 1, /* privilege level field valid */
  447. mcc : 1, /* Machine check corrected */
  448. tv : 1, /* Target address
  449. * structure is valid
  450. */
  451. rq : 1, /* Requester identifier
  452. * structure is valid
  453. */
  454. rp : 1, /* Responder identifier
  455. * structure is valid
  456. */
  457. pi : 1; /* Precise instruction pointer
  458. * structure is valid
  459. */
  460. } pal_cache_check_info_t;
  461. typedef struct pal_tlb_check_info_s {
  462. u64 tr_slot : 8, /* Slot# of TR where
  463. * error occurred
  464. */
  465. trv : 1, /* tr_slot field is valid */
  466. reserved1 : 1,
  467. level : 2, /* TLB level where failure occurred */
  468. reserved2 : 4,
  469. dtr : 1, /* Fail in data TR */
  470. itr : 1, /* Fail in inst TR */
  471. dtc : 1, /* Fail in data TC */
  472. itc : 1, /* Fail in inst. TC */
  473. op : 4, /* Cache operation */
  474. reserved3 : 6,
  475. hlth : 2, /* Health indicator */
  476. reserved4 : 22,
  477. is : 1, /* instruction set (1 == ia32) */
  478. iv : 1, /* instruction set field valid */
  479. pl : 2, /* privilege level */
  480. pv : 1, /* privilege level field valid */
  481. mcc : 1, /* Machine check corrected */
  482. tv : 1, /* Target address
  483. * structure is valid
  484. */
  485. rq : 1, /* Requester identifier
  486. * structure is valid
  487. */
  488. rp : 1, /* Responder identifier
  489. * structure is valid
  490. */
  491. pi : 1; /* Precise instruction pointer
  492. * structure is valid
  493. */
  494. } pal_tlb_check_info_t;
  495. typedef struct pal_bus_check_info_s {
  496. u64 size : 5, /* Xaction size */
  497. ib : 1, /* Internal bus error */
  498. eb : 1, /* External bus error */
  499. cc : 1, /* Error occurred
  500. * during cache-cache
  501. * transfer.
  502. */
  503. type : 8, /* Bus xaction type*/
  504. sev : 5, /* Bus error severity*/
  505. hier : 2, /* Bus hierarchy level */
  506. dp : 1, /* Data poisoned on MBE */
  507. bsi : 8, /* Bus error status
  508. * info
  509. */
  510. reserved2 : 22,
  511. is : 1, /* instruction set (1 == ia32) */
  512. iv : 1, /* instruction set field valid */
  513. pl : 2, /* privilege level */
  514. pv : 1, /* privilege level field valid */
  515. mcc : 1, /* Machine check corrected */
  516. tv : 1, /* Target address
  517. * structure is valid
  518. */
  519. rq : 1, /* Requester identifier
  520. * structure is valid
  521. */
  522. rp : 1, /* Responder identifier
  523. * structure is valid
  524. */
  525. pi : 1; /* Precise instruction pointer
  526. * structure is valid
  527. */
  528. } pal_bus_check_info_t;
  529. typedef struct pal_reg_file_check_info_s {
  530. u64 id : 4, /* Register file identifier */
  531. op : 4, /* Type of register
  532. * operation that
  533. * caused the machine
  534. * check.
  535. */
  536. reg_num : 7, /* Register number */
  537. rnv : 1, /* reg_num valid */
  538. reserved2 : 38,
  539. is : 1, /* instruction set (1 == ia32) */
  540. iv : 1, /* instruction set field valid */
  541. pl : 2, /* privilege level */
  542. pv : 1, /* privilege level field valid */
  543. mcc : 1, /* Machine check corrected */
  544. reserved3 : 3,
  545. pi : 1; /* Precise instruction pointer
  546. * structure is valid
  547. */
  548. } pal_reg_file_check_info_t;
  549. typedef struct pal_uarch_check_info_s {
  550. u64 sid : 5, /* Structure identification */
  551. level : 3, /* Level of failure */
  552. array_id : 4, /* Array identification */
  553. op : 4, /* Type of
  554. * operation that
  555. * caused the machine
  556. * check.
  557. */
  558. way : 6, /* Way of structure */
  559. wv : 1, /* way valid */
  560. xv : 1, /* index valid */
  561. reserved1 : 6,
  562. hlth : 2, /* Health indicator */
  563. index : 8, /* Index or set of the uarch
  564. * structure that failed.
  565. */
  566. reserved2 : 24,
  567. is : 1, /* instruction set (1 == ia32) */
  568. iv : 1, /* instruction set field valid */
  569. pl : 2, /* privilege level */
  570. pv : 1, /* privilege level field valid */
  571. mcc : 1, /* Machine check corrected */
  572. tv : 1, /* Target address
  573. * structure is valid
  574. */
  575. rq : 1, /* Requester identifier
  576. * structure is valid
  577. */
  578. rp : 1, /* Responder identifier
  579. * structure is valid
  580. */
  581. pi : 1; /* Precise instruction pointer
  582. * structure is valid
  583. */
  584. } pal_uarch_check_info_t;
  585. typedef union pal_mc_error_info_u {
  586. u64 pmei_data;
  587. pal_processor_state_info_t pme_processor;
  588. pal_cache_check_info_t pme_cache;
  589. pal_tlb_check_info_t pme_tlb;
  590. pal_bus_check_info_t pme_bus;
  591. pal_reg_file_check_info_t pme_reg_file;
  592. pal_uarch_check_info_t pme_uarch;
  593. } pal_mc_error_info_t;
  594. #define pmci_proc_unknown_check pme_processor.uc
  595. #define pmci_proc_bus_check pme_processor.bc
  596. #define pmci_proc_tlb_check pme_processor.tc
  597. #define pmci_proc_cache_check pme_processor.cc
  598. #define pmci_proc_dynamic_state_size pme_processor.dsize
  599. #define pmci_proc_gpr_valid pme_processor.gr
  600. #define pmci_proc_preserved_bank0_gpr_valid pme_processor.b0
  601. #define pmci_proc_preserved_bank1_gpr_valid pme_processor.b1
  602. #define pmci_proc_fp_valid pme_processor.fp
  603. #define pmci_proc_predicate_regs_valid pme_processor.pr
  604. #define pmci_proc_branch_regs_valid pme_processor.br
  605. #define pmci_proc_app_regs_valid pme_processor.ar
  606. #define pmci_proc_region_regs_valid pme_processor.rr
  607. #define pmci_proc_translation_regs_valid pme_processor.tr
  608. #define pmci_proc_debug_regs_valid pme_processor.dr
  609. #define pmci_proc_perf_counters_valid pme_processor.pc
  610. #define pmci_proc_control_regs_valid pme_processor.cr
  611. #define pmci_proc_machine_check_expected pme_processor.ex
  612. #define pmci_proc_machine_check_corrected pme_processor.cm
  613. #define pmci_proc_rse_valid pme_processor.rs
  614. #define pmci_proc_machine_check_or_init pme_processor.in
  615. #define pmci_proc_dynamic_state_valid pme_processor.dy
  616. #define pmci_proc_operation pme_processor.op
  617. #define pmci_proc_trap_lost pme_processor.tl
  618. #define pmci_proc_hardware_damage pme_processor.hd
  619. #define pmci_proc_uncontained_storage_damage pme_processor.us
  620. #define pmci_proc_machine_check_isolated pme_processor.ci
  621. #define pmci_proc_continuable pme_processor.co
  622. #define pmci_proc_storage_intergrity_synced pme_processor.sy
  623. #define pmci_proc_min_state_save_area_regd pme_processor.mn
  624. #define pmci_proc_distinct_multiple_errors pme_processor.me
  625. #define pmci_proc_pal_attempted_rendezvous pme_processor.ra
  626. #define pmci_proc_pal_rendezvous_complete pme_processor.rz
  627. #define pmci_cache_level pme_cache.level
  628. #define pmci_cache_line_state pme_cache.mesi
  629. #define pmci_cache_line_state_valid pme_cache.mv
  630. #define pmci_cache_line_index pme_cache.index
  631. #define pmci_cache_instr_cache_fail pme_cache.ic
  632. #define pmci_cache_data_cache_fail pme_cache.dc
  633. #define pmci_cache_line_tag_fail pme_cache.tl
  634. #define pmci_cache_line_data_fail pme_cache.dl
  635. #define pmci_cache_operation pme_cache.op
  636. #define pmci_cache_way_valid pme_cache.wv
  637. #define pmci_cache_target_address_valid pme_cache.tv
  638. #define pmci_cache_way pme_cache.way
  639. #define pmci_cache_mc pme_cache.mc
  640. #define pmci_tlb_instr_translation_cache_fail pme_tlb.itc
  641. #define pmci_tlb_data_translation_cache_fail pme_tlb.dtc
  642. #define pmci_tlb_instr_translation_reg_fail pme_tlb.itr
  643. #define pmci_tlb_data_translation_reg_fail pme_tlb.dtr
  644. #define pmci_tlb_translation_reg_slot pme_tlb.tr_slot
  645. #define pmci_tlb_mc pme_tlb.mc
  646. #define pmci_bus_status_info pme_bus.bsi
  647. #define pmci_bus_req_address_valid pme_bus.rq
  648. #define pmci_bus_resp_address_valid pme_bus.rp
  649. #define pmci_bus_target_address_valid pme_bus.tv
  650. #define pmci_bus_error_severity pme_bus.sev
  651. #define pmci_bus_transaction_type pme_bus.type
  652. #define pmci_bus_cache_cache_transfer pme_bus.cc
  653. #define pmci_bus_transaction_size pme_bus.size
  654. #define pmci_bus_internal_error pme_bus.ib
  655. #define pmci_bus_external_error pme_bus.eb
  656. #define pmci_bus_mc pme_bus.mc
  657. /*
  658. * NOTE: this min_state_save area struct only includes the 1KB
  659. * architectural state save area. The other 3 KB is scratch space
  660. * for PAL.
  661. */
  662. typedef struct pal_min_state_area_s {
  663. u64 pmsa_nat_bits; /* nat bits for saved GRs */
  664. u64 pmsa_gr[15]; /* GR1 - GR15 */
  665. u64 pmsa_bank0_gr[16]; /* GR16 - GR31 */
  666. u64 pmsa_bank1_gr[16]; /* GR16 - GR31 */
  667. u64 pmsa_pr; /* predicate registers */
  668. u64 pmsa_br0; /* branch register 0 */
  669. u64 pmsa_rsc; /* ar.rsc */
  670. u64 pmsa_iip; /* cr.iip */
  671. u64 pmsa_ipsr; /* cr.ipsr */
  672. u64 pmsa_ifs; /* cr.ifs */
  673. u64 pmsa_xip; /* previous iip */
  674. u64 pmsa_xpsr; /* previous psr */
  675. u64 pmsa_xfs; /* previous ifs */
  676. u64 pmsa_br1; /* branch register 1 */
  677. u64 pmsa_reserved[70]; /* pal_min_state_area should total to 1KB */
  678. } pal_min_state_area_t;
  679. struct ia64_pal_retval {
  680. /*
  681. * A zero status value indicates call completed without error.
  682. * A negative status value indicates reason of call failure.
  683. * A positive status value indicates success but an
  684. * informational value should be printed (e.g., "reboot for
  685. * change to take effect").
  686. */
  687. s64 status;
  688. u64 v0;
  689. u64 v1;
  690. u64 v2;
  691. };
  692. /*
  693. * Note: Currently unused PAL arguments are generally labeled
  694. * "reserved" so the value specified in the PAL documentation
  695. * (generally 0) MUST be passed. Reserved parameters are not optional
  696. * parameters.
  697. */
  698. extern struct ia64_pal_retval ia64_pal_call_static (u64, u64, u64, u64);
  699. extern struct ia64_pal_retval ia64_pal_call_stacked (u64, u64, u64, u64);
  700. extern struct ia64_pal_retval ia64_pal_call_phys_static (u64, u64, u64, u64);
  701. extern struct ia64_pal_retval ia64_pal_call_phys_stacked (u64, u64, u64, u64);
  702. extern void ia64_save_scratch_fpregs (struct ia64_fpreg *);
  703. extern void ia64_load_scratch_fpregs (struct ia64_fpreg *);
  704. #define PAL_CALL(iprv,a0,a1,a2,a3) do { \
  705. struct ia64_fpreg fr[6]; \
  706. ia64_save_scratch_fpregs(fr); \
  707. iprv = ia64_pal_call_static(a0, a1, a2, a3); \
  708. ia64_load_scratch_fpregs(fr); \
  709. } while (0)
  710. #define PAL_CALL_STK(iprv,a0,a1,a2,a3) do { \
  711. struct ia64_fpreg fr[6]; \
  712. ia64_save_scratch_fpregs(fr); \
  713. iprv = ia64_pal_call_stacked(a0, a1, a2, a3); \
  714. ia64_load_scratch_fpregs(fr); \
  715. } while (0)
  716. #define PAL_CALL_PHYS(iprv,a0,a1,a2,a3) do { \
  717. struct ia64_fpreg fr[6]; \
  718. ia64_save_scratch_fpregs(fr); \
  719. iprv = ia64_pal_call_phys_static(a0, a1, a2, a3); \
  720. ia64_load_scratch_fpregs(fr); \
  721. } while (0)
  722. #define PAL_CALL_PHYS_STK(iprv,a0,a1,a2,a3) do { \
  723. struct ia64_fpreg fr[6]; \
  724. ia64_save_scratch_fpregs(fr); \
  725. iprv = ia64_pal_call_phys_stacked(a0, a1, a2, a3); \
  726. ia64_load_scratch_fpregs(fr); \
  727. } while (0)
  728. typedef int (*ia64_pal_handler) (u64, ...);
  729. extern ia64_pal_handler ia64_pal;
  730. extern void ia64_pal_handler_init (void *);
  731. extern ia64_pal_handler ia64_pal;
  732. extern pal_cache_config_info_t l0d_cache_config_info;
  733. extern pal_cache_config_info_t l0i_cache_config_info;
  734. extern pal_cache_config_info_t l1_cache_config_info;
  735. extern pal_cache_config_info_t l2_cache_config_info;
  736. extern pal_cache_protection_info_t l0d_cache_protection_info;
  737. extern pal_cache_protection_info_t l0i_cache_protection_info;
  738. extern pal_cache_protection_info_t l1_cache_protection_info;
  739. extern pal_cache_protection_info_t l2_cache_protection_info;
  740. extern pal_cache_config_info_t pal_cache_config_info_get(pal_cache_level_t,
  741. pal_cache_type_t);
  742. extern pal_cache_protection_info_t pal_cache_protection_info_get(pal_cache_level_t,
  743. pal_cache_type_t);
  744. extern void pal_error(int);
  745. /* Useful wrappers for the current list of pal procedures */
  746. typedef union pal_bus_features_u {
  747. u64 pal_bus_features_val;
  748. struct {
  749. u64 pbf_reserved1 : 29;
  750. u64 pbf_req_bus_parking : 1;
  751. u64 pbf_bus_lock_mask : 1;
  752. u64 pbf_enable_half_xfer_rate : 1;
  753. u64 pbf_reserved2 : 20;
  754. u64 pbf_enable_shared_line_replace : 1;
  755. u64 pbf_enable_exclusive_line_replace : 1;
  756. u64 pbf_disable_xaction_queueing : 1;
  757. u64 pbf_disable_resp_err_check : 1;
  758. u64 pbf_disable_berr_check : 1;
  759. u64 pbf_disable_bus_req_internal_err_signal : 1;
  760. u64 pbf_disable_bus_req_berr_signal : 1;
  761. u64 pbf_disable_bus_init_event_check : 1;
  762. u64 pbf_disable_bus_init_event_signal : 1;
  763. u64 pbf_disable_bus_addr_err_check : 1;
  764. u64 pbf_disable_bus_addr_err_signal : 1;
  765. u64 pbf_disable_bus_data_err_check : 1;
  766. } pal_bus_features_s;
  767. } pal_bus_features_u_t;
  768. extern void pal_bus_features_print (u64);
  769. /* Provide information about configurable processor bus features */
  770. static inline s64
  771. ia64_pal_bus_get_features (pal_bus_features_u_t *features_avail,
  772. pal_bus_features_u_t *features_status,
  773. pal_bus_features_u_t *features_control)
  774. {
  775. struct ia64_pal_retval iprv;
  776. PAL_CALL_PHYS(iprv, PAL_BUS_GET_FEATURES, 0, 0, 0);
  777. if (features_avail)
  778. features_avail->pal_bus_features_val = iprv.v0;
  779. if (features_status)
  780. features_status->pal_bus_features_val = iprv.v1;
  781. if (features_control)
  782. features_control->pal_bus_features_val = iprv.v2;
  783. return iprv.status;
  784. }
  785. /* Enables/disables specific processor bus features */
  786. static inline s64
  787. ia64_pal_bus_set_features (pal_bus_features_u_t feature_select)
  788. {
  789. struct ia64_pal_retval iprv;
  790. PAL_CALL_PHYS(iprv, PAL_BUS_SET_FEATURES, feature_select.pal_bus_features_val, 0, 0);
  791. return iprv.status;
  792. }
  793. /* Get detailed cache information */
  794. static inline s64
  795. ia64_pal_cache_config_info (u64 cache_level, u64 cache_type, pal_cache_config_info_t *conf)
  796. {
  797. struct ia64_pal_retval iprv;
  798. PAL_CALL(iprv, PAL_CACHE_INFO, cache_level, cache_type, 0);
  799. if (iprv.status == 0) {
  800. conf->pcci_status = iprv.status;
  801. conf->pcci_info_1.pcci1_data = iprv.v0;
  802. conf->pcci_info_2.pcci2_data = iprv.v1;
  803. conf->pcci_reserved = iprv.v2;
  804. }
  805. return iprv.status;
  806. }
  807. /* Get detailed cche protection information */
  808. static inline s64
  809. ia64_pal_cache_prot_info (u64 cache_level, u64 cache_type, pal_cache_protection_info_t *prot)
  810. {
  811. struct ia64_pal_retval iprv;
  812. PAL_CALL(iprv, PAL_CACHE_PROT_INFO, cache_level, cache_type, 0);
  813. if (iprv.status == 0) {
  814. prot->pcpi_status = iprv.status;
  815. prot->pcp_info[0].pcpi_data = iprv.v0 & 0xffffffff;
  816. prot->pcp_info[1].pcpi_data = iprv.v0 >> 32;
  817. prot->pcp_info[2].pcpi_data = iprv.v1 & 0xffffffff;
  818. prot->pcp_info[3].pcpi_data = iprv.v1 >> 32;
  819. prot->pcp_info[4].pcpi_data = iprv.v2 & 0xffffffff;
  820. prot->pcp_info[5].pcpi_data = iprv.v2 >> 32;
  821. }
  822. return iprv.status;
  823. }
  824. /*
  825. * Flush the processor instruction or data caches. *PROGRESS must be
  826. * initialized to zero before calling this for the first time..
  827. */
  828. static inline s64
  829. ia64_pal_cache_flush (u64 cache_type, u64 invalidate, u64 *progress, u64 *vector)
  830. {
  831. struct ia64_pal_retval iprv;
  832. PAL_CALL(iprv, PAL_CACHE_FLUSH, cache_type, invalidate, *progress);
  833. if (vector)
  834. *vector = iprv.v0;
  835. *progress = iprv.v1;
  836. return iprv.status;
  837. }
  838. /* Initialize the processor controlled caches */
  839. static inline s64
  840. ia64_pal_cache_init (u64 level, u64 cache_type, u64 rest)
  841. {
  842. struct ia64_pal_retval iprv;
  843. PAL_CALL(iprv, PAL_CACHE_INIT, level, cache_type, rest);
  844. return iprv.status;
  845. }
  846. /* Initialize the tags and data of a data or unified cache line of
  847. * processor controlled cache to known values without the availability
  848. * of backing memory.
  849. */
  850. static inline s64
  851. ia64_pal_cache_line_init (u64 physical_addr, u64 data_value)
  852. {
  853. struct ia64_pal_retval iprv;
  854. PAL_CALL(iprv, PAL_CACHE_LINE_INIT, physical_addr, data_value, 0);
  855. return iprv.status;
  856. }
  857. /* Read the data and tag of a processor controlled cache line for diags */
  858. static inline s64
  859. ia64_pal_cache_read (pal_cache_line_id_u_t line_id, u64 physical_addr)
  860. {
  861. struct ia64_pal_retval iprv;
  862. PAL_CALL_PHYS_STK(iprv, PAL_CACHE_READ, line_id.pclid_data,
  863. physical_addr, 0);
  864. return iprv.status;
  865. }
  866. /* Return summary information about the hierarchy of caches controlled by the processor */
  867. static inline long ia64_pal_cache_summary(unsigned long *cache_levels,
  868. unsigned long *unique_caches)
  869. {
  870. struct ia64_pal_retval iprv;
  871. PAL_CALL(iprv, PAL_CACHE_SUMMARY, 0, 0, 0);
  872. if (cache_levels)
  873. *cache_levels = iprv.v0;
  874. if (unique_caches)
  875. *unique_caches = iprv.v1;
  876. return iprv.status;
  877. }
  878. /* Write the data and tag of a processor-controlled cache line for diags */
  879. static inline s64
  880. ia64_pal_cache_write (pal_cache_line_id_u_t line_id, u64 physical_addr, u64 data)
  881. {
  882. struct ia64_pal_retval iprv;
  883. PAL_CALL_PHYS_STK(iprv, PAL_CACHE_WRITE, line_id.pclid_data,
  884. physical_addr, data);
  885. return iprv.status;
  886. }
  887. /* Return the parameters needed to copy relocatable PAL procedures from ROM to memory */
  888. static inline s64
  889. ia64_pal_copy_info (u64 copy_type, u64 num_procs, u64 num_iopics,
  890. u64 *buffer_size, u64 *buffer_align)
  891. {
  892. struct ia64_pal_retval iprv;
  893. PAL_CALL(iprv, PAL_COPY_INFO, copy_type, num_procs, num_iopics);
  894. if (buffer_size)
  895. *buffer_size = iprv.v0;
  896. if (buffer_align)
  897. *buffer_align = iprv.v1;
  898. return iprv.status;
  899. }
  900. /* Copy relocatable PAL procedures from ROM to memory */
  901. static inline s64
  902. ia64_pal_copy_pal (u64 target_addr, u64 alloc_size, u64 processor, u64 *pal_proc_offset)
  903. {
  904. struct ia64_pal_retval iprv;
  905. PAL_CALL(iprv, PAL_COPY_PAL, target_addr, alloc_size, processor);
  906. if (pal_proc_offset)
  907. *pal_proc_offset = iprv.v0;
  908. return iprv.status;
  909. }
  910. /* Return the number of instruction and data debug register pairs */
  911. static inline long ia64_pal_debug_info(unsigned long *inst_regs,
  912. unsigned long *data_regs)
  913. {
  914. struct ia64_pal_retval iprv;
  915. PAL_CALL(iprv, PAL_DEBUG_INFO, 0, 0, 0);
  916. if (inst_regs)
  917. *inst_regs = iprv.v0;
  918. if (data_regs)
  919. *data_regs = iprv.v1;
  920. return iprv.status;
  921. }
  922. #ifdef TBD
  923. /* Switch from IA64-system environment to IA-32 system environment */
  924. static inline s64
  925. ia64_pal_enter_ia32_env (ia32_env1, ia32_env2, ia32_env3)
  926. {
  927. struct ia64_pal_retval iprv;
  928. PAL_CALL(iprv, PAL_ENTER_IA_32_ENV, ia32_env1, ia32_env2, ia32_env3);
  929. return iprv.status;
  930. }
  931. #endif
  932. /* Get unique geographical address of this processor on its bus */
  933. static inline s64
  934. ia64_pal_fixed_addr (u64 *global_unique_addr)
  935. {
  936. struct ia64_pal_retval iprv;
  937. PAL_CALL(iprv, PAL_FIXED_ADDR, 0, 0, 0);
  938. if (global_unique_addr)
  939. *global_unique_addr = iprv.v0;
  940. return iprv.status;
  941. }
  942. /* Get base frequency of the platform if generated by the processor */
  943. static inline long ia64_pal_freq_base(unsigned long *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. unsigned long 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. unsigned long ph_data;
  1313. struct {
  1314. unsigned long 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 long ia64_pal_rse_info(unsigned long *num_phys_stacked,
  1323. 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 ia64_pal_vm_page_size(u64 *tr_pages, u64 *vw_pages)
  1429. {
  1430. struct ia64_pal_retval iprv;
  1431. PAL_CALL(iprv, PAL_VM_PAGE_SIZE, 0, 0, 0);
  1432. if (tr_pages)
  1433. *tr_pages = iprv.v0;
  1434. if (vw_pages)
  1435. *vw_pages = iprv.v1;
  1436. return iprv.status;
  1437. }
  1438. typedef union pal_vm_info_1_u {
  1439. u64 pvi1_val;
  1440. struct {
  1441. u64 vw : 1,
  1442. phys_add_size : 7,
  1443. key_size : 8,
  1444. max_pkr : 8,
  1445. hash_tag_id : 8,
  1446. max_dtr_entry : 8,
  1447. max_itr_entry : 8,
  1448. max_unique_tcs : 8,
  1449. num_tc_levels : 8;
  1450. } pal_vm_info_1_s;
  1451. } pal_vm_info_1_u_t;
  1452. #define PAL_MAX_PURGES 0xFFFF /* all ones is means unlimited */
  1453. typedef union pal_vm_info_2_u {
  1454. u64 pvi2_val;
  1455. struct {
  1456. u64 impl_va_msb : 8,
  1457. rid_size : 8,
  1458. max_purges : 16,
  1459. reserved : 32;
  1460. } pal_vm_info_2_s;
  1461. } pal_vm_info_2_u_t;
  1462. /* Get summary information about the virtual memory characteristics of the processor
  1463. * implementation.
  1464. */
  1465. static inline s64
  1466. ia64_pal_vm_summary (pal_vm_info_1_u_t *vm_info_1, pal_vm_info_2_u_t *vm_info_2)
  1467. {
  1468. struct ia64_pal_retval iprv;
  1469. PAL_CALL(iprv, PAL_VM_SUMMARY, 0, 0, 0);
  1470. if (vm_info_1)
  1471. vm_info_1->pvi1_val = iprv.v0;
  1472. if (vm_info_2)
  1473. vm_info_2->pvi2_val = iprv.v1;
  1474. return iprv.status;
  1475. }
  1476. typedef union pal_vp_info_u {
  1477. u64 pvi_val;
  1478. struct {
  1479. u64 index: 48, /* virtual feature set info */
  1480. vmm_id: 16; /* feature set id */
  1481. } pal_vp_info_s;
  1482. } pal_vp_info_u_t;
  1483. /*
  1484. * Returns information about virtual processor features
  1485. */
  1486. static inline s64
  1487. ia64_pal_vp_info (u64 feature_set, u64 vp_buffer, u64 *vp_info, u64 *vmm_id)
  1488. {
  1489. struct ia64_pal_retval iprv;
  1490. PAL_CALL(iprv, PAL_VP_INFO, feature_set, vp_buffer, 0);
  1491. if (vp_info)
  1492. *vp_info = iprv.v0;
  1493. if (vmm_id)
  1494. *vmm_id = iprv.v1;
  1495. return iprv.status;
  1496. }
  1497. typedef union pal_itr_valid_u {
  1498. u64 piv_val;
  1499. struct {
  1500. u64 access_rights_valid : 1,
  1501. priv_level_valid : 1,
  1502. dirty_bit_valid : 1,
  1503. mem_attr_valid : 1,
  1504. reserved : 60;
  1505. } pal_tr_valid_s;
  1506. } pal_tr_valid_u_t;
  1507. /* Read a translation register */
  1508. static inline s64
  1509. ia64_pal_tr_read (u64 reg_num, u64 tr_type, u64 *tr_buffer, pal_tr_valid_u_t *tr_valid)
  1510. {
  1511. struct ia64_pal_retval iprv;
  1512. PAL_CALL_PHYS_STK(iprv, PAL_VM_TR_READ, reg_num, tr_type,(u64)ia64_tpa(tr_buffer));
  1513. if (tr_valid)
  1514. tr_valid->piv_val = iprv.v0;
  1515. return iprv.status;
  1516. }
  1517. /*
  1518. * PAL_PREFETCH_VISIBILITY transaction types
  1519. */
  1520. #define PAL_VISIBILITY_VIRTUAL 0
  1521. #define PAL_VISIBILITY_PHYSICAL 1
  1522. /*
  1523. * PAL_PREFETCH_VISIBILITY return codes
  1524. */
  1525. #define PAL_VISIBILITY_OK 1
  1526. #define PAL_VISIBILITY_OK_REMOTE_NEEDED 0
  1527. #define PAL_VISIBILITY_INVAL_ARG -2
  1528. #define PAL_VISIBILITY_ERROR -3
  1529. static inline s64
  1530. ia64_pal_prefetch_visibility (s64 trans_type)
  1531. {
  1532. struct ia64_pal_retval iprv;
  1533. PAL_CALL(iprv, PAL_PREFETCH_VISIBILITY, trans_type, 0, 0);
  1534. return iprv.status;
  1535. }
  1536. /* data structure for getting information on logical to physical mappings */
  1537. typedef union pal_log_overview_u {
  1538. struct {
  1539. u64 num_log :16, /* Total number of logical
  1540. * processors on this die
  1541. */
  1542. tpc :8, /* Threads per core */
  1543. reserved3 :8, /* Reserved */
  1544. cpp :8, /* Cores per processor */
  1545. reserved2 :8, /* Reserved */
  1546. ppid :8, /* Physical processor ID */
  1547. reserved1 :8; /* Reserved */
  1548. } overview_bits;
  1549. u64 overview_data;
  1550. } pal_log_overview_t;
  1551. typedef union pal_proc_n_log_info1_u{
  1552. struct {
  1553. u64 tid :16, /* Thread id */
  1554. reserved2 :16, /* Reserved */
  1555. cid :16, /* Core id */
  1556. reserved1 :16; /* Reserved */
  1557. } ppli1_bits;
  1558. u64 ppli1_data;
  1559. } pal_proc_n_log_info1_t;
  1560. typedef union pal_proc_n_log_info2_u {
  1561. struct {
  1562. u64 la :16, /* Logical address */
  1563. reserved :48; /* Reserved */
  1564. } ppli2_bits;
  1565. u64 ppli2_data;
  1566. } pal_proc_n_log_info2_t;
  1567. typedef struct pal_logical_to_physical_s
  1568. {
  1569. pal_log_overview_t overview;
  1570. pal_proc_n_log_info1_t ppli1;
  1571. pal_proc_n_log_info2_t ppli2;
  1572. } pal_logical_to_physical_t;
  1573. #define overview_num_log overview.overview_bits.num_log
  1574. #define overview_tpc overview.overview_bits.tpc
  1575. #define overview_cpp overview.overview_bits.cpp
  1576. #define overview_ppid overview.overview_bits.ppid
  1577. #define log1_tid ppli1.ppli1_bits.tid
  1578. #define log1_cid ppli1.ppli1_bits.cid
  1579. #define log2_la ppli2.ppli2_bits.la
  1580. /* Get information on logical to physical processor mappings. */
  1581. static inline s64
  1582. ia64_pal_logical_to_phys(u64 proc_number, pal_logical_to_physical_t *mapping)
  1583. {
  1584. struct ia64_pal_retval iprv;
  1585. PAL_CALL(iprv, PAL_LOGICAL_TO_PHYSICAL, proc_number, 0, 0);
  1586. if (iprv.status == PAL_STATUS_SUCCESS)
  1587. {
  1588. mapping->overview.overview_data = iprv.v0;
  1589. mapping->ppli1.ppli1_data = iprv.v1;
  1590. mapping->ppli2.ppli2_data = iprv.v2;
  1591. }
  1592. return iprv.status;
  1593. }
  1594. typedef struct pal_cache_shared_info_s
  1595. {
  1596. u64 num_shared;
  1597. pal_proc_n_log_info1_t ppli1;
  1598. pal_proc_n_log_info2_t ppli2;
  1599. } pal_cache_shared_info_t;
  1600. /* Get information on logical to physical processor mappings. */
  1601. static inline s64
  1602. ia64_pal_cache_shared_info(u64 level,
  1603. u64 type,
  1604. u64 proc_number,
  1605. pal_cache_shared_info_t *info)
  1606. {
  1607. struct ia64_pal_retval iprv;
  1608. PAL_CALL(iprv, PAL_CACHE_SHARED_INFO, level, type, proc_number);
  1609. if (iprv.status == PAL_STATUS_SUCCESS) {
  1610. info->num_shared = iprv.v0;
  1611. info->ppli1.ppli1_data = iprv.v1;
  1612. info->ppli2.ppli2_data = iprv.v2;
  1613. }
  1614. return iprv.status;
  1615. }
  1616. #endif /* __ASSEMBLY__ */
  1617. #endif /* _ASM_IA64_PAL_H */