[PATCH v2] lib: sbi: Improve csr read and write

Xiang W wxjstz at 126.com
Thu May 26 07:37:40 PDT 2022


在 2022-05-26星期四的 16:31 +0200,Jan Remeš写道:
> On Thu, May 26, 2022 at 4:19 PM Xiang W <wxjstz at 126.com> wrote:
> > 
> > +       uint32_t opcode_buff[2];
> > +       typedef unsigned long (*read_f)(void);
> > +       opcode_buff[0] = (csr_num << 20) | 0x00002573; /* csrr a0, csr */
> > +       opcode_buff[1] = 0x00008067; /* ret */
> > +       return ((read_f)opcode_buff)();
> I am not completely sure here, but doesn't this need a FENCE.I before
> the opcode is executed?
Yes, fence.i is need. 

Thx
 Xiang W
> 
> Best regards,
>   Jan





More information about the opensbi mailing list