664
void ViewInfo(pcilib_t *handle, pcilib_register_t reg, size_t id) {
668
pcilib_value_t val = {0};
669
pcilib_register_value_name_t *vnames;
672
const pcilib_model_description_t *model_info = pcilib_get_model_description(handle);
673
const pcilib_register_description_t *r;
674
const pcilib_view_description_t *v;
676
if (reg == PCILIB_REGISTER_INVALID) {
680
r = &model_info->registers[reg];
681
view = pcilib_find_view_by_name(handle, r->views[id].view);
684
if (view == PCILIB_VIEW_INVALID) return;
685
v = model_info->views[view];
688
printf(" View %s (", r->views[id].name);
690
printf("%s\n", v->name);
691
printf(" Data type : ");
694
case PCILIB_TYPE_STRING:
697
case PCILIB_TYPE_DOUBLE:
700
case PCILIB_TYPE_LONG:
710
err = pcilib_read_register_view_by_id(handle, reg, r->views[id].name, &val);
712
err = pcilib_get_property(handle, v->name, &val);
714
if (!err) err = pcilib_convert_value_type(handle, &val, PCILIB_TYPE_STRING);
717
printf(" Current value : error %i\n", err);
719
printf(" Current value : %s", val.sval);
720
if (v->unit) printf(" (units: %s)", v->unit);
725
pcilib_unit_t unit = pcilib_find_unit_by_name(handle, v->unit);
727
printf(" Supported units: %s", v->unit);
729
if (unit != PCILIB_UNIT_INVALID) {
730
const pcilib_unit_description_t *u = &model_info->units[unit];
732
for (i = 0; u->transforms[i].unit; i++)
733
printf(", %s", u->transforms[i].unit);
738
printf(" Access : ");
739
if ((v->mode&PCILIB_REGISTER_RW) == 0) printf("-");
740
if (v->mode&PCILIB_REGISTER_R) printf("R");
741
if (v->mode&PCILIB_REGISTER_W) printf("W");
744
if ((v->api == &pcilib_enum_view_static_api)||(v->api == &pcilib_enum_view_xml_api)) {
745
vnames = ((pcilib_enum_view_description_t*)v)->names;
746
printf(" Value aliases :");
747
for (i = 0; vnames[i].name; i++) {
749
printf(" %s = %u", vnames[i].name, vnames[i].value);
750
if (vnames[i].min != vnames[i].max)
751
printf(" (%u - %u)", vnames[i].min, vnames[i].max);
754
} else if (v->api == &pcilib_transform_view_api) {
755
const pcilib_transform_view_description_t *tv = (const pcilib_transform_view_description_t*)v;
756
if (tv->read_from_reg)
757
printf(" Read function : %s\n", tv->read_from_reg);
758
if (tv->write_to_reg)
759
printf(" Write function : %s\n", tv->write_to_reg);
763
printf(" Description : %s\n", v->description);
662
766
void RegisterInfo(pcilib_t *handle, pcilib_register_t reg) {
664
pcilib_value_t val = {0};
665
770
pcilib_register_value_t regval;
771
pcilib_register_info_t *info;
667
773
const pcilib_model_description_t *model_info = pcilib_get_model_description(handle);
668
774
const pcilib_register_description_t *r = &model_info->registers[reg];
670
776
const pcilib_register_bank_description_t *b = &model_info->banks[bank];
672
778
err = pcilib_read_register_by_id(handle, reg, ®val);
780
info = pcilib_get_register_info(handle, b->name, r->name, 0);
781
if (!info) Error("Can't obtain register info for %s", r->name);
675
783
printf("%s/%s\n", b->name, r->name);
676
784
printf(" Current value: ");
680
788
if (r->mode&PCILIB_REGISTER_W) {
681
789
printf(" (default: ");
682
790
printf(b->format, r->defvalue);
793
printf(b->format, info->range->min);
795
printf(b->format, info->range->max);
687
801
printf(" Address : 0x%x [%u:%u]\n", r->addr, r->offset, r->offset + r->bits);
802
if ((info->values)&&(info->values[0].name)) {
803
printf(" Value aliases:");
804
for (i = 0; info->values[i].name; i++)
805
printf(" %s", info->values[i].name);
688
808
printf(" Access : ");
689
809
if ((r->mode&PCILIB_REGISTER_RW) == 0) printf("-");
690
810
if (r->mode&PCILIB_REGISTER_R) printf("R");
698
818
printf(" Description : %s\n", r->description);
702
821
printf("\nSupported Views:\n");
703
822
for (i = 0; r->views[i].name; i++) {
704
pcilib_view_t view = pcilib_find_view_by_name(handle, r->views[i].view);
705
if (view == PCILIB_VIEW_INVALID) continue;
707
const pcilib_view_description_t *v = model_info->views[view];
709
printf(" View %s (", r->views[i].name);
711
case PCILIB_TYPE_STRING:
714
case PCILIB_TYPE_DOUBLE:
722
err = pcilib_read_register_view(handle, b->name, r->name, r->views[i].name, &val);
723
if (!err) err = pcilib_convert_value_type(handle, &val, PCILIB_TYPE_STRING);
726
printf(" Current value : error %i\n", err);
728
printf(" Current value : %s", val.sval);
729
if (v->unit) printf(" (units: %s)", v->unit);
734
pcilib_unit_t unit = pcilib_find_unit_by_name(handle, v->unit);
736
printf(" Supported units: %s", v->unit);
738
if (unit != PCILIB_UNIT_INVALID) {
740
const pcilib_unit_description_t *u = &model_info->units[unit];
742
for (j = 0; u->transforms[j].unit; j++)
743
printf(", %s", u->transforms[j].unit);
749
printf(" Description : %s\n", v->description);
823
ViewInfo(handle, reg, i);
754
// printf("Type: %s". r->rw
827
pcilib_free_register_info(handle, info);
757
830
void Info(pcilib_t *handle, const pcilib_model_description_t *model_info, const char *target) {
783
pcilib_register_t reg;
785
reg = pcilib_find_register(handle, NULL, target);
786
if (reg != PCILIB_REGISTER_INVALID)
787
return RegisterInfo(handle, reg);
789
Error(" No register %s is found", target);
856
if (*target == '/') {
858
view = pcilib_find_view_by_name(handle, target);
859
if (view != PCILIB_VIEW_INVALID)
860
return ViewInfo(handle, PCILIB_REGISTER_INVALID, view);
862
Error(" No property %s is found", target);
864
pcilib_register_t reg;
866
reg = pcilib_find_register(handle, NULL, target);
867
if (reg != PCILIB_REGISTER_INVALID)
868
return RegisterInfo(handle, reg);
870
Error(" No register %s is found", target);
792
875
List(handle, model_info, (char*)-1, 0);