<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Read PowerPC Machine State Register from C in S32 Design Studio</title>
    <link>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599308#M9741</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/122643"&gt;@ronjaeger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used this in the past:&lt;/P&gt;
&lt;P&gt;#define MFMSR() ({unsigned int rval; __asm__ volatile("mfmsr %0" : "=r" (rval)); rval;})&lt;BR /&gt;#define MTMSR(v) __asm__ volatile("mtmsr %0" : : "r"(v))&lt;/P&gt;
&lt;P&gt;and then:&lt;/P&gt;
&lt;P&gt;temp = MFMSR();&lt;BR /&gt;MTMSR(0x8000);&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Lukas&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 05:47:48 GMT</pubDate>
    <dc:creator>lukaszadrapa</dc:creator>
    <dc:date>2023-02-15T05:47:48Z</dc:date>
    <item>
      <title>Read PowerPC Machine State Register from C</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599000#M9739</link>
      <description>&lt;P&gt;Using Power PC MPC5775B, how do I read the core Machine State Register from a C routine?&amp;nbsp; Other compilers have had intrinsic functions like __mfmsr() that returned the MSR value.&amp;nbsp; But I can't find the equivalent in S32DS.&amp;nbsp; I want to check the state of the EE bit (external interrupt disable).&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 16:23:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599000#M9739</guid>
      <dc:creator>ronjaeger</dc:creator>
      <dc:date>2023-02-14T16:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Read PowerPC Machine State Register from C</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599308#M9741</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/122643"&gt;@ronjaeger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used this in the past:&lt;/P&gt;
&lt;P&gt;#define MFMSR() ({unsigned int rval; __asm__ volatile("mfmsr %0" : "=r" (rval)); rval;})&lt;BR /&gt;#define MTMSR(v) __asm__ volatile("mtmsr %0" : : "r"(v))&lt;/P&gt;
&lt;P&gt;and then:&lt;/P&gt;
&lt;P&gt;temp = MFMSR();&lt;BR /&gt;MTMSR(0x8000);&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Lukas&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 05:47:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599308#M9741</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2023-02-15T05:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: Read PowerPC Machine State Register from C</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599647#M9745</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; That seems to work.&amp;nbsp; (But see post about warning...)&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 22:23:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599647#M9745</guid>
      <dc:creator>ronjaeger</dc:creator>
      <dc:date>2023-02-15T22:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Read PowerPC Machine State Register from C</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599963#M9747</link>
      <description>&lt;P&gt;Actually, when I use MFMSR(), it compiles without actual error, but I get this warning:&lt;BR /&gt;"warning (etoa:5848): GNU-style inline assembly detected. This feature is not supported."&lt;BR /&gt;&lt;BR /&gt;Should I be concerned about this or just ignore the warning?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 22:17:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1599963#M9747</guid>
      <dc:creator>ronjaeger</dc:creator>
      <dc:date>2023-02-15T22:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Read PowerPC Machine State Register from C</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1600226#M9748</link>
      <description>&lt;P&gt;That's interesting, I can't see such error on my side. If it works, there's probably no problem.&lt;/P&gt;
&lt;P&gt;And I found one more version which can be used to access any SPR register, not only MSR:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#define stringify(s) tostring(s)&lt;BR /&gt;#define tostring(s) #s&lt;BR /&gt;#define mfspr(rn) ({unsigned int rval; __asm__ volatile("mfspr %0," stringify(rn) : "=r" (rval)); rval;})&lt;BR /&gt;#define mtspr(rn, v) __asm__ volatile("mtspr " stringify(rn) ",%0" : : "r" (v))&lt;/P&gt;
&lt;P&gt;And then:&lt;/P&gt;
&lt;P&gt;mtspr(570, content_of_MCSRR0);&lt;/P&gt;
&lt;P&gt;mtspr(572, 0xFFFFFFFF); //clear all flags in MCSR register&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Lukas&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 06:43:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/Read-PowerPC-Machine-State-Register-from-C/m-p/1600226#M9748</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2023-02-16T06:43:34Z</dc:date>
    </item>
  </channel>
</rss>

