예제 #1
0
        private void EncodeLifeCycleState(OpenTitan_LifeCycleState state)
        {
            var positionsConsumed = positionsConsumedToLifeCycleState.FirstOrDefault(x => x.Value == state).Key;
            var mask = 1 << (aValues.Length - 1);

            lock (memoryLock)
            {
                for (int index = 0; index < aValues.Length; index++)
                {
                    var currentPositionConsumed = (positionsConsumed & mask) != 0;
                    var writeOffset             = (uint)OtpItem.LifeCycleState + index * 2;
                    underlyingMemory.WriteWord(writeOffset, currentPositionConsumed ? bValues[index] : aValues[index]);
                    positionsConsumed <<= 1;
                }
            }
        }
예제 #2
0
 private bool IsTransitionTokenValid(OpenTitan_LifeCycleState currentState, OpenTitan_LifeCycleState nextState)
 {
     if (LockedTestStates.Contains(currentState) && UnlockedTestStates.Contains(nextState))
     {
         return(token.SequenceEqual(testUnlockToken));
     }
     else if (UnlockedTestStates.Contains(currentState) && MissionStates.Contains(nextState))
     {
         return(token.SequenceEqual(testExitToken));
     }
     else if (MissionStates.Contains(currentState) && nextState == OpenTitan_LifeCycleState.Rma)
     {
         return(token.SequenceEqual(rmaToken));
     }
     // No token required for this transition
     return(true);
 }
예제 #3
0
        /* End of LifeCycleTransitionCount functions
         */

        /*
         * The LifeCycleState is decoded/encoded using 20 words that are intially written with some combination of Ax/Bx values.
         * Those values are organized in such a way that by advncing the state we consume the Ax val by overwriting it by Bx val,
         * future transition to an allowed state is not possible without knowing the Ax values.
         */
        private bool TryDecodeLifeCycleState(out OpenTitan_LifeCycleState state)
        {
            var lifeCycleState = GetOtpItem(OtpItem.LifeCycleState);

            if (lifeCycleState.All(x => x == 0))
            {
                state = OpenTitan_LifeCycleState.Raw;
                return(true);
            }
            var positionsConsumed = GetConsumedPositionsMap(aValues, bValues, lifeCycleState);

            if (!positionsConsumedToLifeCycleState.ContainsKey(positionsConsumed))
            {
                this.Log(LogLevel.Error, "Unable to convert the consumed positions [{0}] to the LifeCycleState", Convert.ToString(positionsConsumed, 2).PadLeft(4, '0'));
                state = default(OpenTitan_LifeCycleState);
                return(false);
            }
            state = positionsConsumedToLifeCycleState[positionsConsumed];
            return(true);
        }
예제 #4
0
 private bool IsTransitionAllowed(OpenTitan_LifeCycleState currentState, OpenTitan_LifeCycleState nextState)
 {
     if (nextState == OpenTitan_LifeCycleState.Scrap ||
         currentState == OpenTitan_LifeCycleState.Raw && UnlockedTestStates.Contains(nextState))
     {
         return(true);
     }
     else if (UnlockedTestStates.Contains(currentState))
     {
         if (LockedTestStates.Contains(nextState) && (nextState > currentState) ||
             nextState == OpenTitan_LifeCycleState.Rma ||
             MissionStates.Contains(nextState))
         {
             return(true);
         }
     }
     else if ((currentState == OpenTitan_LifeCycleState.Dev || currentState == OpenTitan_LifeCycleState.Prod) &&
              nextState == OpenTitan_LifeCycleState.Rma)
     {
         return(true);
     }
     return(false);
 }