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 */
44 /* Reload other segment registers and adjust %esp */
45 movl $PHYSICAL_DS, %eax
53 /* Restore registers and flags, and return */
59 /****************************************************************************
60 * _phys_to_virt (flat physical addressing)
62 * Switch from flat physical to virtual addresses. %esp is adjusted
63 * to a virtual value. Segment registers are set to virtual
64 * selectors. All other registers are preserved. Flags are
67 * Note that this depends on the GDT already being correctly set up
68 * (e.g. by a call to run_here()).
72 ****************************************************************************
76 /* Preserve registers and flags */
81 /* Switch to virtual code segment */
84 /* Reload data segment registers */
85 movl $VIRTUAL_DS, %eax
91 /* Reload stack segment and adjust %esp */
92 movl virt_offset, %ebp
96 /* Change the return address to a virtual address */
99 /* Restore registers and flags, and return */