1 /* $Id: pfault.c 24443 2006-10-08 10:01:27Z arty $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/mm/powerpc/pfault.c
6 * PURPOSE: Paging file functions
8 * PROGRAMMERS: David Welch (welch@mcmail.com)
11 /* INCLUDES *****************************************************************/
15 #include <internal/debug.h>
16 #include <ppcmmu/mmu.h>
18 /* EXTERNS *******************************************************************/
20 extern ULONG
KiKernelTrapHandler(PKTRAP_FRAME Tf
, ULONG ExceptionNr
, PVOID Cr2
);
22 /* FUNCTIONS *****************************************************************/
24 VOID
MmpPpcTrapFrameToTrapFrame(ppc_trap_frame_t
*frame
, PKTRAP_FRAME Tf
)
26 RtlCopyMemory(&Tf
->Gpr0
, frame
->gpr
, 12 * sizeof(ULONG
));
31 Tf
->Msr
= frame
->srr1
& 0xffff;
32 Tf
->Dr0
= frame
->srr0
;
33 Tf
->Dr1
= frame
->srr1
;
35 Tf
->Dr3
= frame
->dsisr
;
38 int KiPageFaultHandler(int trap
, ppc_trap_frame_t
*frame
)
40 NTSTATUS Status
= STATUS_SUCCESS
;
44 BOOLEAN AccessFault
= !!(frame
->dsisr
& (1<<28));
46 PVOID TrapInfo
= NULL
;
48 /* get the faulting address */
49 if (trap
== 4) /* Instruction miss */
50 VirtualAddr
= frame
->srr0
;
52 VirtualAddr
= frame
->dar
;
55 Mode
= frame
->srr1
& 0x4000 ? KernelMode
: UserMode
;
57 /* handle the fault */
60 Status
= MmAccessFault(Mode
, (PVOID
)VirtualAddr
, FALSE
, TrapInfo
);
65 //Status = MmNotPresentFault(Mode, (PVOID)VirtualAddr, FALSE, TrapInfo);
68 if (NT_SUCCESS(Status
))
71 if (KeGetCurrentThread()->ApcState
.UserApcPending
)
75 KeRaiseIrql(APC_LEVEL
, &oldIrql
);
76 KiDeliverApc(UserMode
, NULL
, NULL
);
80 MmpPpcTrapFrameToTrapFrame(frame
, &Tf
);
82 Er
.ExceptionCode
= STATUS_ACCESS_VIOLATION
;
83 Er
.ExceptionFlags
= 0;
84 Er
.ExceptionRecord
= NULL
;
85 Er
.ExceptionAddress
= (PVOID
)frame
->srr0
;
86 Er
.NumberParameters
= 2;
87 Er
.ExceptionInformation
[0] = AccessFault
;
88 Er
.ExceptionInformation
[1] = VirtualAddr
;
90 /* FIXME: Which exceptions are noncontinuable? */
91 Er
.ExceptionFlags
= 0;
93 KiDispatchException(&Er
, 0, &Tf
, Mode
, TRUE
);