Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. FILE_LICENCE ( GPL2_OR_LATER );
  19. #include <gpxe/bitbash.h>
  20. /** @file
  21. *
  22. * Bit-bashing interfaces
  23. *
  24. */
  25. /**
  26. * Set/clear output bit
  27. *
  28. * @v basher Bit-bashing interface
  29. * @v bit_id Bit number
  30. * @v data Value to write
  31. *
  32. * If @c data is 0, a logic 0 will be written. If @c data is
  33. * non-zero, a logic 1 will be written.
  34. */
  35. void write_bit ( struct bit_basher *basher, unsigned int bit_id,
  36. unsigned long data ) {
  37. basher->op->write ( basher, bit_id, ( data ? -1UL : 0 ) );
  38. }
  39. /**
  40. * Read input bit
  41. *
  42. * @v basher Bit-bashing interface
  43. * @v bit_id Bit number
  44. * @ret data Value read
  45. *
  46. * @c data will always be either 0 or -1UL. The idea is that the
  47. * caller can simply binary-AND the returned value with whatever mask
  48. * it needs to apply.
  49. */
  50. int read_bit ( struct bit_basher *basher, unsigned int bit_id ) {
  51. return ( basher->op->read ( basher, bit_id ) ? -1UL : 0 );
  52. }