4 * Copyright (C) 2002, 2003, 2004 ReactOS Team
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; see the file COPYING.LIB.
18 * If not, write to the Free Software Foundation,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "internal/v86m.h"
27 /* PRIVATE FUNCTIONS **********************************************************/
30 IntInt10AllocateBuffer(
38 PEPROCESS CallingProcess
;
39 PEPROCESS PrevAttachedProcess
;
41 DPRINT("IntInt10AllocateBuffer\n");
43 IntAttachToCSRSS(&CallingProcess
, &PrevAttachedProcess
);
45 MemoryAddress
= (PVOID
)0x20000;
46 Status
= ZwAllocateVirtualMemory(NtCurrentProcess(), &MemoryAddress
, 0,
47 Length
, MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
49 if (!NT_SUCCESS(Status
))
51 DPRINT("- ZwAllocateVirtualMemory failed\n");
52 IntDetachFromCSRSS(&CallingProcess
, &PrevAttachedProcess
);
53 return ERROR_NOT_ENOUGH_MEMORY
;
56 if (MemoryAddress
> (PVOID
)(0x100000 - *Length
))
58 ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress
, Length
,
60 DPRINT("- Unacceptable memory allocated\n");
61 IntDetachFromCSRSS(&CallingProcess
, &PrevAttachedProcess
);
62 return ERROR_NOT_ENOUGH_MEMORY
;
65 *Seg
= (ULONG
)MemoryAddress
>> 4;
66 *Off
= (ULONG
)MemoryAddress
& 0xF;
68 DPRINT("- Segment: %x\n", (ULONG
)MemoryAddress
>> 4);
69 DPRINT("- Offset: %x\n", (ULONG
)MemoryAddress
& 0xF);
70 DPRINT("- Length: %x\n", *Length
);
72 IntDetachFromCSRSS(&CallingProcess
, &PrevAttachedProcess
);
83 PVOID MemoryAddress
= (PVOID
)((Seg
<< 4) | Off
);
85 PEPROCESS CallingProcess
;
86 PEPROCESS PrevAttachedProcess
;
88 DPRINT("IntInt10FreeBuffer\n");
89 DPRINT("- Segment: %x\n", Seg
);
90 DPRINT("- Offset: %x\n", Off
);
92 IntAttachToCSRSS(&CallingProcess
, &PrevAttachedProcess
);
93 Status
= ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress
, 0,
95 IntDetachFromCSRSS(&CallingProcess
, &PrevAttachedProcess
);
108 PEPROCESS CallingProcess
;
109 PEPROCESS PrevAttachedProcess
;
111 DPRINT("IntInt10ReadMemory\n");
112 DPRINT("- Segment: %x\n", Seg
);
113 DPRINT("- Offset: %x\n", Off
);
114 DPRINT("- Buffer: %x\n", Buffer
);
115 DPRINT("- Length: %x\n", Length
);
117 IntAttachToCSRSS(&CallingProcess
, &PrevAttachedProcess
);
118 RtlCopyMemory(Buffer
, (PVOID
)((Seg
<< 4) | Off
), Length
);
119 IntDetachFromCSRSS(&CallingProcess
, &PrevAttachedProcess
);
132 PEPROCESS CallingProcess
;
133 PEPROCESS PrevAttachedProcess
;
135 DPRINT("IntInt10WriteMemory\n");
136 DPRINT("- Segment: %x\n", Seg
);
137 DPRINT("- Offset: %x\n", Off
);
138 DPRINT("- Buffer: %x\n", Buffer
);
139 DPRINT("- Length: %x\n", Length
);
141 IntAttachToCSRSS(&CallingProcess
, &PrevAttachedProcess
);
142 RtlCopyMemory((PVOID
)((Seg
<< 4) | Off
), Buffer
, Length
);
143 IntDetachFromCSRSS(&CallingProcess
, &PrevAttachedProcess
);
151 IN OUT PINT10_BIOS_ARGUMENTS BiosArguments
)
153 KV86M_REGISTERS Regs
;
155 PEPROCESS CallingProcess
;
156 PEPROCESS PrevAttachedProcess
;
158 DPRINT("IntInt10CallBios\n");
160 IntAttachToCSRSS(&CallingProcess
, &PrevAttachedProcess
);
162 memset(&Regs
, 0, sizeof(Regs
));
163 DPRINT("- Input register Eax: %x\n", BiosArguments
->Eax
);
164 Regs
.Eax
= BiosArguments
->Eax
;
165 DPRINT("- Input register Ebx: %x\n", BiosArguments
->Ebx
);
166 Regs
.Ebx
= BiosArguments
->Ebx
;
167 DPRINT("- Input register Ecx: %x\n", BiosArguments
->Ecx
);
168 Regs
.Ecx
= BiosArguments
->Ecx
;
169 DPRINT("- Input register Edx: %x\n", BiosArguments
->Edx
);
170 Regs
.Edx
= BiosArguments
->Edx
;
171 DPRINT("- Input register Esi: %x\n", BiosArguments
->Esi
);
172 Regs
.Esi
= BiosArguments
->Esi
;
173 DPRINT("- Input register Edi: %x\n", BiosArguments
->Edi
);
174 Regs
.Edi
= BiosArguments
->Edi
;
175 DPRINT("- Input register Ebp: %x\n", BiosArguments
->Ebp
);
176 Regs
.Ebp
= BiosArguments
->Ebp
;
177 DPRINT("- Input register SegDs: %x\n", BiosArguments
->SegDs
);
178 Regs
.Ds
= BiosArguments
->SegDs
;
179 DPRINT("- Input register SegEs: %x\n", BiosArguments
->SegEs
);
180 Regs
.Es
= BiosArguments
->SegEs
;
181 Status
= Ke386CallBios(0x10, &Regs
);
182 BiosArguments
->Eax
= Regs
.Eax
;
183 BiosArguments
->Ebx
= Regs
.Ebx
;
184 BiosArguments
->Ecx
= Regs
.Ecx
;
185 BiosArguments
->Edx
= Regs
.Edx
;
186 BiosArguments
->Esi
= Regs
.Esi
;
187 BiosArguments
->Edi
= Regs
.Edi
;
188 BiosArguments
->Ebp
= Regs
.Ebp
;
189 BiosArguments
->SegDs
= Regs
.Ds
;
190 BiosArguments
->SegEs
= Regs
.Es
;
192 IntDetachFromCSRSS(&CallingProcess
, &PrevAttachedProcess
);
197 /* PUBLIC FUNCTIONS ***********************************************************/
205 IN PVOID HwDeviceExtension
,
206 IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments
)
208 KV86M_REGISTERS Regs
;
210 PEPROCESS CallingProcess
;
211 PEPROCESS PrevAttachedProcess
;
213 DPRINT("VideoPortInt10\n");
215 IntAttachToCSRSS(&CallingProcess
, &PrevAttachedProcess
);
217 memset(&Regs
, 0, sizeof(Regs
));
218 DPRINT("- Input register Eax: %x\n", BiosArguments
->Eax
);
219 Regs
.Eax
= BiosArguments
->Eax
;
220 DPRINT("- Input register Ebx: %x\n", BiosArguments
->Ebx
);
221 Regs
.Ebx
= BiosArguments
->Ebx
;
222 DPRINT("- Input register Ecx: %x\n", BiosArguments
->Ecx
);
223 Regs
.Ecx
= BiosArguments
->Ecx
;
224 DPRINT("- Input register Edx: %x\n", BiosArguments
->Edx
);
225 Regs
.Edx
= BiosArguments
->Edx
;
226 DPRINT("- Input register Esi: %x\n", BiosArguments
->Esi
);
227 Regs
.Esi
= BiosArguments
->Esi
;
228 DPRINT("- Input register Edi: %x\n", BiosArguments
->Edi
);
229 Regs
.Edi
= BiosArguments
->Edi
;
230 DPRINT("- Input register Ebp: %x\n", BiosArguments
->Ebp
);
231 Regs
.Ebp
= BiosArguments
->Ebp
;
232 Status
= Ke386CallBios(0x10, &Regs
);
233 BiosArguments
->Eax
= Regs
.Eax
;
234 BiosArguments
->Ebx
= Regs
.Ebx
;
235 BiosArguments
->Ecx
= Regs
.Ecx
;
236 BiosArguments
->Edx
= Regs
.Edx
;
237 BiosArguments
->Esi
= Regs
.Esi
;
238 BiosArguments
->Edi
= Regs
.Edi
;
239 BiosArguments
->Ebp
= Regs
.Ebp
;
241 IntDetachFromCSRSS(&CallingProcess
, &PrevAttachedProcess
);