/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcitool/cli.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-19 13:58:46 UTC
  • Revision ID: csa@suren.me-20151019135846-nz3f6iobifx06xvq
Support computed (property-based) registers

Show diffs side-by-side

added added

removed removed

Lines of Context:
706
706
    if (r) printf(")");
707
707
    printf("\n");
708
708
 
709
 
    if (r) {
710
 
        err = pcilib_read_register_view_by_id(handle, reg, r->views[id].name, &val);
 
709
    if (v->mode&PCILIB_ACCESS_R) {
 
710
        if (r) {
 
711
            err = pcilib_read_register_view_by_id(handle, reg, r->views[id].name, &val);
 
712
        } else {
 
713
            err = pcilib_get_property(handle, v->name, &val);
 
714
        }
 
715
        if (!err) err = pcilib_convert_value_type(handle, &val, PCILIB_TYPE_STRING);
711
716
    } else {
712
 
        err = pcilib_get_property(handle, v->name, &val);
 
717
        err = PCILIB_ERROR_NOTPERMITED;
713
718
    }
714
 
    if (!err) err = pcilib_convert_value_type(handle, &val, PCILIB_TYPE_STRING);
715
719
 
716
 
    if (err)
717
 
        printf("    Current value  : error %i\n", err);
718
 
    else {
 
720
    if (err) {
 
721
        if (err == PCILIB_ERROR_NOTPERMITED)
 
722
            printf("    Current value  : no read access\n");
 
723
        else
 
724
            printf("    Current value  : error %i\n", err);
 
725
    } else {
719
726
        printf("    Current value  : %s", val.sval);
720
727
        if (v->unit) printf(" (units: %s)", v->unit);
721
728
        printf("\n");
775
782
    pcilib_register_bank_t bank = pcilib_find_register_bank_by_addr(handle, r->bank);
776
783
    const pcilib_register_bank_description_t *b = &model_info->banks[bank];
777
784
 
778
 
    err = pcilib_read_register_by_id(handle, reg, &regval);
 
785
    if (r->mode&PCILIB_ACCESS_R) {
 
786
        err = pcilib_read_register_by_id(handle, reg, &regval);
 
787
    } else {
 
788
        err = PCILIB_ERROR_NOTPERMITED;
 
789
    }
779
790
 
780
791
    info = pcilib_get_register_info(handle, b->name, r->name, 0);
781
792
    if (!info) Error("Can't obtain register info for %s", r->name);
782
793
 
783
794
    printf("%s/%s\n", b->name, r->name);
784
795
    printf("  Current value: ");
785
 
    if (err) printf("error %i", err);
786
 
    else printf(b->format, regval);
 
796
    if (err) {
 
797
        if (err == PCILIB_ERROR_NOTPERMITED) printf("no read access");
 
798
        else printf("error %i", err);
 
799
    } else printf(b->format, regval);
787
800
 
788
801
    if (r->mode&PCILIB_REGISTER_W) {
789
802
        printf(" (default: ");