helper/command: change prototype of command_print/command_print_sameline
[openocd.git] / src / flash / nor / str9xpec.c
index e89ecf49f0838f86a5c5cfa7e00bef8a4adf77e7..6e1ecf3476abbbe7023cb4ebf352b97ab62a1c05 100644 (file)
@@ -16,9 +16,7 @@
  *   GNU General Public License for more details.                          *
  *                                                                         *
  *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -199,7 +197,6 @@ static int str9xpec_read_config(struct flash_bank *bank)
        field.out_value = NULL;
        field.in_value = str9xpec_info->options;
 
-
        jtag_add_dr_scan(tap, 1, &field, TAP_IDLE);
        jtag_execute_queue();
 
@@ -566,7 +563,7 @@ static int str9xpec_set_address(struct flash_bank *bank, uint8_t sector)
        return ERROR_OK;
 }
 
-static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer,
+static int str9xpec_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct str9xpec_flash_controller *str9xpec_info = bank->driver_priv;
@@ -749,7 +746,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command)
 
        idcode = buf_get_u32(buffer, 0, 32);
 
-       command_print(CMD_CTX, "str9xpec part id: 0x%8.8" PRIx32 "", idcode);
+       command_print(CMD, "str9xpec part id: 0x%8.8" PRIx32 "", idcode);
 
        free(buffer);
 
@@ -761,12 +758,6 @@ static int str9xpec_erase_check(struct flash_bank *bank)
        return str9xpec_blank_check(bank, 0, bank->num_sectors - 1);
 }
 
-static int get_str9xpec_info(struct flash_bank *bank, char *buf, int buf_size)
-{
-       snprintf(buf, buf_size, "str9xpec flash driver info");
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
 {
        uint8_t status;
@@ -789,33 +780,33 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
 
        /* boot bank */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_CSMAPBIT, 1))
-               command_print(CMD_CTX, "CS Map: bank1");
+               command_print(CMD, "CS Map: bank1");
        else
-               command_print(CMD_CTX, "CS Map: bank0");
+               command_print(CMD, "CS Map: bank0");
 
        /* OTP lock */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_OTPBIT, 1))
-               command_print(CMD_CTX, "OTP Lock: OTP Locked");
+               command_print(CMD, "OTP Lock: OTP Locked");
        else
-               command_print(CMD_CTX, "OTP Lock: OTP Unlocked");
+               command_print(CMD, "OTP Lock: OTP Unlocked");
 
        /* LVD Threshold */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDTHRESBIT, 1))
-               command_print(CMD_CTX, "LVD Threshold: 2.7v");
+               command_print(CMD, "LVD Threshold: 2.7v");
        else
-               command_print(CMD_CTX, "LVD Threshold: 2.4v");
+               command_print(CMD, "LVD Threshold: 2.4v");
 
        /* LVD reset warning */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDWARNBIT, 1))
-               command_print(CMD_CTX, "LVD Reset Warning: VDD or VDDQ Inputs");
+               command_print(CMD, "LVD Reset Warning: VDD or VDDQ Inputs");
        else
-               command_print(CMD_CTX, "LVD Reset Warning: VDD Input Only");
+               command_print(CMD, "LVD Reset Warning: VDD Input Only");
 
        /* LVD reset select */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDSELBIT, 1))
-               command_print(CMD_CTX, "LVD Reset Selection: VDD or VDDQ Inputs");
+               command_print(CMD, "LVD Reset Selection: VDD or VDDQ Inputs");
        else
-               command_print(CMD_CTX, "LVD Reset Selection: VDD Input Only");
+               command_print(CMD, "LVD Reset Selection: VDD Input Only");
 
        return ERROR_OK;
 }
@@ -894,7 +885,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command)
        if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
                return ERROR_FLASH_OPERATION_FAILED;
 
-       command_print(CMD_CTX, "str9xpec write options complete.\n"
+       command_print(CMD, "str9xpec write options complete.\n"
                        "INFO: a reset or power cycle is required "
                        "for the new settings to take effect.");
 
@@ -1026,7 +1017,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command)
        if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
                return ERROR_FLASH_OPERATION_FAILED;
 
-       command_print(CMD_CTX, "str9xpec unlocked.\n"
+       command_print(CMD, "str9xpec unlocked.\n"
                        "INFO: a reset or power cycle is required "
                        "for the new settings to take effect.");
 
@@ -1050,20 +1041,24 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command)
 
        str9xpec_info = bank->driver_priv;
 
-       tap0 = str9xpec_info->tap;
-
        /* remove arm core from chain - enter turbo mode */
+       tap0 = str9xpec_info->tap;
+       if (tap0 == NULL) {
+               /* things are *WRONG* */
+               command_print(CMD, "**STR9FLASH** (tap0) invalid chain?");
+               return ERROR_FAIL;
+       }
        tap1 = tap0->next_tap;
        if (tap1 == NULL) {
                /* things are *WRONG* */
-               command_print(CMD_CTX, "**STR9FLASH** (tap1) invalid chain?");
-               return ERROR_OK;
+               command_print(CMD, "**STR9FLASH** (tap1) invalid chain?");
+               return ERROR_FAIL;
        }
        tap2 = tap1->next_tap;
        if (tap2 == NULL) {
                /* things are *WRONG* */
-               command_print(CMD_CTX, "**STR9FLASH** (tap2) invalid chain?");
-               return ERROR_OK;
+               command_print(CMD, "**STR9FLASH** (tap2) invalid chain?");
+               return ERROR_FAIL;
        }
 
        /* enable turbo mode - TURBO-PROG-ENABLE */
@@ -1182,9 +1177,10 @@ static const struct command_registration str9xpec_config_command_handlers[] = {
        },
        {
                .name = "part_id",
+               .usage = "<bank>",
                .handler = str9xpec_handle_part_id_command,
                .mode = COMMAND_EXEC,
-               .help = "print part id of str9xpec flash bank <num>",
+               .help = "print part id of str9xpec flash bank",
        },
        COMMAND_REGISTRATION_DONE
 };
@@ -1200,7 +1196,7 @@ static const struct command_registration str9xpec_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver str9xpec_flash = {
+const struct flash_driver str9xpec_flash = {
        .name = "str9xpec",
        .commands = str9xpec_command_handlers,
        .flash_bank_command = str9xpec_flash_bank_command,
@@ -1212,5 +1208,5 @@ struct flash_driver str9xpec_flash = {
        .auto_probe = str9xpec_probe,
        .erase_check = str9xpec_erase_check,
        .protect_check = str9xpec_protect_check,
-       .info = get_str9xpec_info,
+       .free_driver_priv = default_flash_free_driver_priv,
 };

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)