VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/Etherboot-src/arch/i386/include/segoff.h@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette