Re: Definition of the CSRs

From: Himanshu Chauhan <himanshu_at_thechauhan.dev>
Date: Mon, 23 Dec 2024 11:35:09 UTC

> On 23 Dec 2024, at 16:55, Himanshu Chauhan <himanshu@thechauhan.dev> wrote:
> 
> Hi,
> 
> I see the following in the code:
> 
> csr_read(sstatus)
> csr_read(stval)
> 
> But I can’t figure out where these sstatus and stval are defined. I want to define CSRs for IMSIC. I am using hard coded values for now but want to get rid of them. How can I do that?
> 

Something like this in my C file works okay:

#define IMSIC_CSR_SISELECT      0x150 
#define IMSIC_CSR_SIREG            0x151
#define IMSIC_CSR_STOPEI          0x15c 
#define IMSIC_CSR_STOPI            0xdb0

#ifdef DECLARE_CSR                                
DECLARE_CSR(siselect, IMSIC_SISELCT)
DECLARE_CSR(sireg, IMSIC_SIREG)    
DECLARE_CSR(stopei, IMSIC_STOPEI)
DECLARE_CSR(stopi, IMSIC_STOPI)
#endif

Is this the right way to do it?

> Regards
> Himanshu
>