1/**
2 * \file
3 * \brief Dispatcher entry points.
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#include <barrelfish/dispatch.h>
16#include <asmoffsets.h>
17
18	.text
19	.globl run_entry, pagefault_entry, disabled_pagefault_entry, trap_entry, lrpc_entry
20
21run_entry:
22        // Get dispatcher stack to rsp
23        movq    %rdi, %rsp
24        addq    $(OFFSETOF_DISP_PRIV_STACK_LIMIT), %rsp
25	callq	disp_run	// Handle activation in C
26
27//
28// void pagefault_entry(vaddr_t fault_addr, uintptr_t error, vaddr_t ip)
29//
30pagefault_entry:
31	// Get dispatcher stack
32        movq    %rdi, %rsp
33        addq    $(OFFSETOF_DISP_PRIV_STACK_LIMIT), %rsp
34	callq	disp_pagefault	// handle activation in C
35
36//
37// void disabled_pagefault_entry(vaddr_t fault_addr, uintptr_t error, vaddr_t ip)
38//
39disabled_pagefault_entry:
40	// Get trap stack
41        movq    %rdi, %rsp
42        addq    $(OFFSETOF_DISP_PRIV_TRAP_STACK_LIMIT), %rsp
43	callq	disp_pagefault_disabled	// handle activation in C
44
45//
46// void trap_entry(uintptr_t irq, uintptr_t error, vaddr_t ip)
47//
48trap_entry:
49	// Get trap stack
50        movq    %rdi, %rsp
51        addq    $(OFFSETOF_DISP_PRIV_TRAP_STACK_LIMIT), %rsp
52	callq	disp_trap	// handle activation in C
53
54lrpc_entry:
55        /* register state:
56         * rdi = epoffset
57         * esi = bufpos of reserved space in endpoint
58         * rdx, r10, r8, r9 = message body
59         * rax = dispatcher
60         */
61
62        /* shuffle registers to match calling parameters of disp_lrpc */
63        mov     %r10, %rcx
64
65        // Load dispatcher to rsp
66        movq    %rax, %rsp
67
68        // Compute address of endpoint
69        addq    %rsp, %rdi
70        subq    $OFFSETOF_LMP_ENDPOINT_KERNPART, %rdi
71
72        // Load dispatcher stack to rsp
73        addq    $(OFFSETOF_DISP_PRIV_STACK_LIMIT), %rsp
74
75        // Align the stack
76        subq    $8, %rsp
77
78        // Push dispatcher pointer to top of stack (7th function argument)
79        pushq   %rax
80
81        callq   disp_lrpc /* disp_lrpc(ep, bufpos, w1, w2, w3, w4, handle) */
82