2 * Functions to support the virtual addressing method of relocation
7 FILE_LICENCE ( GPL2_OR_LATER )
15 /****************************************************************************
16 * _virt_to_phys (virtual addressing)
18 * Switch from virtual to flat physical addresses. %esp is adjusted
19 * to a physical value. Segment registers are set to flat physical
20 * selectors. All other registers are preserved. Flags are
25 ****************************************************************************
29 /* Preserve registers and flags */
34 /* Change return address to a physical address */
35 movl virt_offset, %ebp
38 /* Switch to physical code segment */
45 /* Reload other segment registers and adjust %esp */
46 movl $PHYSICAL_DS, %eax
54 /* Restore registers and flags, and return */
60 /****************************************************************************
61 * _phys_to_virt (flat physical addressing)
63 * Switch from flat physical to virtual addresses. %esp is adjusted
64 * to a virtual value. Segment registers are set to virtual
65 * selectors. All other registers are preserved. Flags are
70 ****************************************************************************
74 /* Preserve registers and flags */
79 /* Switch to virtual code segment */
83 /* Reload data segment registers */
84 movl $VIRTUAL_DS, %eax
90 /* Reload stack segment and adjust %esp */
91 movl virt_offset, %ebp
95 /* Change the return address to a virtual address */
98 /* Restore registers and flags, and return */
104 /****************************************************************************
105 * _intr_to_virt (virtual code segment, virtual or physical stack segment)
107 * Switch from virtual code segment with either a virtual or physical
108 * stack segment to using virtual addressing. %esp is adjusted if
109 * necessary to a virtual value. Segment registers are set to virtual
110 * selectors. All other registers are preserved. Flags are
115 ****************************************************************************
119 /* Preserve registers and flags */
124 /* Check whether stack segment is physical or virtual */
126 cmpw $VIRTUAL_DS, %ax
127 movl $VIRTUAL_DS, %eax
129 /* Reload data segment registers */
135 /* Reload stack segment and adjust %esp if necessary */
137 movl virt_offset, %ebp
141 /* Restore registers and flags, and return */