Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
3 | * Use is subject to license terms. | |
4 | */ | |
5 | ||
6 | ||
7 | #ifdef T1_FPGA_SNET | |
8 | ||
9 | #include <sys/asm_linkage.h> | |
10 | #include <hypervisor.h> | |
11 | #include <asi.h> | |
12 | #include <mmu.h> | |
13 | ||
14 | #include <guest.h> | |
15 | #include <offsets.h> | |
16 | #include <util.h> | |
17 | #include <vdev_snet.h> | |
18 | #include <vdev_intr.h> | |
19 | ||
20 | ||
21 | #define PKT_BUF_ADDR_ALIGNMENT 8 | |
22 | ||
23 | ||
24 | /* | |
25 | * Propagate an interrupt received from an snet device to the | |
26 | * snet device driver. | |
27 | */ | |
28 | ENTRY_NP(snet_mondo) | |
29 | GUEST_STRUCT(%g2) | |
30 | set GUEST_SNET, %g3 | |
31 | add %g2, %g3, %g3 | |
32 | ldx [%g3 + SNET_INO], %g3 | |
33 | GUEST2VDEVSTATE(%g2, %g1) | |
34 | !! %g1 = &guestp->vdev_state | |
35 | VINO2MAPREG(%g1, %g3, %g2) | |
36 | mov %g2, %g1 | |
37 | brz,pt %g0, vdev_intr_generate | |
38 | rd %pc, %g7 | |
39 | retry | |
40 | SET_SIZE(snet_mondo) | |
41 | ||
42 | /* | |
43 | * The hypervisor simply provides a mechanism for the device driver | |
44 | * to communicate with the snet device. The hypervisor doesn't | |
45 | * interpret the data. | |
46 | * | |
47 | * For performance reasons, ldx and stx are used in hcall_snet_read and | |
48 | * hcall_snet_write functions. Therefore the source and target buffer | |
49 | * must be double word aligned and also the size of the buffers must | |
50 | * be double word aligned. | |
51 | * | |
52 | */ | |
53 | ||
54 | /* | |
55 | * snet read | |
56 | * | |
57 | * arg1 target real address (%o0) | |
58 | * arg2 size (%o1) | |
59 | * -- | |
60 | * ret0 status (%o0) | |
61 | * ret1 size (%o1) | |
62 | * | |
63 | */ | |
64 | ENTRY_NP(hcall_snet_read) | |
65 | ||
66 | btst PKT_BUF_ADDR_ALIGNMENT - 1, %o0 | |
67 | bnz,pn %xcc, herr_badalign | |
68 | nop | |
69 | ||
70 | GUEST_STRUCT(%g1) | |
71 | add %o1, 0x7, %g4 | |
72 | andn %g4, 0x7, %g4 | |
73 | RA2PA_RANGE_CONV_UNK_SIZE(%g1, %o0, %g4, herr_noraddr, %g3, %g2) | |
74 | ! %g2 paddr | |
75 | ||
76 | set GUEST_SNET, %g3 | |
77 | add %g1, %g3, %g1 | |
78 | ldx [%g1 + SNET_PA], %g1 | |
79 | ||
80 | 1: | |
81 | ldx [%g1], %g3 | |
82 | stx %g3, [%g2] | |
83 | subcc %g4, 8, %g4 | |
84 | brnz,pt %g4, 1b | |
85 | add %g2, 8, %g2 | |
86 | ||
87 | HCALL_RET(EOK) | |
88 | SET_SIZE(hcall_snet_read) | |
89 | ||
90 | /* | |
91 | * snet write | |
92 | * | |
93 | * arg1 source real address (%o0) | |
94 | * arg2 size (%o1) | |
95 | * -- | |
96 | * ret0 status (%o0) | |
97 | * ret1 size (%o1) | |
98 | */ | |
99 | ENTRY_NP(hcall_snet_write) | |
100 | ||
101 | btst PKT_BUF_ADDR_ALIGNMENT - 1, %o0 | |
102 | bnz,pn %xcc, herr_badalign | |
103 | nop | |
104 | ||
105 | GUEST_STRUCT(%g1) | |
106 | add %o1, 0x7, %g4 | |
107 | andn %g4, 0x7, %g4 | |
108 | RA2PA_RANGE_CONV_UNK_SIZE(%g1, %o0, %g4, herr_noraddr, %g3, %g2) | |
109 | ! %g2 paddr | |
110 | ||
111 | set GUEST_SNET, %g3 | |
112 | add %g1, %g3, %g1 | |
113 | ldx [%g1 + SNET_PA], %g1 | |
114 | ||
115 | 1: | |
116 | ldx [%g2], %g3 | |
117 | stx %g3, [%g1] | |
118 | subcc %g4, 8, %g4 | |
119 | brnz,pt %g4, 1b | |
120 | add %g2, 8, %g2 | |
121 | ||
122 | HCALL_RET(EOK) | |
123 | SET_SIZE(hcall_snet_write) | |
124 | ||
125 | #endif /* ifdef T1_FPGA_SNET */ |