2 Replies Latest reply on Oct 10, 2011 10:14 AM by jheld

    Using MSRs on baremetal




      I have the following prioblem. I wish to edit the msrs without the use of an operating system. On baremetal, I cannot use msr tools since they need to be installed after each booting, which is impossible without an operating system. So I decided trying inline assembly to read and write the registers. My problem is, I do not know how to address them. I tried, for example, using the keyword CTR0 for the first counter out of the two provided by p54c ( as stated in chapter 26 of P54C_Architecture_And_Programming_Vol3 ) but the gcc compiler would not recognise it.

      Here is a sample of the code I am trying to use with MSRs:


      int main(void)
              int value = 10, test = 0;
              __asm__ __volatile__("movl  %0, %%eax\n"
      __asm__ __volatile__("movl  %%eax,%0\n"
              printf("Test is=%d\n", test);
              return 0;


      This segment assigns a value to register eax and then passes on that value to a variable. Printf verifies that the writing is done successfully (Test is 10 after the execution of the program).

      If I am able to write the control register and read a counter, my job would be done easily. Any help would be appreciated!