Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

segoff.h 952B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Segment:offset types and macros
  3. *
  4. * Initially written by Michael Brown (mcb30).
  5. */
  6. #ifndef SEGOFF_H
  7. #define SEGOFF_H
  8. #include <stdint.h>
  9. #include <osdep.h>
  10. #include <io.h>
  11. /* Segment:offset structure. Note that the order within the structure
  12. * is offset:segment.
  13. */
  14. typedef struct {
  15. uint16_t offset;
  16. uint16_t segment;
  17. } segoff_t;
  18. /* Macros for converting from virtual to segment:offset addresses,
  19. * when we don't actually care which of the many isomorphic results we
  20. * get.
  21. */
  22. #ifdef DEBUG_SEGMENT
  23. uint16_t SEGMENT ( const void * const ptr ) {
  24. uint32_t phys = virt_to_phys ( ptr );
  25. if ( phys > 0xfffff ) {
  26. printf ( "FATAL ERROR: segment address out of range\n" );
  27. }
  28. return phys >> 4;
  29. }
  30. #else
  31. #define SEGMENT(x) ( virt_to_phys ( x ) >> 4 )
  32. #endif
  33. #define OFFSET(x) ( virt_to_phys ( x ) & 0xf )
  34. #define SEGOFF(x) { OFFSET(x), SEGMENT(x) }
  35. #define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )
  36. #endif /* SEGOFF_H */