<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 2/25/2013 1:37 PM, Matthew J
      Fletcher wrote:<br>
    </div>
    <blockquote cite="mid:512BBD6E.4050500@gmail.com" type="cite">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <p dir="ltr">Hi,</p>
      <p dir="ltr">I guess it my fault for not 100% copying the rtl22xx
        BSP into my new one, i had the cpsr register in a different
        state at boot_card() time than the generic ARM context switch
        code expects. I think that common binary blob commercial RTOS
        must do a cpsr read before the first context switch, rather than
        rely on a fixed state as i've not encountered this type of issue
        before.</p>
      <p dir="ltr"><br>
      </p>
    </blockquote>
    Some architectures construct the entire value of the status
    register. Others<br>
    start with what the BSP had and modify it.<br>
    <br>
    The question is which bits mattered and why RTEMS missed them. Could<br>
    we generically know the complete set of correct bits to set?<br>
    <br>
    If so, it is definitely safer to compute the entire value of a
    task's status register.<br>
    <br>
    --joel<br>
    <blockquote cite="mid:512BBD6E.4050500@gmail.com" type="cite">
      <p dir="ltr"> </p>
      <div class="gmail_quote">On 25 Feb 2013 17:40, "Joel Sherrill"
        <<a moz-do-not-send="true"
          href="mailto:joel.sherrill@oarcorp.com">joel.sherrill@oarcorp.com</a>>

        wrote:<br type="attribution">
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div text="#000000" bgcolor="#FFFFFF">
            <div>On 2/25/2013 11:25 AM, Matthew J Fletcher wrote:<br>
            </div>
            <blockquote type="cite">Sebastain,<br>
              <br>
              I changed the code so now with the cpsr set as expected
              before main() the context switch occurs fine and we end up
              in Init().<br>
              <br>
            </blockquote>
            Is this a generic issue that needs addressing in the RTEMS<br>
            git repo? Or something you broke accidentally when making<br>
            other changes?<br>
            <blockquote type="cite">Thanks for all your help.<br>
              <br>
            </blockquote>
            A little early for a beer here but it is definitely after 5
            for<br>
            Sebastian. Good job Sebastian!<br>
            <br>
            --joel<br>
            <blockquote type="cite"><br>
              <div class="gmail_quote">On 25 February 2013 17:10,
                Matthew J Fletcher <span dir="ltr"><<a
                    moz-do-not-send="true"
                    href="mailto:amimjf@gmail.com" target="_blank">amimjf@gmail.com</a>></span>
                wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
                  <br>
                  The cpsr thats saved out to r2 is 0x800000df, but is
                  restored back to 0x13. Thanks for pointing out that no
                  cpsr change must happen, i will check how the
                  rtl22xx_t bsp sets up the cpsr.
                  <div>
                    <div><br>
                      <br>
                      <br>
                      <div class="gmail_quote"> On 25 February 2013
                        16:52, Sebastian Huber <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:sebastian.huber@embedded-brains.de"
                            target="_blank">sebastian.huber@embedded-brains.de</a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex"> On 02/25/2013 05:47
                          PM, Matthew J Fletcher wrote:<br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex"> Hi,<br>
                            <br>
                            r2 is 0x13 before the msr, so I guess
                            new_level must have been 0.<br>
                            <br>
                            On 25 Feb 2013 15:02, "Sebastian Huber" <<a
                              moz-do-not-send="true"
                              href="mailto:sebastian.huber@embedded-brains.de"
                              target="_blank">sebastian.huber@embedded-brains.de</a><br>
                            <mailto:<a moz-do-not-send="true"
                              href="mailto:sebastian.huber@embedded-brains.de"
                              target="_blank">sebastian.huber@embedded-brains.de</a>>>


                            wrote:<br>
                            <br>
                                On 02/25/2013 03:15 PM, Matthew J
                            Fletcher wrote:<br>
                            <br>
                                    Sebastian,<br>
                            <br>
                                    The _Thread_Heir->Registers are
                            ok into the _Context_Switch() call, sp<br>
                                    and lr<br>
                                    both sensible.<br>
                            <br>
                                    At the 'mrs r2, cpsr' line sp is
                            0x40001b2c (rubbish) and pc sensible.<br>
                            <br>
                                    In _restore, after the 'ldmia r1,
                            ...' instruction the sp and lr are loaded<br>
                                    with the correct values from
                            _Thread_Heir->Registers.<br>
                            <br>
                                    Its the 'msr cpsr, r2' messes up the
                            sp and lr<br>
                            <br>
                            <br>
                                Ok, if you load undefined values into
                            the CPSR, then a lot of things may<br>
                                happen.  What is the value of r2 before
                            the msr?  It should be 0x13.<br>
                          </blockquote>
                          <br>
                          Ok, then maybe the mode in the BSP execution
                          context is wrong.  During _Context_Switch() no
                          mode change must happen.  What is the CPSR
                          before the msr?<span><font color="#888888"><br>
                              <br>
                              -- <br>
                              Sebastian Huber, embedded brains GmbH<br>
                              <br>
                              Address : Dornierstr. 4, D-82178 Puchheim,
                              Germany<br>
                              Phone   : <a moz-do-not-send="true"
                                href="tel:%2B49%2089%20189%2047%2041-16"
                                value="+4989189474116" target="_blank">+49

                                89 189 47 41-16</a><br>
                              Fax     : <a moz-do-not-send="true"
                                href="tel:%2B49%2089%20189%2047%2041-09"
                                value="+4989189474109" target="_blank">+49

                                89 189 47 41-09</a><br>
                              E-Mail  : <a moz-do-not-send="true"
                                href="mailto:sebastian.huber@embedded-brains.de"
                                target="_blank">sebastian.huber@embedded-brains.de</a><br>
                              PGP     : Public key available on request.<br>
                              <br>
                              Diese Nachricht ist keine geschäftliche
                              Mitteilung im Sinne des EHUG.<br>
                            </font></span></blockquote>
                      </div>
                      <br>
                      <br clear="all">
                      <br>
                    </div>
                  </div>
                  <span><font color="#888888">-- <br>
                      <div><br>
                        regards</div>
                      <div>---</div>
                      <div>Matthew J Fletcher</div>
                      <br>
                    </font></span></blockquote>
              </div>
              <br>
              <br clear="all">
              <br>
              -- <br>
              <div><br>
                regards</div>
              <div>---</div>
              <div>Matthew J Fletcher</div>
              <br>
            </blockquote>
            <br>
            <br>
            <pre cols="72">-- 
Joel Sherrill, Ph.D.             Director of Research & Development 
<a moz-do-not-send="true" href="mailto:joel.sherrill@OARcorp.com" target="_blank">joel.sherrill@OARcorp.com</a>        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805 
Support Available                (256) 722-9985 </pre>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Joel Sherrill, Ph.D.             Director of Research & Development 
<a class="moz-txt-link-abbreviated" href="mailto:joel.sherrill@OARcorp.com">joel.sherrill@OARcorp.com</a>        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805 
Support Available                (256) 722-9985 </pre>
  </body>
</html>