@@ -35,9 +35,12 @@ static const bool debug = false;
3535static void intcfg_decode (SiFiveCLICState * clic , int hartid , int intcfg ,
3636 int * mode , int * level , int * priority )
3737{
38- int nmbits = clic -> nmbits [hartid ], nmshift = 8 - nmbits ;
39- int nlbits = clic -> nlbits [hartid ], nlshift = 8 - nmbits - nlbits ;
40- int npbits = clic -> npbits [hartid ], npshift = 8 - nmbits - nlbits - npbits ;
38+ int nmbits = clic -> nmbits [hartid ];
39+ int nlbits = clic -> nlbits [hartid ];
40+ int npbits = clic -> npbits [hartid ];
41+ int nmshift = SIFIVE_CLIC_MAX_INT_BITS - nmbits ;
42+ int nlshift = SIFIVE_CLIC_MAX_INT_BITS - nmbits - nlbits ;
43+ int npshift = SIFIVE_CLIC_MAX_INT_BITS - nmbits - nlbits - npbits ;
4144 int decoded_mode = (intcfg >> nmshift ) & ((1 << nmbits ) - 1 );
4245 int decoded_level = (intcfg >> nlshift ) & ((1 << nlbits ) - 1 );
4346 int decoded_priority = (intcfg >> npshift ) & ((1 << npbits ) - 1 );
@@ -55,12 +58,12 @@ static void intcfg_decode(SiFiveCLICState *clic, int hartid, int intcfg,
5558 }
5659
5760 /* unused level bits are set to 1 */
58- * level = decoded_level << (SIFIVE_CLIC_LEVEL_BITS - nlbits ) |
59- ((1 << (SIFIVE_CLIC_LEVEL_BITS - nlbits )) - 1 );
61+ * level = decoded_level << (SIFIVE_CLIC_MAX_LEVEL_BITS - nlbits ) |
62+ ((1 << (SIFIVE_CLIC_MAX_LEVEL_BITS - nlbits )) - 1 );
6063
6164 /* unused priority bits are set to 1 */
62- * priority = decoded_priority << (SIFIVE_CLIC_PRIORITY_BITS - nlbits ) |
63- ((1 << (SIFIVE_CLIC_PRIORITY_BITS - npbits )) - 1 );
65+ * priority = decoded_priority << (SIFIVE_CLIC_MAX_PRIORITY_BITS - nlbits ) |
66+ ((1 << (SIFIVE_CLIC_MAX_PRIORITY_BITS - npbits )) - 1 );
6467}
6568
6669static void sifive_clic_next_interrupt (SiFiveCLICState * clic , int hartid )
@@ -779,11 +782,13 @@ DeviceState *sifive_clic_create(hwaddr addr, hwaddr size,
779782{
780783 int i ;
781784
782- assert (num_sources >= 4 && num_sources <= 1024 );
783- assert (int_bits >= 2 && int_bits <= 8 );
784- assert (mode_bits <= 2 );
785- assert (level_bits <= 8 );
786- assert (vec_bits <= 1 );
785+ assert (num_sources >= SIFIVE_CLIC_MIN_SOURCES );
786+ assert (num_sources <= SIFIVE_CLIC_MAX_SOURCES );
787+ assert (int_bits >= SIFIVE_CLIC_MIN_INT_BITS );
788+ assert (int_bits <= SIFIVE_CLIC_MAX_INT_BITS );
789+ assert (mode_bits <= SIFIVE_CLIC_MAX_MODE_BITS );
790+ assert (level_bits <= SIFIVE_CLIC_MAX_LEVEL_BITS );
791+ assert (vec_bits <= SIFIVE_CLIC_MAX_VEC_BITS );
787792
788793 DeviceState * dev = qdev_create (NULL , TYPE_SIFIVE_CLIC );
789794
0 commit comments