Working version
This commit is contained in:
		| @@ -1,3 +1,4 @@ | ||||
| // See LICENSE for license details. | ||||
| #ifndef _RISCV_BITS_H | ||||
| #define _RISCV_BITS_H | ||||
|  | ||||
| @@ -17,7 +18,7 @@ | ||||
| #define STR(x) XSTR(x) | ||||
| #define XSTR(x) #x | ||||
|  | ||||
| #ifdef __riscv64 | ||||
| #if __riscv_xlen == 64 | ||||
| # define SLL32    sllw | ||||
| # define STORE    sd | ||||
| # define LOAD     ld | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| // See LICENSE for license details. | ||||
| /* Derived from <linux/const.h> */ | ||||
|  | ||||
| #ifndef _SIFIVE_CONST_H | ||||
|   | ||||
							
								
								
									
										30
									
								
								hello-world/bsp/include/sifive/devices/clic.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								hello-world/bsp/include/sifive/devices/clic.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| // See LICENSE for license details. | ||||
|  | ||||
| #ifndef _SIFIVE_CLIC_H | ||||
| #define _SIFIVE_CLIC_H | ||||
|  | ||||
| #define CLIC_HART0          0x00800000 | ||||
| #define CLIC_MSIP           0x0000 | ||||
| #define CLIC_MSIP_size      0x4 | ||||
| #define CLIC_MTIMECMP       0x4000 | ||||
| #define CLIC_MTIMECMP_size  0x8 | ||||
| #define CLIC_MTIME          0xBFF8 | ||||
| #define CLIC_MTIME_size     0x8 | ||||
|  | ||||
| #define CLIC_INTIP          0x000 | ||||
| #define CLIC_INTIE          0x400 | ||||
| #define CLIC_INTCFG         0x800 | ||||
| #define CLIC_CFG            0xc00 | ||||
|  | ||||
| // These interrupt IDs are consistent across old and new mtvec modes | ||||
| #define SSIPID              1 | ||||
| #define MSIPID              3 | ||||
| #define STIPID              5 | ||||
| #define MTIPID              7 | ||||
| #define SEIPID              9 | ||||
| #define MEIPID              11 | ||||
| #define CSIPID              12 | ||||
| #define LOCALINTIDBASE      16 | ||||
|  | ||||
|  | ||||
| #endif /* _SIFIVE_CLIC_H */  | ||||
| @@ -30,8 +30,8 @@ | ||||
|  | ||||
| /* Fields */ | ||||
|  | ||||
| #define SPI_SCK_POL             0x1 | ||||
| #define SPI_SCK_PHA             0x2 | ||||
| #define SPI_SCK_PHA             0x1 | ||||
| #define SPI_SCK_POL             0x2 | ||||
|  | ||||
| #define SPI_FMT_PROTO(x)        ((x) & 0x3) | ||||
| #define SPI_FMT_ENDIAN(x)       (((x) & 0x1) << 2) | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| // See LICENSE for license details. | ||||
| #ifndef _SECTIONS_H | ||||
| #define _SECTIONS_H | ||||
|  | ||||
|   | ||||
							
								
								
									
										65
									
								
								hello-world/bsp/include/sifive/smp.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								hello-world/bsp/include/sifive/smp.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| #ifndef SIFIVE_SMP | ||||
| #define SIFIVE_SMP | ||||
|  | ||||
| // The maximum number of HARTs this code supports | ||||
| #ifndef MAX_HARTS | ||||
| #define MAX_HARTS 32 | ||||
| #endif | ||||
| #define CLINT_END_HART_IPI CLINT_CTRL_ADDR + (MAX_HARTS*4) | ||||
|  | ||||
| // The hart that non-SMP tests should run on | ||||
| #ifndef NONSMP_HART | ||||
| #define NONSMP_HART 0 | ||||
| #endif | ||||
|  | ||||
| /* If your test cannot handle multiple-threads, use this:  | ||||
|  *   smp_disable(reg1) | ||||
|  */ | ||||
| #define smp_disable(reg1, reg2)			 \ | ||||
|   csrr reg1, mhartid				;\ | ||||
|   li   reg2, NONSMP_HART			;\ | ||||
|   beq  reg1, reg2, hart0_entry			;\ | ||||
| 42:						;\ | ||||
|   wfi    					;\ | ||||
|   j 42b						;\ | ||||
| hart0_entry: | ||||
|  | ||||
| /* If your test needs to temporarily block multiple-threads, do this: | ||||
|  *    smp_pause(reg1, reg2) | ||||
|  *    ... single-threaded work ... | ||||
|  *    smp_resume(reg1, reg2) | ||||
|  *    ... multi-threaded work ... | ||||
|  */ | ||||
|  | ||||
| #define smp_pause(reg1, reg2)	 \ | ||||
|   li reg2, 0x8			;\ | ||||
|   csrw mie, reg2		;\ | ||||
|   csrr reg2, mhartid		;\ | ||||
|   bnez reg2, 42f | ||||
|  | ||||
| #define smp_resume(reg1, reg2)	 \ | ||||
|   li reg1, CLINT_CTRL_ADDR	;\ | ||||
| 41:				;\ | ||||
|   li reg2, 1			;\ | ||||
|   sw reg2, 0(reg1)		;\ | ||||
|   addi reg1, reg1, 4		;\ | ||||
|   li reg2, CLINT_END_HART_IPI	;\ | ||||
|   blt reg1, reg2, 41b		;\ | ||||
| 42:				;\ | ||||
|   wfi    			;\ | ||||
|   csrr reg2, mip		;\ | ||||
|   andi reg2, reg2, 0x8		;\ | ||||
|   beqz reg2, 42b		;\ | ||||
|   li reg1, CLINT_CTRL_ADDR	;\ | ||||
|   csrr reg2, mhartid		;\ | ||||
|   slli reg2, reg2, 2		;\ | ||||
|   add reg2, reg2, reg1		;\ | ||||
|   sw zero, 0(reg2)		;\ | ||||
| 41:				;\ | ||||
|   lw reg2, 0(reg1)		;\ | ||||
|   bnez reg2, 41b		;\ | ||||
|   addi reg1, reg1, 4		;\ | ||||
|   li reg2, CLINT_END_HART_IPI	;\ | ||||
|   blt reg1, reg2, 41b | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user