Sony PlayStation2 Study
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.2 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /**
  2. * @file
  3. * Packet library functions.
  4. */
  5. #ifndef __PACKET_H__
  6. #define __PACKET_H__
  7. #include <tamtypes.h>
  8. /** Maximum number allowed, but each channel has its own limitations. */
  9. #define QWC_MAX 65535
  10. #define PACKET_NORMAL 0x00
  11. #define PACKET_UCAB 0x01
  12. #define PACKET_SPR 0x02
  13. /**
  14. * Dmatags use qwc for the number of qwords for they handle.
  15. *
  16. * The dma channel QWC register uses it as the total number of qwords that
  17. * are being sent at a time.
  18. */
  19. typedef struct {
  20. u32 qwords;
  21. u16 qwc;
  22. u16 type;
  23. qword_t *data __attribute__((aligned(64)));
  24. } packet_t;
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /** Allocate a new packet for use, size in quadwords. */
  29. packet_t *packet_init(int qwords, int type);
  30. /** Reset the packet quadword counter and zero out data. */
  31. void packet_reset(packet_t *packet);
  32. /** Free the space allocated by packet. */
  33. void packet_free(packet_t *packet);
  34. /** Advances the qwc and returns the current qword count. */
  35. qword_t *packet_increment_qwc(packet_t *packet, int num);
  36. /** For those that like getters and setters */
  37. static inline qword_t *packet_get_qword(packet_t *packet)
  38. {
  39. return packet->data;
  40. }
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif /* __PACKET_H__ */