developer | 02e6591 | 2023-08-17 16:33:10 +0800 | [diff] [blame] | 1 | /* eip97_global_fsm.c |
| 2 | * |
| 3 | * EIP-97 Global Control Driver Library API State Machine Internal Interface |
| 4 | * implementation |
| 5 | */ |
| 6 | |
| 7 | /* -------------------------------------------------------------------------- */ |
| 8 | /* */ |
| 9 | /* Module : ddk197 */ |
| 10 | /* Version : 5.6.1 */ |
| 11 | /* Configuration : DDK-197-GPL */ |
| 12 | /* */ |
| 13 | /* Date : 2022-Dec-16 */ |
| 14 | /* */ |
| 15 | /* Copyright (c) 2008-2022 by Rambus, Inc. and/or its subsidiaries. */ |
| 16 | /* */ |
| 17 | /* This program is free software: you can redistribute it and/or modify */ |
| 18 | /* it under the terms of the GNU General Public License as published by */ |
| 19 | /* the Free Software Foundation, either version 2 of the License, or */ |
| 20 | /* any later version. */ |
| 21 | /* */ |
| 22 | /* This program is distributed in the hope that it will be useful, */ |
| 23 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 24 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
| 25 | /* GNU General Public License for more details. */ |
| 26 | /* */ |
| 27 | /* You should have received a copy of the GNU General Public License */ |
| 28 | /* along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 29 | /* -------------------------------------------------------------------------- */ |
| 30 | |
| 31 | /*---------------------------------------------------------------------------- |
| 32 | * This module implements (provides) the following interface(s): |
| 33 | */ |
| 34 | |
| 35 | #include "eip97_global_fsm.h" |
| 36 | |
| 37 | /*---------------------------------------------------------------------------- |
| 38 | * This module uses (requires) the following interface(s): |
| 39 | */ |
| 40 | |
| 41 | // EIP-97 Driver Library Types API |
| 42 | #include "eip97_global_types.h" // EIP97_Global_* types |
| 43 | |
| 44 | |
| 45 | /*---------------------------------------------------------------------------- |
| 46 | * EIP97_Global_State_Set |
| 47 | * |
| 48 | */ |
| 49 | EIP97_Global_Error_t |
| 50 | EIP97_Global_State_Set( |
| 51 | volatile EIP97_Global_State_t * const CurrentState, |
| 52 | const EIP97_Global_State_t NewState) |
| 53 | { |
| 54 | switch(*CurrentState) |
| 55 | { |
| 56 | case EIP97_GLOBAL_STATE_UNKNOWN: |
| 57 | switch(NewState) |
| 58 | { |
| 59 | case EIP97_GLOBAL_STATE_SW_RESET_START: |
| 60 | *CurrentState = NewState; |
| 61 | break; |
| 62 | case EIP97_GLOBAL_STATE_SW_RESET_DONE: |
| 63 | *CurrentState = NewState; |
| 64 | break; |
| 65 | default: |
| 66 | return EIP97_GLOBAL_ILLEGAL_IN_STATE; |
| 67 | } |
| 68 | break; |
| 69 | |
| 70 | case EIP97_GLOBAL_STATE_HW_RESET_DONE: |
| 71 | switch(NewState) |
| 72 | { |
| 73 | case EIP97_GLOBAL_STATE_INITIALIZED: |
| 74 | *CurrentState = NewState; |
| 75 | break; |
| 76 | default: |
| 77 | return EIP97_GLOBAL_ILLEGAL_IN_STATE; |
| 78 | } |
| 79 | break; |
| 80 | |
| 81 | case EIP97_GLOBAL_STATE_SW_RESET_START: |
| 82 | switch(NewState) |
| 83 | { |
| 84 | case EIP97_GLOBAL_STATE_SW_RESET_DONE: |
| 85 | *CurrentState = NewState; |
| 86 | break; |
| 87 | case EIP97_GLOBAL_STATE_SW_RESET_START: |
| 88 | *CurrentState = NewState; |
| 89 | break; |
| 90 | default: |
| 91 | return EIP97_GLOBAL_ILLEGAL_IN_STATE; |
| 92 | } |
| 93 | break; |
| 94 | |
| 95 | case EIP97_GLOBAL_STATE_SW_RESET_DONE: |
| 96 | switch(NewState) |
| 97 | { |
| 98 | case EIP97_GLOBAL_STATE_SW_RESET_DONE: |
| 99 | case EIP97_GLOBAL_STATE_INITIALIZED: |
| 100 | *CurrentState = NewState; |
| 101 | break; |
| 102 | default: |
| 103 | return EIP97_GLOBAL_ILLEGAL_IN_STATE; |
| 104 | } |
| 105 | break; |
| 106 | |
| 107 | case EIP97_GLOBAL_STATE_INITIALIZED: |
| 108 | switch(NewState) |
| 109 | { |
| 110 | case EIP97_GLOBAL_STATE_ENABLED: |
| 111 | *CurrentState = NewState; |
| 112 | break; |
| 113 | case EIP97_GLOBAL_STATE_SW_RESET_DONE: |
| 114 | *CurrentState = NewState; |
| 115 | break; |
| 116 | case EIP97_GLOBAL_STATE_INITIALIZED: |
| 117 | *CurrentState = NewState; |
| 118 | break; |
| 119 | default: |
| 120 | return EIP97_GLOBAL_ILLEGAL_IN_STATE; |
| 121 | } |
| 122 | break; |
| 123 | |
| 124 | case EIP97_GLOBAL_STATE_ENABLED: |
| 125 | switch(NewState) |
| 126 | { |
| 127 | case EIP97_GLOBAL_STATE_SW_RESET_START: |
| 128 | *CurrentState = NewState; |
| 129 | break; |
| 130 | case EIP97_GLOBAL_STATE_SW_RESET_DONE: |
| 131 | *CurrentState = NewState; |
| 132 | break; |
| 133 | case EIP97_GLOBAL_STATE_FATAL_ERROR: |
| 134 | break; |
| 135 | case EIP97_GLOBAL_STATE_ENABLED: |
| 136 | break; |
| 137 | default: |
| 138 | return EIP97_GLOBAL_ILLEGAL_IN_STATE; |
| 139 | } |
| 140 | break; |
| 141 | |
| 142 | case EIP97_GLOBAL_STATE_FATAL_ERROR: |
| 143 | switch(NewState) |
| 144 | { |
| 145 | case EIP97_GLOBAL_STATE_SW_RESET_START: |
| 146 | *CurrentState = NewState; |
| 147 | break; |
| 148 | case EIP97_GLOBAL_STATE_SW_RESET_DONE: |
| 149 | *CurrentState = NewState; |
| 150 | break; |
| 151 | default: |
| 152 | return EIP97_GLOBAL_ILLEGAL_IN_STATE; |
| 153 | } |
| 154 | break; |
| 155 | |
| 156 | default: |
| 157 | return EIP97_GLOBAL_ILLEGAL_IN_STATE; |
| 158 | } |
| 159 | |
| 160 | return EIP97_GLOBAL_NO_ERROR; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | /* end of file eip97_global_fsm.c */ |