mips: use const for code sequences
authorØyvind Harboe <oyvind.harboe@zylin.com>
Sun, 22 Nov 2009 19:18:26 +0000 (20:18 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Sun, 22 Nov 2009 19:18:26 +0000 (20:18 +0100)
This will allow data to be allocated in read only
memory instead of on the stack. Speeds things up
and reduces stack usage.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/target/mips32_pracc.c
src/target/mips32_pracc.h

index abc4a6f548207151faa19c3c662ef2e018545985..3177e0f291959482e42d2a33e06f61c71cff5062 100644 (file)
@@ -83,7 +83,7 @@ struct mips32_pracc_context
        int num_iparam;
        uint32_t *local_oparam;
        int num_oparam;
-       uint32_t *code;
+       const uint32_t *code;
        int code_len;
        uint32_t stack[32];
        int stack_offset;
@@ -208,7 +208,7 @@ static int mips32_pracc_exec_write(struct mips32_pracc_context *ctx, uint32_t ad
        return ERROR_OK;
 }
 
-int mips32_pracc_exec(struct mips_ejtag *ejtag_info, int code_len, uint32_t *code, int num_param_in, uint32_t *param_in, int num_param_out, uint32_t *param_out, int cycle)
+int mips32_pracc_exec(struct mips_ejtag *ejtag_info, int code_len, const uint32_t *code, int num_param_in, uint32_t *param_in, int num_param_out, uint32_t *param_out, int cycle)
 {
        uint32_t ejtag_ctrl;
        uint32_t address, data;
@@ -290,7 +290,7 @@ int mips32_pracc_read_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size
 
 int mips32_pracc_read_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint32_t *buf)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                        /* start: */
                MIPS32_MTC0(15,31,0),                                                           /* move $15 to COP0 DeSave */
                MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)),             /* $15 = MIPS32_PRACC_STACK */
@@ -364,7 +364,7 @@ int mips32_pracc_read_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int co
 
 int mips32_pracc_read_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t *buf)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                        /* start: */
                MIPS32_MTC0(15,31,0),                                                           /* move $15 to COP0 DeSave */
                MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)),             /* $15 = MIPS32_PRACC_STACK */
@@ -398,7 +398,7 @@ int mips32_pracc_read_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t
 
 int mips32_pracc_read_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                        /* start: */
                MIPS32_MTC0(15,31,0),                                                           /* move $15 to COP0 DeSave */
                MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)),             /* $15 = MIPS32_PRACC_STACK */
@@ -477,7 +477,7 @@ int mips32_pracc_read_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int co
 
 int mips32_pracc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                        /* start: */
                MIPS32_MTC0(15,31,0),                                                           /* move $15 to COP0 DeSave */
                MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)),             /* $15 = MIPS32_PRACC_STACK */
@@ -576,7 +576,7 @@ int mips32_pracc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int c
 {
 
 //NC: use destination pointer as loop counter (last address is in $10)
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                        /* start: */
                MIPS32_MTC0(15,31,0),                                                           /* move $15 to COP0 DeSave */
                MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)),             /* $15 = MIPS32_PRACC_STACK */
@@ -623,7 +623,7 @@ int mips32_pracc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int c
 
 int mips32_pracc_write_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t *buf)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                        /* start: */
                MIPS32_MTC0(15,31,0),                                                           /* move $15 to COP0 DeSave */
                MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)),             /* $15 = MIPS32_PRACC_STACK */
@@ -656,7 +656,7 @@ int mips32_pracc_write_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_
 
 int mips32_pracc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                        /* start: */
                MIPS32_MTC0(15,31,0),                                                           /* move $15 to COP0 DeSave */
                MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)),             /* $15 = MIPS32_PRACC_STACK */
@@ -716,7 +716,7 @@ int mips32_pracc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int c
 
 int mips32_pracc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                        /* start: */
                MIPS32_MTC0(15,31,0),                                                           /* move $15 to COP0 DeSave */
                MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)),             /* $15 = MIPS32_PRACC_STACK */
@@ -777,7 +777,7 @@ int mips32_pracc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int co
 
 int mips32_pracc_write_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                /* start: */
                MIPS32_LUI(2,UPPER16(MIPS32_PRACC_PARAM_IN)),   /* $2 = MIPS32_PRACC_PARAM_IN */
                MIPS32_ORI(2,2,LOWER16(MIPS32_PRACC_PARAM_IN)),
@@ -849,7 +849,7 @@ int mips32_pracc_write_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
 
 int mips32_pracc_read_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
 {
-       uint32_t code[] = {
+       static const uint32_t code[] = {
                                                                                                                /* start: */
                MIPS32_MTC0(2,31,0),                                                    /* move $2 to COP0 DeSave */
                MIPS32_LUI(2,UPPER16(MIPS32_PRACC_PARAM_OUT)),  /* $2 = MIPS32_PRACC_PARAM_OUT */
index 3b124c78a9f2fd4f367864978840c780d6342f16..5d1cf3dd6f1b1bbc98172d8338e2533ece8d7b5a 100644 (file)
@@ -63,7 +63,7 @@ int mips32_pracc_write_u32(struct mips_ejtag *ejtag_info,
 int mips32_pracc_read_regs(struct mips_ejtag *ejtag_info, uint32_t *regs);
 int mips32_pracc_write_regs(struct mips_ejtag *ejtag_info, uint32_t *regs);
 
-int mips32_pracc_exec(struct mips_ejtag *ejtag_info, int code_len, uint32_t *code,
+int mips32_pracc_exec(struct mips_ejtag *ejtag_info, int code_len, const uint32_t *code,
                int num_param_in, uint32_t *param_in,
                int num_param_out, uint32_t *param_out, int cycle);
 

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)