riscv-non-isa / riscv-rvm-csi

RVM-CSI (RISC-V eMbedded - Common Software Interface) aims to provide a source-level portability layer providing a simplified transition path between different microcontrollers based on RISC-V. This repo contains the specification documentation, and language-specific source files for implementing the API (initially, C header files).
https://jira.riscv.org/browse/RVG-27
Creative Commons Attribution 4.0 International
10 stars 4 forks source link

CSR Register Accessing API Proposal #8

Open fanghuaqi opened 1 year ago

fanghuaqi commented 1 year ago

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

WiseCrohn commented 1 year ago

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

WiseCrohn commented 1 year ago

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.

fanghuaqi commented 1 year ago

Hi @WiseCrohn , I have comment on this https://jira.riscv.org/secure/RapidBoard.jspa?rapidView=397&view=detail&selectedIssue=RECSI-17

WiseCrohn commented 1 year ago

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

dongyongtao commented 1 year ago

@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;                                                    \
          })
fanghuaqi commented 1 year ago

My teammate have opened an PR here for CSR access API, see https://github.com/riscv-non-isa/riscv-rvm-csi/pull/10

WiseCrohn commented 1 year ago

@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?

dongyongtao commented 1 year ago

@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.

WiseCrohn commented 1 year ago

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

fanghuaqi commented 1 year ago

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

dongyongtao commented 1 year ago

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

ok, I will have a try, thanks

dongyongtao commented 1 year ago

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.