#include <stdlib.h>#include <flash.h>#include <myconfig.h>
Go to the source code of this file.
Functions | |
| int | cmd_erase (int argc, char **argv) |
| int | cmd_erase_area (int argc, char **argv) |
| int | cmd_program (int argc, char **argv) |
| char * | dupstr (int) |
| static char * | flash_complete (char *text, int state) const |
| static void | init_flash_func (void) |
| mycmd_init (erase_area, cmd_erase_area,"erase_area start end sectorsize","erase sectors,\tenv: flash") | |
| mycmd_init (erase, cmd_erase,"erase","erase whole chip,\tenv: flash") | |
| mycmd_init (program, cmd_program,"program ramaddr flashaddr size ","program address,\tenv: flash") | |
| myconfig_init1 ("flash.type", config_flash_type, CONFIG_S,"flash type", flash_complete) | |
Variables | |
| struct flash_function | begin_flash_func |
| static unsigned int | code_erase_sst16 [] |
| static unsigned int | code_erase_sst8 [] |
| static unsigned int | code_program_sst16 [] |
| static unsigned int | code_program_sst8 [] |
| static char * | config_flash_type = "sst8" |
| struct flash_function | end_flash_func |
| struct flash_function * | flash_func_head |
| struct flash_function * | flash_func_tail |
| static struct flash_function | flash_functions [] |
| int cmd_erase | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 239 of file flash.c.
References flash_function.erase, fMIPS32_ExecuteDebugModule(), flash_function.init, flash_function.name, and flash_function.next.
00240 { 00241 char *type; 00242 struct flash_function *pflash; 00243 00244 if(!(type=config_flash_type)) 00245 goto unfind; 00246 for(pflash=flash_func_head;pflash;pflash=pflash->next) 00247 if(!strcmp(pflash->name,type))break; 00248 if(!pflash)goto unfind; 00249 00250 if(pflash->init) pflash->init(pflash); 00251 fMIPS32_ExecuteDebugModule(pflash->erase,0x8000,1); 00252 return 0; 00253 unfind: 00254 printf("unfind flash,doest not setevn flash,or unsuppoted flashtype.\nmaybe run setenv flash sst8\n"); 00255 return -1; 00256 00257 }
| int cmd_erase_area | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 259 of file flash.c.
References flash_function.erase_area, fMIPS32_ExecuteDebugModule(), flash_function.init, flash_function.name, flash_function.next, and ui_datamem.
00260 { 00261 char *type; 00262 struct flash_function *pflash; 00263 unsigned int start_addr,end_addr,sector_size; 00264 00265 if(argc != 4) return -1; 00266 00267 if(!(type=config_flash_type)) 00268 goto unfind; 00269 for(pflash=flash_func_head;pflash;pflash=pflash->next) 00270 if(!strcmp(pflash->name,type))break; 00271 if(!pflash)goto unfind; 00272 if(!pflash->erase_area)goto unsupport; 00273 if(pflash->init) pflash->init(pflash); 00274 start_addr = strtoul(argv[1],0,0); 00275 end_addr = strtoul(argv[2],0,0); 00276 sector_size = strtoul(argv[3],0,0); 00277 ui_datamem[0] = start_addr; 00278 ui_datamem[1] = end_addr; 00279 ui_datamem[2] = sector_size; 00280 fMIPS32_ExecuteDebugModule(pflash->erase_area,0x8000,1); 00281 return 0; 00282 unfind: 00283 printf("unfind flash,doest not setevn flash,or unsuppoted flashtype.\nmaybe run setenv flash sst8\n"); 00284 return -1; 00285 unsupport: 00286 printf("unsupport erase flash area\n"); 00287 return -2; 00288 }
| int cmd_program | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 192 of file flash.c.
References context_reg, context_restore(), context_save(), dMIPS32_NUM_DEBUG_REGISTERS, fMIPS32_ExecuteDebugModule(), help_addr, flash_function.init, jtag_putmem(), miro_inst_2, flash_function.name, flash_function.next, flash_function.program, flash_function.program_code_size, and tgt_compile.
00193 { 00194 char *type; 00195 struct flash_function *pflash; 00196 int context_reg[dMIPS32_NUM_DEBUG_REGISTERS]; 00197 if(!(type=config_flash_type)) 00198 goto unfind; 00199 for(pflash=flash_func_head;pflash;pflash=pflash->next) 00200 if(!strcmp(pflash->name,type))break; 00201 if(!pflash)goto unfind; 00202 00203 if(pflash->init) pflash->init(pflash); 00204 00205 context_save(context_reg); 00206 00207 jtag_putmem(pflash->program,help_addr,pflash->program_code_size); 00208 00209 { 00210 unsigned int miro_inst_2[]= 00211 tgt_compile(\ 00212 "bal 1f;\n" \ 00213 "nop;\n" \ 00214 ".space 16 \n" \ 00215 "1:\n" \ 00216 "lw v0,(ra);\n" \ 00217 "lw a0,4(ra);\n" \ 00218 "lw a1,8(ra);\n" \ 00219 "lw a2,12(ra);\n" \ 00220 "jr v0;\n" \ 00221 "nop ;\n" \ 00222 ); 00223 miro_inst_2[2]=help_addr; 00224 miro_inst_2[3]=strtoul(argv[1],0,0); //ram address 00225 miro_inst_2[4]=strtoul(argv[2],0,0); //flash address 00226 miro_inst_2[5]=strtoul(argv[3],0,0); 00227 fMIPS32_ExecuteDebugModule(miro_inst_2,sizeof(miro_inst_2),1); 00228 } 00229 00230 context_restore(context_reg); 00231 00232 00233 return 0; 00234 unfind: 00235 printf("unfind flash,doest not setevn flash,or unsuppoted flashtype.\nmaybe run setenv flash sst8\n"); 00236 return -1; 00237 }
| char* dupstr | ( | int | ) |
Definition at line 3 of file readline.c.
00005 { 00006 char *r; 00007 00008 r = xmalloc (strlen (s) + 1); 00009 strcpy (r, s); 00010 return (r); 00011 }
| static char* flash_complete | ( | char * | text, | |
| int | state | |||
| ) | const [static] |
Definition at line 152 of file flash.c.
References dupstr(), flash_function.name, and flash_function.next.
00155 { 00156 static int list_index, len; 00157 char *name; 00158 static struct flash_function *pflash; 00159 00160 /* If this is a new word to complete, initialize now. This 00161 includes saving the length of TEXT for efficiency, and 00162 initializing the index variable to 0. */ 00163 if (!state) 00164 { 00165 pflash = flash_func_head; 00166 len = strlen (text); 00167 } 00168 00169 /* Return the next name which partially matches from the 00170 command list. */ 00171 00172 00173 00174 while (pflash && (name = pflash->name)) 00175 { 00176 pflash = pflash->next; 00177 00178 if (strncmp (name, text, len) == 0) 00179 return (dupstr(name)); 00180 } 00181 00182 /* If no names matched, then return NULL. */ 00183 return ((char *)NULL); 00184 00185 }
| static void init_flash_func | ( | void | ) | [static] |
Definition at line 125 of file flash.c.
References begin_flash_func, end_flash_func, flash_functions, flash_function.name, and flash_function.next.
00127 { 00128 int i; 00129 struct flash_function *pflash; 00130 flash_func_head = flash_functions; 00131 flash_func_tail = flash_functions; 00132 00133 for(pflash = flash_functions + 1; pflash->name; pflash++) 00134 { 00135 flash_func_tail->next = pflash; 00136 flash_func_tail = pflash; 00137 } 00138 00139 for(pflash = &begin_flash_func + 1; pflash != &end_flash_func; pflash++) 00140 { 00141 flash_func_tail->next = pflash; 00142 flash_func_tail = pflash; 00143 } 00144 00145 }
| mycmd_init | ( | erase_area | , | |
| cmd_erase_area | , | |||
| "erase_area start end sectorsize" | , | |||
| "erase | sectors, | |||
| \tenv:flash" | ||||
| ) |
| mycmd_init | ( | erase | , | |
| cmd_erase | , | |||
| "erase" | , | |||
| "erase whole | chip, | |||
| \tenv:flash" | ||||
| ) |
| mycmd_init | ( | program | , | |
| cmd_program | , | |||
| "program ramaddr flashaddr size " | , | |||
| "program | address, | |||
| \tenv:flash" | ||||
| ) |
| myconfig_init1 | ( | "flash.type" | , | |
| config_flash_type | , | |||
| CONFIG_S | , | |||
| "flash type" | , | |||
| flash_complete | ||||
| ) |
| struct flash_function begin_flash_func |
Referenced by init_flash_func().
unsigned int code_erase_sst16[] [static] |
Initial value:
tgt_compile( "1:mtc0 v0, $31;\n" "li v0,0xff200000;\n" "sw v1,0x1fc(v0);\n" "li v0,0xbfc05554;\n" "li v1,0xaa;\n" "sh v1,0x5556(v0);\n" "li v1,0x55;\n" "sh v1,0(v0);\n" "li v1,0x80;\n" "sh v1,0x5556(v0);\n" "li v1,0xaa;\n" "sh v1,0x5556(v0);\n" "li v1,0x55;\n" "sh v1,0(v0);\n" "li v1,0x10;\n" "sh v1,0x5556(v0);\n" "li v0,0xff200000;\n" "lw v1,0x1fc(v0);\n" "mfc0 v0, $31;\n" "b 1b;\n" "nop;\n" )
unsigned int code_erase_sst8[] [static] |
Initial value:
tgt_compile( "1:mtc0 v0, $31;\n" "li v0,0xff200000;\n" "sw v1,0x1fc(v0);\n" "li v0,0xbfc02aaa;\n" "li v1,0xaa;\n" "sb v1,0x2aab(v0);\n" "li v1,0x55;\n" "sb v1,0(v0);\n" "li v1,0x80;\n" "sb v1,0x2aab(v0);\n" "li v1,0xaa;\n" "sb v1,0x2aab(v0);\n" "li v1,0x55;\n" "sb v1,0(v0);\n" "li v1,0x10;\n" "sb v1,0x2aab(v0);\n" "li v0,0xff200000;\n" "lw v1,0x1fc(v0);\n" "mfc0 v0, $31;\n" "b 1b;\n" "nop;\n" )
unsigned int code_program_sst16[] [static] |
Initial value:
tgt_compile( "1:li v0,0xbfc05554;\n" "li v1,0xaa\n" "sh v1,0x5556(v0);\n" "li v1,0x55;\n" "sh v1,(v0);\n" "li v1,0xa0\n" "sh v1,0x5556(v0);\n" "lh v0,(a0);\n" "sh v0,(a1);\n" "2:\n" "lh v0,(a1);\n" "lh v1,(a1);\n" "bne v0,v1,2b;\n" "nop;\n" "addiu a0,2;\n" "addiu a1,2;\n" "addiu a2,-2;\n" "bnez a2,1b;\n" "nop;\n" "li ra,0xff200200 ;\n" "jr ra ;\n" "nop;\n" )
unsigned int code_program_sst8[] [static] |
Initial value:
tgt_compile( "1:li v0,0xbfc02aaa;\n" "li v1,0xaa\n" "sb v1,0x2aab(v0);\n" "li v1,0x55;\n" "sb v1,(v0);\n" "li v1,0xa0\n" "sb v1,0x2aab(v0);\n" "lb v0,(a0);\n" "sb v0,(a1);\n" "2:\n" "lb v0,(a1);\n" "lb v1,(a1);\n" "bne v0,v1,2b;\n" "nop;\n" "addiu a0,1;\n" "addiu a1,1;\n" "addiu a2,-1;\n" "bnez a2,1b;\n" "nop;\n" "li ra,0xff200200 ;\n" "jr ra ;\n" "nop;\n" )
char* config_flash_type = "sst8" [static] |
| struct flash_function end_flash_func |
Referenced by init_flash_func().
| struct flash_function* flash_func_head |
| struct flash_function* flash_func_tail |
struct flash_function flash_functions[] [static] |
Initial value:
{
{"sst16",code_program_sst16,sizeof(code_program_sst16),code_erase_sst16},
{"sst8",code_program_sst8,sizeof(code_program_sst8),code_erase_sst8},
{0}
}
Definition at line 114 of file flash.c.
Referenced by init_flash_func().
1.5.6