vexriscv: clone from riscv crate
Base the vexriscv crate on the riscv crate, but add vexriscv-specific instructions. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
0259333c75
commit
28ded4136a
15
.gitattributes
vendored
Normal file
15
.gitattributes
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
*.rs text eol=lf
|
||||||
|
*.S text eol=lf
|
||||||
|
*.a binary
|
||||||
|
*.h text eol=lf
|
||||||
|
*.s text eol=lf
|
||||||
|
*.S text eol=lf
|
||||||
|
README.* text eol=lf
|
||||||
|
LICENSE text eol=lf
|
||||||
|
*.md text eol=lf
|
||||||
|
*.sh text eol=lf
|
||||||
|
*.ps1 text eol=crlf
|
||||||
|
.gitignore text eol=lf
|
||||||
|
.gitattributes text eol=lf
|
||||||
|
*.yml text eol=lf
|
||||||
|
*.toml text eol=lf
|
14
Cargo.toml
14
Cargo.toml
@ -1,11 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "riscv"
|
name = "vexriscv"
|
||||||
version = "0.5.4"
|
version = "0.0.1"
|
||||||
repository = "https://github.com/rust-embedded/riscv"
|
repository = "https://github.com/xobs/vexriscv-rust"
|
||||||
authors = ["The RISC-V Team <risc-v@teams.rust-embedded.org>"]
|
authors = ["Sean Cross <sean@xobs.io>", "The RISC-V Team <risc-v@teams.rust-embedded.org>"]
|
||||||
categories = ["embedded", "hardware-support", "no-std"]
|
categories = ["embedded", "hardware-support", "no-std", "vexriscv"]
|
||||||
description = "Low level access to RISC-V processors"
|
description = "Low level access to the VexRiscv processor"
|
||||||
keywords = ["riscv", "register", "peripheral"]
|
keywords = ["riscv", "register", "peripheral", "vexriscv"]
|
||||||
license = "ISC"
|
license = "ISC"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
6
LICENSE.md
Normal file
6
LICENSE.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Copyright (c) 2020, Sean Cross \<sean@xobs.io\>
|
||||||
|
Copyright (c) 2019, RISC-V team https://github.com/rust-embedded/wg#the-riscv-team
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
15
README.md
15
README.md
@ -1,17 +1,18 @@
|
|||||||
[![crates.io](https://img.shields.io/crates/d/riscv.svg)](https://crates.io/crates/riscv)
|
[![crates.io](https://img.shields.io/crates/d/riscv.svg)](https://crates.io/crates/vexriscv)
|
||||||
[![crates.io](https://img.shields.io/crates/v/riscv.svg)](https://crates.io/crates/riscv)
|
[![crates.io](https://img.shields.io/crates/v/riscv.svg)](https://crates.io/crates/vexriscv)
|
||||||
[![Build Status](https://travis-ci.org/rust-embedded/riscv.svg?branch=master)](https://travis-ci.org/rust-embedded/riscv)
|
[![Build Status](https://travis-ci.org/rust-embedded/riscv.svg?branch=master)](https://travis-ci.org/xobs/vexriscv)
|
||||||
|
|
||||||
# `riscv`
|
# `veriscv`
|
||||||
|
|
||||||
> Low level access to RISC-V processors
|
> Low level access to parts of the VexRiscv RISC-V processor
|
||||||
|
|
||||||
This project is developed and maintained by the [RISC-V team][team].
|
This project is derived from [riscv](https://github.com/rust-embedded/riscv), developed and maintained by the [RISC-V team][team].
|
||||||
|
|
||||||
## [Documentation](https://docs.rs/crate/riscv)
|
## [Documentation](https://docs.rs/crate/vexriscv)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
Copyright 2020 Sean "xobs" Cross
|
||||||
Copyright 2019 [RISC-V team][team]
|
Copyright 2019 [RISC-V team][team]
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||||
|
51
asm.S
51
asm.S
@ -1,4 +1,46 @@
|
|||||||
#include "asm.h"
|
#define REG_READ(name, offset) \
|
||||||
|
.section .text.__read_ ## name; \
|
||||||
|
.global __read_ ## name; \
|
||||||
|
__read_ ## name: \
|
||||||
|
csrrs a0, offset, x0; \
|
||||||
|
ret
|
||||||
|
|
||||||
|
#define REG_WRITE(name, offset) \
|
||||||
|
.section .text.__write_ ## name; \
|
||||||
|
.global __write_ ## name; \
|
||||||
|
__write_ ## name: \
|
||||||
|
csrrw x0, offset, a0; \
|
||||||
|
ret
|
||||||
|
|
||||||
|
#define REG_SET(name, offset) \
|
||||||
|
.section .text.__set_ ## name; \
|
||||||
|
.global __set_ ## name; \
|
||||||
|
__set_ ## name: \
|
||||||
|
csrrs x0, offset, a0; \
|
||||||
|
ret
|
||||||
|
|
||||||
|
#define REG_CLEAR(name, offset) \
|
||||||
|
.section .text.__clear_ ## name; \
|
||||||
|
.global __clear_ ## name; \
|
||||||
|
__clear_ ## name: \
|
||||||
|
csrrc x0, offset, a0; \
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
#define REG_READ_WRITE(name, offset) REG_READ(name, offset); REG_WRITE(name, offset)
|
||||||
|
#define REG_SET_CLEAR(name, offset) REG_SET(name, offset); REG_CLEAR(name, offset)
|
||||||
|
|
||||||
|
#define RW(offset, name) REG_READ_WRITE(name, offset); REG_SET_CLEAR(name, offset)
|
||||||
|
#define RO(offset, name) REG_READ(name, offset)
|
||||||
|
|
||||||
|
#if __riscv_xlen == 32
|
||||||
|
#define RW32(offset, name) RW(offset, name)
|
||||||
|
#define RO32(offset, name) RO(offset, name)
|
||||||
|
#else
|
||||||
|
#define RW32(offset, name)
|
||||||
|
#define RO32(offset, name)
|
||||||
|
#endif
|
||||||
|
// ----------------------- //
|
||||||
|
|
||||||
.section .text.__ebreak
|
.section .text.__ebreak
|
||||||
.global __ebreak
|
.global __ebreak
|
||||||
@ -273,3 +315,10 @@ RW(0x7A3, tdata3) // Third Debug/Trace trigger data register
|
|||||||
RW(0x7B0, dcsr) // Debug control and status register
|
RW(0x7B0, dcsr) // Debug control and status register
|
||||||
RW(0x7B1, dpc) // Debug PC
|
RW(0x7B1, dpc) // Debug PC
|
||||||
RW(0x7B2, dscratch) // Debug scratch register
|
RW(0x7B2, dscratch) // Debug scratch register
|
||||||
|
|
||||||
|
// VexRiscv custom registers
|
||||||
|
RW(0xBC0, vmim) // Machine IRQ Mask
|
||||||
|
RW(0xFC0, vmip) // Machine IRQ Pending
|
||||||
|
RW(0x9C0, vsim) // Supervisor IRQ Mask
|
||||||
|
RW(0xDC0, vsip) // Supervisor IRQ Pending
|
||||||
|
RW(0xCC0, vdci) // DCache Info
|
||||||
|
48
asm.h
48
asm.h
@ -1,48 +0,0 @@
|
|||||||
#ifndef __ASM_H
|
|
||||||
#define __ASM_H
|
|
||||||
|
|
||||||
#define REG_READ(name, offset) \
|
|
||||||
.section .text.__read_ ## name; \
|
|
||||||
.global __read_ ## name; \
|
|
||||||
__read_ ## name: \
|
|
||||||
csrrs a0, offset, x0; \
|
|
||||||
ret
|
|
||||||
|
|
||||||
#define REG_WRITE(name, offset) \
|
|
||||||
.section .text.__write_ ## name; \
|
|
||||||
.global __write_ ## name; \
|
|
||||||
__write_ ## name: \
|
|
||||||
csrrw x0, offset, a0; \
|
|
||||||
ret
|
|
||||||
|
|
||||||
#define REG_SET(name, offset) \
|
|
||||||
.section .text.__set_ ## name; \
|
|
||||||
.global __set_ ## name; \
|
|
||||||
__set_ ## name: \
|
|
||||||
csrrs x0, offset, a0; \
|
|
||||||
ret
|
|
||||||
|
|
||||||
#define REG_CLEAR(name, offset) \
|
|
||||||
.section .text.__clear_ ## name; \
|
|
||||||
.global __clear_ ## name; \
|
|
||||||
__clear_ ## name: \
|
|
||||||
csrrc x0, offset, a0; \
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
#define REG_READ_WRITE(name, offset) REG_READ(name, offset); REG_WRITE(name, offset)
|
|
||||||
#define REG_SET_CLEAR(name, offset) REG_SET(name, offset); REG_CLEAR(name, offset)
|
|
||||||
|
|
||||||
#define RW(offset, name) REG_READ_WRITE(name, offset); REG_SET_CLEAR(name, offset)
|
|
||||||
#define RO(offset, name) REG_READ(name, offset)
|
|
||||||
|
|
||||||
#if __riscv_xlen == 32
|
|
||||||
#define RW32(offset, name) RW(offset, name)
|
|
||||||
#define RO32(offset, name) RO(offset, name)
|
|
||||||
#else
|
|
||||||
#define RW32(offset, name)
|
|
||||||
#define RO32(offset, name)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __ASM_H */
|
|
||||||
|
|
19
assemble.ps1
Normal file
19
assemble.ps1
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
New-Item -Force -Name bin -Type Directory
|
||||||
|
|
||||||
|
# remove existing blobs because otherwise this will append object files to the old blobs
|
||||||
|
Remove-Item -Force bin/*.a
|
||||||
|
|
||||||
|
$crate = "xous-riscv"
|
||||||
|
|
||||||
|
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32imac asm.S -o bin/$crate.o
|
||||||
|
riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
||||||
|
riscv64-unknown-elf-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
|
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32i asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
||||||
|
riscv64-unknown-elf-ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
|
riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64imac asm.S -o bin/$crate.o
|
||||||
|
riscv64-unknown-elf-ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
|
||||||
|
riscv64-unknown-elf-ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
|
Remove-Item bin/$crate.o
|
10
assemble.sh
10
assemble.sh
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
crate=riscv
|
crate=riscv-rt
|
||||||
|
|
||||||
# remove existing blobs because otherwise this will append object files to the old blobs
|
# remove existing blobs because otherwise this will append object files to the old blobs
|
||||||
rm -f bin/*.a
|
rm -f bin/*.a
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32i asm.S -o bin/$crate.o
|
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32imac asm.S -o bin/$crate.o
|
||||||
ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
|
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32imc asm.S -o bin/$crate.o
|
|
||||||
ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
||||||
ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
|
riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32i asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
||||||
|
ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64imac asm.S -o bin/$crate.o
|
riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64imac asm.S -o bin/$crate.o
|
||||||
ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
|
||||||
ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
|
||||||
|
Loading…
Reference in New Issue
Block a user