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.

bitbash.h 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _GPXE_BITBASH_H
  2. #define _GPXE_BITBASH_H
  3. /** @file
  4. *
  5. * Bit-bashing interfaces
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. struct bit_basher;
  10. /** Bit-bashing operations */
  11. struct bit_basher_operations {
  12. /**
  13. * Set/clear output bit
  14. *
  15. * @v basher Bit-bashing interface
  16. * @v bit_id Bit number
  17. * @v data Value to write
  18. *
  19. * @c data will be 0 if a logic 0 should be written (i.e. the
  20. * bit should be cleared), or -1UL if a logic 1 should be
  21. * written (i.e. the bit should be set). This is done so that
  22. * the method may simply binary-AND @c data with the
  23. * appropriate bit mask.
  24. */
  25. void ( * write ) ( struct bit_basher *basher, unsigned int bit_id,
  26. unsigned long data );
  27. /**
  28. * Read input bit
  29. *
  30. * @v basher Bit-bashing interface
  31. * @v bit_id Bit number
  32. * @ret zero Input is a logic 0
  33. * @ret non-zero Input is a logic 1
  34. */
  35. int ( * read ) ( struct bit_basher *basher, unsigned int bit_id );
  36. };
  37. /** A bit-bashing interface */
  38. struct bit_basher {
  39. /** Bit-bashing operations */
  40. struct bit_basher_operations *op;
  41. };
  42. extern void write_bit ( struct bit_basher *basher, unsigned int bit_id,
  43. unsigned long data );
  44. extern int read_bit ( struct bit_basher *basher, unsigned int bit_id );
  45. #endif /* _GPXE_BITBASH_H */