riscv-non-isa/riscv-rvm-csi

CSR Register Accessing API Proposal

Opened this issue · 12 comments

Hi @WiseCrohn @VincentCui632 , we will start to do CSR Access API based on existing NMSIS-Core CSR API macros, the macros implementation and documentation can be found here:

  1. Implementation: https://github.com/Nuclei-Software/NMSIS/blob/master/NMSIS/Core/Include/core_feature_base.h#L450-L578
  2. Doc: https://doc.nucleisys.com/nmsis/core/api/core_csr_access.html

If you have any feedback, we can discuss it here, and we will push this CSR accessing API PR when we have done it.

Thanks

Yes, that looks like the kind of thing we need, thank you.

Could you please go to https://github.com/riscv-admin/help/issues/new/choose and request Jira access? Then we can assign you to the Jira task.

Yes I have seen your comment, but I can't assign the task to you.

@WiseCrohn hello, it seems the csi_parser.py doesn't support macro_define-type function like the normal functions with 'description', 'c-params','c-return-value'. The macro_define-type function can only be decribed as fragment, which is not suitable.

so I will pull request the hand-coded csi_csr_access.h without the yaml file first?

  - comment:
      Read the content of csr register to __v, 
      then write content of val into csr register, then return __v
    fragment: |
      #define __RV_CSR_SWAP(csr, val)                                 \
          ({                                                          \
              rv_csr_t __v = (unsigned long)(val);                    \
              __ASM volatile("csrrw %0, " STRINGIFY(csr) ", %1"       \
                           : "=r"(__v)                                \
                           : "rK"(__v)                                \
                           : "memory");                               \
              __v;                                                    \
          })

My teammate have opened an PR here for CSR access API, see #10

@WiseCrohn hello, it seems the csi_parser.py doesn't support macro_define-type function like the normal functions with 'description', 'c-params','c-return-value'. The macro_define-type function can only be decribed as fragment, which is not suitable.

You can just use the c-definitions field like in csi_hl_console_spec.yaml. This allows for fragments with a comment above each fragment. I think it can produce exactly what you have in the header you submitted?

@WiseCrohn hello, it seems the csi_parser.py doesn't support macro_define-type function like the normal functions with 'description', 'c-params','c-return-value'. The macro_define-type function can only be decribed as fragment, which is not suitable.

You can just use the c-definitions field like in csi_hl_console_spec.yaml. This allows for fragments with a comment above each fragment. I think it can produce exactly what you have in the header you submitted?

Yes,I already did this like c-definitions field in csi_hl_console_spec.yaml,
but I thought describing params and return value like functions field will be better , so I didn't push the ready yaml.

OK, I can push this yaml just using fragment.

PR #11 addresses your points about defining a macro with arguments.

@dongyongtao maybe you could take a try when you are free.

PR #11 addresses your points about defining a macro with arguments.

ok, I will have a try, thanks

PR #11 addresses your points about defining a macro with arguments.

it‘s ok, and what I want. The yaml has updated macros by this PR.