]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/Ipf/ReadCr.s
1. Simplify the implementation of AsmReadApplicationRegister() & AsmReadControlRegist...
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ipf / ReadCr.s
index 839ea6fb34613a829d9321f6b8edf4fb3bdeeb97..fe5d80dcbdc69d778552793b8a6c12c763ec7f28 100644 (file)
 ///\r
 \r
 \r
-.text\r
-.type   AsmReadControlRegisterDcr, @function\r
-.proc   AsmReadControlRegisterDcr\r
-//\r
-// Reads control register DCR.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_DCR\r
-//\r
-// @return The 64-bit control register DCR.\r
-//\r
-AsmReadControlRegisterDcr::\r
-  mov            r8 = cr.dcr;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterDcr\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterItm, @function\r
-.proc   AsmReadControlRegisterItm\r
-//\r
-// Reads control register ITM.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_ITM\r
-//\r
-// @return The 64-bit control register ITM.\r
-//\r
-AsmReadControlRegisterItm::\r
-  mov            r8 = cr.itm;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterItm\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIva, @function\r
-.proc   AsmReadControlRegisterIva\r
-//\r
-// Reads control register IVA.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IVA\r
-//\r
-// @return The 64-bit control register IVA.\r
-//\r
-AsmReadControlRegisterIva::\r
-  mov            r8 = cr.iva;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIva\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterPta, @function\r
-.proc   AsmReadControlRegisterPta\r
-//\r
-// Reads control register PTA.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_PTA\r
-//\r
-// @return The 64-bit control register PTA.\r
-//\r
-AsmReadControlRegisterPta::\r
-  mov            r8 = cr.pta;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterPta\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIpsr, @function\r
-.proc   AsmReadControlRegisterIpsr\r
-//\r
-// Reads control register IPSR.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IPSR\r
-//\r
-// @return The 64-bit control register IPSR.\r
-//\r
-AsmReadControlRegisterIpsr::\r
-  mov            r8 = cr.ipsr;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIpsr\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIsr, @function\r
-.proc   AsmReadControlRegisterIsr\r
-//\r
-// Reads control register ISR.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_ISR\r
-//\r
-// @return The 64-bit control register ISR.\r
-//\r
-AsmReadControlRegisterIsr::\r
-  mov            r8 = cr.isr;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIsr\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIip, @function\r
-.proc   AsmReadControlRegisterIip\r
-//\r
-// Reads control register IIP.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IIP\r
-//\r
-// @return The 64-bit control register IIP.\r
-//\r
-AsmReadControlRegisterIip::\r
-  mov            r8 = cr.iip;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIip\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIfa, @function\r
-.proc   AsmReadControlRegisterIfa\r
-//\r
-// Reads control register IFA.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IFA\r
-//\r
-// @return The 64-bit control register IFA.\r
-//\r
-AsmReadControlRegisterIfa::\r
-  mov            r8 = cr.ifa;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIfa\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterItir, @function\r
-.proc   AsmReadControlRegisterItir\r
-//\r
-// Reads control register ITIR.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_ITIR\r
-//\r
-// @return The 64-bit control register ITIR.\r
-//\r
-AsmReadControlRegisterItir::\r
-  mov            r8 = cr.itir;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterItir\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIipa, @function\r
-.proc   AsmReadControlRegisterIipa\r
-//\r
-// Reads control register IIPA.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IIPA\r
-//\r
-// @return The 64-bit control register IIPA.\r
-//\r
-AsmReadControlRegisterIipa::\r
-  mov            r8 = cr.iipa;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIipa\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIfs, @function\r
-.proc   AsmReadControlRegisterIfs\r
-//\r
-// Reads control register IFS.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IFS\r
-//\r
-// @return The 64-bit control register IFS.\r
-//\r
-AsmReadControlRegisterIfs::\r
-  mov            r8 = cr.ifs;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIfs\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIim, @function\r
-.proc   AsmReadControlRegisterIim\r
-//\r
-// Reads control register IIM.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IIM\r
-//\r
-// @return The 64-bit control register IIM.\r
-//\r
-AsmReadControlRegisterIim::\r
-  mov            r8 = cr.iim;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIim\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIha, @function\r
-.proc   AsmReadControlRegisterIha\r
-//\r
-// Reads control register IHA.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IHA\r
-//\r
-// @return The 64-bit control register IHA.\r
-//\r
-AsmReadControlRegisterIha::\r
-  mov            r8 = cr.iha;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIha\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterLid, @function\r
-.proc   AsmReadControlRegisterLid\r
-//\r
-// Reads control register LID.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_LID\r
-//\r
-// @return The 64-bit control register LID.\r
-//\r
-AsmReadControlRegisterLid::\r
-  mov            r8 = cr.lid;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterLid\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIvr, @function\r
-.proc   AsmReadControlRegisterIvr\r
-//\r
-// Reads control register IVR.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IVR\r
-//\r
-// @return The 64-bit control register IVR.\r
-//\r
-AsmReadControlRegisterIvr::\r
-  mov            r8 = cr.ivr;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIvr\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterTpr, @function\r
-.proc   AsmReadControlRegisterTpr\r
-//\r
-// Reads control register TPR.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_TPR\r
-//\r
-// @return The 64-bit control register TPR.\r
-//\r
-AsmReadControlRegisterTpr::\r
-  mov            r8 = cr.tpr;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterTpr\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterEoi, @function\r
-.proc   AsmReadControlRegisterEoi\r
-//\r
-// Reads control register EOI.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_EOI\r
-//\r
-// @return The 64-bit control register EOI.\r
-//\r
-AsmReadControlRegisterEoi::\r
-  mov            r8 = cr.eoi;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterEoi\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIrr0, @function\r
-.proc   AsmReadControlRegisterIrr0\r
-//\r
-// Reads control register IRR0.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IRR0\r
-//\r
-// @return The 64-bit control register IRR0.\r
-//\r
-AsmReadControlRegisterIrr0::\r
-  mov            r8 = cr.irr0;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIrr0\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIrr1, @function\r
-.proc   AsmReadControlRegisterIrr1\r
-//\r
-// Reads control register IRR1.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IRR1\r
-//\r
-// @return The 64-bit control register IRR1.\r
-//\r
-AsmReadControlRegisterIrr1::\r
-  mov            r8 = cr.irr1;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIrr1\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIrr2, @function\r
-.proc   AsmReadControlRegisterIrr2\r
-//\r
-// Reads control register IRR2.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IRR2\r
-//\r
-// @return The 64-bit control register IRR2.\r
-//\r
-AsmReadControlRegisterIrr2::\r
-  mov            r8 = cr.irr2;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIrr2\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterIrr3, @function\r
-.proc   AsmReadControlRegisterIrr3\r
-//\r
-// Reads control register IRR3.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_IRR3\r
-//\r
-// @return The 64-bit control register IRR3.\r
-//\r
-AsmReadControlRegisterIrr3::\r
-  mov            r8 = cr.irr3;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterIrr3\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterItv, @function\r
-.proc   AsmReadControlRegisterItv\r
-//\r
-// Reads control register ITV.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_ITV\r
-//\r
-// @return The 64-bit control register ITV.\r
-//\r
-AsmReadControlRegisterItv::\r
-  mov            r8 = cr.itv;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterItv\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterPmv, @function\r
-.proc   AsmReadControlRegisterPmv\r
-//\r
-// Reads control register PMV.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_PMV\r
-//\r
-// @return The 64-bit control register PMV.\r
-//\r
-AsmReadControlRegisterPmv::\r
-  mov            r8 = cr.pmv;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterPmv\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterCmcv, @function\r
-.proc   AsmReadControlRegisterCmcv\r
-//\r
-// Reads control register CMCV.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_CMCV\r
-//\r
-// @return The 64-bit control register CMCV.\r
-//\r
-AsmReadControlRegisterCmcv::\r
-  mov            r8 = cr.cmcv;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterCmcv\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterLrr0, @function\r
-.proc   AsmReadControlRegisterLrr0\r
-//\r
-// Reads control register LRR0.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_LRR0\r
-//\r
-// @return The 64-bit control register LRR0.\r
-//\r
-AsmReadControlRegisterLrr0::\r
-  mov            r8 = cr.lrr0;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterLrr0\r
-\r
-\r
-\r
-.text\r
-.type   AsmReadControlRegisterLrr1, @function\r
-.proc   AsmReadControlRegisterLrr1\r
-//\r
-// Reads control register LRR1.\r
-//\r
-// This is a worker function for AsmReadControlRegister()\r
-// when its parameter Index is IPF_CONTROL_REGISTER_LRR1\r
-//\r
-// @return The 64-bit control register LRR1.\r
-//\r
-AsmReadControlRegisterLrr1::\r
-  mov            r8 = cr.lrr1;;\r
-  br.ret.dpnt    b0;;\r
-.endp   AsmReadControlRegisterLrr1\r
 \r
+//---------------------------------------------------------------------------------\r
+//++\r
+// AsmReadControlRegister\r
+//\r
+// Reads a 64-bit control register.\r
+//\r
+// Reads and returns the control register specified by Index.\r
+// If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned.  This function is only available on IPF.\r
+//\r
+// Arguments :\r
+//\r
+// On Entry : The index of the control register to read.\r
+//\r
+// Return Value: The control register specified by Index.\r
+//\r
+//--\r
+//----------------------------------------------------------------------------------\r
+.text\r
+.type   AsmReadControlRegister, @function\r
+.proc   AsmReadControlRegister\r
+.regstk 1, 0, 0, 0\r
+\r
+AsmReadControlRegister::\r
+  //\r
+  // CRs are defined in the ranges 0-25 and 64-81 (with some holes).\r
+  // Compact this list by subtracting 32 from the top range.\r
+  // 0-25, 64-81 -> 0-25, 32-49\r
+  //\r
+  mov  r15=2\r
+  mov  r14=pr                    // save predicates\r
+  cmp.leu  p6,p7=64,in0          // p6 = CR# >= 64\r
+  ;;\r
+  (p7)  cmp.leu  p7,p0=32,in0    // p7 = 32 <= CR# < 64\r
+  (p6)  add  in0=-32,in0         // if (CR >= 64) CR# -= 32\r
+  ;;\r
+  (p7)  mov  r15=0               // if bad range (32-63)\r
+  ;;\r
+  mov  ret0=-1                   // in case of illegal CR #\r
+  shl  r15=r15,in0               // r15 = 0x2 << CR#\r
+  ;;\r
+  mov  pr=r15,-1\r
+  ;;\r
+\r
+  //\r
+  // At this point the predicates contain a bit field of the\r
+  // CR desired.  (The bit is the CR+1, since pr0 is always 1.)\r
+  //\r
+  .pred.rel "mutex",p1,p2,p3,p9,p17,p18,p20,p21,p22,p23,p24,p25,p26,\\r
+    p33,p34,p35,p36,p37,p38,p39,p40,p41,p42,p43,p49,p50\r
+  (p1)  mov  ret0=cr.dcr        // cr0\r
+  (p2)  mov  ret0=cr.itm        // cr1\r
+  (p3)  mov  ret0=cr.iva        // cr2\r
+  (p9)  mov  ret0=cr.pta        // cr8\r
+  (p17)  mov  ret0=cr.ipsr      // cr16\r
+  (p18)  mov  ret0=cr.isr       // cr17\r
+  (p20)  mov  ret0=cr.iip       // cr19\r
+  (p21)  mov  ret0=cr.ifa       // cr20\r
+  (p22)  mov  ret0=cr.itir      // cr21\r
+  (p23)  mov  ret0=cr.iipa      // cr22\r
+  (p24)  mov  ret0=cr.ifs       // cr23\r
+  (p25)  mov  ret0=cr.iim       // cr24\r
+  (p26)  mov  ret0=cr.iha       // cr25\r
+\r
+  // This is the translated (-32) range.\r
+\r
+  (p33)  mov  ret0=cr.lid       // cr64\r
+  (p34)  mov  ret0=cr.ivr       // cr65\r
+  (p35)  mov  ret0=cr.tpr       // cr66\r
+  (p36)  mov  ret0=cr.eoi       // cr67\r
+  (p37)  mov  ret0=cr.irr0      // cr68\r
+  (p38)  mov  ret0=cr.irr1      // cr69\r
+  (p39)  mov  ret0=cr.irr2      // cr70\r
+  (p40)  mov  ret0=cr.irr3      // cr71\r
+  (p41)  mov  ret0=cr.itv       // cr72\r
+  (p42)  mov  ret0=cr.pmv       // cr73\r
+  (p43)  mov  ret0=cr.cmcv      // cr74\r
+  (p49)  mov  ret0=cr.lrr0      // cr80\r
+  (p50)  mov  ret0=cr.lrr1      // cr81\r
+  \r
+  //\r
+  // Restore predicates and return.\r
+  //\r
+  mov  pr=r14,-1\r
+  br.ret.sptk  b0\r
+  .endp\r