3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; version 2 of the License.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <lv1_hvcall.h>
22 #include <lv2_syscall.h>
25 #define LV1_PA 0x0000000000000000ull
26 #define LV1_EA 0x8000000014000000ull
27 #define LV1_SIZE (16 * 1024 * 1024)
29 static uint64_t lv1_lpar
;
34 uint64_t lv1_peek(uint64_t addr
)
36 return lv2_peek(LV1_EA
+ addr
);
42 void lv1_poke(uint64_t addr
, uint64_t val
)
44 lv2_poke(LV1_EA
+ addr
, val
);
50 void lv1_poke_8(uint64_t addr
, uint8_t val
)
54 val_64
= lv1_peek(addr
& ~0x7ull
);
56 val_64
&= ~(0xffull
<< ((sizeof(uint64_t) - (addr
& 0x7ull
) - 1) * 8));
57 val_64
|= ((uint64_t) val
) << ((sizeof(uint64_t) - (addr
& 0x7ull
) - 1) * 8);
59 lv1_poke(addr
& ~0x7ull
, val_64
);
65 void lv1_memcpy_to(uint64_t addr
, const void *data
, unsigned int size
)
70 ptr
= (uint8_t *) data
;
73 nbytes
= sizeof(uint64_t) - (addr
& 0x7ull
);
78 lv1_poke_8(addr
++, *ptr
++);
81 while (size
>= sizeof(uint64_t)) {
82 lv1_poke(addr
, *(uint64_t *) ptr
);
84 addr
+= sizeof(uint64_t);
85 ptr
+= sizeof(uint64_t);
86 size
-= sizeof(uint64_t);
90 lv1_poke_8(addr
++, *ptr
++);
103 result
= lv1_undocumented_function_114(LV1_PA
, PAGE_SIZE_4KB
, LV1_SIZE
, &lv1_lpar
);
107 result
= mm_map_lpar_memory_region(0, MM_EA2VA(LV1_EA
), lv1_lpar
, LV1_SIZE
, PAGE_SIZE_4KB
, 0, 0);
109 lv1_undocumented_function_115(lv1_lpar
);
127 result
= lv1_undocumented_function_115(lv1_lpar
);