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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * librm: a library for interfacing to real-mode code
  3. *
  4. * Michael Brown <mbrown@fensystems.co.uk>
  5. *
  6. */
  7. #ifdef KEEP_IT_REAL
  8. /* Build a null object under -DKEEP_IT_REAL */
  9. #else
  10. #include <stdint.h>
  11. #include <librm.h>
  12. /*
  13. * This file provides functions for managing librm.
  14. *
  15. */
  16. /*
  17. * Allocate space on the real-mode stack and copy data there.
  18. *
  19. */
  20. uint16_t copy_to_rm_stack ( void *data, size_t size ) {
  21. #ifdef DEBUG_LIBRM
  22. if ( rm_sp <= size ) {
  23. printf ( "librm: out of space in RM stack\n" );
  24. lockup();
  25. }
  26. #endif
  27. rm_sp -= size;
  28. copy_to_real ( rm_ss, rm_sp, data, size );
  29. return rm_sp;
  30. };
  31. /*
  32. * Deallocate space on the real-mode stack, optionally copying back
  33. * data.
  34. *
  35. */
  36. void remove_from_rm_stack ( void *data, size_t size ) {
  37. if ( data ) {
  38. copy_from_real ( data, rm_ss, rm_sp, size );
  39. }
  40. rm_sp += size;
  41. };
  42. #endif /* KEEP_IT_REAL */