pal.h 46 KB

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