listdev: Style cleanup. No functional change.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006-2012, Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -15,35 +21,44 @@
|
|||||||
status_t init_dm_wrapper(void)
|
status_t init_dm_wrapper(void)
|
||||||
{
|
{
|
||||||
uint32 version = 0;
|
uint32 version = 0;
|
||||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, B_SYSCALL_INFO, &version, sizeof(version));
|
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, B_SYSCALL_INFO,
|
||||||
|
&version, sizeof(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t uninit_dm_wrapper(void)
|
status_t uninit_dm_wrapper(void)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
get_root(device_node_cookie *cookie)
|
get_root(device_node_cookie *cookie)
|
||||||
{
|
{
|
||||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_ROOT, cookie, sizeof(device_node_cookie));
|
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_ROOT,
|
||||||
|
cookie, sizeof(device_node_cookie));
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
|
||||||
|
status_t
|
||||||
get_child(device_node_cookie *device)
|
get_child(device_node_cookie *device)
|
||||||
{
|
{
|
||||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_CHILD, device, sizeof(device_node_cookie));
|
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_CHILD,
|
||||||
|
device, sizeof(device_node_cookie));
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
|
||||||
|
status_t
|
||||||
get_next_child(device_node_cookie *device)
|
get_next_child(device_node_cookie *device)
|
||||||
{
|
{
|
||||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_NEXT_CHILD, device, sizeof(device_node_cookie));
|
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_NEXT_CHILD,
|
||||||
|
device, sizeof(device_node_cookie));
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
|
||||||
|
status_t
|
||||||
dm_get_next_attr(struct device_attr_info *attr)
|
dm_get_next_attr(struct device_attr_info *attr)
|
||||||
{
|
{
|
||||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_NEXT_ATTRIBUTE, attr, sizeof(struct device_attr_info));
|
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_NEXT_ATTRIBUTE,
|
||||||
|
attr, sizeof(struct device_attr_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006-2012, Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
#ifndef _DM_WRAPPER_H_
|
#ifndef _DM_WRAPPER_H_
|
||||||
#define _DM_WRAPPER_H_
|
#define _DM_WRAPPER_H_
|
||||||
|
|
||||||
|
|
||||||
#include "device_manager_defs.h"
|
#include "device_manager_defs.h"
|
||||||
|
|
||||||
|
|
||||||
status_t init_dm_wrapper(void);
|
status_t init_dm_wrapper(void);
|
||||||
status_t uninit_dm_wrapper(void);
|
status_t uninit_dm_wrapper(void);
|
||||||
|
|
||||||
@@ -11,4 +17,5 @@ status_t get_child(device_node_cookie *cookie);
|
|||||||
status_t get_next_child(device_node_cookie *cookie);
|
status_t get_next_child(device_node_cookie *cookie);
|
||||||
status_t dm_get_next_attr(struct device_attr_info *attr);
|
status_t dm_get_next_attr(struct device_attr_info *attr);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+35
-27
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2006-2012, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "pcihdr.h"
|
#include "pcihdr.h"
|
||||||
#include "pci-utils.h"
|
#include "pci-utils.h"
|
||||||
|
|
||||||
|
|
||||||
extern const char *__progname;
|
extern const char *__progname;
|
||||||
|
|
||||||
#define DUMP_MODE 0
|
#define DUMP_MODE 0
|
||||||
@@ -32,6 +33,7 @@ int gMode = USER_MODE;
|
|||||||
#define BUS_PCI 2
|
#define BUS_PCI 2
|
||||||
#define BUS_SCSI 3
|
#define BUS_SCSI 3
|
||||||
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
get_scsi_device_type(uint8 type)
|
get_scsi_device_type(uint8 type)
|
||||||
{
|
{
|
||||||
@@ -99,7 +101,7 @@ dump_attribute(struct device_attr_info *attr, int32 level)
|
|||||||
default:
|
default:
|
||||||
printf("raw data");
|
printf("raw data");
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -127,12 +129,12 @@ dump_nodes(device_node_cookie *node, uint8 level)
|
|||||||
status_t err;
|
status_t err;
|
||||||
device_node_cookie child = *node;
|
device_node_cookie child = *node;
|
||||||
dump_device(node, level);
|
dump_device(node, level);
|
||||||
|
|
||||||
if (get_child(&child) != B_OK)
|
if (get_child(&child) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
dump_nodes(&child, level+1);
|
dump_nodes(&child, level + 1);
|
||||||
} while ((err = get_next_child(&child)) == B_OK);
|
} while ((err = get_next_child(&child)) == B_OK);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -166,7 +168,7 @@ display_device(device_node_cookie *node, uint8 level)
|
|||||||
uint8 scsi_type = 255;
|
uint8 scsi_type = 255;
|
||||||
char scsi_vendor[64];
|
char scsi_vendor[64];
|
||||||
char scsi_product[64];
|
char scsi_product[64];
|
||||||
|
|
||||||
const char *venShort;
|
const char *venShort;
|
||||||
const char *venFull;
|
const char *venFull;
|
||||||
const char *devShort;
|
const char *devShort;
|
||||||
@@ -185,7 +187,7 @@ display_device(device_node_cookie *node, uint8 level)
|
|||||||
&& attr.type == B_UINT8_TYPE) {
|
&& attr.type == B_UINT8_TYPE) {
|
||||||
scsi_path_id = attr.value.ui8;
|
scsi_path_id = attr.value.ui8;
|
||||||
} else if (!strcmp(attr.name, B_DEVICE_TYPE)
|
} else if (!strcmp(attr.name, B_DEVICE_TYPE)
|
||||||
&& attr.type == B_UINT16_TYPE)
|
&& attr.type == B_UINT16_TYPE)
|
||||||
pci_class_base_id = attr.value.ui8;
|
pci_class_base_id = attr.value.ui8;
|
||||||
else if (!strcmp(attr.name, B_DEVICE_SUB_TYPE)
|
else if (!strcmp(attr.name, B_DEVICE_SUB_TYPE)
|
||||||
&& attr.type == B_UINT16_TYPE)
|
&& attr.type == B_UINT16_TYPE)
|
||||||
@@ -228,47 +230,53 @@ display_device(device_node_cookie *node, uint8 level)
|
|||||||
else if (!strcmp(attr.name, PCI_DEVICE_SUBSYSTEM_ID_ITEM)
|
else if (!strcmp(attr.name, PCI_DEVICE_SUBSYSTEM_ID_ITEM)
|
||||||
&& attr.type == B_UINT16_TYPE)
|
&& attr.type == B_UINT16_TYPE)
|
||||||
pci_subsystem_id = attr.value.ui16;*/
|
pci_subsystem_id = attr.value.ui16;*/
|
||||||
|
|
||||||
attr.value.raw.data = data;
|
attr.value.raw.data = data;
|
||||||
attr.value.raw.length = sizeof(data);
|
attr.value.raw.length = sizeof(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (bus) {
|
switch (bus) {
|
||||||
case BUS_ISA:
|
case BUS_ISA:
|
||||||
new_level=level+1;
|
new_level = level + 1;
|
||||||
break;
|
break;
|
||||||
case BUS_PCI:
|
case BUS_PCI:
|
||||||
printf("\n");
|
printf("\n");
|
||||||
{
|
{
|
||||||
char classInfo[64];
|
char classInfo[64];
|
||||||
get_class_info(pci_class_base_id, pci_class_sub_id, pci_class_api_id, classInfo, 64);
|
get_class_info(pci_class_base_id, pci_class_sub_id,
|
||||||
|
pci_class_api_id, classInfo, 64);
|
||||||
put_level(level);
|
put_level(level);
|
||||||
printf("device %s [%x|%x|%x]\n", classInfo, pci_class_base_id, pci_class_sub_id, pci_class_api_id);
|
printf("device %s [%x|%x|%x]\n", classInfo, pci_class_base_id,
|
||||||
|
pci_class_sub_id, pci_class_api_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
put_level(level);
|
put_level(level);
|
||||||
printf(" ");
|
printf(" ");
|
||||||
get_vendor_info(pci_vendor_id, &venShort, &venFull);
|
get_vendor_info(pci_vendor_id, &venShort, &venFull);
|
||||||
if (!venShort && !venFull) {
|
if (!venShort && !venFull) {
|
||||||
printf("vendor %04x: Unknown\n", pci_vendor_id);
|
printf("vendor %04x: Unknown\n", pci_vendor_id);
|
||||||
} else if (venShort && venFull) {
|
} else if (venShort && venFull) {
|
||||||
printf("vendor %04x: %s - %s\n", pci_vendor_id, venShort, venFull);
|
printf("vendor %04x: %s - %s\n", pci_vendor_id,
|
||||||
|
venShort, venFull);
|
||||||
} else {
|
} else {
|
||||||
printf("vendor %04x: %s\n", pci_vendor_id, venShort ? venShort : venFull);
|
printf("vendor %04x: %s\n", pci_vendor_id,
|
||||||
|
venShort ? venShort : venFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
put_level(level);
|
put_level(level);
|
||||||
printf(" ");
|
printf(" ");
|
||||||
get_device_info(pci_vendor_id, pci_device_id, pci_subsystem_vendor_id, pci_subsystem_id,
|
get_device_info(pci_vendor_id, pci_device_id,
|
||||||
&devShort, &devFull);
|
pci_subsystem_vendor_id, pci_subsystem_id, &devShort, &devFull);
|
||||||
if (!devShort && !devFull) {
|
if (!devShort && !devFull) {
|
||||||
printf("device %04x: Unknown\n", pci_device_id);
|
printf("device %04x: Unknown\n", pci_device_id);
|
||||||
} else if (devShort && devFull) {
|
} else if (devShort && devFull) {
|
||||||
printf("device %04x: %s (%s)\n", pci_device_id, devShort, devFull);
|
printf("device %04x: %s (%s)\n", pci_device_id,
|
||||||
|
devShort, devFull);
|
||||||
} else {
|
} else {
|
||||||
printf("device %04x: %s\n", pci_device_id, devShort ? devShort : devFull);
|
printf("device %04x: %s\n", pci_device_id,
|
||||||
|
devShort ? devShort : devFull);
|
||||||
}
|
}
|
||||||
new_level = level+1;
|
new_level = level + 1;
|
||||||
break;
|
break;
|
||||||
case BUS_SCSI:
|
case BUS_SCSI:
|
||||||
if (scsi_type == 255)
|
if (scsi_type == 255)
|
||||||
@@ -276,13 +284,13 @@ display_device(device_node_cookie *node, uint8 level)
|
|||||||
put_level(level);
|
put_level(level);
|
||||||
printf(" device [%x|%x]\n", scsi_target_id, scsi_target_lun);
|
printf(" device [%x|%x]\n", scsi_target_id, scsi_target_lun);
|
||||||
put_level(level);
|
put_level(level);
|
||||||
printf(" vendor %15s\tmodel %15s\ttype %s\n", scsi_vendor,
|
printf(" vendor %15s\tmodel %15s\ttype %s\n", scsi_vendor,
|
||||||
scsi_product, get_scsi_device_type(scsi_type));
|
scsi_product, get_scsi_device_type(scsi_type));
|
||||||
|
|
||||||
new_level = level+1;
|
new_level = level + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new_level;
|
return new_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +304,7 @@ display_nodes(device_node_cookie *node, uint8 level)
|
|||||||
|
|
||||||
if (get_child(&child) != B_OK)
|
if (get_child(&child) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
display_nodes(&child, level);
|
display_nodes(&child, level);
|
||||||
} while ((err = get_next_child(&child)) == B_OK);
|
} while ((err = get_next_child(&child)) == B_OK);
|
||||||
@@ -313,9 +321,9 @@ main(int argc, char **argv)
|
|||||||
printf("Error initializing device manager (%s)\n", strerror(error));
|
printf("Error initializing device manager (%s)\n", strerror(error));
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
if (!strcmp(argv[1], "-d")) {
|
if (!strcmp(argv[1], "-d")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user