/*********************************************************************** * * Function: cmd_peek * * Purpose: Peek command * * Processing: * Parse the string elements for the peek command and display the * peeked value. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was processed, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_peek(void) { UNS_32 newaddr, newwidth; /* If only 1 parsed command, then print at current address and width */ if (parse_get_entry_count() > 1) { /* Get address */ newaddr = cmd_get_field_val(1); /* Width */ newwidth = last_width; if (parse_get_entry_count() >= 3) { newwidth = cmd_get_field_val(2); if (!((newwidth == 1) || (newwidth == 2) || (newwidth == 4))) { newwidth = 1; } } last_addr = newaddr; last_width = newwidth; } /* Based on width, limit address start */ last_addr = last_addr & ~(last_width - 1); /* Dump data */ hex_dump(last_addr, last_width, 1); return TRUE; }
/*********************************************************************** * * Function: cmd_fill * * Purpose: Fill command * * Processing: * Parse the string elements for the fill command and fill the * requested data range with data. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was processed, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_fill(void) { UNS_32 addr, width, bytes, fillval; /* Get address */ addr = cmd_get_field_val(1); /* Number of bytes */ bytes = cmd_get_field_val(2); /* Hex fill value */ fillval = cmd_get_field_val(3); /* Width */ width = cmd_get_field_val(4); if (!((width == 1) || (width == 2) || (width == 4))) { width = 1; } /* Limit number of bytes based on addressing size */ bytes = bytes & ~(width - 1); addr = addr & ~(width - 1); if (width == 1) { UNS_8 *faddr = (UNS_8 *) addr; while (bytes > 0) { *faddr = (UNS_8) fillval; faddr++; bytes--; } } else if (width == 2) { UNS_16 *faddr = (UNS_16 *) addr; while (bytes > 0) { *faddr = (UNS_16) fillval; faddr++; bytes -= 2; } } else { UNS_32 *faddr = (UNS_32 *) addr; while (bytes > 0) { *faddr = fillval; faddr++; bytes -= 4; } } return TRUE; }
/*********************************************************************** * * Function: cmd_bwtest * * Purpose: Performs memory bandwidth tests * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was good, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_bwtest(void) { UNS_32 hexaddr1, hexaddr2, bytes, loops; /* Get arguments */ hexaddr1 = cmd_get_field_val(1); hexaddr2 = cmd_get_field_val(2); bytes = cmd_get_field_val(3); loops = cmd_get_field_val(4); bw_test(hexaddr1, hexaddr2, bytes, loops); return TRUE; }
/*********************************************************************** * * Function: cmd_clock * * Purpose: Clock command * * Processing: * Parse the string elements for the clock command and sets the * new clock value. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was processed, otherwise FALSE * * Notes: May not work in DDR systems. * **********************************************************************/ BOOL_32 cmd_clock(void) { UNS_32 freqr, armclk, hclkdiv, pclkdiv; UNS_8 dclk [32]; BOOL_32 processed = TRUE; /* Get arguments */ armclk = cmd_get_field_val(1); hclkdiv = cmd_get_field_val(2); pclkdiv = cmd_get_field_val(3); if (!((hclkdiv == 1) || (hclkdiv == 2) || (hclkdiv == 4))) { processed = FALSE; } if ((pclkdiv < 1) || (pclkdiv > 32)) { processed = FALSE; } if ((armclk < 33) || (armclk > 550)) { term_dat_out_crlf(clockerr_msg); processed = FALSE; } else { armclk = armclk * 1000 * 1000; } if (processed == TRUE) { sys_saved_data.clksetup.armclk = armclk; sys_saved_data.clksetup.hclkdiv = hclkdiv; sys_saved_data.clksetup.pclkdiv = pclkdiv; freqr = clock_adjust(); if (freqr == 0) { term_dat_out_crlf(clockbad_msg); } else { term_dat_out(clock_msg); str_makedec(dclk, freqr); term_dat_out_crlf(dclk); sys_save(&sys_saved_data); } } return TRUE; }
/*********************************************************************** * * Function: cmd_dump * * Purpose: Dump command * * Processing: * Parse the string elements for the dump command and display the * dumped values. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was processed, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_dump(void) { UNS_32 newaddr, newwidth, newtrans; /* If only 1 parsed command, then print at current address and width */ if (parse_get_entry_count() > 1) { newaddr = dump_addr; newwidth = dump_width; newtrans = dump_trans; /* Get address */ newaddr = cmd_get_field_val(1); /* Convert decimal value to width */ if (parse_get_entry_count() >= 3) { newtrans = cmd_get_field_val(2); } if (parse_get_entry_count() >= 4) { newwidth = cmd_get_field_val(3); if (!((newwidth == 1) || (newwidth == 2) || (newwidth == 4))) { newwidth = 1; } } dump_addr = newaddr; dump_width = newwidth; dump_trans = newtrans; /* Limit dump size to 1024 bytes */ if ((dump_trans * dump_width) > 1024) { dump_trans = dump_trans / dump_width; } } /* Based on width, limit address start */ dump_addr = dump_addr & ~(dump_width - 1); /* Dump data and increment address */ hex_dump(dump_addr, dump_width, dump_trans); dump_addr = dump_addr + (dump_width * dump_trans); return TRUE; }
/*********************************************************************** * * Function: cmd_comp * * Purpose: Compare data between 2 regions * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was good, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_comp(void) { UNS_8 *ha1, *ha2; UNS_32 hexaddr1, hexaddr2, bytes; UNS_8 str [16]; BOOL_32 mtch; /* Get arguments */ hexaddr1 = cmd_get_field_val(1); hexaddr2 = cmd_get_field_val(2); bytes = cmd_get_field_val(3); mtch = TRUE; ha1 = (UNS_8 *) hexaddr1; ha2 = (UNS_8 *) hexaddr2; term_dat_out(scomp_msg); while (bytes > 0) { if (*ha1 != *ha2) { mtch = FALSE; bytes = 0; } else { bytes--; ha1++; ha2++; } } if (mtch == TRUE) { term_dat_out_crlf(ssame_msg); } else { term_dat_out(snsame_msg); str_makehex(str, (UNS_32) ha1, 8); term_dat_out(str); term_dat_out(and); str_makehex(str, (UNS_32) ha2, 8); term_dat_out_crlf(str); } return TRUE; }
/*********************************************************************** * * Function: cmd_prompt * * Purpose: prompt command * * Processing: * Parse the string elements for the prompt command and set the new * prompt and timeout values. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was processed, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_prompt(void) { UNS_8 tmpprmpt [16]; UNS_32 to; /* Get new prompt */ str_copy(tmpprmpt, (void *) cmd_get_field_val(1)); /* Get new timeout */ to = cmd_get_field_val(2); str_copy(syscfg.prmpt, tmpprmpt); syscfg.prmpt_to = to; key_prompt_set(syscfg.prmpt); cfg_save(&syscfg); return TRUE; }
/*********************************************************************** * * Function: cmd_nrsv * * Purpose: Reserve a range of blocks for WinCE * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Always returns TRUE * * Notes: None * **********************************************************************/ BOOL_32 cmd_nrsv(void) { UNS_32 lblock, fblock, nblks; /* Get arguments */ fblock = cmd_get_field_val(1); nblks = cmd_get_field_val(2); /* Limit range outside of boot blocks */ if (fblock < BL_NUM_BLOCKS) { /* Boot blocks are already marked as reserved, so skip them */ /* Get last block to mark */ lblock = (fblock + nblks) - 1; if (lblock < BL_NUM_BLOCKS) { nblks = 0; } else { fblock = 25; nblks = (lblock - fblock) + 1; } } /* Mark all of the blocks, skipping bad blocks */ while (nblks > 0) { if (flash_reserve_block(fblock) == FALSE) { term_dat_out_crlf(blkmkerr_msg); nblks = 0; } else { fblock++; nblks--; } } return TRUE; }
/*********************************************************************** * * Function: cmd_memtst * * Purpose: Performs memory tests * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was good, otherwise FALSE * * Notes: * memtst [hex address][bytes to test][1, 2, or 4 bytes][0(all) - 5][iterations] * **********************************************************************/ static BOOL_32 cmd_memtst(void) { UNS_32 iters, hexaddr, bytes, width, tstnum; /* Get arguments */ hexaddr = cmd_get_field_val(1); bytes = cmd_get_field_val(2); width = cmd_get_field_val(3); tstnum = cmd_get_field_val(4); iters = cmd_get_field_val(5); if (tstnum == 0) { tstnum = MTST_ALL; } else { tstnum--; } memory_test(hexaddr, bytes, width, tstnum, iters); return TRUE; }
/*********************************************************************** * * Function: cmd_poke * * Purpose: Poke command * * Processing: * Parse the string elements for the poke command and update * requested memory. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was processed, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_poke(void) { UNS_32 addr, width, fillval; /* Get address */ addr = cmd_get_field_val(1); /* Hex fill value */ fillval = cmd_get_field_val(2); /* Width */ width = cmd_get_field_val(3); if (!((width == 1) || (width == 2) || (width == 4))) { width = 1; } /* Limit addressing size */ addr = addr & ~(width - 1); if (width == 1) { UNS_8 *faddr = (UNS_8 *) addr; *faddr = (UNS_8) fillval; } else if (width == 2) { UNS_16 *faddr = (UNS_16 *) addr; *faddr = (UNS_16) fillval; } else { UNS_32 *faddr = (UNS_32 *) addr; *faddr = fillval; } return TRUE; }
/*********************************************************************** * * Function: cmd_copy * * Purpose: Copy data between 2 regions * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was good, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_copy(void) { UNS_8 *ha1, *ha2; UNS_32 hexaddr1, hexaddr2, bytes; /* Get arguments */ hexaddr1 = cmd_get_field_val(1); hexaddr2 = cmd_get_field_val(2); bytes = cmd_get_field_val(3); ha1 = (UNS_8 *) hexaddr1; ha2 = (UNS_8 *) hexaddr2; while (bytes > 0) { *ha2 = *ha1; ha1++; ha2++; bytes--; } term_dat_out_crlf(scp_msg); return TRUE; }
/*********************************************************************** * * Function: cmd_baud * * Purpose: Sets new baud rate * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the baud rate change was good, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_baud(void) { UNS_32 nb; nb = cmd_get_field_val(1); if ((nb == 115200) || (nb == 57600) || (nb == 38400) || (nb == 19200) || (nb == 9600)) { term_setbaud(nb); syscfg.baudrate = nb; cfg_save(&syscfg); } return TRUE; }