-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[d1][f133]add sid payload for d1/f133, using word access instead of b…
…yte access
- Loading branch information
1 parent
ae832eb
commit 77c7853
Showing
18 changed files
with
899 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Normal rules | ||
# | ||
*~ | ||
|
||
# | ||
# Generated files | ||
# | ||
/.obj | ||
/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# | ||
# Top makefile | ||
# | ||
|
||
CROSS ?= ~/Xuantie-900-gcc-linux-5.10.4-musl64-x86_64-V2.4.0/bin/riscv64-unknown-linux-musl- | ||
NAME := sid | ||
|
||
# | ||
# System environment variable. | ||
# | ||
# | ||
# System environment variable. | ||
# | ||
ifeq ($(OS), Windows_NT) | ||
HOSTOS := windows | ||
else | ||
ifneq (,$(findstring Linux, $(shell uname -a))) | ||
HOSTOS := linux | ||
endif | ||
endif | ||
|
||
# | ||
# Load default variables. | ||
# | ||
ASFLAGS := -g -ggdb -Wall -O3 | ||
CFLAGS := -g -ggdb -Wall -O3 | ||
CXXFLAGS := -g -ggdb -Wall -O3 | ||
LDFLAGS := -T link.ld -nostdlib | ||
ARFLAGS := -rcs | ||
OCFLAGS := -v -O binary | ||
ODFLAGS := | ||
MCFLAGS := -march=rv64gvxthead -mabi=lp64d -mcmodel=medany -fno-stack-protector | ||
|
||
LIBDIRS := | ||
LIBS := | ||
INCDIRS := | ||
SRCDIRS := | ||
|
||
# | ||
# Add external library | ||
# | ||
INCDIRS += include \ | ||
include/external | ||
SRCDIRS += source \ | ||
source/external | ||
|
||
# | ||
# You shouldn't need to change anything below this point. | ||
# | ||
AS := $(CROSS)gcc -x assembler-with-cpp | ||
CC := $(CROSS)gcc | ||
CXX := $(CROSS)g++ | ||
LD := $(CROSS)ld | ||
AR := $(CROSS)ar | ||
OC := $(CROSS)objcopy | ||
OD := $(CROSS)objdump | ||
MKDIR := mkdir -p | ||
CP := cp -af | ||
RM := rm -fr | ||
CD := cd | ||
FIND := find | ||
|
||
# | ||
# X variables | ||
# | ||
X_ASFLAGS := $(MCFLAGS) $(ASFLAGS) | ||
X_CFLAGS := $(MCFLAGS) $(CFLAGS) | ||
X_CXXFLAGS := $(MCFLAGS) $(CXXFLAGS) | ||
X_LDFLAGS := $(LDFLAGS) | ||
X_OCFLAGS := $(OCFLAGS) | ||
X_LIBDIRS := $(LIBDIRS) | ||
X_LIBS := $(LIBS) -lgcc | ||
|
||
X_OUT := output | ||
X_NAME := $(patsubst %, $(X_OUT)/%, $(NAME)) | ||
X_INCDIRS := $(patsubst %, -I %, $(INCDIRS)) | ||
X_SRCDIRS := $(patsubst %, %, $(SRCDIRS)) | ||
X_OBJDIRS := $(patsubst %, .obj/%, $(X_SRCDIRS)) | ||
|
||
X_SFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.S)) | ||
X_CFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.c)) | ||
X_CPPFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.cpp)) | ||
|
||
X_SDEPS := $(patsubst %, .obj/%, $(X_SFILES:.S=.o.d)) | ||
X_CDEPS := $(patsubst %, .obj/%, $(X_CFILES:.c=.o.d)) | ||
X_CPPDEPS := $(patsubst %, .obj/%, $(X_CPPFILES:.cpp=.o.d)) | ||
X_DEPS := $(X_SDEPS) $(X_CDEPS) $(X_CPPDEPS) | ||
|
||
X_SOBJS := $(patsubst %, .obj/%, $(X_SFILES:.S=.o)) | ||
X_COBJS := $(patsubst %, .obj/%, $(X_CFILES:.c=.o)) | ||
X_CPPOBJS := $(patsubst %, .obj/%, $(X_CPPFILES:.cpp=.o)) | ||
X_OBJS := $(X_SOBJS) $(X_COBJS) $(X_CPPOBJS) | ||
|
||
VPATH := $(X_OBJDIRS) | ||
|
||
.PHONY: all clean | ||
all : $(X_NAME) | ||
|
||
$(X_NAME) : $(X_OBJS) | ||
@echo [LD] Linking $@.elf | ||
@$(CC) $(X_LDFLAGS) $(X_LIBDIRS) -Wl,--cref,-Map=$@.map $^ -o $@.elf $(X_LIBS) | ||
@echo [OC] Objcopying $@.bin | ||
@$(OC) $(X_OCFLAGS) $@.elf $@.bin | ||
|
||
$(X_SOBJS) : .obj/%.o : %.S | ||
@echo [AS] $< | ||
@$(AS) $(X_ASFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@ | ||
|
||
$(X_COBJS) : .obj/%.o : %.c | ||
@echo [CC] $< | ||
@$(CC) $(X_CFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@ | ||
|
||
$(X_CPPOBJS) : .obj/%.o : %.cpp | ||
@echo [CXX] $< | ||
@$(CXX) $(X_CXXFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@ | ||
|
||
clean: | ||
@$(RM) .obj $(X_OUT) | ||
|
||
# | ||
# Include the dependency files, should be place the last of makefile | ||
# | ||
sinclude $(shell $(MKDIR) $(X_OBJDIRS) $(X_OUT)) $(X_DEPS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#ifndef __BYTEORDER_H__ | ||
#define __BYTEORDER_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <types.h> | ||
|
||
static inline u16_t __swab16(u16_t x) | ||
{ | ||
return ( (x<<8) | (x>>8) ); | ||
} | ||
|
||
static inline u32_t __swab32(u32_t x) | ||
{ | ||
return ( (x<<24) | (x>>24) | \ | ||
((x & (u32_t)0x0000ff00UL)<<8) | \ | ||
((x & (u32_t)0x00ff0000UL)>>8) ); | ||
} | ||
|
||
static inline u64_t __swab64(u64_t x) | ||
{ | ||
return ( (x<<56) | (x>>56) | \ | ||
((x & (u64_t)0x000000000000ff00ULL)<<40) | \ | ||
((x & (u64_t)0x0000000000ff0000ULL)<<24) | \ | ||
((x & (u64_t)0x00000000ff000000ULL)<< 8) | \ | ||
((x & (u64_t)0x000000ff00000000ULL)>> 8) | \ | ||
((x & (u64_t)0x0000ff0000000000ULL)>>24) | \ | ||
((x & (u64_t)0x00ff000000000000ULL)>>40) ); | ||
} | ||
|
||
/* | ||
* swap bytes bizarrely. | ||
* swahw32 - swap 16-bit half-words in a 32-bit word | ||
*/ | ||
static inline u32_t __swahw32(u32_t x) | ||
{ | ||
return ( ((x & (u32_t)0x0000ffffUL)<<16) | ((x & (u32_t)0xffff0000UL)>>16) ); | ||
} | ||
|
||
/* | ||
* swap bytes bizarrely. | ||
* swahb32 - swap 8-bit halves of each 16-bit half-word in a 32-bit word | ||
*/ | ||
static inline u32_t __swahb32(u32_t x) | ||
{ | ||
return ( ((x & (u32_t)0x00ff00ffUL)<<8) | ((x & (u32_t)0xff00ff00UL)>>8) ); | ||
} | ||
|
||
#if (BYTE_ORDER == BIG_ENDIAN) | ||
#define cpu_to_le64(x) (__swab64((u64_t)(x))) | ||
#define le64_to_cpu(x) (__swab64((u64_t)(x))) | ||
#define cpu_to_le32(x) (__swab32((u32_t)(x))) | ||
#define le32_to_cpu(x) (__swab32((u32_t)(x))) | ||
#define cpu_to_le16(x) (__swab16((u16_t)(x))) | ||
#define le16_to_cpu(x) (__swab16((u16_t)(x))) | ||
#define cpu_to_be64(x) ((u64_t)(x)) | ||
#define be64_to_cpu(x) ((u64_t)(x)) | ||
#define cpu_to_be32(x) ((u32_t)(x)) | ||
#define be32_to_cpu(x) ((u32_t)(x)) | ||
#define cpu_to_be16(x) ((u16_t)(x)) | ||
#define be16_to_cpu(x) ((u16_t)(x)) | ||
#else | ||
#define cpu_to_le64(x) ((u64_t)(x)) | ||
#define le64_to_cpu(x) ((u64_t)(x)) | ||
#define cpu_to_le32(x) ((u32_t)(x)) | ||
#define le32_to_cpu(x) ((u32_t)(x)) | ||
#define cpu_to_le16(x) ((u16_t)(x)) | ||
#define le16_to_cpu(x) ((u16_t)(x)) | ||
#define cpu_to_be64(x) (__swab64((u64_t)(x))) | ||
#define be64_to_cpu(x) (__swab64((u64_t)(x))) | ||
#define cpu_to_be32(x) (__swab32((u32_t)(x))) | ||
#define be32_to_cpu(x) (__swab32((u32_t)(x))) | ||
#define cpu_to_be16(x) (__swab16((u16_t)(x))) | ||
#define be16_to_cpu(x) (__swab16((u16_t)(x))) | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __BYTEORDER_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#ifndef __D1_REG_CCU_H__ | ||
#define __D1_REG_CCU_H__ | ||
|
||
#define D1_CCU_BASE (0x02001000) | ||
|
||
#define CCU_PLL_CPU_CTRL_REG (0x000) | ||
#define CCU_PLL_DDR_CTRL_REG (0x010) | ||
#define CCU_PLL_PERI0_CTRL_REG (0x020) | ||
#define CCU_PLL_PERI1_CTRL_REG (0x028) | ||
#define CCU_PLL_GPU_CTRL_REG (0x030) | ||
#define CCU_PLL_VIDEO0_CTRL_REG (0x040) | ||
#define CCU_PLL_VIDEO1_CTRL_REG (0x048) | ||
#define CCU_PLL_VE_CTRL (0x058) | ||
#define CCU_PLL_DE_CTRL (0x060) | ||
#define CCU_PLL_HSIC_CTRL (0x070) | ||
#define CCU_PLL_AUDIO0_CTRL_REG (0x078) | ||
#define CCU_PLL_AUDIO1_CTRL_REG (0x080) | ||
#define CCU_PLL_DDR_PAT0_CTRL_REG (0x110) | ||
#define CCU_PLL_DDR_PAT1_CTRL_REG (0x114) | ||
#define CCU_PLL_PERI0_PAT0_CTRL_REG (0x120) | ||
#define CCU_PLL_PERI0_PAT1_CTRL_REG (0x124) | ||
#define CCU_PLL_PERI1_PAT0_CTRL_REG (0x128) | ||
#define CCU_PLL_PERI1_PAT1_CTRL_REG (0x12c) | ||
#define CCU_PLL_GPU_PAT0_CTRL_REG (0x130) | ||
#define CCU_PLL_GPU_PAT1_CTRL_REG (0x134) | ||
#define CCU_PLL_VIDEO0_PAT0_CTRL_REG (0x140) | ||
#define CCU_PLL_VIDEO0_PAT1_CTRL_REG (0x144) | ||
#define CCU_PLL_VIDEO1_PAT0_CTRL_REG (0x148) | ||
#define CCU_PLL_VIDEO1_PAT1_CTRL_REG (0x14c) | ||
#define CCU_PLL_VE_PAT0_CTRL_REG (0x158) | ||
#define CCU_PLL_VE_PAT1_CTRL_REG (0x15c) | ||
#define CCU_PLL_DE_PAT0_CTRL_REG (0x160) | ||
#define CCU_PLL_DE_PAT1_CTRL_REG (0x164) | ||
#define CCU_PLL_HSIC_PAT0_CTRL_REG (0x170) | ||
#define CCU_PLL_HSIC_PAT1_CTRL_REG (0x174) | ||
#define CCU_PLL_AUDIO0_PAT0_CTRL_REG (0x178) | ||
#define CCU_PLL_AUDIO0_PAT1_CTRL_REG (0x17c) | ||
#define CCU_PLL_AUDIO1_PAT0_CTRL_REG (0x180) | ||
#define CCU_PLL_AUDIO1_PAT1_CTRL_REG (0x184) | ||
#define CCU_PLL_CPU_BIAS_REG (0x300) | ||
#define CCU_PLL_DDR_BIAS_REG (0x310) | ||
#define CCU_PLL_PERI0_BIAS_REG (0x320) | ||
#define CCU_PLL_PERI1_BIAS_REG (0x328) | ||
#define CCU_PLL_GPU_BIAS_REG (0x330) | ||
#define CCU_PLL_VIDEO0_BIAS_REG (0x340) | ||
#define CCU_PLL_VIDEO1_BIAS_REG (0x348) | ||
#define CCU_PLL_VE_BIAS_REG (0x358) | ||
#define CCU_PLL_DE_BIAS_REG (0x360) | ||
#define CCU_PLL_HSIC_BIAS_REG (0x370) | ||
#define CCU_PLL_AUDIO0_BIAS_REG (0x378) | ||
#define CCU_PLL_AUDIO1_BIAS_REG (0x380) | ||
#define CCU_PLL_CPU_TUN_REG (0x400) | ||
#define CCU_CPU_AXI_CFG_REG (0x500) | ||
#define CCU_CPU_GATING_REG (0x504) | ||
#define CCU_PSI_CLK_REG (0x510) | ||
#define CCU_AHB3_CLK_REG (0x51c) | ||
#define CCU_APB0_CLK_REG (0x520) | ||
#define CCU_APB1_CLK_REG (0x524) | ||
#define CCU_MBUS_CLK_REG (0x540) | ||
#define CCU_DMA_BGR_REG (0x70c) | ||
#define CCU_DRAM_CLK_REG (0x800) | ||
#define CCU_MBUS_MAT_CLK_GATING_REG (0x804) | ||
#define CCU_DRAM_BGR_REG (0x80c) | ||
#define CCU_RISCV_CLK_REG (0xd00) | ||
#define CCU_RISCV_GATING_REG (0xd04) | ||
#define CCU_RISCV_CFG_BGR_REG (0xd0c) | ||
|
||
#endif /* __D1_REG_CCU_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef __RISCV64_ENDIAN_H__ | ||
#define __RISCV64_ENDIAN_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define LITTLE_ENDIAN (0x1234) | ||
#define BIG_ENDIAN (0x4321) | ||
|
||
#if ( !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN) ) | ||
#define __LITTLE_ENDIAN | ||
#endif | ||
|
||
#if defined(__LITTLE_ENDIAN) | ||
#define BYTE_ORDER LITTLE_ENDIAN | ||
#elif defined(__BIG_ENDIAN) | ||
#define BYTE_ORDER BIG_ENDIAN | ||
#else | ||
#error "Unknown byte order!" | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __RISCV64_ENDIAN_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef __IO_H__ | ||
#define __IO_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <types.h> | ||
|
||
static inline u8_t read8(virtual_addr_t addr) | ||
{ | ||
return( *((volatile u8_t *)(addr)) ); | ||
} | ||
|
||
static inline u16_t read16(virtual_addr_t addr) | ||
{ | ||
return( *((volatile u16_t *)(addr)) ); | ||
} | ||
|
||
static inline u32_t read32(virtual_addr_t addr) | ||
{ | ||
return( *((volatile u32_t *)(addr)) ); | ||
} | ||
|
||
static inline u64_t read64(virtual_addr_t addr) | ||
{ | ||
return( *((volatile u64_t *)(addr)) ); | ||
} | ||
|
||
static inline void write8(virtual_addr_t addr, u8_t value) | ||
{ | ||
*((volatile u8_t *)(addr)) = value; | ||
} | ||
|
||
static inline void write16(virtual_addr_t addr, u16_t value) | ||
{ | ||
*((volatile u16_t *)(addr)) = value; | ||
} | ||
|
||
static inline void write32(virtual_addr_t addr, u32_t value) | ||
{ | ||
*((volatile u32_t *)(addr)) = value; | ||
} | ||
|
||
static inline void write64(virtual_addr_t addr, u64_t value) | ||
{ | ||
*((volatile u64_t *)(addr)) = value; | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __IO_H__ */ |
Oops, something went wrong.