byte_access.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef BYTE_ACCESS_H
  2. #define BYTE_ACCESS_H
  3. /* Conversion routines for accessing
  4. * integers (short, long, long long)
  5. * from a byte array.
  6. *
  7. * The viper (gcc I assume) does not
  8. * allow for non frame aligned access.
  9. * From what I can tell, it clamps
  10. * the address to the nearest frame
  11. * depending on the type you're accessing
  12. * and reads starting from this position.
  13. * This leads to misframed data being
  14. * read if you dereference it from a
  15. * non framed position. I would
  16. * also assume writing has the same problem.
  17. *
  18. * These functions will read or write
  19. * short, long or long long (unsigned)
  20. * integers starting at the pointer location.
  21. *
  22. * Storage is least significant byte first.
  23. * For example:
  24. * _uliw(p, 67305985) would write:
  25. *
  26. * p[0] = 0x01
  27. * p[1] = 0x02
  28. * p[2] = 0x03
  29. * p[3] = 0x04
  30. *
  31. * _uli(p) would return 67305985
  32. *
  33. */
  34. unsigned short int _usi(void *p);
  35. unsigned long int _uli(void *p);
  36. unsigned long long int _ulli(void *p);
  37. void _usiw(void *p, unsigned short int usi);
  38. void _uliw(void *p, unsigned long int uli);
  39. void _ulliw(void *p, unsigned long long int ulli);
  40. #endif