Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenint10.c
Go to the documentation of this file.
00001 /* 00002 * VideoPort driver 00003 * 00004 * Copyright (C) 2002, 2003, 2004 ReactOS Team 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 */ 00021 00022 #include "videoprt.h" 00023 00024 /* PRIVATE FUNCTIONS **********************************************************/ 00025 00026 #if defined(_M_IX86) 00027 VP_STATUS NTAPI 00028 IntInt10AllocateBuffer( 00029 IN PVOID Context, 00030 OUT PUSHORT Seg, 00031 OUT PUSHORT Off, 00032 IN OUT PULONG Length) 00033 { 00034 PVOID MemoryAddress; 00035 NTSTATUS Status; 00036 PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); 00037 KAPC_STATE ApcState; 00038 00039 TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n"); 00040 00041 IntAttachToCSRSS(&CallingProcess, &ApcState); 00042 00043 MemoryAddress = (PVOID)0x20000; 00044 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0, 00045 Length, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 00046 00047 if (!NT_SUCCESS(Status)) 00048 { 00049 WARN_(VIDEOPRT, "- ZwAllocateVirtualMemory failed\n"); 00050 IntDetachFromCSRSS(&CallingProcess, &ApcState); 00051 return ERROR_NOT_ENOUGH_MEMORY; 00052 } 00053 00054 if (MemoryAddress > (PVOID)(0x100000 - *Length)) 00055 { 00056 ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, Length, 00057 MEM_RELEASE); 00058 WARN_(VIDEOPRT, "- Unacceptable memory allocated\n"); 00059 IntDetachFromCSRSS(&CallingProcess, &ApcState); 00060 return ERROR_NOT_ENOUGH_MEMORY; 00061 } 00062 00063 *Seg = (USHORT)((ULONG)MemoryAddress >> 4); 00064 *Off = (USHORT)((ULONG)MemoryAddress & 0xF); 00065 00066 INFO_(VIDEOPRT, "- Segment: %x\n", (ULONG)MemoryAddress >> 4); 00067 INFO_(VIDEOPRT, "- Offset: %x\n", (ULONG)MemoryAddress & 0xF); 00068 INFO_(VIDEOPRT, "- Length: %x\n", *Length); 00069 00070 IntDetachFromCSRSS(&CallingProcess, &ApcState); 00071 00072 return NO_ERROR; 00073 } 00074 00075 VP_STATUS NTAPI 00076 IntInt10FreeBuffer( 00077 IN PVOID Context, 00078 IN USHORT Seg, 00079 IN USHORT Off) 00080 { 00081 PVOID MemoryAddress = (PVOID)((Seg << 4) | Off); 00082 NTSTATUS Status; 00083 PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); 00084 KAPC_STATE ApcState; 00085 SIZE_T Size = 0; 00086 00087 TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n"); 00088 INFO_(VIDEOPRT, "- Segment: %x\n", Seg); 00089 INFO_(VIDEOPRT, "- Offset: %x\n", Off); 00090 00091 IntAttachToCSRSS(&CallingProcess, &ApcState); 00092 Status = ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, &Size, 00093 MEM_RELEASE); 00094 IntDetachFromCSRSS(&CallingProcess, &ApcState); 00095 00096 return Status; 00097 } 00098 00099 VP_STATUS NTAPI 00100 IntInt10ReadMemory( 00101 IN PVOID Context, 00102 IN USHORT Seg, 00103 IN USHORT Off, 00104 OUT PVOID Buffer, 00105 IN ULONG Length) 00106 { 00107 PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); 00108 KAPC_STATE ApcState; 00109 00110 TRACE_(VIDEOPRT, "IntInt10ReadMemory\n"); 00111 INFO_(VIDEOPRT, "- Segment: %x\n", Seg); 00112 INFO_(VIDEOPRT, "- Offset: %x\n", Off); 00113 INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer); 00114 INFO_(VIDEOPRT, "- Length: %x\n", Length); 00115 00116 IntAttachToCSRSS(&CallingProcess, &ApcState); 00117 RtlCopyMemory(Buffer, (PVOID)((Seg << 4) | Off), Length); 00118 IntDetachFromCSRSS(&CallingProcess, &ApcState); 00119 00120 return NO_ERROR; 00121 } 00122 00123 VP_STATUS NTAPI 00124 IntInt10WriteMemory( 00125 IN PVOID Context, 00126 IN USHORT Seg, 00127 IN USHORT Off, 00128 IN PVOID Buffer, 00129 IN ULONG Length) 00130 { 00131 PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); 00132 KAPC_STATE ApcState; 00133 00134 TRACE_(VIDEOPRT, "IntInt10WriteMemory\n"); 00135 INFO_(VIDEOPRT, "- Segment: %x\n", Seg); 00136 INFO_(VIDEOPRT, "- Offset: %x\n", Off); 00137 INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer); 00138 INFO_(VIDEOPRT, "- Length: %x\n", Length); 00139 00140 IntAttachToCSRSS(&CallingProcess, &ApcState); 00141 RtlCopyMemory((PVOID)((Seg << 4) | Off), Buffer, Length); 00142 IntDetachFromCSRSS(&CallingProcess, &ApcState); 00143 00144 return NO_ERROR; 00145 } 00146 00147 VP_STATUS 00148 NTAPI 00149 IntInt10CallBios( 00150 IN PVOID Context, 00151 IN OUT PINT10_BIOS_ARGUMENTS BiosArguments) 00152 { 00153 CONTEXT BiosContext; 00154 NTSTATUS Status; 00155 PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); 00156 KAPC_STATE ApcState; 00157 00158 /* Attach to CSRSS */ 00159 IntAttachToCSRSS(&CallingProcess, &ApcState); 00160 00161 /* Clear the context */ 00162 RtlZeroMemory(&BiosContext, sizeof(CONTEXT)); 00163 00164 /* Fill out the bios arguments */ 00165 BiosContext.Eax = BiosArguments->Eax; 00166 BiosContext.Ebx = BiosArguments->Ebx; 00167 BiosContext.Ecx = BiosArguments->Ecx; 00168 BiosContext.Edx = BiosArguments->Edx; 00169 BiosContext.Esi = BiosArguments->Esi; 00170 BiosContext.Edi = BiosArguments->Edi; 00171 BiosContext.Ebp = BiosArguments->Ebp; 00172 BiosContext.SegDs = BiosArguments->SegDs; 00173 BiosContext.SegEs = BiosArguments->SegEs; 00174 00175 /* Do the ROM BIOS call */ 00176 Status = Ke386CallBios(0x10, &BiosContext); 00177 00178 /* Return the arguments */ 00179 BiosArguments->Eax = BiosContext.Eax; 00180 BiosArguments->Ebx = BiosContext.Ebx; 00181 BiosArguments->Ecx = BiosContext.Ecx; 00182 BiosArguments->Edx = BiosContext.Edx; 00183 BiosArguments->Esi = BiosContext.Esi; 00184 BiosArguments->Edi = BiosContext.Edi; 00185 BiosArguments->Ebp = BiosContext.Ebp; 00186 BiosArguments->SegDs = (USHORT)BiosContext.SegDs; 00187 BiosArguments->SegEs = (USHORT)BiosContext.SegEs; 00188 00189 /* Detach and return status */ 00190 IntDetachFromCSRSS(&CallingProcess, &ApcState); 00191 if (NT_SUCCESS(Status)) return NO_ERROR; 00192 return ERROR_INVALID_PARAMETER; 00193 } 00194 #endif 00195 00196 /* PUBLIC FUNCTIONS ***********************************************************/ 00197 00198 /* 00199 * @implemented 00200 */ 00201 00202 VP_STATUS NTAPI 00203 VideoPortInt10( 00204 IN PVOID HwDeviceExtension, 00205 IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments) 00206 { 00207 #if defined(_M_IX86) 00208 CONTEXT BiosContext; 00209 NTSTATUS Status; 00210 PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); 00211 KAPC_STATE ApcState; 00212 00213 if (!CsrssInitialized) 00214 { 00215 return ERROR_INVALID_PARAMETER; 00216 } 00217 00218 /* Attach to CSRSS */ 00219 IntAttachToCSRSS(&CallingProcess, &ApcState); 00220 00221 /* Clear the context */ 00222 RtlZeroMemory(&BiosContext, sizeof(CONTEXT)); 00223 00224 /* Fill out the bios arguments */ 00225 BiosContext.Eax = BiosArguments->Eax; 00226 BiosContext.Ebx = BiosArguments->Ebx; 00227 BiosContext.Ecx = BiosArguments->Ecx; 00228 BiosContext.Edx = BiosArguments->Edx; 00229 BiosContext.Esi = BiosArguments->Esi; 00230 BiosContext.Edi = BiosArguments->Edi; 00231 BiosContext.Ebp = BiosArguments->Ebp; 00232 00233 /* Do the ROM BIOS call */ 00234 Status = Ke386CallBios(0x10, &BiosContext); 00235 00236 /* Return the arguments */ 00237 BiosArguments->Eax = BiosContext.Eax; 00238 BiosArguments->Ebx = BiosContext.Ebx; 00239 BiosArguments->Ecx = BiosContext.Ecx; 00240 BiosArguments->Edx = BiosContext.Edx; 00241 BiosArguments->Esi = BiosContext.Esi; 00242 BiosArguments->Edi = BiosContext.Edi; 00243 BiosArguments->Ebp = BiosContext.Ebp; 00244 00245 /* Detach from CSRSS */ 00246 IntDetachFromCSRSS(&CallingProcess, &ApcState); 00247 if (NT_SUCCESS(Status)) return NO_ERROR; 00248 return ERROR_INVALID_PARAMETER; 00249 #else 00250 /* Not implemented for anything else than X86*/ 00251 DPRINT1("Int10 not available on non-x86!\n"); 00252 return ERROR_INVALID_FUNCTION; 00253 #endif 00254 } Generated on Mon May 28 2012 04:38:02 for ReactOS by
1.7.6.1
|