fixed IOS_NET_EURUS_LPAR_BIT_MASK
[install_otheros_bootloader_loader.git] / source / main.c
blobe6d54a118eac81e24a8ba831f3a88892cd2b3da4
2 /*
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
17 #include <unistd.h>
19 #include <psl1ght/lv2/net.h>
21 #include <lv1_map.h>
22 #include <udp_printf.h>
25 * GameOS system manager object in HV process 9
27 #define GAMEOS_SYSMGR_OFFSET 0x000a5dd0ull
30 * log2 of boot memory size for GameOS (3.41)
32 #define LOG2_PAGE_SIZE_OFFSET (GAMEOS_SYSMGR_OFFSET + 0x1b0ull)
33 #define LOG2_PAGE_SIZE 0x0000001bull
36 * Ability mask for GameOS (3.41)
38 #define ABILITY_MASK_OFFSET (GAMEOS_SYSMGR_OFFSET + 0x1c0ull)
39 #define IOS_NET_EURUS_LPAR_BIT_MASK (1ull << 9)
42 * sll_load_lv2 (3.41)
44 #define SLL_LOAD_LV2_OFFSET 0x00165e44ull
46 static uint8_t otheros_bootloader_loader[] = {
47 #include "otheros_bootloader_loader.hex"
51 * main
53 int main(int argc, char **argv)
55 uint64_t ability_mask;
56 int result;
58 netInitialize();
60 udp_printf_init();
62 PRINTF("%s:%d: start\n", __func__, __LINE__);
64 PRINTF("%s:%d: OtherOS bootloader loader size (0x%08x)\n",
65 __func__, __LINE__, sizeof(otheros_bootloader_loader));
67 result = lv1_map();
68 if (result) {
69 PRINTF("%s:%d: lv1_map failed (0x%08x)\n", __func__, __LINE__, result);
70 goto done;
73 PRINTF("%s:%d: patching log2 page size\n", __func__, __LINE__);
75 lv1_poke(LOG2_PAGE_SIZE_OFFSET, LOG2_PAGE_SIZE);
78 * Patch ios.net.eurus.lpar bit in ability mask because GameOS uses HV calls 195 and 196
79 * to access PS3 gelic wireless device but Linux uses HV call lv1_net_control !!!
82 PRINTF("%s:%d: patching ios.net.eurus.lpar bit in ability mask\n", __func__, __LINE__);
84 ability_mask = lv1_peek(ABILITY_MASK_OFFSET);
85 ability_mask &= ~IOS_NET_EURUS_LPAR_BIT_MASK;
86 lv1_poke(ABILITY_MASK_OFFSET, ability_mask);
88 PRINTF("%s:%d: patching sll load lv2\n", __func__, __LINE__);
90 lv1_memcpy_to(SLL_LOAD_LV2_OFFSET, otheros_bootloader_loader, sizeof(otheros_bootloader_loader));
92 PRINTF("%s:%d: end\n", __func__, __LINE__);
94 done:
96 result = lv1_unmap();
97 if (result)
98 PRINTF("%s:%d: lv1_unmap failed (0x%08x)\n", __func__, __LINE__, result);
100 udp_printf_deinit();
102 netDeinitialize();
104 return 0;