1/*
2 * Copyright 2018, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
8 * See "LICENSE_GPLv2.txt" for details.
9 *
10 * @TAG(DATA61_GPL)
11 */
12
13/*
14 *
15 * Copyright 2016, 2017 Hesham Almatary, Data61/CSIRO <hesham.almatary@data61.csiro.au>
16 * Copyright 2015, 2016 Hesham Almatary <heshamelmatary@gmail.com>
17 */
18
19#include <types.h>
20#include <object.h>
21#include <kernel/vspace.h>
22#include <api/faults.h>
23#include <api/syscall.h>
24
25#include <types.h>
26#include <machine/io.h>
27#include <api/faults.h>
28#include <api/syscall.h>
29#include <util.h>
30
31bool_t Arch_handleFaultReply(tcb_t *receiver, tcb_t *sender, word_t faultType)
32{
33    switch (faultType) {
34    case seL4_Fault_VMFault:
35        return true;
36
37    default:
38        fail("Invalid fault");
39    }
40}
41
42word_t
43Arch_setMRs_fault(tcb_t *sender, tcb_t* receiver, word_t *receiveIPCBuffer, word_t faultType)
44{
45    switch (faultType) {
46    case seL4_Fault_VMFault: {
47        setMR(receiver, receiveIPCBuffer, seL4_VMFault_IP, getRestartPC(sender));
48        setMR(receiver, receiveIPCBuffer, seL4_VMFault_PrefetchFault,
49              seL4_Fault_VMFault_get_instructionFault(sender->tcbFault));
50        setMR(receiver, receiveIPCBuffer, seL4_VMFault_Addr,
51              seL4_Fault_VMFault_get_address(sender->tcbFault));
52        return setMR(receiver, receiveIPCBuffer, seL4_VMFault_FSR,
53                     seL4_Fault_VMFault_get_FSR(sender->tcbFault));
54    }
55    default:
56        fail("Invalid fault");
57    }
58}
59