Commit a3323d1a authored by Geoff Levand's avatar Geoff Levand Committed by Paul Mackerras

[POWERPC] PS3: Repository probe cleanups

Repository updates:
  - Extract ps3_repository_find_bus() from ps3_repository_find_device(), as the
    storage driver needs it.
  - Make ps3_repository_find_device() return -ENODEV if a device is not found,
    just like if a bus is not found.
  - Add ps3_repository_read_vuart_sysmgr_port() and
    ps3_repository_read_vuart_av_port() to get vuart port info.
  - Add device enumeration routines ps3_repository_find_device() and
    ps3_repository_find_devices().
  - Cleanup debug routines.
Signed-off-by: default avatarGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: default avatarGeoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 6758555d
...@@ -131,24 +131,28 @@ int ps3_repository_read_dev_reg(unsigned int bus_index, ...@@ -131,24 +131,28 @@ int ps3_repository_read_dev_reg(unsigned int bus_index,
/* repository bus enumerators */ /* repository bus enumerators */
struct ps3_repository_device { struct ps3_repository_device {
enum ps3_bus_type bus_type;
unsigned int bus_index; unsigned int bus_index;
unsigned int bus_id;
enum ps3_dev_type dev_type;
unsigned int dev_index; unsigned int dev_index;
struct ps3_device_id did; unsigned int dev_id;
}; };
int ps3_repository_find_device(enum ps3_bus_type bus_type, static inline struct ps3_repository_device *ps3_repository_bump_device(
enum ps3_dev_type dev_type, struct ps3_repository_device *repo)
const struct ps3_repository_device *start_dev,
struct ps3_repository_device *dev);
static inline int ps3_repository_find_first_device(
enum ps3_bus_type bus_type, enum ps3_dev_type dev_type,
struct ps3_repository_device *dev)
{ {
return ps3_repository_find_device(bus_type, dev_type, NULL, dev); repo->dev_index++;
return repo;
} }
int ps3_repository_find_interrupt(const struct ps3_repository_device *dev, int ps3_repository_find_device(struct ps3_repository_device *repo);
int ps3_repository_find_devices(enum ps3_bus_type bus_type,
int (*callback)(const struct ps3_repository_device *repo));
int ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from,
unsigned int *bus_index);
int ps3_repository_find_interrupt(const struct ps3_repository_device *repo,
enum ps3_interrupt_type intr_type, unsigned int *interrupt_id); enum ps3_interrupt_type intr_type, unsigned int *interrupt_id);
int ps3_repository_find_reg(const struct ps3_repository_device *dev, int ps3_repository_find_reg(const struct ps3_repository_device *repo,
enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len); enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len);
/* repository block device info */ /* repository block device info */
...@@ -218,6 +222,11 @@ int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id); ...@@ -218,6 +222,11 @@ int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id);
int ps3_repository_read_spu_resource_id(unsigned int res_index, int ps3_repository_read_spu_resource_id(unsigned int res_index,
enum ps3_spu_resource_type* resource_type, unsigned int *resource_id); enum ps3_spu_resource_type* resource_type, unsigned int *resource_id);
/* repository vuart info */
int ps3_repository_read_vuart_av_port(unsigned int *port);
int ps3_repository_read_vuart_sysmgr_port(unsigned int *port);
/* Page table entries */ /* Page table entries */
#define IOPTE_PP_W 0x8000000000000000ul /* protection: write */ #define IOPTE_PP_W 0x8000000000000000ul /* protection: write */
#define IOPTE_PP_R 0x4000000000000000ul /* protection: read */ #define IOPTE_PP_R 0x4000000000000000ul /* protection: read */
......
...@@ -138,7 +138,7 @@ static int read_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4, ...@@ -138,7 +138,7 @@ static int read_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
pr_debug("%s:%d: lv1_get_repository_node_value failed: %s\n", pr_debug("%s:%d: lv1_get_repository_node_value failed: %s\n",
__func__, __LINE__, ps3_result(result)); __func__, __LINE__, ps3_result(result));
dump_node_name(lpar_id, n1, n2, n3, n4); dump_node_name(lpar_id, n1, n2, n3, n4);
return result; return -ENOENT;
} }
dump_node(lpar_id, n1, n2, n3, n4, v1, v2); dump_node(lpar_id, n1, n2, n3, n4, v1, v2);
...@@ -155,7 +155,7 @@ static int read_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4, ...@@ -155,7 +155,7 @@ static int read_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
pr_debug("%s:%d: warning: discarding non-zero v2: %016lx\n", pr_debug("%s:%d: warning: discarding non-zero v2: %016lx\n",
__func__, __LINE__, v2); __func__, __LINE__, v2);
return result; return 0;
} }
int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str, int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
...@@ -314,324 +314,140 @@ int ps3_repository_read_dev_reg(unsigned int bus_index, ...@@ -314,324 +314,140 @@ int ps3_repository_read_dev_reg(unsigned int bus_index,
reg_index, bus_addr, len); reg_index, bus_addr, len);
} }
#if defined(DEBUG)
int ps3_repository_dump_resource_info(unsigned int bus_index,
unsigned int dev_index)
{
int result = 0;
unsigned int res_index;
pr_debug(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
bus_index, dev_index);
for (res_index = 0; res_index < 10; res_index++) { int ps3_repository_find_device(struct ps3_repository_device *repo)
enum ps3_interrupt_type intr_type; {
unsigned int interrupt_id; int result;
struct ps3_repository_device tmp = *repo;
unsigned int num_dev;
result = ps3_repository_read_dev_intr(bus_index, dev_index, BUG_ON(repo->bus_index > 10);
res_index, &intr_type, &interrupt_id); BUG_ON(repo->dev_index > 10);
if (result) { result = ps3_repository_read_bus_num_dev(tmp.bus_index, &num_dev);
if (result != LV1_NO_ENTRY)
pr_debug("%s:%d ps3_repository_read_dev_intr"
" (%u:%u) failed\n", __func__, __LINE__,
bus_index, dev_index);
break;
}
pr_debug("%s:%d (%u:%u) intr_type %u, interrupt_id %u\n", if (result) {
__func__, __LINE__, bus_index, dev_index, intr_type, pr_debug("%s:%d read_bus_num_dev failed\n", __func__, __LINE__);
interrupt_id); return result;
} }
for (res_index = 0; res_index < 10; res_index++) { pr_debug("%s:%d: bus_type %u, bus_index %u, bus_id %u, num_dev %u\n",
enum ps3_reg_type reg_type; __func__, __LINE__, tmp.bus_type, tmp.bus_index, tmp.bus_id,
u64 bus_addr; num_dev);
u64 len;
result = ps3_repository_read_dev_reg(bus_index, dev_index,
res_index, &reg_type, &bus_addr, &len);
if (result) { if (tmp.dev_index >= num_dev) {
if (result != LV1_NO_ENTRY) pr_debug("%s:%d: no device found\n", __func__, __LINE__);
pr_debug("%s:%d ps3_repository_read_dev_reg" return -ENODEV;
" (%u:%u) failed\n", __func__, __LINE__,
bus_index, dev_index);
break;
}
pr_debug("%s:%d (%u:%u) reg_type %u, bus_addr %lxh, len %lxh\n",
__func__, __LINE__, bus_index, dev_index, reg_type,
bus_addr, len);
} }
pr_debug(" <- %s:%d\n", __func__, __LINE__); result = ps3_repository_read_dev_type(tmp.bus_index, tmp.dev_index,
return result; &tmp.dev_type);
}
static int dump_stor_dev_info(unsigned int bus_index, unsigned int dev_index)
{
int result = 0;
unsigned int num_regions, region_index;
u64 port, blk_size, num_blocks;
pr_debug(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
bus_index, dev_index);
result = ps3_repository_read_stor_dev_info(bus_index, dev_index, &port,
&blk_size, &num_blocks, &num_regions);
if (result) { if (result) {
pr_debug("%s:%d ps3_repository_read_stor_dev_info" pr_debug("%s:%d read_dev_type failed\n", __func__, __LINE__);
" (%u:%u) failed\n", __func__, __LINE__, return result;
bus_index, dev_index);
goto out;
} }
pr_debug("%s:%d (%u:%u): port %lu, blk_size %lu, num_blocks " result = ps3_repository_read_dev_id(tmp.bus_index, tmp.dev_index,
"%lu, num_regions %u\n", &tmp.dev_id);
__func__, __LINE__, bus_index, dev_index, port,
blk_size, num_blocks, num_regions);
for (region_index = 0; region_index < num_regions; region_index++) {
unsigned int region_id;
u64 region_start, region_size;
result = ps3_repository_read_stor_dev_region(bus_index,
dev_index, region_index, &region_id, &region_start,
&region_size);
if (result) {
pr_debug("%s:%d ps3_repository_read_stor_dev_region"
" (%u:%u) failed\n", __func__, __LINE__,
bus_index, dev_index);
break;
}
pr_debug("%s:%d (%u:%u) region_id %u, start %lxh, size %lxh\n", if (result) {
__func__, __LINE__, bus_index, dev_index, region_id, pr_debug("%s:%d ps3_repository_read_dev_id failed\n", __func__,
region_start, region_size); __LINE__);
return result;
} }
out: pr_debug("%s:%d: found: dev_type %u, dev_index %u, dev_id %u\n",
pr_debug(" <- %s:%d\n", __func__, __LINE__); __func__, __LINE__, tmp.dev_type, tmp.dev_index, tmp.dev_id);
return result;
}
static int dump_device_info(unsigned int bus_index, enum ps3_bus_type bus_type,
unsigned int num_dev)
{
int result = 0;
unsigned int dev_index;
pr_debug(" -> %s:%d: bus_%u\n", __func__, __LINE__, bus_index);
for (dev_index = 0; dev_index < num_dev; dev_index++) {
enum ps3_dev_type dev_type;
unsigned int dev_id;
result = ps3_repository_read_dev_type(bus_index, dev_index,
&dev_type);
if (result) {
pr_debug("%s:%d ps3_repository_read_dev_type"
" (%u:%u) failed\n", __func__, __LINE__,
bus_index, dev_index);
break;
}
result = ps3_repository_read_dev_id(bus_index, dev_index,
&dev_id);
if (result) {
pr_debug("%s:%d ps3_repository_read_dev_id"
" (%u:%u) failed\n", __func__, __LINE__,
bus_index, dev_index);
continue;
}
pr_debug("%s:%d (%u:%u): dev_type %u, dev_id %u\n", __func__, *repo = tmp;
__LINE__, bus_index, dev_index, dev_type, dev_id); return 0;
ps3_repository_dump_resource_info(bus_index, dev_index);
if (bus_type == PS3_BUS_TYPE_STORAGE)
dump_stor_dev_info(bus_index, dev_index);
}
pr_debug(" <- %s:%d\n", __func__, __LINE__);
return result;
} }
int ps3_repository_dump_bus_info(void) int __devinit ps3_repository_find_devices(enum ps3_bus_type bus_type,
int (*callback)(const struct ps3_repository_device *repo))
{ {
int result = 0; int result = 0;
unsigned int bus_index; struct ps3_repository_device repo;
pr_debug(" -> %s:%d\n", __func__, __LINE__); pr_debug(" -> %s:%d: find bus_type %u\n", __func__, __LINE__, bus_type);
for (bus_index = 0; bus_index < 10; bus_index++) { for (repo.bus_index = 0; repo.bus_index < 10; repo.bus_index++) {
enum ps3_bus_type bus_type;
unsigned int bus_id;
unsigned int num_dev;
result = ps3_repository_read_bus_type(bus_index, &bus_type); result = ps3_repository_read_bus_type(repo.bus_index,
&repo.bus_type);
if (result) { if (result) {
pr_debug("%s:%d read_bus_type(%u) failed\n", pr_debug("%s:%d read_bus_type(%u) failed\n",
__func__, __LINE__, bus_index); __func__, __LINE__, repo.bus_index);
break; break;
} }
result = ps3_repository_read_bus_id(bus_index, &bus_id); if (repo.bus_type != bus_type) {
pr_debug("%s:%d: skip, bus_type %u\n", __func__,
if (result) { __LINE__, repo.bus_type);
pr_debug("%s:%d read_bus_id(%u) failed\n",
__func__, __LINE__, bus_index);
continue; continue;
} }
if (bus_index != bus_id) result = ps3_repository_read_bus_id(repo.bus_index,
pr_debug("%s:%d bus_index != bus_id\n", &repo.bus_id);
__func__, __LINE__);
result = ps3_repository_read_bus_num_dev(bus_index, &num_dev);
if (result) { if (result) {
pr_debug("%s:%d read_bus_num_dev(%u) failed\n", pr_debug("%s:%d read_bus_id(%u) failed\n",
__func__, __LINE__, bus_index); __func__, __LINE__, repo.bus_index);
continue; continue;
} }
pr_debug("%s:%d bus_%u: bus_type %u, bus_id %u, num_dev %u\n", for (repo.dev_index = 0; ; repo.dev_index++) {
__func__, __LINE__, bus_index, bus_type, bus_id, result = ps3_repository_find_device(&repo);
num_dev);
dump_device_info(bus_index, bus_type, num_dev); if (result == -ENODEV) {
} result = 0;
break;
} else if (result)
break;
pr_debug(" <- %s:%d\n", __func__, __LINE__); result = callback(&repo);
return result;
}
#endif /* defined(DEBUG) */
static int find_device(unsigned int bus_index, unsigned int num_dev,
unsigned int start_dev_index, enum ps3_dev_type dev_type,
struct ps3_repository_device *dev)
{
int result = 0;
unsigned int dev_index;
pr_debug("%s:%d: find dev_type %u\n", __func__, __LINE__, dev_type); if (result) {
pr_debug("%s:%d: abort at callback\n", __func__,
dev->dev_index = UINT_MAX; __LINE__);
break;
for (dev_index = start_dev_index; dev_index < num_dev; dev_index++) { }
enum ps3_dev_type x;
result = ps3_repository_read_dev_type(bus_index, dev_index,
&x);
if (result) {
pr_debug("%s:%d read_dev_type failed\n",
__func__, __LINE__);
return result;
} }
break;
if (x == dev_type)
break;
}
if (dev_index == num_dev)
return -1;
pr_debug("%s:%d: found dev_type %u at dev_index %u\n",
__func__, __LINE__, dev_type, dev_index);
result = ps3_repository_read_dev_id(bus_index, dev_index,
&dev->did.dev_id);
if (result) {
pr_debug("%s:%d read_dev_id failed\n",
__func__, __LINE__);
return result;
} }
dev->dev_index = dev_index; pr_debug(" <- %s:%d\n", __func__, __LINE__);
pr_debug("%s:%d found: dev_id %u\n", __func__, __LINE__,
dev->did.dev_id);
return result; return result;
} }
int ps3_repository_find_device (enum ps3_bus_type bus_type, int ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from,
enum ps3_dev_type dev_type, unsigned int *bus_index)
const struct ps3_repository_device *start_dev,
struct ps3_repository_device *dev)
{ {
int result = 0; unsigned int i;
unsigned int bus_index; enum ps3_bus_type type;
unsigned int num_dev; int error;
pr_debug("%s:%d: find bus_type %u, dev_type %u\n", __func__, __LINE__,
bus_type, dev_type);
BUG_ON(start_dev && start_dev->bus_index > 10);
for (bus_index = start_dev ? start_dev->bus_index : 0; bus_index < 10;
bus_index++) {
enum ps3_bus_type x;
result = ps3_repository_read_bus_type(bus_index, &x);
if (result) { for (i = from; i < 10; i++) {
error = ps3_repository_read_bus_type(i, &type);
if (error) {
pr_debug("%s:%d read_bus_type failed\n", pr_debug("%s:%d read_bus_type failed\n",
__func__, __LINE__); __func__, __LINE__);
dev->bus_index = UINT_MAX; *bus_index = UINT_MAX;
return result; return error;
}
if (type == bus_type) {
*bus_index = i;
return 0;
} }
if (x == bus_type)
break;
}
if (bus_index >= 10)
return -ENODEV;
pr_debug("%s:%d: found bus_type %u at bus_index %u\n",
__func__, __LINE__, bus_type, bus_index);
result = ps3_repository_read_bus_num_dev(bus_index, &num_dev);
if (result) {
pr_debug("%s:%d read_bus_num_dev failed\n",
__func__, __LINE__);
return result;
}
result = find_device(bus_index, num_dev, start_dev
? start_dev->dev_index + 1 : 0, dev_type, dev);
if (result) {
pr_debug("%s:%d get_did failed\n", __func__, __LINE__);
return result;
}
result = ps3_repository_read_bus_id(bus_index, &dev->did.bus_id);
if (result) {
pr_debug("%s:%d read_bus_id failed\n",
__func__, __LINE__);
return result;
} }
*bus_index = UINT_MAX;
dev->bus_index = bus_index; return -ENODEV;
pr_debug("%s:%d found: bus_id %u, dev_id %u\n",
__func__, __LINE__, dev->did.bus_id, dev->did.dev_id);
return result;
} }
int ps3_repository_find_interrupt(const struct ps3_repository_device *dev, int ps3_repository_find_interrupt(const struct ps3_repository_device *repo,
enum ps3_interrupt_type intr_type, unsigned int *interrupt_id) enum ps3_interrupt_type intr_type, unsigned int *interrupt_id)
{ {
int result = 0; int result = 0;
...@@ -645,8 +461,8 @@ int ps3_repository_find_interrupt(const struct ps3_repository_device *dev, ...@@ -645,8 +461,8 @@ int ps3_repository_find_interrupt(const struct ps3_repository_device *dev,
enum ps3_interrupt_type t; enum ps3_interrupt_type t;
unsigned int id; unsigned int id;
result = ps3_repository_read_dev_intr(dev->bus_index, result = ps3_repository_read_dev_intr(repo->bus_index,
dev->dev_index, res_index, &t, &id); repo->dev_index, res_index, &t, &id);
if (result) { if (result) {
pr_debug("%s:%d read_dev_intr failed\n", pr_debug("%s:%d read_dev_intr failed\n",
...@@ -669,7 +485,7 @@ int ps3_repository_find_interrupt(const struct ps3_repository_device *dev, ...@@ -669,7 +485,7 @@ int ps3_repository_find_interrupt(const struct ps3_repository_device *dev,
return result; return result;
} }
int ps3_repository_find_reg(const struct ps3_repository_device *dev, int ps3_repository_find_reg(const struct ps3_repository_device *repo,
enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len) enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len)
{ {
int result = 0; int result = 0;
...@@ -684,8 +500,8 @@ int ps3_repository_find_reg(const struct ps3_repository_device *dev, ...@@ -684,8 +500,8 @@ int ps3_repository_find_reg(const struct ps3_repository_device *dev,
u64 a; u64 a;
u64 l; u64 l;
result = ps3_repository_read_dev_reg(dev->bus_index, result = ps3_repository_read_dev_reg(repo->bus_index,
dev->dev_index, res_index, &t, &a, &l); repo->dev_index, res_index, &t, &a, &l);
if (result) { if (result) {
pr_debug("%s:%d read_dev_reg failed\n", pr_debug("%s:%d read_dev_reg failed\n",
...@@ -965,6 +781,36 @@ int ps3_repository_read_boot_dat_size(unsigned int *size) ...@@ -965,6 +781,36 @@ int ps3_repository_read_boot_dat_size(unsigned int *size)
return result; return result;
} }
int ps3_repository_read_vuart_av_port(unsigned int *port)
{
int result;
u64 v1;
result = read_node(PS3_LPAR_ID_CURRENT,
make_first_field("bi", 0),
make_field("vir_uart", 0),
make_field("port", 0),
make_field("avset", 0),
&v1, 0);
*port = v1;
return result;
}
int ps3_repository_read_vuart_sysmgr_port(unsigned int *port)
{
int result;
u64 v1;
result = read_node(PS3_LPAR_ID_CURRENT,
make_first_field("bi", 0),
make_field("vir_uart", 0),
make_field("port", 0),
make_field("sysmgr", 0),
&v1, 0);
*port = v1;
return result;
}
/** /**
* ps3_repository_read_boot_dat_info - Get address and size of cell_ext_os_area. * ps3_repository_read_boot_dat_info - Get address and size of cell_ext_os_area.
* address: lpar address of cell_ext_os_area * address: lpar address of cell_ext_os_area
...@@ -1026,3 +872,205 @@ int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq) ...@@ -1026,3 +872,205 @@ int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq)
return result ? result return result ? result
: ps3_repository_read_tb_freq(node_id, tb_freq); : ps3_repository_read_tb_freq(node_id, tb_freq);
} }
#if defined(DEBUG)
int ps3_repository_dump_resource_info(const struct ps3_repository_device *repo)
{
int result = 0;
unsigned int res_index;
pr_debug(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
repo->bus_index, repo->dev_index);
for (res_index = 0; res_index < 10; res_index++) {
enum ps3_interrupt_type intr_type;
unsigned int interrupt_id;
result = ps3_repository_read_dev_intr(repo->bus_index,
repo->dev_index, res_index, &intr_type, &interrupt_id);
if (result) {
if (result != LV1_NO_ENTRY)
pr_debug("%s:%d ps3_repository_read_dev_intr"
" (%u:%u) failed\n", __func__, __LINE__,
repo->bus_index, repo->dev_index);
break;
}
pr_debug("%s:%d (%u:%u) intr_type %u, interrupt_id %u\n",
__func__, __LINE__, repo->bus_index, repo->dev_index,
intr_type, interrupt_id);
}
for (res_index = 0; res_index < 10; res_index++) {
enum ps3_reg_type reg_type;
u64 bus_addr;
u64 len;
result = ps3_repository_read_dev_reg(repo->bus_index,
repo->dev_index, res_index, &reg_type, &bus_addr, &len);
if (result) {
if (result != LV1_NO_ENTRY)
pr_debug("%s:%d ps3_repository_read_dev_reg"
" (%u:%u) failed\n", __func__, __LINE__,
repo->bus_index, repo->dev_index);
break;
}
pr_debug("%s:%d (%u:%u) reg_type %u, bus_addr %lxh, len %lxh\n",
__func__, __LINE__, repo->bus_index, repo->dev_index,
reg_type, bus_addr, len);
}
pr_debug(" <- %s:%d\n", __func__, __LINE__);
return result;
}
static int dump_stor_dev_info(struct ps3_repository_device *repo)
{
int result = 0;
unsigned int num_regions, region_index;
u64 port, blk_size, num_blocks;
pr_debug(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
repo->bus_index, repo->dev_index);
result = ps3_repository_read_stor_dev_info(repo->bus_index,
repo->dev_index, &port, &blk_size, &num_blocks, &num_regions);
if (result) {
pr_debug("%s:%d ps3_repository_read_stor_dev_info"
" (%u:%u) failed\n", __func__, __LINE__,
repo->bus_index, repo->dev_index);
goto out;
}
pr_debug("%s:%d (%u:%u): port %lu, blk_size %lu, num_blocks "
"%lu, num_regions %u\n",
__func__, __LINE__, repo->bus_index, repo->dev_index, port,
blk_size, num_blocks, num_regions);
for (region_index = 0; region_index < num_regions; region_index++) {
unsigned int region_id;
u64 region_start, region_size;
result = ps3_repository_read_stor_dev_region(repo->bus_index,
repo->dev_index, region_index, &region_id,
&region_start, &region_size);
if (result) {
pr_debug("%s:%d ps3_repository_read_stor_dev_region"
" (%u:%u) failed\n", __func__, __LINE__,
repo->bus_index, repo->dev_index);
break;
}
pr_debug("%s:%d (%u:%u) region_id %u, start %lxh, size %lxh\n",
__func__, __LINE__, repo->bus_index, repo->dev_index,
region_id, region_start, region_size);
}
out:
pr_debug(" <- %s:%d\n", __func__, __LINE__);
return result;
}
static int dump_device_info(struct ps3_repository_device *repo,
unsigned int num_dev)
{
int result = 0;
pr_debug(" -> %s:%d: bus_%u\n", __func__, __LINE__, repo->bus_index);
for (repo->dev_index = 0; repo->dev_index < num_dev;
repo->dev_index++) {
result = ps3_repository_read_dev_type(repo->bus_index,
repo->dev_index, &repo->dev_type);
if (result) {
pr_debug("%s:%d ps3_repository_read_dev_type"
" (%u:%u) failed\n", __func__, __LINE__,
repo->bus_index, repo->dev_index);
break;
}
result = ps3_repository_read_dev_id(repo->bus_index,
repo->dev_index, &repo->dev_id);
if (result) {
pr_debug("%s:%d ps3_repository_read_dev_id"
" (%u:%u) failed\n", __func__, __LINE__,
repo->bus_index, repo->dev_index);
continue;
}
pr_debug("%s:%d (%u:%u): dev_type %u, dev_id %u\n", __func__,
__LINE__, repo->bus_index, repo->dev_index,
repo->dev_type, repo->dev_id);
ps3_repository_dump_resource_info(repo);
if (repo->bus_type == PS3_BUS_TYPE_STORAGE)
dump_stor_dev_info(repo);
}
pr_debug(" <- %s:%d\n", __func__, __LINE__);
return result;
}
int ps3_repository_dump_bus_info(void)
{
int result = 0;
struct ps3_repository_device repo;
pr_debug(" -> %s:%d\n", __func__, __LINE__);
memset(&repo, 0, sizeof(repo));
for (repo.bus_index = 0; repo.bus_index < 10; repo.bus_index++) {
unsigned int num_dev;
result = ps3_repository_read_bus_type(repo.bus_index,
&repo.bus_type);
if (result) {
pr_debug("%s:%d read_bus_type(%u) failed\n",
__func__, __LINE__, repo.bus_index);
break;
}
result = ps3_repository_read_bus_id(repo.bus_index,
&repo.bus_id);
if (result) {
pr_debug("%s:%d read_bus_id(%u) failed\n",
__func__, __LINE__, repo.bus_index);
continue;
}
if (repo.bus_index != repo.bus_id)
pr_debug("%s:%d bus_index != bus_id\n",
__func__, __LINE__);
result = ps3_repository_read_bus_num_dev(repo.bus_index,
&num_dev);
if (result) {
pr_debug("%s:%d read_bus_num_dev(%u) failed\n",
__func__, __LINE__, repo.bus_index);
continue;
}
pr_debug("%s:%d bus_%u: bus_type %u, bus_id %u, num_dev %u\n",
__func__, __LINE__, repo.bus_index, repo.bus_type,
repo.bus_id, num_dev);
dump_device_info(&repo, num_dev);
}
pr_debug(" <- %s:%d\n", __func__, __LINE__);
return result;
}
#endif /* defined(DEBUG) */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment