Subversion Repositories pentevo

Rev

Rev 908 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  1. #ifndef _IHEX_C_
  2. #define _IHEX_C_
  3.  
  4. // max length of bytes in ihex is 255, thus 512+ chars maximum length. So the value below is sane.
  5. #define IHEX_BUF_SZ (1024)
  6.  
  7. // maximum sane length of ihex line:
  8. //   1 : semicolon
  9. //   2 : byte length
  10. //   4 : word address
  11. //   2 : byte type
  12. // 510 : hex string of max 255 bytes
  13. //   2 : byte checksum
  14. //   2 : newlines
  15. // =523 bytes
  16. #define MAX_IHEX_LENGTH (523)
  17.  
  18. // types of IHEX recors
  19. #define IHEX_TYPE_DATA     (0)
  20. #define IHEX_TYPE_EOF      (1)
  21. #define IHEX_TYPE_SEGADDR  (2)
  22. #define IHEX_TYPE_STARTSEG (3)
  23. #define IHEX_TYPE_ELINADDR (4)
  24. #define IHEX_TYPE_STARTLIN (5)
  25.  
  26.  
  27.  
  28. // parses intelhex file into the memory area so that low_bound<=every byte's address<high_bound.
  29. //
  30. // when a byte is put in the buffer, a 'disp' value is added to its address to
  31. // make index into 'buffer' array.
  32. //
  33. // it is assumed that low_bound+disp .. high_bound+disp-1 are all valid indices
  34. // into the 'buffer' array
  35. //
  36. // unspecified bytes are filled with 'fill' value.
  37. //
  38. // returns zero in case of any errors, otherwise non-zero.
  39. //
  40. // detected errors:
  41. // - any of file errors
  42. // - intelhex format errors (incl. unknown record types)
  43. // - addressing errors (any byte from intelhex goes outside bounds)
  44. // an appropriate error message is printed into stderr
  45. int parse_ihex(uint8_t * buffer, int32_t disp, int32_t low_bound, int32_t high_bound, uint8_t fill, char * filename);
  46.  
  47.  
  48. // writes intelhex from memory buffer. addresses are from low_bound to high_bound,
  49. // indices in the buffer are from low_bound+disp to high_bound+disp.
  50. //
  51. // returns zero in case of any errors, otherwise non-zero.
  52. int write_ihex(uint8_t * buffer, int32_t disp, int32_t low_bound, int32_t high_bound, char * filename);
  53.  
  54. #endif // _IHEX_C_
  55.  
  56.