35 #define dump_field(_a, _b) _dump_field(_a, _b, __func__, __LINE__)
36 static void _dump_field(
const char *
hdr,
u64 n,
const char *
func,
int line)
40 const char *
const in = (
const char *)&n;
43 for (i = 0; i < 8; i++)
44 s[i] = (in[i] <= 126 && in[i] >= 32) ? in[
i] :
'.';
47 pr_devel(
"%s:%d: %s%016llx : %s\n", func, line, hdr, n, s);
51 #define dump_node_name(_a, _b, _c, _d, _e) \
52 _dump_node_name(_a, _b, _c, _d, _e, __func__, __LINE__)
53 static void _dump_node_name(
unsigned int lpar_id,
u64 n1,
u64 n2,
u64 n3,
56 pr_devel(
"%s:%d: lpar: %u\n", func, line, lpar_id);
57 _dump_field(
"n1: ", n1, func, line);
58 _dump_field(
"n2: ", n2, func, line);
59 _dump_field(
"n3: ", n3, func, line);
60 _dump_field(
"n4: ", n4, func, line);
63 #define dump_node(_a, _b, _c, _d, _e, _f, _g) \
64 _dump_node(_a, _b, _c, _d, _e, _f, _g, __func__, __LINE__)
65 static void _dump_node(
unsigned int lpar_id,
u64 n1,
u64 n2,
u64 n3,
u64 n4,
68 pr_devel(
"%s:%d: lpar: %u\n", func, line, lpar_id);
69 _dump_field(
"n1: ", n1, func, line);
70 _dump_field(
"n2: ", n2, func, line);
71 _dump_field(
"n3: ", n3, func, line);
72 _dump_field(
"n4: ", n4, func, line);
73 pr_devel(
"%s:%d: v1: %016llx\n", func, line, v1);
74 pr_devel(
"%s:%d: v2: %016llx\n", func, line, v2);
102 static u64 make_field(
const char *text,
u64 index)
121 static int read_node(
unsigned int lpar_id,
u64 n1,
u64 n2,
u64 n3,
u64 n4,
134 result = lv1_read_repository_node(lpar_id, n1, n2, n3, n4, &v1,
138 pr_warn(
"%s:%d: lv1_read_repository_node failed: %s\n",
139 __func__, __LINE__, ps3_result(result));
144 dump_node(lpar_id, n1, n2, n3, n4, v1, v2);
152 pr_devel(
"%s:%d: warning: discarding non-zero v1: %016llx\n",
153 __func__, __LINE__, v1);
155 pr_devel(
"%s:%d: warning: discarding non-zero v2: %016llx\n",
156 __func__, __LINE__, v2);
165 make_first_field(
"bus", bus_index),
166 make_field(bus_str, 0),
176 make_first_field(
"bus", bus_index),
190 make_first_field(
"bus", bus_index),
191 make_field(
"type", 0),
199 unsigned int *num_dev)
205 make_first_field(
"bus", bus_index),
206 make_field(
"num_dev", 0),
214 unsigned int dev_index,
const char *dev_str,
u64 *
value)
217 make_first_field(
"bus", bus_index),
218 make_field(
"dev", dev_index),
219 make_field(dev_str, 0),
230 make_first_field(
"bus", bus_index),
231 make_field(
"dev", dev_index),
245 make_first_field(
"bus", bus_index),
246 make_field(
"dev", dev_index),
247 make_field(
"type", 0),
255 unsigned int dev_index,
unsigned int intr_index,
263 make_first_field(
"bus", bus_index),
264 make_field(
"dev", dev_index),
265 make_field(
"intr", intr_index),
274 unsigned int dev_index,
unsigned int reg_index,
281 make_first_field(
"bus", bus_index),
282 make_field(
"dev", dev_index),
283 make_field(
"reg", reg_index),
284 make_field(
"type", 0),
291 unsigned int dev_index,
unsigned int reg_index,
u64 *bus_addr,
u64 *len)
294 make_first_field(
"bus", bus_index),
295 make_field(
"dev", dev_index),
296 make_field(
"reg", reg_index),
297 make_field(
"data", 0),
302 unsigned int dev_index,
unsigned int reg_index,
306 reg_index, reg_type);
307 return result ? result
309 reg_index, bus_addr, len);
318 unsigned int num_dev;
326 pr_devel(
"%s:%d read_bus_num_dev failed\n", __func__, __LINE__);
330 pr_devel(
"%s:%d: bus_type %u, bus_index %u, bus_id %llu, num_dev %u\n",
335 pr_devel(
"%s:%d: no device found\n", __func__, __LINE__);
343 pr_devel(
"%s:%d read_dev_type failed\n", __func__, __LINE__);
351 pr_devel(
"%s:%d ps3_repository_read_dev_id failed\n", __func__,
356 pr_devel(
"%s:%d: found: dev_type %u, dev_index %u, dev_id %llu\n",
368 unsigned int num_dev;
370 pr_devel(
" -> %s:%u: find device by id %llu:%llu\n", __func__, __LINE__,
377 pr_devel(
"%s:%u read_bus_id(%u) failed\n", __func__,
385 pr_devel(
"%s:%u: skip, bus_id %llu\n", __func__, __LINE__,
388 pr_devel(
" <- %s:%u: bus not found\n", __func__, __LINE__);
394 pr_devel(
"%s:%u read_bus_type(%u) failed\n", __func__,
401 pr_devel(
"%s:%u read_bus_num_dev failed\n", __func__,
411 pr_devel(
"%s:%u read_dev_id(%u:%u) failed\n", __func__,
419 pr_devel(
"%s:%u: skip, dev_id %llu\n", __func__, __LINE__,
422 pr_devel(
" <- %s:%u: dev not found\n", __func__, __LINE__);
429 pr_devel(
"%s:%u read_dev_type failed\n", __func__, __LINE__);
433 pr_devel(
" <- %s:%u: found: type (%u:%u) index (%u:%u) id (%llu:%llu)\n",
446 pr_devel(
" -> %s:%d: find bus_type %u\n", __func__, __LINE__, bus_type);
451 pr_devel(
" <- %s:%u: bus not found\n", __func__, __LINE__);
457 pr_devel(
"%s:%d read_bus_id(%u) failed\n", __func__, __LINE__,
472 pr_devel(
"%s:%d: abort at callback\n", __func__,
478 pr_devel(
" <- %s:%d\n", __func__, __LINE__);
489 for (i = from; i < 10; i++) {
492 pr_devel(
"%s:%d read_bus_type failed\n",
497 if (type == bus_type) {
510 unsigned int res_index;
512 pr_devel(
"%s:%d: find intr_type %u\n", __func__, __LINE__, intr_type);
516 for (res_index = 0; res_index < 10; res_index++) {
524 pr_devel(
"%s:%d read_dev_intr failed\n",
529 if (t == intr_type) {
538 pr_devel(
"%s:%d: found intr_type %u at res_index %u\n",
539 __func__, __LINE__, intr_type, res_index);
548 unsigned int res_index;
550 pr_devel(
"%s:%d: find reg_type %u\n", __func__, __LINE__, reg_type);
552 *bus_addr = *len = 0;
554 for (res_index = 0; res_index < 10; res_index++) {
563 pr_devel(
"%s:%d read_dev_reg failed\n",
578 pr_devel(
"%s:%d: found reg_type %u at res_index %u\n",
579 __func__, __LINE__, reg_type, res_index);
588 make_first_field(
"bus", bus_index),
589 make_field(
"dev", dev_index),
590 make_field(
"port", 0),
598 make_first_field(
"bus", bus_index),
599 make_field(
"dev", dev_index),
600 make_field(
"blk_size", 0),
608 make_first_field(
"bus", bus_index),
609 make_field(
"dev", dev_index),
610 make_field(
"n_blocks", 0),
611 0, num_blocks,
NULL);
615 unsigned int dev_index,
unsigned int *num_regions)
621 make_first_field(
"bus", bus_index),
622 make_field(
"dev", dev_index),
623 make_field(
"n_regs", 0),
630 unsigned int dev_index,
unsigned int region_index,
631 unsigned int *region_id)
637 make_first_field(
"bus", bus_index),
638 make_field(
"dev", dev_index),
639 make_field(
"region", region_index),
647 unsigned int dev_index,
unsigned int region_index,
u64 *region_size)
650 make_first_field(
"bus", bus_index),
651 make_field(
"dev", dev_index),
652 make_field(
"region", region_index),
653 make_field(
"size", 0),
658 unsigned int dev_index,
unsigned int region_index,
u64 *region_start)
661 make_first_field(
"bus", bus_index),
662 make_field(
"dev", dev_index),
663 make_field(
"region", region_index),
664 make_field(
"start", 0),
670 u64 *num_blocks,
unsigned int *num_regions)
694 unsigned int dev_index,
unsigned int region_index,
695 unsigned int *region_id,
u64 *region_start,
u64 *region_size)
700 region_index, region_id);
705 region_index, region_start);
710 region_index, region_size);
722 make_first_field(
"bi", 0),
723 make_field(
"pun", 0),
737 make_first_field(
"bi", 0),
738 make_field(
"pu", pu_index),
746 make_first_field(
"bi", 0),
749 make_field(
"rm_size", 0),
756 make_first_field(
"bi", 0),
757 make_field(
"rgntotal", 0),
777 return result ? result
794 make_first_field(
"highmem", 0),
795 make_field(
"region", 0),
796 make_field(
"count", 0),
808 make_first_field(
"highmem", 0),
809 make_field(
"region", region_index),
810 make_field(
"base", 0),
819 make_first_field(
"highmem", 0),
820 make_field(
"region", region_index),
821 make_field(
"size", 0),
837 u64 *highmem_base,
u64 *highmem_size)
843 return result ? result
858 make_first_field(
"bi", 0),
859 make_field(
"spun", 0),
862 *num_spu_reserved =
v1;
877 make_first_field(
"bi", 0),
878 make_field(
"spursvn", 0),
881 *num_resource_id =
v1;
900 make_first_field(
"bi", 0),
901 make_field(
"spursv", 0),
910 static int ps3_repository_read_boot_dat_address(
u64 *
address)
913 make_first_field(
"bi", 0),
914 make_field(
"boot_dat", 0),
915 make_field(
"address", 0),
926 make_first_field(
"bi", 0),
927 make_field(
"boot_dat", 0),
928 make_field(
"size", 0),
941 make_first_field(
"bi", 0),
942 make_field(
"vir_uart", 0),
943 make_field(
"port", 0),
944 make_field(
"avset", 0),
956 make_first_field(
"bi", 0),
957 make_field(
"vir_uart", 0),
958 make_field(
"port", 0),
959 make_field(
"sysmgr", 0),
976 result = ps3_repository_read_boot_dat_address(lpar_addr);
977 return result ? result
991 make_first_field(
"ben", 0),
1009 make_first_field(
"be", be_index),
1025 make_first_field(
"be", 0),
1035 make_first_field(
"be", 0),
1037 make_field(
"clock", 0),
1049 return result ? result
1062 return result ? result
1064 make_first_field(
"be", 0),
1066 make_field(
"lpm", 0),
1067 make_field(
"priv", 0),
1071 #if defined(CONFIG_PS3_REPOSITORY_WRITE)
1079 result = lv1_create_repository_node(n1, n2, n3, n4, v1, v2);
1082 pr_devel(
"%s:%d: lv1_create_repository_node failed: %s\n",
1083 __func__, __LINE__, ps3_result(result));
1096 result = lv1_delete_repository_node(n1, n2, n3, n4);
1099 pr_devel(
"%s:%d: lv1_delete_repository_node failed: %s\n",
1100 __func__, __LINE__, ps3_result(result));
1111 result = create_node(n1, n2, n3, n4, v1, v2);
1116 result = lv1_write_repository_node(n1, n2, n3, n4, v1, v2);
1119 pr_devel(
"%s:%d: lv1_write_repository_node failed: %s\n",
1120 __func__, __LINE__, ps3_result(result));
1130 u64 v1 = (
u64)region_count;
1132 result = write_node(
1133 make_first_field(
"highmem", 0),
1134 make_field(
"region", 0),
1135 make_field(
"count", 0),
1145 make_first_field(
"highmem", 0),
1146 make_field(
"region", region_index),
1147 make_field(
"base", 0),
1156 make_first_field(
"highmem", 0),
1157 make_field(
"region", region_index),
1158 make_field(
"size", 0),
1164 u64 highmem_base,
u64 highmem_size)
1169 return result ? result
1173 static int ps3_repository_delete_highmem_base(
unsigned int region_index)
1176 make_first_field(
"highmem", 0),
1177 make_field(
"region", region_index),
1178 make_field(
"base", 0),
1182 static int ps3_repository_delete_highmem_size(
unsigned int region_index)
1185 make_first_field(
"highmem", 0),
1186 make_field(
"region", region_index),
1187 make_field(
"size", 0),
1195 result = ps3_repository_delete_highmem_base(region_index);
1196 result += ps3_repository_delete_highmem_size(region_index);
1198 return result ? -1 : 0;
1208 unsigned int res_index;
1210 pr_devel(
" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
1213 for (res_index = 0; res_index < 10; res_index++) {
1215 unsigned int interrupt_id;
1218 repo->
dev_index, res_index, &intr_type, &interrupt_id);
1222 pr_devel(
"%s:%d ps3_repository_read_dev_intr"
1223 " (%u:%u) failed\n", __func__, __LINE__,
1228 pr_devel(
"%s:%d (%u:%u) intr_type %u, interrupt_id %u\n",
1230 intr_type, interrupt_id);
1233 for (res_index = 0; res_index < 10; res_index++) {
1239 repo->
dev_index, res_index, ®_type, &bus_addr, &len);
1243 pr_devel(
"%s:%d ps3_repository_read_dev_reg"
1244 " (%u:%u) failed\n", __func__, __LINE__,
1249 pr_devel(
"%s:%d (%u:%u) reg_type %u, bus_addr %llxh, len %llxh\n",
1251 reg_type, bus_addr, len);
1254 pr_devel(
" <- %s:%d\n", __func__, __LINE__);
1261 unsigned int num_regions, region_index;
1264 pr_devel(
" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
1268 repo->
dev_index, &port, &blk_size, &num_blocks, &num_regions);
1270 pr_devel(
"%s:%d ps3_repository_read_stor_dev_info"
1271 " (%u:%u) failed\n", __func__, __LINE__,
1276 pr_devel(
"%s:%d (%u:%u): port %llu, blk_size %llu, num_blocks "
1277 "%llu, num_regions %u\n",
1279 port, blk_size, num_blocks, num_regions);
1281 for (region_index = 0; region_index < num_regions; region_index++) {
1282 unsigned int region_id;
1283 u64 region_start, region_size;
1286 repo->
dev_index, region_index, ®ion_id,
1287 ®ion_start, ®ion_size);
1289 pr_devel(
"%s:%d ps3_repository_read_stor_dev_region"
1290 " (%u:%u) failed\n", __func__, __LINE__,
1295 pr_devel(
"%s:%d (%u:%u) region_id %u, start %lxh, size %lxh\n",
1297 region_id, (
unsigned long)region_start,
1298 (
unsigned long)region_size);
1302 pr_devel(
" <- %s:%d\n", __func__, __LINE__);
1307 unsigned int num_dev)
1320 pr_devel(
"%s:%d ps3_repository_read_dev_type"
1321 " (%u:%u) failed\n", __func__, __LINE__,
1330 pr_devel(
"%s:%d ps3_repository_read_dev_id"
1331 " (%u:%u) failed\n", __func__, __LINE__,
1336 pr_devel(
"%s:%d (%u:%u): dev_type %u, dev_id %lu\n", __func__,
1340 ps3_repository_dump_resource_info(repo);
1343 dump_stor_dev_info(repo);
1346 pr_devel(
" <- %s:%d\n", __func__, __LINE__);
1350 int ps3_repository_dump_bus_info(
void)
1355 pr_devel(
" -> %s:%d\n", __func__, __LINE__);
1357 memset(&repo, 0,
sizeof(repo));
1360 unsigned int num_dev;
1366 pr_devel(
"%s:%d read_bus_type(%u) failed\n",
1375 pr_devel(
"%s:%d read_bus_id(%u) failed\n",
1381 pr_devel(
"%s:%d bus_index != bus_id\n",
1382 __func__, __LINE__);
1388 pr_devel(
"%s:%d read_bus_num_dev(%u) failed\n",
1393 pr_devel(
"%s:%d bus_%u: bus_type %u, bus_id %lu, num_dev %u\n",
1395 (
unsigned long)repo.
bus_id, num_dev);
1397 dump_device_info(&repo, num_dev);
1400 pr_devel(
" <- %s:%d\n", __func__, __LINE__);