2 * Copyright (C) 2010 Nathan Whitehorn
3 * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 /* Hypercall stubs. Note: this is all a hack and should die. */
31 #define hc .long 0x44000022
33 #define LD64_IM(r, highest, higher, high, low) \
40 #define SIMPLE_HVCALL(x, c) \
52 clrldi %r10,%r10,32; \
60 SIMPLE_HVCALL(lv1_open_device, 170)
61 SIMPLE_HVCALL(lv1_close_device, 171)
62 SIMPLE_HVCALL(lv1_gpu_open, 210)
63 SIMPLE_HVCALL(lv1_gpu_context_attribute, 225)
64 SIMPLE_HVCALL(lv1_panic, 255)
65 SIMPLE_HVCALL(lv1_net_start_tx_dma, 187)
66 SIMPLE_HVCALL(lv1_net_stop_tx_dma, 188)
67 SIMPLE_HVCALL(lv1_net_start_rx_dma, 189)
68 SIMPLE_HVCALL(lv1_net_stop_rx_dma, 190)
70 .global lv1_get_physmem
74 stw %r3,-8(%r1) /* Address for maxmem */
76 li %r11,69 /* Get PU ID */
80 li %r11,74 /* Get LPAR ID */
85 LD64_IM(%r4,0x0000,0x0000,0x6269,0x0000 /* "bi" */)
86 LD64_IM(%r5,0x7075,0x0000,0x0000,0x0000 /* "pu" */)
88 LD64_IM(%r7,0x726d,0x5f73,0x697a,0x6500 /* "rm_size" */)
100 .global lv1_setup_address_space
101 lv1_setup_address_space:
108 li %r3,18 /* PT size: log2(256 KB) */
109 li %r4,2 /* Two page sizes */
110 li %r5,24 /* Page sizes: (24 << 56) | (16 << 48) */
117 li %r11,2 /* lv1_construct_virtual_address_space */
127 li %r11,7 /* lv1_select_virtual_address_space */
135 .global lv1_insert_pte
140 mr %r11,%r4 /* Save R4 */
145 sldi %r4,%r3,3 /* Convert ptegidx into base PTE slot */
146 li %r3,0 /* Current address space */
149 li %r8,0 /* No other flags */
159 .global lv1_gpu_context_allocate
160 lv1_gpu_context_allocate:
182 .global lv1_gpu_memory_allocate
183 lv1_gpu_memory_allocate:
202 .global lv1_net_control
219 .global lv1_setup_dma
229 lis %r5,0x0800 /* 128 MB */
230 li %r6,24 /* log2(IO_PAGESIZE) */
232 li %r11,174 /* lv1_allocate_device_dma_region */
243 lis %r7,0x0800 /* 128 MB */
244 lis %r8,0xf800 /* flags */
246 li %r11,176 /* lv1_map_device_dma_region */
258 .global lv1_get_repository_node_value
259 lv1_get_repository_node_value:
293 .global lv1_storage_read
324 .global lv1_storage_check_async_status
325 lv1_storage_check_async_status: