1/*
2 * Copyright (c) 2015 Travis Geiselbrecht
3 *
4 * Use of this source code is governed by a MIT-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/MIT
7 */
8#include <lk/asm.h>
9
10/* void microblaze_context_switch(
11    struct microblaze_context_switch_frame *oldcs,
12    struct microblaze_context_switch_frame *newcs); */
13FUNCTION(microblaze_context_switch)
14    # r5 = oldcs
15    # r6 = newcs
16    swi     r1, r5, 0x0
17    swi     r2, r5, 0x4
18    swi     r13, r5, 0x8
19    swi     r14, r5, 0xc
20    swi     r15, r5, 0x10
21    swi     r16, r5, 0x14
22    swi     r17, r5, 0x18
23    swi     r18, r5, 0x1c
24    swi     r19, r5, 0x20
25    swi     r20, r5, 0x24
26    swi     r21, r5, 0x28
27    swi     r22, r5, 0x2c
28    swi     r23, r5, 0x30
29    swi     r24, r5, 0x34
30    swi     r25, r5, 0x38
31    swi     r26, r5, 0x3c
32    swi     r27, r5, 0x40
33    swi     r28, r5, 0x44
34    swi     r29, r5, 0x48
35    swi     r30, r5, 0x4c
36    swi     r31, r5, 0x50
37
38    # restore the new context
39    lwi     r31, r6, 0x50
40    lwi     r30, r6, 0x4c
41    lwi     r29, r6, 0x48
42    lwi     r28, r6, 0x44
43    lwi     r27, r6, 0x40
44    lwi     r26, r6, 0x3c
45    lwi     r25, r6, 0x38
46    lwi     r24, r6, 0x34
47    lwi     r23, r6, 0x30
48    lwi     r22, r6, 0x2c
49    lwi     r21, r6, 0x28
50    lwi     r20, r6, 0x24
51    lwi     r19, r6, 0x20
52    lwi     r18, r6, 0x1c
53    lwi     r17, r6, 0x18
54    lwi     r16, r6, 0x14
55    lwi     r15, r6, 0x10
56    lwi     r14, r6, 0xc
57    lwi     r13, r6, 0x8
58    lwi     r2, r6, 0x4
59    lwi     r1, r6, 0x0
60
61    rtsd    r15, 8
62    nop
63
64