|
|
1.1 root 1: /*
2: * Copyright (c) 1995 The University of Utah and
3: * the Computer Systems Laboratory at the University of Utah (CSL).
4: * All rights reserved.
5: *
6: * Permission to use, copy, modify and distribute this software is hereby
7: * granted provided that (1) source code retains these copyright, permission,
8: * and disclaimer notices, and (2) redistributions including binaries
9: * reproduce the notices in supporting documentation, and (3) all advertising
10: * materials mentioning features or use of this software display the following
11: * acknowledgement: ``This product includes software developed by the
12: * Computer Systems Laboratory at the University of Utah.''
13: *
14: * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
15: * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
16: * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17: *
18: * CSL requests users of this software to return to [email protected] any
19: * improvements that they make and grant CSL redistribution rights.
20: *
21: * Author: Bryan Ford, University of Utah CSL
22: */
23:
24: #include <mach/machine/asm.h>
25: #include <mach/machine/eflags.h>
26:
27: #include "trap.h"
28: #include "i386_asm.h"
29: #include "pc_asm.h"
30: #include "trap_asm.h"
31:
32: .text
33: .globl rv86_real_int_asm
34: rv86_real_int_asm:
35:
36: /* Stash our protected-mode stack pointer. */
37: movl %esp,EXT(real_tss)+TSS_ESP0
38:
39: /* Load the linear/physical-address data segment into ES,
40: for easy access to real-mode memory. */
41: movl $LINEAR_DS,%edx
42: movw %dx,%es
43:
44: /* Find the physical address of the real-mode interrupt stack (es:ebx).
45: A 6-byte stack frame has already been allocated on it. */
46: movl EXT(rv86_usp)+4,%ebx
47: shll $4,%ebx
48: addl EXT(rv86_usp),%ebx
49:
50: /* Store the magic return pointer into the real-mode interrupt stack frame. */
51: movl EXT(rv86_rp),%edx
52: movl %edx,%es:(%ebx)
53: movw RCD_FLAGS(%eax),%dx
54: movw %dx,%es:4(%ebx)
55:
56: /* Find the address of the real mode interrupt vector (es:esi). */
57: shll $2,%esi
58:
59: /* Build the v86 trap frame. */
60: xorl %edx,%edx
61: movw RCD_GS(%eax),%dx
62: pushl %edx
63: movw RCD_FS(%eax),%dx
64: pushl %edx
65: movw RCD_DS(%eax),%dx
66: pushl %edx
67: movw RCD_ES(%eax),%dx
68: pushl %edx
69: pushl EXT(rv86_usp)+4
70: pushl EXT(rv86_usp)
71: movl $EFL_VM+EFL_IOPL_USER,%ecx
72: orw RCD_FLAGS(%eax),%cx
73: andl $-1-EFL_IF-EFL_TF,%ecx
74: pushl %ecx
75: movw %es:2(%esi),%edx
76: pushl %edx
77: movw %es:(%esi),%edx
78: pushl %edx
79:
80: /* Load the requested register state. */
81: movl RCD_EDI(%eax),%edi
82: movl RCD_ESI(%eax),%esi
83: movl RCD_EBP(%eax),%ebp
84: movl RCD_EBX(%eax),%ebx
85: movl RCD_EDX(%eax),%edx
86: movl RCD_ECX(%eax),%ecx
87: movl RCD_EAX(%eax),%eax
88:
89: /* Drop into v86 mode. */
90: iret
91:
92: ENTRY(rv86_return)
93:
94: /* Restore the kernel segment registers. */
95: movw %ss,%ax
96: movw %ax,%ds
97: movw %ax,%es
98:
99: /* Retrieve the real_call_data pointer from rv86_real_int_asm's stack frame. */
100: movl TR_V86SIZE+4(%esp),%eax
101:
102: /* Stash the final register state. */
103: movl TR_EDI(%esp),%edx; movl %edx,RCD_EDI(%eax)
104: movl TR_ESI(%esp),%edx; movl %edx,RCD_ESI(%eax)
105: movl TR_EBP(%esp),%edx; movl %edx,RCD_EBP(%eax)
106: movl TR_EBX(%esp),%edx; movl %edx,RCD_EBX(%eax)
107: movl TR_EDX(%esp),%edx; movl %edx,RCD_EDX(%eax)
108: movl TR_ECX(%esp),%edx; movl %edx,RCD_ECX(%eax)
109: movl TR_EAX(%esp),%edx; movl %edx,RCD_EAX(%eax)
110: movl TR_EFLAGS(%esp),%edx; movw %dx,RCD_FLAGS(%eax)
111: movl TR_V86_ES(%esp),%edx; movw %dx,RCD_ES(%eax)
112: movl TR_V86_DS(%esp),%edx; movw %dx,RCD_DS(%eax)
113: movl TR_V86_FS(%esp),%edx; movw %dx,RCD_FS(%eax)
114: movl TR_V86_GS(%esp),%edx; movw %dx,RCD_GS(%eax)
115:
116: /* Return from the call to rv86_real_int_asm. */
117: lea TR_V86SIZE(%esp),%esp
118: ret
119:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.