2 * Segment:offset types and macros
4 * Initially written by Michael Brown (mcb30).
13 /* Segment:offset structure. Note that the order within the structure
22 typedef segoff_t SEGOFF16_t
;
24 /* Macros for converting from virtual to segment:offset addresses,
25 * when we don't actually care which of the many isomorphic results we
29 uint16_t SEGMENT ( const void * const ptr
) {
30 uint32_t phys
= virt_to_phys ( ptr
);
31 if ( phys
> 0xfffff ) {
32 printf ( "FATAL ERROR: segment address out of range\n" );
37 #define SEGMENT(x) ( virt_to_phys ( x ) >> 4 )
39 #define OFFSET(x) ( virt_to_phys ( x ) & 0xf )
40 #define SEGOFF(x) { OFFSET(x), SEGMENT(x) }
41 #define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )