4 /* Segment selectors as used in our protected-mode GDTs.
6 * Don't change these unless you really know what you're doing.
9 #define VIRTUAL_CS 0x08
10 #define VIRTUAL_DS 0x10
11 #define PHYSICAL_CS 0x18
12 #define PHYSICAL_DS 0x20
25 * Without -DKEEP_IT_REAL, we are in 32-bit protected mode with a
26 * fixed link address but an unknown physical start address. Our GDT
27 * sets up code and data segments with an offset of virt_offset, so
28 * that link-time addresses can still work.
32 /* Variables in virtaddr.S */
33 extern unsigned long virt_offset;
36 * Convert between virtual and physical addresses
39 static inline unsigned long virt_to_phys ( volatile const void *virt_addr ) {
40 return ( ( unsigned long ) virt_addr ) + virt_offset;
43 static inline void * phys_to_virt ( unsigned long phys_addr ) {
44 return ( void * ) ( phys_addr - virt_offset );
47 #else /* KEEP_IT_REAL */
52 * With -DKEEP_IT_REAL, we are in 16-bit real mode with fixed link
53 * addresses and a segmented memory model. We have separate code and
56 * Because we may be called in 16-bit protected mode (damn PXE spec),
57 * we cannot simply assume that physical = segment * 16 + offset.
58 * Instead, we have to look up the physical start address of the
59 * segment in the !PXE structure. We have to assume that
60 * virt_to_phys() is called only on pointers within the data segment,
61 * because nothing passes segment information to us.
63 * We don't implement phys_to_virt at all, because there will be many
64 * addresses that simply cannot be reached via a virtual address when
65 * the virtual address space is limited to 64kB!
68 static inline unsigned long virt_to_phys ( volatile const void *virt_addr ) {
69 /* Cheat: just for now, do the segment*16+offset calculation */
72 __asm__ ( "movw %%ds, %%ax" : "=a" ( ds ) : );
73 return ( 16 * ds + ( ( unsigned long ) virt_addr ) );
76 /* Define it as a deprecated function so that we get compile-time
77 * warnings, rather than just the link-time errors.
79 extern void * phys_to_virt ( unsigned long phys_addr )
80 __attribute__ ((deprecated));
82 #endif /* KEEP_IT_REAL */
86 #endif /* VIRTADDR_H */