summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
Diffstat (limited to 'software')
-rw-r--r--software/asm_main/Makefile6
-rw-r--r--software/asm_main/asm_main.S8
-rw-r--r--software/clic_vectored/Makefile10
-rw-r--r--software/clic_vectored/clic_vectored.c197
-rw-r--r--software/coremark/.gitignore9
-rw-r--r--software/coremark/.unsupported-boards6
-rw-r--r--software/coremark/Makefile20
-rw-r--r--software/coremark/core_portme.c52
-rw-r--r--software/coremark/core_portme.h58
-rw-r--r--software/coreplexip_welcome/.unsupported-boards2
-rw-r--r--software/coreplexip_welcome/Makefile8
-rw-r--r--software/coreplexip_welcome/coreplexip_welcome.c124
-rw-r--r--software/demo_gpio/.gitignore1
-rw-r--r--software/demo_gpio/Makefile9
-rw-r--r--software/demo_gpio/demo_gpio.c252
-rw-r--r--software/dhrystone/.gitignore1
-rw-r--r--software/dhrystone/Makefile21
-rw-r--r--software/dhrystone/dhry.h423
-rw-r--r--software/dhrystone/dhry_1.c385
-rw-r--r--software/dhrystone/dhry_2.c192
-rw-r--r--software/dhrystone/dhry_printf.c271
-rw-r--r--software/dhrystone/dhry_stubs.c15
-rw-r--r--software/double_tap_dontboot/.unsupported-boards3
-rw-r--r--software/double_tap_dontboot/Makefile6
-rw-r--r--software/double_tap_dontboot/double_tap_dontboot.c153
-rw-r--r--software/global_interrupts/.unsupported-boards2
-rw-r--r--software/global_interrupts/Makefile9
-rw-r--r--software/global_interrupts/global_interrupts.c250
-rw-r--r--software/i2c_demo/.gitignore1
-rw-r--r--software/i2c_demo/Makefile6
-rw-r--r--software/i2c_demo/i2c_demo.c318
-rw-r--r--software/led_fade/.unsupported-boards4
-rw-r--r--software/led_fade/Makefile6
-rw-r--r--software/led_fade/led_fade.c167
-rw-r--r--software/local_interrupts/.unsupported-boards2
-rw-r--r--software/local_interrupts/Makefile8
-rw-r--r--software/local_interrupts/local_interrupts.c216
-rw-r--r--software/performance_counters/Makefile6
-rw-r--r--software/performance_counters/performance_counters.c133
-rw-r--r--software/smp/Makefile6
-rw-r--r--software/smp/atomic.h29
-rw-r--r--software/smp/smp.c40
-rw-r--r--software/vectored_interrupts/Makefile10
-rw-r--r--software/vectored_interrupts/vectored_interrupts.c270
-rw-r--r--software/watchdog/.gitignore1
-rw-r--r--software/watchdog/.unsupported-boards1
-rw-r--r--software/watchdog/Makefile9
-rw-r--r--software/watchdog/watchdog.c221
48 files changed, 0 insertions, 3947 deletions
diff --git a/software/asm_main/Makefile b/software/asm_main/Makefile
deleted file mode 100644
index 40c1175..0000000
--- a/software/asm_main/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-TARGET = asm_main
-ASM_SRCS += asm_main.S
-CFLAGS += -O2 -DNO_INIT
-
-BSP_BASE = ../../bsp
-include $(BSP_BASE)/env/common.mk
diff --git a/software/asm_main/asm_main.S b/software/asm_main/asm_main.S
deleted file mode 100644
index 6241bb1..0000000
--- a/software/asm_main/asm_main.S
+++ /dev/null
@@ -1,8 +0,0 @@
- .section .text
- .globl main
-
-
-main:
- add t0,zero,zero
-1: addi t0,t0, 1
- j 1b
diff --git a/software/clic_vectored/Makefile b/software/clic_vectored/Makefile
deleted file mode 100644
index d6e2342..0000000
--- a/software/clic_vectored/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-TARGET = clic_vectored
-CFLAGS += -Og -fno-builtin-printf
-
-BSP_BASE = ../../bsp
-
-C_SRCS += clic_vectored.c
-
-C_SRCS += $(BSP_BASE)/drivers/clic/clic_driver.c
-
-include $(BSP_BASE)/env/common.mk
diff --git a/software/clic_vectored/clic_vectored.c b/software/clic_vectored/clic_vectored.c
deleted file mode 100644
index 37ea723..0000000
--- a/software/clic_vectored/clic_vectored.c
+++ /dev/null
@@ -1,197 +0,0 @@
-// See LICENSE for license details.
-#include <stdio.h>
-#include <stdlib.h>
-#include "platform.h"
-#include <string.h>
-#include "encoding.h"
-#include <unistd.h>
-#include "sifive/devices/clic.h"
-#include "clic/clic_driver.h"
-#include "sifive/devices/clint.h"
-
-#ifndef _SIFIVE_COREPLEXIP_ARTY_H
-#error 'local_interrupts' demo only supported for Core IP Eval Kits
-#endif
-
-// Global Variable used to show
-// software interrupts.
-volatile uint32_t g_debouncing;
-
-// vector table defined in init.c
-typedef void (*interrupt_function_ptr_t) (void);
-extern interrupt_function_ptr_t localISR[CLIC_NUM_INTERRUPTS];
-extern void default_handler(void);
-
-//clic data structure
-clic_instance_t clic;
-
-const char * instructions_msg = " \
-\n\
- SiFive, Inc\n\
-\n\
- 5555555555555555555555555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555555555555555555555\n\
- 5555 555555555555555555555555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555\n\
-5555555555555555555555555555 55555\n\
- 55555 555555555 55555\n\
- 55555 55555 55555\n\
- 55555 5 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 555555555\n\
- 55555\n\
- 5\n\
-\n\
-E2 Core IP Eval Kit 'clic_vectored' demo.\n\
-This demo uses buttons 0, 1, and 2 on the\n\
-Arty board to trigger vectored clic interrupts.\n\
-The higher the button number, the higher the\n\
-interupt priority. Button 0's handler runs for\n\
-10 seconds, button 1's for 5, and button 2's for 1.\n\
-Preemption is enabled so that higher priority\n\
-interrupts can be triggered while in low priority\n\
-handlers. The demo also uses the CLIC's software\n\
-interrupt to pend a lower priority interrupt from\n\
-button 2's handler.\n\
-\n\
-Note the buttons are wired directly into the local\n\
-interrupts, so a given interrupt will stay asserted\n\
-as long as the button is being pushed.\n\
-\n\
-This demo works for both the E20 and E21 FPGA\n\
-as long as CLIC_CONFIG_BITS matches the desired\n\
-core.\n\
-\n";
-
-void print_instructions() {
- write (STDERR_FILENO, instructions_msg, strlen(instructions_msg));
-}
-
-
-//busy wait for the specified time
-void wait_ms(uint64_t ms) {
- static const uint64_t ms_tick = RTC_FREQ/1000;
- volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
- uint64_t then = (ms_tick * ms) + *mtime;
- while(*mtime<then);
-}
-
-void button_0_isr(void) __attribute__((interrupt("SiFive-CLIC-preemptible")));
-void button_0_isr(void) {
- // Toggle Red LED
- uint8_t level = clic_get_int_level(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_0));
- printf("Button 0 was pressed, interrupt level %d. Toggle Red.\n", level);
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << RED_LED_OFFSET);
- wait_ms(10000);
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << RED_LED_OFFSET);
-}
-
-void button_0_setup(void) {
- clic_install_handler(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_0), button_0_isr);
- clic_set_int_level(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_0), 1);
- clic_enable_interrupt(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_0));
-}
-
-void button_1_isr(void) __attribute__((interrupt("SiFive-CLIC-preemptible")));
-void button_1_isr(void) {
- // Toggle Red LED
- uint8_t level = clic_get_int_level(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_1));
- printf("Button 1 was pressed, interrupt level %d. Toggle Blue.\n", level);
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << BLUE_LED_OFFSET);
- wait_ms(5000);
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << BLUE_LED_OFFSET);
-}
-
-void button_1_setup(void) {
- clic_install_handler(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_1), button_1_isr);
- clic_set_int_level(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_1), 2);
- clic_enable_interrupt(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_1));
-}
-
-void button_2_isr(void) __attribute__((interrupt("SiFive-CLIC-preemptible")));
-void button_2_isr(void) {
- // Toggle Red LED
- uint8_t level = clic_get_int_level(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_2));
- printf("Button 2 was pressed, interrupt level %d. Pending CSIPID and toggle Green.\n", level);
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << GREEN_LED_OFFSET);
- //pend a software interrupt
- clic_set_pending(&clic, CSIPID);
- wait_ms(1000);
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << GREEN_LED_OFFSET);
-}
-
-void button_2_setup(void) {
- clic_install_handler(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_2), button_2_isr);
- clic_set_int_level(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_2), 3);
- clic_enable_interrupt(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_2));
-}
-
-/*Entry Point for Machine Software Interrupt Handler*/
-uint32_t COUNT;
-void csip_isr()__attribute((interrupt));
-void csip_isr() {
- //clear the SW interrupt
- CLIC0_REG8(CLIC_INTIP + CSIPID) = 0;
- COUNT++;
-}
-
-void csip_setup(void) {
- clic_install_handler(&clic, CSIPID, csip_isr);
- clic_set_int_level(&clic, CSIPID, 1);
- clic_enable_interrupt(&clic, CSIPID);
-}
-
-void config_gpio() {
- // Configure LEDs as outputs.
- GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
- GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
- GPIO_REG(GPIO_OUTPUT_VAL) &= ((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET)| (0x1 << BLUE_LED_OFFSET)) ;
-}
-
-int main(int argc, char **argv)
-{
- clear_csr(mstatus, MSTATUS_MIE);
- clear_csr(mie, IRQ_M_SOFT);
- clear_csr(mie, IRQ_M_TIMER);
-
- //initialize clic registers and vector table
- clic_init(&clic, CLIC_HART0_ADDR,
- (interrupt_function_ptr_t*)localISR,
- default_handler,
- CLIC_NUM_INTERRUPTS,
- CLIC_CONFIG_BITS);
-
- //use all 4 config bits for levels, no shv
- clic_set_cliccfg(&clic, (CLIC_CONFIG_BITS<<1));
-
- //initialize gpio and buttons.
- //each button registers an interrupt handler
- config_gpio();
- button_0_setup();
- button_1_setup();
- button_2_setup();
- csip_setup();
-
- // Enable all global interrupts
- set_csr(mstatus, MSTATUS_MIE);
- print_instructions();
-
- while(1) {
- wait_ms(10000);
- printf("Count=%d\n", COUNT);
- //Trigger a SW interrupt
- clic_set_pending(&clic, CSIPID);
- }
-
- return 0;
-
-}
diff --git a/software/coremark/.gitignore b/software/coremark/.gitignore
deleted file mode 100644
index 6bd8438..0000000
--- a/software/coremark/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-/*.o
-/coremark
-/core_list_join.c
-/core_main.c
-/coremark.h
-/core_matrix.c
-/core_state.c
-/core_util.c
-/trans.c
diff --git a/software/coremark/.unsupported-boards b/software/coremark/.unsupported-boards
deleted file mode 100644
index 9221334..0000000
--- a/software/coremark/.unsupported-boards
+++ /dev/null
@@ -1,6 +0,0 @@
-# We don't deliver the full coremark sources for license reasons, so this can't
-# run in regression.
-freedom-e300-hifive1
-freedom-e300-arty
-coreplexip-e31-arty
-coreplexip-e51-arty
diff --git a/software/coremark/Makefile b/software/coremark/Makefile
deleted file mode 100644
index b57151e..0000000
--- a/software/coremark/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGET := coremark
-
-C_SRCS := \
- core_list_join.c \
- core_main.c \
- core_matrix.c \
- core_state.c \
- core_util.c \
- core_portme.c \
-
-HEADERS := \
- coremark.h \
- core_portme.h \
-
-CFLAGS := -O2 -fno-common -funroll-loops -finline-functions --param max-inline-insns-auto=20 -falign-functions=4 -falign-jumps=4 -falign-loops=4
-CFLAGS += -DFLAGS_STR=\""$(CFLAGS)"\"
-CFLAGS += -DITERATIONS=10000 -DPERFORMANCE_RUN=1
-
-BSP_BASE = ../../bsp
-include $(BSP_BASE)/env/common.mk
diff --git a/software/coremark/core_portme.c b/software/coremark/core_portme.c
deleted file mode 100644
index cbf1396..0000000
--- a/software/coremark/core_portme.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "coremark.h"
-#include "platform.h"
-#include "encoding.h"
-
-#if VALIDATION_RUN
- volatile ee_s32 seed1_volatile=0x3415;
- volatile ee_s32 seed2_volatile=0x3415;
- volatile ee_s32 seed3_volatile=0x66;
-#endif
-
-#if PERFORMANCE_RUN
- volatile ee_s32 seed1_volatile=0x0;
- volatile ee_s32 seed2_volatile=0x0;
- volatile ee_s32 seed3_volatile=0x66;
-#endif
-
-#if PROFILE_RUN
- volatile ee_s32 seed1_volatile=0x8;
- volatile ee_s32 seed2_volatile=0x8;
- volatile ee_s32 seed3_volatile=0x8;
-#endif
-
-volatile ee_s32 seed4_volatile=ITERATIONS;
-volatile ee_s32 seed5_volatile=0;
-
-static CORE_TICKS t0, t1;
-
-void start_time(void)
-{
- t0 = get_timer_value();
-}
-
-void stop_time(void)
-{
- t1 = get_timer_value();
-}
-
-CORE_TICKS get_time(void)
-{
- return t1 - t0;
-}
-
-secs_ret time_in_secs(CORE_TICKS ticks)
-{
- // scale timer down to avoid uint64_t -> double conversion in RV32
- int scale = 256;
- uint32_t delta = ticks / scale;
- uint32_t freq = get_timer_freq() / scale;
- return delta / (double)freq;
-}
diff --git a/software/coremark/core_portme.h b/software/coremark/core_portme.h
deleted file mode 100644
index 82298d6..0000000
--- a/software/coremark/core_portme.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef FESDK_CORE_PORTME_H
-#define FESDK_CORE_PORTME_H
-
-#include <stdint.h>
-#include <stddef.h>
-
-#define HAS_FLOAT 1
-#define HAS_TIME_H 1
-#define USE_CLOCK 1
-#define HAS_STDIO 1
-#define HAS_PRINTF 1
-#define SEED_METHOD SEED_VOLATILE
-#define CORE_TICKS uint64_t
-#define ee_u8 uint8_t
-#define ee_u16 uint16_t
-#define ee_u32 uint32_t
-#define ee_s16 int16_t
-#define ee_s32 int32_t
-#define ee_ptr_int uintptr_t
-#define ee_size_t size_t
-#define COMPILER_FLAGS FLAGS_STR
-
-#define align_mem(x) (void *)(((ee_ptr_int)(x) + sizeof(ee_u32) - 1) & -sizeof(ee_u32))
-
-#ifdef __GNUC__
-# define COMPILER_VERSION "GCC"__VERSION__
-#else
-# error
-#endif
-
-#define MEM_METHOD MEM_STACK
-#define MEM_LOCATION "STACK"
-
-#define MAIN_HAS_NOARGC 0
-#define MAIN_HAS_NORETURN 0
-
-#define MULTITHREAD 1
-#define USE_PTHREAD 0
-#define USE_FORK 0
-#define USE_SOCKET 0
-
-#define default_num_contexts MULTITHREAD
-
-typedef int core_portable;
-static void portable_init(core_portable *p, int *argc, char *argv[]) {}
-static void portable_fini(core_portable *p) {}
-
-#if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) && !defined(VALIDATION_RUN)
-#if (TOTAL_DATA_SIZE==1200)
-#define PROFILE_RUN 1
-#elif (TOTAL_DATA_SIZE==2000)
-#define PERFORMANCE_RUN 1
-#else
-#define VALIDATION_RUN 1
-#endif
-#endif
-
-#endif
diff --git a/software/coreplexip_welcome/.unsupported-boards b/software/coreplexip_welcome/.unsupported-boards
deleted file mode 100644
index 33cea3a..0000000
--- a/software/coreplexip_welcome/.unsupported-boards
+++ /dev/null
@@ -1,2 +0,0 @@
-freedom-e300-arty
-freedom-e300-hifive1
diff --git a/software/coreplexip_welcome/Makefile b/software/coreplexip_welcome/Makefile
deleted file mode 100644
index e56ed12..0000000
--- a/software/coreplexip_welcome/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-TARGET = coreplexip_welcome
-CFLAGS += -O2 -fno-builtin-printf -DNO_INIT
-
-BSP_BASE = ../../bsp
-
-C_SRCS += coreplexip_welcome.c
-
-include $(BSP_BASE)/env/common.mk
diff --git a/software/coreplexip_welcome/coreplexip_welcome.c b/software/coreplexip_welcome/coreplexip_welcome.c
deleted file mode 100644
index c090b37..0000000
--- a/software/coreplexip_welcome/coreplexip_welcome.c
+++ /dev/null
@@ -1,124 +0,0 @@
-// See LICENSE for license details.
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdatomic.h>
-#include "encoding.h"
-#include <platform.h>
-
-#ifndef _SIFIVE_COREPLEXIP_ARTY_H
-#error 'coreplexip_welcome' demo only supported for Coreplex IP Eval Kits
-#endif
-
-static const char sifive_msg[] = "\n\r\
-\n\r\
- SIFIVE, INC.\n\r\
-\n\r\
- 5555555555555555555555555\n\r\
- 5555 5555\n\r\
- 5555 5555\n\r\
- 5555 5555\n\r\
- 5555 5555555555555555555555\n\r\
- 5555 555555555555555555555555\n\r\
- 5555 5555\n\r\
- 5555 5555\n\r\
- 5555 5555\n\r\
-5555555555555555555555555555 55555\n\r\
- 55555 555555555 55555\n\r\
- 55555 55555 55555\n\r\
- 55555 5 55555\n\r\
- 55555 55555\n\r\
- 55555 55555\n\r\
- 55555 55555\n\r\
- 55555 55555\n\r\
- 55555 55555\n\r\
- 555555555\n\r\
- 55555\n\r\
- 5\n\r\
-\n\r\
-";
-
-#if __riscv_xlen == 32
- static const char welcome_msg[] = "\n\r\
-\n\r\
-Welcome to the E31 Coreplex IP FPGA Evaluation Kit!\n\r\
-\n\r";
-#else
-static const char welcome_msg[] = "\n\r\
-\n\r\
-Welcome to the E51 Coreplex IP FPGA Evaluation Kit!\n\r\
-\n\r";
-#endif
-
-static void _putc(char c) {
- while ((int32_t) UART0_REG(UART_REG_TXFIFO) < 0);
- UART0_REG(UART_REG_TXFIFO) = c;
-}
-
-int _getc(char * c){
- int32_t val = (int32_t) UART0_REG(UART_REG_RXFIFO);
- if (val > 0) {
- *c = val & 0xFF;
- return 1;
- }
- return 0;
-}
-
-static void _puts(const char * s) {
- while (*s != '\0'){
- _putc(*s++);
- }
-}
-
-int main (void){
-
- // 115200 Baud Rate at (65 / 2) MHz
- UART0_REG(UART_REG_DIV) = 282;
- UART0_REG(UART_REG_TXCTRL) = UART_TXEN;
- UART0_REG(UART_REG_RXCTRL) = UART_RXEN;
-
- // Wait a bit because we were changing the GPIOs
- volatile int i=0;
- while(i < 10000){i++;}
-
- _puts(sifive_msg);
-
- _puts(welcome_msg);
-
- uint16_t r=0x3F;
- uint16_t g=0;
- uint16_t b=0;
- // Set up RGB PWM
-
- PWM0_REG(PWM_CFG) = 0;
- PWM0_REG(PWM_CFG) = (PWM_CFG_ENALWAYS) | (PWM_CFG_ZEROCMP) | (PWM_CFG_DEGLITCH);
- PWM0_REG(PWM_COUNT) = 0;
-
- // The LEDs are intentionally left somewhat dim.
- PWM0_REG(PWM_CMP0) = 0xFE;
-
- while(1){
- volatile uint64_t * now = (volatile uint64_t*)(CLINT_CTRL_ADDR + CLINT_MTIME);
- volatile uint64_t then = *now + 400;
- while (*now < then) { }
-
- if(r > 0 && b == 0){
- r--;
- g++;
- }
- if(g > 0 && r == 0){
- g--;
- b++;
- }
- if(b > 0 && g == 0){
- r++;
- b--;
- }
-
- PWM0_REG(PWM_CMP1) = 0xFF - (r >> 2);
- PWM0_REG(PWM_CMP2) = 0xFF - (g >> 2);
- PWM0_REG(PWM_CMP3) = 0xFF - (b >> 2);
-
- }// While (1)
-}
-
diff --git a/software/demo_gpio/.gitignore b/software/demo_gpio/.gitignore
deleted file mode 100644
index 35566c7..0000000
--- a/software/demo_gpio/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-demo_gpio
diff --git a/software/demo_gpio/Makefile b/software/demo_gpio/Makefile
deleted file mode 100644
index b181c5f..0000000
--- a/software/demo_gpio/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = demo_gpio
-CFLAGS += -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME
-
-BSP_BASE = ../../bsp
-
-C_SRCS += demo_gpio.c
-C_SRCS += $(BSP_BASE)/drivers/plic/plic_driver.c
-
-include $(BSP_BASE)/env/common.mk
diff --git a/software/demo_gpio/demo_gpio.c b/software/demo_gpio/demo_gpio.c
deleted file mode 100644
index 8fe03e1..0000000
--- a/software/demo_gpio/demo_gpio.c
+++ /dev/null
@@ -1,252 +0,0 @@
-// See LICENSE for license details.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "platform.h"
-#include <string.h>
-#include "plic/plic_driver.h"
-#include "encoding.h"
-#include <unistd.h>
-#include "stdatomic.h"
-
-void reset_demo (void);
-
-// Structures for registering different interrupt handlers
-// for different parts of the application.
-typedef void (*function_ptr_t) (void);
-
-void no_interrupt_handler (void) {};
-
-function_ptr_t g_ext_interrupt_handlers[PLIC_NUM_INTERRUPTS];
-
-
-// Instance data for the PLIC.
-
-plic_instance_t g_plic;
-
-
-/*Entry Point for PLIC Interrupt Handler*/
-void handle_m_ext_interrupt(){
- plic_source int_num = PLIC_claim_interrupt(&g_plic);
- if ((int_num >=1 ) && (int_num < PLIC_NUM_INTERRUPTS)) {
- g_ext_interrupt_handlers[int_num]();
- }
- else {
- exit(1 + (uintptr_t) int_num);
- }
- PLIC_complete_interrupt(&g_plic, int_num);
-}
-
-
-/*Entry Point for Machine Timer Interrupt Handler*/
-void handle_m_time_interrupt(){
-
- clear_csr(mie, MIP_MTIP);
-
- // Reset the timer for 3s in the future.
- // This also clears the existing timer interrupt.
-
- volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
- volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
- uint64_t now = *mtime;
- uint64_t then = now + 2 * RTC_FREQ;
- *mtimecmp = then;
-
- // read the current value of the LEDS and invert them.
- uint32_t leds = GPIO_REG(GPIO_OUTPUT_VAL);
-
- GPIO_REG(GPIO_OUTPUT_VAL) ^= ((0x1 << RED_LED_OFFSET) |
- (0x1 << GREEN_LED_OFFSET) |
- (0x1 << BLUE_LED_OFFSET));
-
- // Re-enable the timer interrupt.
- set_csr(mie, MIP_MTIP);
-
-}
-
-
-const char * instructions_msg = " \
-\n\
- SIFIVE, INC.\n\
-\n\
- 5555555555555555555555555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555555555555555555555\n\
- 5555 555555555555555555555555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555\n\
-5555555555555555555555555555 55555\n\
- 55555 555555555 55555\n\
- 55555 55555 55555\n\
- 55555 5 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 555555555\n\
- 55555\n\
- 5\n\
-\n\
-SiFive E-Series Software Development Kit 'demo_gpio' program.\n\
-Every 2 second, the Timer Interrupt will invert the LEDs.\n\
-(Arty Dev Kit Only): Press Buttons 0, 1, 2 to Set the LEDs.\n\
-Pin 19 (HiFive1) or A5 (Arty Dev Kit) is being bit-banged\n\
-for GPIO speed demonstration.\n\
-\n\
- ";
-
-void print_instructions() {
-
- write (STDOUT_FILENO, instructions_msg, strlen(instructions_msg));
-
-}
-
-#ifdef HAS_BOARD_BUTTONS
-void button_0_handler(void) {
-
- // Red LED on
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << RED_LED_OFFSET);
-
- // Clear the GPIO Pending interrupt by writing 1.
- GPIO_REG(GPIO_RISE_IP) = (0x1 << BUTTON_0_OFFSET);
-
-};
-
-void button_1_handler(void) {
-
- // Green LED On
- GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << GREEN_LED_OFFSET);
-
- // Clear the GPIO Pending interrupt by writing 1.
- GPIO_REG(GPIO_RISE_IP) = (0x1 << BUTTON_1_OFFSET);
-
-};
-
-
-void button_2_handler(void) {
-
- // Blue LED On
- GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << BLUE_LED_OFFSET);
-
- GPIO_REG(GPIO_RISE_IP) = (0x1 << BUTTON_2_OFFSET);
-
-};
-#endif
-
-void reset_demo (){
-
- // Disable the machine & timer interrupts until setup is done.
-
- clear_csr(mie, MIP_MEIP);
- clear_csr(mie, MIP_MTIP);
-
- for (int ii = 0; ii < PLIC_NUM_INTERRUPTS; ii ++){
- g_ext_interrupt_handlers[ii] = no_interrupt_handler;
- }
-
-#ifdef HAS_BOARD_BUTTONS
- g_ext_interrupt_handlers[INT_DEVICE_BUTTON_0] = button_0_handler;
- g_ext_interrupt_handlers[INT_DEVICE_BUTTON_1] = button_1_handler;
- g_ext_interrupt_handlers[INT_DEVICE_BUTTON_2] = button_2_handler;
-#endif
-
- print_instructions();
-
-#ifdef HAS_BOARD_BUTTONS
-
- // Have to enable the interrupt both at the GPIO level,
- // and at the PLIC level.
- PLIC_enable_interrupt (&g_plic, INT_DEVICE_BUTTON_0);
- PLIC_enable_interrupt (&g_plic, INT_DEVICE_BUTTON_1);
- PLIC_enable_interrupt (&g_plic, INT_DEVICE_BUTTON_2);
-
- // Priority must be set > 0 to trigger the interrupt.
- PLIC_set_priority(&g_plic, INT_DEVICE_BUTTON_0, 1);
- PLIC_set_priority(&g_plic, INT_DEVICE_BUTTON_1, 1);
- PLIC_set_priority(&g_plic, INT_DEVICE_BUTTON_2, 1);
-
- GPIO_REG(GPIO_RISE_IE) |= (1 << BUTTON_0_OFFSET);
- GPIO_REG(GPIO_RISE_IE) |= (1 << BUTTON_1_OFFSET);
- GPIO_REG(GPIO_RISE_IE) |= (1 << BUTTON_2_OFFSET);
-
-#endif
-
- // Set the machine timer to go off in 3 seconds.
- // The
- volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
- volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
- uint64_t now = *mtime;
- uint64_t then = now + 2*RTC_FREQ;
- *mtimecmp = then;
-
- // Enable the Machine-External bit in MIE
- set_csr(mie, MIP_MEIP);
-
- // Enable the Machine-Timer bit in MIE
- set_csr(mie, MIP_MTIP);
-
- // Enable interrupts in general.
- set_csr(mstatus, MSTATUS_MIE);
-}
-
-int main(int argc, char **argv)
-{
- // Set up the GPIOs such that the LED GPIO
- // can be used as both Inputs and Outputs.
-
-
-#ifdef HAS_BOARD_BUTTONS
- GPIO_REG(GPIO_OUTPUT_EN) &= ~((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
- GPIO_REG(GPIO_PULLUP_EN) &= ~((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
- GPIO_REG(GPIO_INPUT_EN) |= ((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
-#endif
-
- GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
- GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << BLUE_LED_OFFSET) ;
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET)) ;
-
-
- // For Bit-banging with Atomics demo.
-
- uint32_t bitbang_mask = 0;
-#ifdef _SIFIVE_HIFIVE1_H
- bitbang_mask = (1 << PIN_19_OFFSET);
-#else
-#ifdef _SIFIVE_COREPLEXIP_ARTY_H
- bitbang_mask = (0x1 << JA_0_OFFSET);
-#endif
-#endif
-
- GPIO_REG(GPIO_OUTPUT_EN) |= bitbang_mask;
-
- /**************************************************************************
- * Set up the PLIC
- *
- *************************************************************************/
- PLIC_init(&g_plic,
- PLIC_CTRL_ADDR,
- PLIC_NUM_INTERRUPTS,
- PLIC_NUM_PRIORITIES);
-
- reset_demo();
-
- /**************************************************************************
- * Demonstrate fast GPIO bit-banging.
- * One can bang it faster than this if you know
- * the entire OUTPUT_VAL that you want to write, but
- * Atomics give a quick way to control a single bit.
- *************************************************************************/
- // For Bit-banging with Atomics demo.
-
- while (1){
- atomic_fetch_xor_explicit(&GPIO_REG(GPIO_OUTPUT_VAL), bitbang_mask, memory_order_relaxed);
- }
-
- return 0;
-
-}
diff --git a/software/dhrystone/.gitignore b/software/dhrystone/.gitignore
deleted file mode 100644
index eb51a6c..0000000
--- a/software/dhrystone/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-dhrystone
diff --git a/software/dhrystone/Makefile b/software/dhrystone/Makefile
deleted file mode 100644
index 4602653..0000000
--- a/software/dhrystone/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-TARGET := dhrystone
-
-ASM_SRCS :=
-C_SRCS := dhry_stubs.c dhry_printf.c
-HEADERS := dhry.h
-
-DHRY_SRCS := dhry_1.c dhry_2.c
-DHRY_CFLAGS := -O3 -DTIME -fno-inline -fno-builtin-printf -Wno-implicit -mcmodel=medany -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI)
-
-XLEN ?= 32
-CFLAGS := -O3 -fno-common -mcmodel=medany -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -mexplicit-relocs -DNOENUM -falign-functions=4
-LDFLAGS := -Wl,--wrap=scanf -Wl,--wrap=printf -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -mcmodel=medany
-
-DHRY_OBJS := $(patsubst %.c,%.o,$(DHRY_SRCS))
-LINK_OBJS := $(DHRY_OBJS)
-
-BSP_BASE = ../../bsp
-include $(BSP_BASE)/env/common.mk
-
-$(DHRY_OBJS): %.o: %.c $(HEADERS)
- $(CC) $(CFLAGS) $(DHRY_CFLAGS) -c -o $@ $<
diff --git a/software/dhrystone/dhry.h b/software/dhrystone/dhry.h
deleted file mode 100644
index b556ecc..0000000
--- a/software/dhrystone/dhry.h
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- ****************************************************************************
- *
- * "DHRYSTONE" Benchmark Program
- * -----------------------------
- *
- * Version: C, Version 2.1
- *
- * File: dhry.h (part 1 of 3)
- *
- * Date: May 25, 1988
- *
- * Author: Reinhold P. Weicker
- * Siemens AG, AUT E 51
- * Postfach 3220
- * 8520 Erlangen
- * Germany (West)
- * Phone: [+49]-9131-7-20330
- * (8-17 Central European Time)
- * Usenet: ..!mcsun!unido!estevax!weicker
- *
- * Original Version (in Ada) published in
- * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
- * pp. 1013 - 1030, together with the statistics
- * on which the distribution of statements etc. is based.
- *
- * In this C version, the following C library functions are used:
- * - strcpy, strcmp (inside the measurement loop)
- * - printf, scanf (outside the measurement loop)
- * In addition, Berkeley UNIX system calls "times ()" or "time ()"
- * are used for execution time measurement. For measurements
- * on other systems, these calls have to be changed.
- *
- * Collection of Results:
- * Reinhold Weicker (address see above) and
- *
- * Rick Richardson
- * PC Research. Inc.
- * 94 Apple Orchard Drive
- * Tinton Falls, NJ 07724
- * Phone: (201) 389-8963 (9-17 EST)
- * Usenet: ...!uunet!pcrat!rick
- *
- * Please send results to Rick Richardson and/or Reinhold Weicker.
- * Complete information should be given on hardware and software used.
- * Hardware information includes: Machine type, CPU, type and size
- * of caches; for microprocessors: clock frequency, memory speed
- * (number of wait states).
- * Software information includes: Compiler (and runtime library)
- * manufacturer and version, compilation switches, OS version.
- * The Operating System version may give an indication about the
- * compiler; Dhrystone itself performs no OS calls in the measurement loop.
- *
- * The complete output generated by the program should be mailed
- * such that at least some checks for correctness can be made.
- *
- ***************************************************************************
- *
- * History: This version C/2.1 has been made for two reasons:
- *
- * 1) There is an obvious need for a common C version of
- * Dhrystone, since C is at present the most popular system
- * programming language for the class of processors
- * (microcomputers, minicomputers) where Dhrystone is used most.
- * There should be, as far as possible, only one C version of
- * Dhrystone such that results can be compared without
- * restrictions. In the past, the C versions distributed
- * by Rick Richardson (Version 1.1) and by Reinhold Weicker
- * had small (though not significant) differences.
- *
- * 2) As far as it is possible without changes to the Dhrystone
- * statistics, optimizing compilers should be prevented from
- * removing significant statements.
- *
- * This C version has been developed in cooperation with
- * Rick Richardson (Tinton Falls, NJ), it incorporates many
- * ideas from the "Version 1.1" distributed previously by
- * him over the UNIX network Usenet.
- * I also thank Chaim Benedelac (National Semiconductor),
- * David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
- * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
- * for their help with comments on earlier versions of the
- * benchmark.
- *
- * Changes: In the initialization part, this version follows mostly
- * Rick Richardson's version distributed via Usenet, not the
- * version distributed earlier via floppy disk by Reinhold Weicker.
- * As a concession to older compilers, names have been made
- * unique within the first 8 characters.
- * Inside the measurement loop, this version follows the
- * version previously distributed by Reinhold Weicker.
- *
- * At several places in the benchmark, code has been added,
- * but within the measurement loop only in branches that
- * are not executed. The intention is that optimizing compilers
- * should be prevented from moving code out of the measurement
- * loop, or from removing code altogether. Since the statements
- * that are executed within the measurement loop have NOT been
- * changed, the numbers defining the "Dhrystone distribution"
- * (distribution of statements, operand types and locality)
- * still hold. Except for sophisticated optimizing compilers,
- * execution times for this version should be the same as
- * for previous versions.
- *
- * Since it has proven difficult to subtract the time for the
- * measurement loop overhead in a correct way, the loop check
- * has been made a part of the benchmark. This does have
- * an impact - though a very minor one - on the distribution
- * statistics which have been updated for this version.
- *
- * All changes within the measurement loop are described
- * and discussed in the companion paper "Rationale for
- * Dhrystone version 2".
- *
- * Because of the self-imposed limitation that the order and
- * distribution of the executed statements should not be
- * changed, there are still cases where optimizing compilers
- * may not generate code for some statements. To a certain
- * degree, this is unavoidable for small synthetic benchmarks.
- * Users of the benchmark are advised to check code listings
- * whether code is generated for all statements of Dhrystone.
- *
- * Version 2.1 is identical to version 2.0 distributed via
- * the UNIX network Usenet in March 1988 except that it corrects
- * some minor deficiencies that were found by users of version 2.0.
- * The only change within the measurement loop is that a
- * non-executed "else" part was added to the "if" statement in
- * Func_3, and a non-executed "else" part removed from Proc_3.
- *
- ***************************************************************************
- *
- * Defines: The following "Defines" are possible:
- * -DREG=register (default: Not defined)
- * As an approximation to what an average C programmer
- * might do, the "register" storage class is applied
- * (if enabled by -DREG=register)
- * - for local variables, if they are used (dynamically)
- * five or more times
- * - for parameters if they are used (dynamically)
- * six or more times
- * Note that an optimal "register" strategy is
- * compiler-dependent, and that "register" declarations
- * do not necessarily lead to faster execution.
- * -DNOSTRUCTASSIGN (default: Not defined)
- * Define if the C compiler does not support
- * assignment of structures.
- * -DNOENUMS (default: Not defined)
- * Define if the C compiler does not support
- * enumeration types.
- * -DTIMES (default)
- * -DTIME
- * The "times" function of UNIX (returning process times)
- * or the "time" function (returning wallclock time)
- * is used for measurement.
- * For single user machines, "time ()" is adequate. For
- * multi-user machines where you cannot get single-user
- * access, use the "times ()" function. If you have
- * neither, use a stopwatch in the dead of night.
- * "printf"s are provided marking the points "Start Timer"
- * and "Stop Timer". DO NOT use the UNIX "time(1)"
- * command, as this will measure the total time to
- * run this program, which will (erroneously) include
- * the time to allocate storage (malloc) and to perform
- * the initialization.
- * -DHZ=nnn
- * In Berkeley UNIX, the function "times" returns process
- * time in 1/HZ seconds, with HZ = 60 for most systems.
- * CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
- * A VALUE.
- *
- ***************************************************************************
- *
- * Compilation model and measurement (IMPORTANT):
- *
- * This C version of Dhrystone consists of three files:
- * - dhry.h (this file, containing global definitions and comments)
- * - dhry_1.c (containing the code corresponding to Ada package Pack_1)
- * - dhry_2.c (containing the code corresponding to Ada package Pack_2)
- *
- * The following "ground rules" apply for measurements:
- * - Separate compilation
- * - No procedure merging
- * - Otherwise, compiler optimizations are allowed but should be indicated
- * - Default results are those without register declarations
- * See the companion paper "Rationale for Dhrystone Version 2" for a more
- * detailed discussion of these ground rules.
- *
- * For 16-Bit processors (e.g. 80186, 80286), times for all compilation
- * models ("small", "medium", "large" etc.) should be given if possible,
- * together with a definition of these models for the compiler system used.
- *
- **************************************************************************
- *
- * Dhrystone (C version) statistics:
- *
- * [Comment from the first distribution, updated for version 2.
- * Note that because of language differences, the numbers are slightly
- * different from the Ada version.]
- *
- * The following program contains statements of a high level programming
- * language (here: C) in a distribution considered representative:
- *
- * assignments 52 (51.0 %)
- * control statements 33 (32.4 %)
- * procedure, function calls 17 (16.7 %)
- *
- * 103 statements are dynamically executed. The program is balanced with
- * respect to the three aspects:
- *
- * - statement type
- * - operand type
- * - operand locality
- * operand global, local, parameter, or constant.
- *
- * The combination of these three aspects is balanced only approximately.
- *
- * 1. Statement Type:
- * ----------------- number
- *
- * V1 = V2 9
- * (incl. V1 = F(..)
- * V = Constant 12
- * Assignment, 7
- * with array element
- * Assignment, 6
- * with record component
- * --
- * 34 34
- *
- * X = Y +|-|"&&"|"|" Z 5
- * X = Y +|-|"==" Constant 6
- * X = X +|- 1 3
- * X = Y *|/ Z 2
- * X = Expression, 1
- * two operators
- * X = Expression, 1
- * three operators
- * --
- * 18 18
- *
- * if .... 14
- * with "else" 7
- * without "else" 7
- * executed 3
- * not executed 4
- * for ... 7 | counted every time
- * while ... 4 | the loop condition
- * do ... while 1 | is evaluated
- * switch ... 1
- * break 1
- * declaration with 1
- * initialization
- * --
- * 34 34
- *
- * P (...) procedure call 11
- * user procedure 10
- * library procedure 1
- * X = F (...)
- * function call 6
- * user function 5
- * library function 1
- * --
- * 17 17
- * ---
- * 103
- *
- * The average number of parameters in procedure or function calls
- * is 1.82 (not counting the function values as implicit parameters).
- *
- *
- * 2. Operators
- * ------------
- * number approximate
- * percentage
- *
- * Arithmetic 32 50.8
- *
- * + 21 33.3
- * - 7 11.1
- * * 3 4.8
- * / (int div) 1 1.6
- *
- * Comparison 27 42.8
- *
- * == 9 14.3
- * /= 4 6.3
- * > 1 1.6
- * < 3 4.8
- * >= 1 1.6
- * <= 9 14.3
- *
- * Logic 4 6.3
- *
- * && (AND-THEN) 1 1.6
- * | (OR) 1 1.6
- * ! (NOT) 2 3.2
- *
- * -- -----
- * 63 100.1
- *
- *
- * 3. Operand Type (counted once per operand reference):
- * ---------------
- * number approximate
- * percentage
- *
- * Integer 175 72.3 %
- * Character 45 18.6 %
- * Pointer 12 5.0 %
- * String30 6 2.5 %
- * Array 2 0.8 %
- * Record 2 0.8 %
- * --- -------
- * 242 100.0 %
- *
- * When there is an access path leading to the final operand (e.g. a record
- * component), only the final data type on the access path is counted.
- *
- *
- * 4. Operand Locality:
- * -------------------
- * number approximate
- * percentage
- *
- * local variable 114 47.1 %
- * global variable 22 9.1 %
- * parameter 45 18.6 %
- * value 23 9.5 %
- * reference 22 9.1 %
- * function result 6 2.5 %
- * constant 55 22.7 %
- * --- -------
- * 242 100.0 %
- *
- *
- * The program does not compute anything meaningful, but it is syntactically
- * and semantically correct. All variables have a value assigned to them
- * before they are used as a source operand.
- *
- * There has been no explicit effort to account for the effects of a
- * cache, or to balance the use of long or short displacements for code or
- * data.
- *
- ***************************************************************************
- */
-
-/* Compiler and system dependent definitions: */
-
-#ifndef TIME
-#define TIMES
-#endif
- /* Use times(2) time function unless */
- /* explicitly defined otherwise */
-
-#ifdef TIMES
-#include <sys/types.h>
-#include <sys/times.h>
- /* for "times" */
-#endif
-
-#define Mic_secs_Per_Second 1000000
- /* Berkeley UNIX C returns process times in seconds/HZ */
-
-#ifdef NOSTRUCTASSIGN
-#define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
-#else
-#define structassign(d, s) d = s
-#endif
-
-#ifdef NOENUM
-#define Ident_1 0
-#define Ident_2 1
-#define Ident_3 2
-#define Ident_4 3
-#define Ident_5 4
- typedef int Enumeration;
-#else
- typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
- Enumeration;
-#endif
- /* for boolean and enumeration types in Ada, Pascal */
-
-/* General definitions: */
-
-#include <stdio.h>
- /* for strcpy, strcmp */
-
-#define Null 0
- /* Value of a Null pointer */
-#define true 1
-#define false 0
-
-typedef int One_Thirty;
-typedef int One_Fifty;
-typedef char Capital_Letter;
-typedef int Boolean;
-typedef char Str_30 [31];
-typedef int Arr_1_Dim [50];
-typedef int Arr_2_Dim [50] [50];
-
-typedef struct record
- {
- struct record *Ptr_Comp;
- Enumeration Discr;
- union {
- struct {
- Enumeration Enum_Comp;
- int Int_Comp;
- char Str_Comp [31];
- } var_1;
- struct {
- Enumeration E_Comp_2;
- char Str_2_Comp [31];
- } var_2;
- struct {
- char Ch_1_Comp;
- char Ch_2_Comp;
- } var_3;
- } variant;
- } Rec_Type, *Rec_Pointer;
-
-
diff --git a/software/dhrystone/dhry_1.c b/software/dhrystone/dhry_1.c
deleted file mode 100644
index 7ab02a8..0000000
--- a/software/dhrystone/dhry_1.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- ****************************************************************************
- *
- * "DHRYSTONE" Benchmark Program
- * -----------------------------
- *
- * Version: C, Version 2.1
- *
- * File: dhry_1.c (part 2 of 3)
- *
- * Date: May 25, 1988
- *
- * Author: Reinhold P. Weicker
- *
- ****************************************************************************
- */
-
-#include "dhry.h"
-
-/* Global Variables: */
-
-Rec_Pointer Ptr_Glob,
- Next_Ptr_Glob;
-int Int_Glob;
-Boolean Bool_Glob;
-char Ch_1_Glob,
- Ch_2_Glob;
-int Arr_1_Glob [50];
-int Arr_2_Glob [50] [50];
-
-extern char *malloc ();
-Enumeration Func_1 ();
- /* forward declaration necessary since Enumeration may not simply be int */
-
-#ifndef REG
- Boolean Reg = false;
-#define REG
- /* REG becomes defined as empty */
- /* i.e. no register variables */
-#else
- Boolean Reg = true;
-#endif
-
-/* variables for time measurement: */
-
-#ifdef TIMES
-struct tms time_info;
-extern int times ();
- /* see library function "times" */
-#define Too_Small_Time 120
- /* Measurements should last at least about 2 seconds */
-#endif
-#ifdef TIME
-extern long time();
- /* see library function "time" */
-#define Too_Small_Time 2
- /* Measurements should last at least 2 seconds */
-#endif
-
-long Begin_Time,
- End_Time,
- User_Time;
-float Microseconds,
- Dhrystones_Per_Second;
-
-/* end of variables for time measurement */
-
-
-main ()
-/*****/
-
- /* main program, corresponds to procedures */
- /* Main and Proc_0 in the Ada version */
-{
- One_Fifty Int_1_Loc;
- REG One_Fifty Int_2_Loc;
- One_Fifty Int_3_Loc;
- REG char Ch_Index;
- Enumeration Enum_Loc;
- Str_30 Str_1_Loc;
- Str_30 Str_2_Loc;
- REG int Run_Index;
- REG int Number_Of_Runs;
-
- /* Initializations */
-
- Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
- Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
-
- Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
- Ptr_Glob->Discr = Ident_1;
- Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
- Ptr_Glob->variant.var_1.Int_Comp = 40;
- strcpy (Ptr_Glob->variant.var_1.Str_Comp,
- "DHRYSTONE PROGRAM, SOME STRING");
- strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
-
- Arr_2_Glob [8][7] = 10;
- /* Was missing in published program. Without this statement, */
- /* Arr_2_Glob [8][7] would have an undefined value. */
- /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
- /* overflow may occur for this array element. */
-
- printf ("\n");
- printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
- printf ("\n");
- if (Reg)
- {
- printf ("Program compiled with 'register' attribute\n");
- printf ("\n");
- }
- else
- {
- printf ("Program compiled without 'register' attribute\n");
- printf ("\n");
- }
- printf ("Please give the number of runs through the benchmark: ");
- {
- int n;
- scanf ("%d", &n);
- Number_Of_Runs = n;
- }
- printf ("\n");
-
- printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
-
- /***************/
- /* Start timer */
- /***************/
-
-#ifdef TIMES
- times (&time_info);
- Begin_Time = (long) time_info.tms_utime;
-#endif
-#ifdef TIME
- Begin_Time = time ( (long *) 0);
-#endif
-
- for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
- {
-
- Proc_5();
- Proc_4();
- /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
- Int_1_Loc = 2;
- Int_2_Loc = 3;
- strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
- Enum_Loc = Ident_2;
- Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
- /* Bool_Glob == 1 */
- while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
- {
- Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
- /* Int_3_Loc == 7 */
- Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
- /* Int_3_Loc == 7 */
- Int_1_Loc += 1;
- } /* while */
- /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
- Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
- /* Int_Glob == 5 */
- Proc_1 (Ptr_Glob);
- for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
- /* loop body executed twice */
- {
- if (Enum_Loc == Func_1 (Ch_Index, 'C'))
- /* then, not executed */
- {
- Proc_6 (Ident_1, &Enum_Loc);
- strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
- Int_2_Loc = Run_Index;
- Int_Glob = Run_Index;
- }
- }
- /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
- Int_2_Loc = Int_2_Loc * Int_1_Loc;
- Int_1_Loc = Int_2_Loc / Int_3_Loc;
- Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
- /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
- Proc_2 (&Int_1_Loc);
- /* Int_1_Loc == 5 */
-
- } /* loop "for Run_Index" */
-
- /**************/
- /* Stop timer */
- /**************/
-
-#ifdef TIMES
- times (&time_info);
- End_Time = (long) time_info.tms_utime;
-#endif
-#ifdef TIME
- End_Time = time ( (long *) 0);
-#endif
-
- printf ("Execution ends\n");
- printf ("\n");
- printf ("Final values of the variables used in the benchmark:\n");
- printf ("\n");
- printf ("Int_Glob: %d\n", Int_Glob);
- printf (" should be: %d\n", 5);
- printf ("Bool_Glob: %d\n", Bool_Glob);
- printf (" should be: %d\n", 1);
- printf ("Ch_1_Glob: %c\n", Ch_1_Glob);
- printf (" should be: %c\n", 'A');
- printf ("Ch_2_Glob: %c\n", Ch_2_Glob);
- printf (" should be: %c\n", 'B');
- printf ("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
- printf (" should be: %d\n", 7);
- printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
- printf (" should be: Number_Of_Runs + 10\n");
- printf ("Ptr_Glob->\n");
- printf (" Ptr_Comp: %d\n", (int) Ptr_Glob->Ptr_Comp);
- printf (" should be: (implementation-dependent)\n");
- printf (" Discr: %d\n", Ptr_Glob->Discr);
- printf (" should be: %d\n", 0);
- printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
- printf (" should be: %d\n", 2);
- printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
- printf (" should be: %d\n", 17);
- printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
- printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
- printf ("Next_Ptr_Glob->\n");
- printf (" Ptr_Comp: %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
- printf (" should be: (implementation-dependent), same as above\n");
- printf (" Discr: %d\n", Next_Ptr_Glob->Discr);
- printf (" should be: %d\n", 0);
- printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
- printf (" should be: %d\n", 1);
- printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
- printf (" should be: %d\n", 18);
- printf (" Str_Comp: %s\n",
- Next_Ptr_Glob->variant.var_1.Str_Comp);
- printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
- printf ("Int_1_Loc: %d\n", Int_1_Loc);
- printf (" should be: %d\n", 5);
- printf ("Int_2_Loc: %d\n", Int_2_Loc);
- printf (" should be: %d\n", 13);
- printf ("Int_3_Loc: %d\n", Int_3_Loc);
- printf (" should be: %d\n", 7);
- printf ("Enum_Loc: %d\n", Enum_Loc);
- printf (" should be: %d\n", 1);
- printf ("Str_1_Loc: %s\n", Str_1_Loc);
- printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
- printf ("Str_2_Loc: %s\n", Str_2_Loc);
- printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
- printf ("\n");
-
- User_Time = End_Time - Begin_Time;
-
- if (User_Time < Too_Small_Time)
- {
- printf ("Measured time too small to obtain meaningful results\n");
- printf ("Please increase number of runs\n");
- printf ("\n");
- }
- else
- {
-#ifdef TIME
- Microseconds = (float) User_Time * Mic_secs_Per_Second
- / (float) Number_Of_Runs;
- Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time;
-#else
- Microseconds = (float) User_Time * Mic_secs_Per_Second
- / ((float) HZ * ((float) Number_Of_Runs));
- Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
- / (float) User_Time;
-#endif
- printf ("Microseconds for one run through Dhrystone: ");
- printf ("%6.1f \n", Microseconds);
- printf ("Dhrystones per Second: ");
- printf ("%6.1f \n", Dhrystones_Per_Second);
- printf ("\n");
- }
-
-}
-
-
-Proc_1 (Ptr_Val_Par)
-/******************/
-
-REG Rec_Pointer Ptr_Val_Par;
- /* executed once */
-{
- REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
- /* == Ptr_Glob_Next */
- /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
- /* corresponds to "rename" in Ada, "with" in Pascal */
-
- structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
- Ptr_Val_Par->variant.var_1.Int_Comp = 5;
- Next_Record->variant.var_1.Int_Comp
- = Ptr_Val_Par->variant.var_1.Int_Comp;
- Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
- Proc_3 (&Next_Record->Ptr_Comp);
- /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
- == Ptr_Glob->Ptr_Comp */
- if (Next_Record->Discr == Ident_1)
- /* then, executed */
- {
- Next_Record->variant.var_1.Int_Comp = 6;
- Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
- &Next_Record->variant.var_1.Enum_Comp);
- Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
- Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
- &Next_Record->variant.var_1.Int_Comp);
- }
- else /* not executed */
- structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
-} /* Proc_1 */
-
-
-Proc_2 (Int_Par_Ref)
-/******************/
- /* executed once */
- /* *Int_Par_Ref == 1, becomes 4 */
-
-One_Fifty *Int_Par_Ref;
-{
- One_Fifty Int_Loc;
- Enumeration Enum_Loc;
-
- Int_Loc = *Int_Par_Ref + 10;
- do /* executed once */
- if (Ch_1_Glob == 'A')
- /* then, executed */
- {
- Int_Loc -= 1;
- *Int_Par_Ref = Int_Loc - Int_Glob;
- Enum_Loc = Ident_1;
- } /* if */
- while (Enum_Loc != Ident_1); /* true */
-} /* Proc_2 */
-
-
-Proc_3 (Ptr_Ref_Par)
-/******************/
- /* executed once */
- /* Ptr_Ref_Par becomes Ptr_Glob */
-
-Rec_Pointer *Ptr_Ref_Par;
-
-{
- if (Ptr_Glob != Null)
- /* then, executed */
- *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
- Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
-} /* Proc_3 */
-
-
-Proc_4 () /* without parameters */
-/*******/
- /* executed once */
-{
- Boolean Bool_Loc;
-
- Bool_Loc = Ch_1_Glob == 'A';
- Bool_Glob = Bool_Loc | Bool_Glob;
- Ch_2_Glob = 'B';
-} /* Proc_4 */
-
-
-Proc_5 () /* without parameters */
-/*******/
- /* executed once */
-{
- Ch_1_Glob = 'A';
- Bool_Glob = false;
-} /* Proc_5 */
-
-
- /* Procedure for the assignment of structures, */
- /* if the C compiler doesn't support this feature */
-#ifdef NOSTRUCTASSIGN
-memcpy (d, s, l)
-register char *d;
-register char *s;
-register int l;
-{
- while (l--) *d++ = *s++;
-}
-#endif
-
-
diff --git a/software/dhrystone/dhry_2.c b/software/dhrystone/dhry_2.c
deleted file mode 100644
index 63a3d3e..0000000
--- a/software/dhrystone/dhry_2.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- ****************************************************************************
- *
- * "DHRYSTONE" Benchmark Program
- * -----------------------------
- *
- * Version: C, Version 2.1
- *
- * File: dhry_2.c (part 3 of 3)
- *
- * Date: May 25, 1988
- *
- * Author: Reinhold P. Weicker
- *
- ****************************************************************************
- */
-
-#include "dhry.h"
-
-#ifndef REG
-#define REG
- /* REG becomes defined as empty */
- /* i.e. no register variables */
-#endif
-
-extern int Int_Glob;
-extern char Ch_1_Glob;
-
-
-Proc_6 (Enum_Val_Par, Enum_Ref_Par)
-/*********************************/
- /* executed once */
- /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
-
-Enumeration Enum_Val_Par;
-Enumeration *Enum_Ref_Par;
-{
- *Enum_Ref_Par = Enum_Val_Par;
- if (! Func_3 (Enum_Val_Par))
- /* then, not executed */
- *Enum_Ref_Par = Ident_4;
- switch (Enum_Val_Par)
- {
- case Ident_1:
- *Enum_Ref_Par = Ident_1;
- break;
- case Ident_2:
- if (Int_Glob > 100)
- /* then */
- *Enum_Ref_Par = Ident_1;
- else *Enum_Ref_Par = Ident_4;
- break;
- case Ident_3: /* executed */
- *Enum_Ref_Par = Ident_2;
- break;
- case Ident_4: break;
- case Ident_5:
- *Enum_Ref_Par = Ident_3;
- break;
- } /* switch */
-} /* Proc_6 */
-
-
-Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
-/**********************************************/
- /* executed three times */
- /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
- /* Int_Par_Ref becomes 7 */
- /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
- /* Int_Par_Ref becomes 17 */
- /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
- /* Int_Par_Ref becomes 18 */
-One_Fifty Int_1_Par_Val;
-One_Fifty Int_2_Par_Val;
-One_Fifty *Int_Par_Ref;
-{
- One_Fifty Int_Loc;
-
- Int_Loc = Int_1_Par_Val + 2;
- *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
-} /* Proc_7 */
-
-
-Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
-/*********************************************************************/
- /* executed once */
- /* Int_Par_Val_1 == 3 */
- /* Int_Par_Val_2 == 7 */
-Arr_1_Dim Arr_1_Par_Ref;
-Arr_2_Dim Arr_2_Par_Ref;
-int Int_1_Par_Val;
-int Int_2_Par_Val;
-{
- REG One_Fifty Int_Index;
- REG One_Fifty Int_Loc;
-
- Int_Loc = Int_1_Par_Val + 5;
- Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
- Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
- Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
- for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
- Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
- Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
- Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
- Int_Glob = 5;
-} /* Proc_8 */
-
-
-Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val)
-/*************************************************/
- /* executed three times */
- /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
- /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
- /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
-
-Capital_Letter Ch_1_Par_Val;
-Capital_Letter Ch_2_Par_Val;
-{
- Capital_Letter Ch_1_Loc;
- Capital_Letter Ch_2_Loc;
-
- Ch_1_Loc = Ch_1_Par_Val;
- Ch_2_Loc = Ch_1_Loc;
- if (Ch_2_Loc != Ch_2_Par_Val)
- /* then, executed */
- return (Ident_1);
- else /* not executed */
- {
- Ch_1_Glob = Ch_1_Loc;
- return (Ident_2);
- }
-} /* Func_1 */
-
-
-Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
-/*************************************************/
- /* executed once */
- /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
- /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
-
-Str_30 Str_1_Par_Ref;
-Str_30 Str_2_Par_Ref;
-{
- REG One_Thirty Int_Loc;
- Capital_Letter Ch_Loc;
-
- Int_Loc = 2;
- while (Int_Loc <= 2) /* loop body executed once */
- if (Func_1 (Str_1_Par_Ref[Int_Loc],
- Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
- /* then, executed */
- {
- Ch_Loc = 'A';
- Int_Loc += 1;
- } /* if, while */
- if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
- /* then, not executed */
- Int_Loc = 7;
- if (Ch_Loc == 'R')
- /* then, not executed */
- return (true);
- else /* executed */
- {
- if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
- /* then, not executed */
- {
- Int_Loc += 7;
- Int_Glob = Int_Loc;
- return (true);
- }
- else /* executed */
- return (false);
- } /* if Ch_Loc */
-} /* Func_2 */
-
-
-Boolean Func_3 (Enum_Par_Val)
-/***************************/
- /* executed once */
- /* Enum_Par_Val == Ident_3 */
-Enumeration Enum_Par_Val;
-{
- Enumeration Enum_Loc;
-
- Enum_Loc = Enum_Par_Val;
- if (Enum_Loc == Ident_3)
- /* then, executed */
- return (true);
- else /* not executed */
- return (false);
-} /* Func_3 */
-
diff --git a/software/dhrystone/dhry_printf.c b/software/dhrystone/dhry_printf.c
deleted file mode 100644
index 025d231..0000000
--- a/software/dhrystone/dhry_printf.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/* The functions in this file are only meant to support Dhrystone on an
- * embedded RV32 system and are obviously incorrect in general. */
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-
-#undef putchar
-int putchar(int ch)
-{
- return write(1, &ch, 1) == 1 ? ch : -1;
-}
-
-static void sprintf_putch(int ch, void** data)
-{
- char** pstr = (char**)data;
- **pstr = ch;
- (*pstr)++;
-}
-
-static unsigned long getuint(va_list *ap, int lflag)
-{
- if (lflag)
- return va_arg(*ap, unsigned long);
- else
- return va_arg(*ap, unsigned int);
-}
-
-static long getint(va_list *ap, int lflag)
-{
- if (lflag)
- return va_arg(*ap, long);
- else
- return va_arg(*ap, int);
-}
-
-static inline void printnum(void (*putch)(int, void**), void **putdat,
- unsigned long num, unsigned base, int width, int padc)
-{
- unsigned digs[sizeof(num)*8];
- int pos = 0;
-
- while (1)
- {
- digs[pos++] = num % base;
- if (num < base)
- break;
- num /= base;
- }
-
- while (width-- > pos)
- putch(padc, putdat);
-
- while (pos-- > 0)
- putch(digs[pos] + (digs[pos] >= 10 ? 'a' - 10 : '0'), putdat);
-}
-
-static inline void print_double(void (*putch)(int, void**), void **putdat,
- double num, int width, int prec)
-{
- union {
- double d;
- uint64_t u;
- } u;
- u.d = num;
-
- if (u.u & (1ULL << 63)) {
- putch('-', putdat);
- u.u &= ~(1ULL << 63);
- }
-
- for (int i = 0; i < prec; i++)
- u.d *= 10;
-
- char buf[32], *pbuf = buf;
- printnum(sprintf_putch, (void**)&pbuf, (unsigned long)u.d, 10, 0, 0);
- if (prec > 0) {
- for (int i = 0; i < prec; i++) {
- pbuf[-i] = pbuf[-i-1];
- }
- pbuf[-prec] = '.';
- pbuf++;
- }
-
- for (char* p = buf; p < pbuf; p++)
- putch(*p, putdat);
-}
-
-static void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt, va_list ap)
-{
- register const char* p;
- const char* last_fmt;
- register int ch, err;
- unsigned long num;
- int base, lflag, width, precision, altflag;
- char padc;
-
- while (1) {
- while ((ch = *(unsigned char *) fmt) != '%') {
- if (ch == '\0')
- return;
- fmt++;
- putch(ch, putdat);
- }
- fmt++;
-
- // Process a %-escape sequence
- last_fmt = fmt;
- padc = ' ';
- width = -1;
- precision = -1;
- lflag = 0;
- altflag = 0;
- reswitch:
- switch (ch = *(unsigned char *) fmt++) {
-
- // flag to pad on the right
- case '-':
- padc = '-';
- goto reswitch;
-
- // flag to pad with 0's instead of spaces
- case '0':
- padc = '0';
- goto reswitch;
-
- // width field
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- for (precision = 0; ; ++fmt) {
- precision = precision * 10 + ch - '0';
- ch = *fmt;
- if (ch < '0' || ch > '9')
- break;
- }
- goto process_precision;
-
- case '*':
- precision = va_arg(ap, int);
- goto process_precision;
-
- case '.':
- if (width < 0)
- width = 0;
- goto reswitch;
-
- case '#':
- altflag = 1;
- goto reswitch;
-
- process_precision:
- if (width < 0)
- width = precision, precision = -1;
- goto reswitch;
-
- // long flag
- case 'l':
- if (lflag)
- goto bad;
- goto reswitch;
-
- // character
- case 'c':
- putch(va_arg(ap, int), putdat);
- break;
-
- // double
- case 'f':
- print_double(putch, putdat, va_arg(ap, double), width, precision);
- break;
-
- // string
- case 's':
- if ((p = va_arg(ap, char *)) == NULL)
- p = "(null)";
- if (width > 0 && padc != '-')
- for (width -= strnlen(p, precision); width > 0; width--)
- putch(padc, putdat);
- for (; (ch = *p) != '\0' && (precision < 0 || --precision >= 0); width--) {
- putch(ch, putdat);
- p++;
- }
- for (; width > 0; width--)
- putch(' ', putdat);
- break;
-
- // (signed) decimal
- case 'd':
- num = getint(&ap, lflag);
- if ((long) num < 0) {
- putch('-', putdat);
- num = -(long) num;
- }
- base = 10;
- goto signed_number;
-
- // unsigned decimal
- case 'u':
- base = 10;
- goto unsigned_number;
-
- // (unsigned) octal
- case 'o':
- // should do something with padding so it's always 3 octits
- base = 8;
- goto unsigned_number;
-
- // pointer
- case 'p':
- lflag = 1;
- putch('0', putdat);
- putch('x', putdat);
- /* fall through to 'x' */
-
- // (unsigned) hexadecimal
- case 'x':
- base = 16;
- unsigned_number:
- num = getuint(&ap, lflag);
- signed_number:
- printnum(putch, putdat, num, base, width, padc);
- break;
-
- // escaped '%' character
- case '%':
- putch(ch, putdat);
- break;
-
- // unrecognized escape sequence - just print it literally
- default:
- bad:
- putch('%', putdat);
- fmt = last_fmt;
- break;
- }
- }
-}
-
-int __wrap_printf(const char* fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
-
- vprintfmt((void*)putchar, 0, fmt, ap);
-
- va_end(ap);
- return 0; // incorrect return value, but who cares, anyway?
-}
-
-int __wrap_sprintf(char* str, const char* fmt, ...)
-{
- va_list ap;
- char* str0 = str;
- va_start(ap, fmt);
-
- vprintfmt(sprintf_putch, (void**)&str, fmt, ap);
- *str = 0;
-
- va_end(ap);
- return str - str0;
-}
diff --git a/software/dhrystone/dhry_stubs.c b/software/dhrystone/dhry_stubs.c
deleted file mode 100644
index 0616f86..0000000
--- a/software/dhrystone/dhry_stubs.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "platform.h"
-
-/* The functions in this file are only meant to support Dhrystone on an
- * embedded RV32 system and are obviously incorrect in general. */
-
-long time(void)
-{
- return get_timer_value() / get_timer_freq();
-}
-
-// set the number of dhrystone iterations
-void __wrap_scanf(const char* fmt, int* n)
-{
- *n = 100000000;
-}
diff --git a/software/double_tap_dontboot/.unsupported-boards b/software/double_tap_dontboot/.unsupported-boards
deleted file mode 100644
index 4e93148..0000000
--- a/software/double_tap_dontboot/.unsupported-boards
+++ /dev/null
@@ -1,3 +0,0 @@
-coreplexip-e31-arty
-coreplexip-e51-arty
-
diff --git a/software/double_tap_dontboot/Makefile b/software/double_tap_dontboot/Makefile
deleted file mode 100644
index ae89c51..0000000
--- a/software/double_tap_dontboot/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-TARGET = double_tap_dontboot
-C_SRCS += double_tap_dontboot.c
-CFLAGS += -O2 -fno-builtin-printf -DNO_INIT
-
-BSP_BASE = ../../bsp
-include $(BSP_BASE)/env/common.mk
diff --git a/software/double_tap_dontboot/double_tap_dontboot.c b/software/double_tap_dontboot/double_tap_dontboot.c
deleted file mode 100644
index 53c2c64..0000000
--- a/software/double_tap_dontboot/double_tap_dontboot.c
+++ /dev/null
@@ -1,153 +0,0 @@
-// See LICENSE for license details.
-
-// This is the 'bootloader' which ships on HiFive1 boards,
-// at SPI Flash location 0x20000000.
-// HiFive1 boards have code burned into their OTP which ends with
-// a jump to 0x20000000. The Freedom E SDK and the Arduino IDE
-// linker scripts cause user programs to be compiled and
-// flashed at 0x20400000. Therefore, this code ultimately jumps
-// to 0x20400000, while attempting to leave the machine state as close
-// to its reset state as possible.
-//
-// When compiled in the freedom-e-sdk environment, this code will
-// be compiled as a user program at 0x20400000, so will continuously jump to itself.
-// It is provided in the freedom-e-sdk mostly for reference purposes, so
-// users know what is running on their board. Replacing the bootloader
-// at 0x20000000 is not currently supported by the SDK.
-//
-// These are the instructions for the user of this program, from the
-// HiFive1 Getting Started Guide:
-//
-// This program is designed to allow quick boot, but
-// also a "safe" reboot option if a "bad" program
-// is flashed into the HiFive1's SPI Flash. A "bad" program
-// is one which makes it impossible for the programmer
-// to communicate with the HiFive1. For example, a program which
-// disables FE310's active clock, or which puts the FE310 to sleep
-// with no way of waking it up. Bad programs can always be restarted using
-// the RESET button, and using the "safe" bootloader can be halted
-// before they perform any unsafe behavior.
-//
-// To activate "normal" boot mode, press the RESET button on
-// the HiFive1. After approximately 1s, the green LED will flash
-// for 1/2 second, then the user program will execute.
-//
-// To activate "safe" boot mode, press the RESET button. When
-// the green LED flashes, immediately press the RESET button again.
-// After 1 second, the red LED will blink. The user program will not
-// execute, and the programmer can connect. To exit "safe" boot mode,
-// press the RESET button a final time.
-
-#include <stdint.h>
-#include "platform.h"
-#include "encoding.h"
-
-#ifndef _SIFIVE_HIFIVE1_H
-#error "double_tap_dontboot is designed to run on HiFive1 and/or E300 Arty Dev Kit."
-#endif
-
-
-#define BACKUP15_MAGIC 0xD027B007
-
-#define FINAL_ADDRESS 0x20400000
-
-#define RED_LED 22
-#define GREEN_LED 19
-
-int main(void)
-{
- uint64_t now;
- uint64_t then;
-
- // Restore the default mtvec (which may have been set by initialization
- // code, depending on the environment in which this C code is compiled).
- // By default, this would cause an infinite loop upon exception, which is
- // also "safe" behavior and the debugger can connect.
-
- write_csr(mtvec, 0x0);
-
- // How did we get here? We only want to execute this code
- // on resets (vs waking up from sleep).
- if ((AON_REG(AON_PMUCAUSE) & AON_PMUCAUSE_WAKEUPCAUSE) ==
- AON_WAKEUPCAUSE_RESET) {
-
- if (AON_REG(AON_BACKUP15) == BACKUP15_MAGIC) {
- // Reset was "double-tapped".
-
- // Re-arm the reset double-tap
- AON_REG(AON_BACKUP15) = 0;
-
- // PWM Red LED
-
- GPIO_REG(GPIO_IOF_EN) |= (1 << RED_LED);
- GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << RED_LED);
- GPIO_REG(GPIO_IOF_SEL) |= (1 << RED_LED);
-
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(1 << GREEN_LED);
- GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << GREEN_LED);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << GREEN_LED);
-
- PWM1_REG(PWM_CFG) = 0;
- PWM1_REG(PWM_COUNT) = 0;
- PWM1_REG(PWM_CMP0) = 0xFF;
- PWM1_REG(PWM_CMP3) = 0xFF;
- PWM1_REG(PWM_CFG) = PWM_CFG_ENALWAYS;
-
- int pwm_val = 255;
-
- // Wait for debugger or another RESET press.
- while(1){
-
- // Make the PWM a fade. This is preferable to just a PWM blink
- // because it makes it clear that the processor is actually
- // running this code, not just the PWM hardware.
-
- now = *((volatile uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME));
- then = now + 32768/500;
- while (*((volatile uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME)) < then) {
- asm volatile ("");
- }
- pwm_val = (pwm_val == 0) ? 255 : (pwm_val -1);
- PWM1_REG(PWM_CMP3) = pwm_val << 4;
- }
-
- } // If Magic
-
- // Turn on Green LED to indicate time-to-double-tap
- // LEDs are Active-Low
- GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << GREEN_LED);
- GPIO_REG(GPIO_OUTPUT_XOR) |= (1 << GREEN_LED);
- GPIO_REG(GPIO_OUTPUT_EN) |= (1 << GREEN_LED);
-
- // Re-arm the reset double-tap
- uint32_t save = AON_REG(AON_BACKUP15);
-
- AON_REG(AON_BACKUP15) = BACKUP15_MAGIC;
-
- // Wait 500 ms. If reset is tapped at this point,
- // we will execute the "magic" loop above.
- now = *((volatile uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME));
- then = now + 32768/2;
- while (*((volatile uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME)) < then) {
- asm volatile ("");
- }
-
- // Re-arm the reset double-tap
- AON_REG(AON_BACKUP15) = save;
-
- }
-
- // Restore the GPIO Registers to their default
- GPIO_REG(GPIO_OUTPUT_VAL) = 0;
- GPIO_REG(GPIO_OUTPUT_XOR) = 0;
- GPIO_REG(GPIO_OUTPUT_EN) = 0;
-
- // Jump to "user code" in SPI Flash.
- void (*pgm_start)(void) = (void*) FINAL_ADDRESS;
- pgm_start();
-
- // This value is meaningless, but
- // since this code should never be reached,
- // make it non-zero.
- return (1234567);
-}
diff --git a/software/global_interrupts/.unsupported-boards b/software/global_interrupts/.unsupported-boards
deleted file mode 100644
index 33cea3a..0000000
--- a/software/global_interrupts/.unsupported-boards
+++ /dev/null
@@ -1,2 +0,0 @@
-freedom-e300-arty
-freedom-e300-hifive1
diff --git a/software/global_interrupts/Makefile b/software/global_interrupts/Makefile
deleted file mode 100644
index 6a09f97..0000000
--- a/software/global_interrupts/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = global_interrupts
-CFLAGS += -O2 -fno-builtin-printf -DUSE_LOCAL_ISR
-
-BSP_BASE = ../../bsp
-
-C_SRCS += global_interrupts.c
-C_SRCS += $(BSP_BASE)/drivers/plic/plic_driver.c
-
-include $(BSP_BASE)/env/common.mk
diff --git a/software/global_interrupts/global_interrupts.c b/software/global_interrupts/global_interrupts.c
deleted file mode 100644
index 4d3a554..0000000
--- a/software/global_interrupts/global_interrupts.c
+++ /dev/null
@@ -1,250 +0,0 @@
-// See LICENSE for license details.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "platform.h"
-#include <string.h>
-#include "plic/plic_driver.h"
-#include "encoding.h"
-#include <unistd.h>
-
-#ifndef _SIFIVE_COREPLEXIP_ARTY_H
-#error 'global_interrupts' demo only supported for Coreplex IP Eval Kits
-#endif
-
-// Global Instance data for the PLIC
-// for use by the PLIC Driver.
-plic_instance_t g_plic;
-
-// Flag for state
-int g_switch1Wins;
-
-// Debounce counter (PWM can't go slow enough)
-int g_debounce;
-
-void debounce();
-
-// Structures for registering different interrupt handlers
-// for different parts of the application.
-typedef void (*interrupt_function_ptr_t) (void);
-
-// See bsp/env/<BOARD>/init.c for how this
-// interrupt vector is used.
-interrupt_function_ptr_t localISR[32];
-
-interrupt_function_ptr_t g_ext_interrupt_handlers[PLIC_NUM_INTERRUPTS];
-
-void set_timer() {
-
- volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
- volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
- uint64_t now = *mtime;
- uint64_t then = now + 10*RTC_FREQ;
- *mtimecmp = then;
-
-}
-
-/*Entry Point for Machine Timer Interrupt Handler*/
-void mti_isr(){
-
- if (g_switch1Wins) {
- printf("#### Giving Switch 1 Priority for 10 seconds ####\n");
- // All other things being equal, lower IDs have
- // higher priority. We have already set
- // Switch 1 to priority 2
- // in the setup, so by giving these equal priority Switch 1 will win.
- PLIC_set_priority(&g_plic, INT_EXT_DEVICE_SW_2, 2);
- } else {
- printf("**** Giving Switch 2 Priority for 10 seconds ****\n");
- // By setting Switch 2 a higher integer priority, it will win over switch 1.
- PLIC_set_priority(&g_plic, INT_EXT_DEVICE_SW_2, 3);
- }
- g_switch1Wins ^= 0x1;
-
- set_timer();
-
-}
-
-/*Entry Point for PLIC Interrupt Handler*/
-void mei_isr(){
- plic_source int_num = PLIC_claim_interrupt(&g_plic);
- if ((int_num >=1 ) && (int_num < PLIC_NUM_INTERRUPTS)) {
- g_ext_interrupt_handlers[int_num]();
- }
- else {
- exit(1 + (uintptr_t) int_num);
- }
- PLIC_complete_interrupt(&g_plic, int_num);
-}
-
-const char * instructions_msg = " \
-\n\
- SIFIVE, INC.\n\
-E31/E51 Coreplex IP Eval Kit 'global_interrupts' demo.\n\
-\n\
-Switches 1 and 2 are enabled as External Global Interrupts \n\
-(they don't go through the PLIC). You an observe priorities.\n\
-Priorities invert every few seconds, which is driven by the \n\
-PWM0 global interrupt. \n\
-\n";
-
-void print_instructions() {
-
- write (STDOUT_FILENO, instructions_msg, strlen(instructions_msg));
-
-}
-
-void invalid_global_isr() {
- printf("Unexpected global interrupt!\n");
-}
-
-void invalid_local_isr() {
- printf ("Unexpected local interrupt!\n");
-}
-
-void switch_1_handler() {
-
- printf("Switch 1 is on! Even if Switch 2 is on, Switch 1 must have higher priority right now.\n");
-
- // Set Green LED
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << GREEN_LED_OFFSET) ;
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1<< RED_LED_OFFSET));
-
- debounce();
-
-}
-
-void switch_2_handler() {
- printf("Switch 2 is on! Even if Switch 1 is on, Switch 2 must have higher priority right now.\n");
-
- // Set RED LED
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << GREEN_LED_OFFSET) ;
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1<< RED_LED_OFFSET);
-
- debounce();
-}
-
-// We use PWM 0 as a
-// timer interrupt for debouncing.
-
-void pwm_0_handler() {
-
-
- if (g_debounce == 0) {
- printf(" Done debouncing.\n");
-
- //Lower the threshold s.t. the switches can hit.
- PLIC_set_threshold(&g_plic, 1);
-
- // Clear the PWM interrupt
- PWM0_REG(PWM_CFG) = 0;
-
- } else {
- // Keep waiting
- g_debounce --;
- // This clears out the interrupt and re-arms the timer.
- PWM0_REG(PWM_CFG) = ((PWM_CFG_ONESHOT) | (PWM_CFG_ZEROCMP)| 0x7 | (PWM_CFG_STICKY));
-
- }
-
-}
-
-void debounce(int local_interrupt_num) {
-
- printf(" Starting a debounce.\n");
-
- g_debounce = 600;
-
- // This clears out the interrupt and re-arms the timer.
- PWM0_REG(PWM_CFG) = ((PWM_CFG_ONESHOT) | (PWM_CFG_ZEROCMP)| 0x7 | (PWM_CFG_STICKY));
-
- // Set the threshold high enough that the
- // switches won't cause the interrupt to fire,
- // only the PWM or timer interrupts.
- PLIC_set_threshold(&g_plic, 4);
-
-}
-
-int main(int argc, char **argv)
-{
-
- for (int gisr = 0; gisr < PLIC_NUM_INTERRUPTS; gisr++){
- g_ext_interrupt_handlers[PLIC_NUM_INTERRUPTS] = invalid_global_isr;
- }
- g_ext_interrupt_handlers[PWM0_INT_BASE + 0] = pwm_0_handler;
- g_ext_interrupt_handlers[INT_EXT_DEVICE_SW_1] = switch_1_handler;
- g_ext_interrupt_handlers[INT_EXT_DEVICE_SW_2] = switch_2_handler;
-
- for (int lisr = 0; lisr < 32; lisr++){
- localISR[lisr] = invalid_local_isr;
- }
-
- localISR[IRQ_M_TIMER] = mti_isr;
- localISR[IRQ_M_EXT] = mei_isr;
-
- print_instructions();
-
- // Set up RGB LEDs for a visual.
-
- GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET));
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << GREEN_LED_OFFSET) ;
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1<< RED_LED_OFFSET);
-
- /**************************************************************************
- * Set up the PLIC
- *
- *************************************************************************/
- PLIC_init(&g_plic,
- PLIC_CTRL_ADDR,
- PLIC_NUM_INTERRUPTS,
- PLIC_NUM_PRIORITIES);
-
- /**************************************************************************
- * Give Switch 1 and Switch 2 Equal priority of 2.
- *
- *************************************************************************/
-
- PLIC_enable_interrupt (&g_plic, PWM0_INT_BASE + 0);
- PLIC_enable_interrupt (&g_plic, INT_EXT_DEVICE_SW_1);
- PLIC_enable_interrupt (&g_plic, INT_EXT_DEVICE_SW_2);
-
- // PWM always beats the switches, because we use it
- // as a debouncer, and we lower the threshold
- // to do so.
-
- PWM0_REG(PWM_CFG) = 0;
-
- // Make sure people aren't blinded by LEDs connected here.
- PWM0_REG(PWM_CMP0) = 0xFE;
- PWM0_REG(PWM_CMP1) = 0xFF;
- PWM0_REG(PWM_CMP2) = 0xFF;
- PWM0_REG(PWM_CMP3) = 0xFF;
- PLIC_set_priority(&g_plic, PWM0_INT_BASE + 0 , 5);
-
- // Start the switches out at the same priority. Switch1
- // would win.
- PLIC_set_priority(&g_plic, INT_EXT_DEVICE_SW_1, 2);
- PLIC_set_priority(&g_plic, INT_EXT_DEVICE_SW_2, 2);
-
- // Set up machine timer interrupt. Every few seconds it
- // will invert the switch priorities.
- set_timer();
-
- // Enable timer interrupts.
- set_csr(mie, MIP_MTIP);
-
- // Enable Global (PLIC) interrupts.
- set_csr(mie, MIP_MEIP);
-
- g_switch1Wins = 1;
-
- // Enable all interrupts
- set_csr(mstatus, MSTATUS_MIE);
-
- while(1){
- asm volatile ("wfi");
- }
-
- return 0;
-
-}
diff --git a/software/i2c_demo/.gitignore b/software/i2c_demo/.gitignore
deleted file mode 100644
index 7a8011b..0000000
--- a/software/i2c_demo/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-i2c_demo
diff --git a/software/i2c_demo/Makefile b/software/i2c_demo/Makefile
deleted file mode 100644
index ef29ef2..0000000
--- a/software/i2c_demo/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-TARGET = i2c_demo
-C_SRCS += i2c_demo.c
-CFLAGS += -O2 -fno-builtin-printf
-
-BSP_BASE = ../../bsp
-include $(BSP_BASE)/env/common.mk
diff --git a/software/i2c_demo/i2c_demo.c b/software/i2c_demo/i2c_demo.c
deleted file mode 100644
index 4011c09..0000000
--- a/software/i2c_demo/i2c_demo.c
+++ /dev/null
@@ -1,318 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "platform.h"
-#include <string.h>
-#include <unistd.h>
-#include <math.h>
-#include "stdatomic.h"
-
-#define MPU6050_ADDR 0x68
-
-#define MPU6050_RA_ACCEL_XOUT_H 0x3B
-#define MPU6050_RA_ACCEL_XOUT_L 0x3C
-#define MPU6050_RA_ACCEL_YOUT_H 0x3D
-#define MPU6050_RA_ACCEL_YOUT_L 0x3E
-#define MPU6050_RA_ACCEL_ZOUT_H 0x3F
-#define MPU6050_RA_ACCEL_ZOUT_L 0x40
-#define MPU6050_RA_TEMP_OUT_H 0x41
-#define MPU6050_RA_TEMP_OUT_L 0x42
-#define MPU6050_RA_GYRO_XOUT_H 0x43
-#define MPU6050_RA_GYRO_XOUT_L 0x44
-#define MPU6050_RA_GYRO_YOUT_H 0x45
-#define MPU6050_RA_GYRO_YOUT_L 0x46
-#define MPU6050_RA_GYRO_ZOUT_H 0x47
-#define MPU6050_RA_GYRO_ZOUT_L 0x48
-#define MPU6050_RA_PWR_MGMT_1 0x6B
-#define MPU6050_RA_WHO_AM_I 0x75
-
-#define SDA PIN_8_OFFSET
-#define SCL PIN_9_OFFSET
-
-#define LONG 25 // Equals ~400KHz
-#define SHORT 5
-
-//busy wait for the specified time
-void wait_ms(uint64_t ms) {
- static const uint64_t ms_tick = RTC_FREQ/1000;
- volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
- uint64_t then = (ms_tick * ms) + *mtime;
- while(*mtime<then);
-}
-
-inline void delay_number_of_nop(uint32_t count)
-{
- for(volatile uint32_t j = 0; j < count; j++)
- {
- asm("nop");
- }
-}
-
-_Bool i2c_busy(void)
-{
- GPIO_REG(GPIO_INPUT_EN) |= ((0x1 << SCL) | (0x1 << SDA));
- GPIO_REG(GPIO_OUTPUT_EN) &= ~((0x1 << SCL) | (0x1 << SDA));
- return (GPIO_REG(GPIO_INPUT_VAL) & ((0x1 << SCL) | (0x1 << SDA))) != ((0x1 << SCL) | (0x1 << SDA));
-}
-
-void i2c_start(void)
-{
- GPIO_REG(GPIO_INPUT_EN) &= ~((0x1 << SDA) | (0x1 << SCL));
-
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) |= (0x1 << SDA);
- delay_number_of_nop(SHORT);
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SCL);
- GPIO_REG(GPIO_OUTPUT_EN) |= (0x1 << SCL);
-}
-
-void i2c_repeated_start(void)
-{
- delay_number_of_nop(SHORT);
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << SCL);
- GPIO_REG(GPIO_OUTPUT_EN) |= (0x1 << SCL);
- delay_number_of_nop(SHORT);
- i2c_start();
-}
-
-
-void i2c_stop(void)
-{
- GPIO_REG(GPIO_INPUT_EN) |= (0x1 << SCL);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(0x1 << SCL);
- delay_number_of_nop(SHORT);
- GPIO_REG(GPIO_INPUT_EN) |= (0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(0x1 << SDA);
-}
-
-void i2c_init(void)
-{
- //GPIO_REG(GPIO_IOF_EN) &= ((0x1 << SCL) | (0x1 << SDA));
- GPIO_REG(GPIO_OUTPUT_EN) &= ~((0x1 << SCL) | (0x1 << SDA));
- GPIO_REG(GPIO_PULLUP_EN) |= ((0x1 << SDA) | (0x1 << SCL));
- GPIO_REG(GPIO_INPUT_EN) |= (0x1 << SDA) | (0x1 << SCL);
-}
-
-void i2c_send_bytes_rs(uint8_t* data, uint8_t size, _Bool rs, uint8_t* data_r, uint8_t size_r)
-{
- uint8_t address_r = data[0] | 0x01;
-
- for(uint8_t ii=0; ii<size; ii++)
- {
- GPIO_REG(GPIO_INPUT_EN) &= ~(0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) |= (0x1 << SDA);
- for(uint8_t i=0; i<9; i++)
- {
- delay_number_of_nop(SHORT);
-
- if(i != 8)
- {
- if(data[ii] & 0x80)
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << SDA);
- else
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SDA);
- }
- else
- {
- GPIO_REG(GPIO_INPUT_EN) |= (0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(0x1 << SDA);
- if((GPIO_REG(GPIO_INPUT_VAL) & (0x1 << SDA)) != 0x0)
- {
- printf("NO ACK\n");
- }
-
- GPIO_REG(GPIO_INPUT_EN) &= ~(0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) |= (0x1 << SDA);
- if(rs == 0)
- {
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SDA);
- }
- else
- {
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << SDA);
- }
-
- }
- delay_number_of_nop(LONG-SHORT);
-
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << SCL);
-
- delay_number_of_nop(LONG);
-
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SCL);
-
- data[ii] <<= 1;
- }
- }
-
- if(rs == 0)
- return;
-
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << SCL);
-
- delay_number_of_nop(SHORT);
-
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SDA);
-
- delay_number_of_nop(SHORT);
-
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SCL);
-
- for(uint8_t i=0; i<9; i++)
- {
- delay_number_of_nop(SHORT);
- if(i != 8)
- {
- if(address_r & 0x80)
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << SDA);
- else
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SDA);
- }
- else
- {
- GPIO_REG(GPIO_INPUT_EN) |= (0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(0x1 << SDA);
- if((GPIO_REG(GPIO_INPUT_VAL) & (0x1 << SDA)) != 0x0)
- {
- printf("NO ACK\n");
- }
- }
- delay_number_of_nop(LONG-SHORT);
-
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << SCL);
-
- delay_number_of_nop(LONG);
-
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SCL);
-
- address_r <<= 1;
- }
-
- // Receive Data
- for(uint8_t ii=0; ii<size_r; ii++)
- {
- for(uint8_t i=0; i<9; i++)
- {
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << SCL);
-
- if(i!=8)
- data_r[ii] <<= 1;
-
- delay_number_of_nop(SHORT);
-
- if(i!=8)
- {
- if((GPIO_REG(GPIO_INPUT_VAL) & (0x1 << SDA)) != 0x0)
- {
- data_r[ii] |= 0x1;
- }
- }
- else if(ii == (size_r-1))
- {
- GPIO_REG(GPIO_INPUT_EN) &= ~(0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) |= (0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SDA);
- } else {
-
- }
-
- delay_number_of_nop(LONG-SHORT);
-
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SCL);
-
- if((i==7) && (ii != (size_r-1))){
- GPIO_REG(GPIO_INPUT_EN) &= ~(0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) |= (0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << SDA);
- }
- delay_number_of_nop(LONG);
-
- }
-
- if(ii != (size_r-1)){
- GPIO_REG(GPIO_INPUT_EN) |= (0x1 << SDA);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(0x1 << SDA);
- delay_number_of_nop(SHORT);
- }
- }
-}
-
-void write_byte(uint8_t address, uint8_t reg_addr, uint8_t val)
-{
- uint8_t temp[3];
- uint8_t data;
- temp[0]=address<<1;
- temp[1]=reg_addr;
- temp[2]=val;
- while(i2c_busy());
- i2c_start();
- i2c_send_bytes_rs(temp, sizeof(temp), 0, &data, 1);
- i2c_stop();
-}
-
-uint8_t read_byte(uint8_t address, uint8_t reg_addr)
-{
- uint8_t temp[2];
- uint8_t data;
- temp[0]=address<<1;
- temp[1]=reg_addr;
- while(i2c_busy());
- i2c_start();
- i2c_send_bytes_rs(temp, sizeof(temp), 1, &data, 1);
- i2c_stop();
- return data;
-}
-
-void read_bytes(uint8_t address, uint8_t reg_addr, uint8_t* data, uint8_t size)
-{
- uint8_t temp[2];
- temp[0]=address<<1;
- temp[1]=reg_addr;
- while(i2c_busy());
- i2c_start();
- i2c_send_bytes_rs(temp, sizeof(temp), 1, data, size);
- i2c_stop();
-}
-
-int main(int argc, char **argv)
-{
- uint8_t data;
- uint8_t accel[6];
-
- printf("BIT-BANG I2C DEMO with MPU-6050 IMU\n");
-
- i2c_init();
-
- printf("Power Management 1: 0x%02X\n", read_byte(MPU6050_ADDR, MPU6050_RA_PWR_MGMT_1));
- write_byte(MPU6050_ADDR, MPU6050_RA_PWR_MGMT_1, 0x80);
-
- wait_ms(10);
-
- printf("Power Management 1: 0x%02X\n", read_byte(MPU6050_ADDR, MPU6050_RA_PWR_MGMT_1));
- write_byte(MPU6050_ADDR, MPU6050_RA_PWR_MGMT_1, 0x00);
-
- printf("CHIP_ID: 0x%02X\n", read_byte(MPU6050_ADDR, MPU6050_RA_WHO_AM_I));
- printf("DONE\n");
-
- while(1)
- {
- //for(uint8_t i=0; i<6; i++){
- // accel[i]=read_byte(MPU6050_ADDR, 0x3B+i);
- //}
- read_bytes(MPU6050_ADDR, 0x3B, accel, 6);
- int16_t x_accel = (accel[0]<<8)+accel[1];
- int16_t y_accel = (accel[2]<<8)+accel[3];
- int16_t z_accel = (accel[4]<<8)+accel[5];
-
- float z_g = z_accel;
- z_g = z_g/16384.0;
- int32_t z_g_int = z_g*100;
- z_g_int = abs(z_g_int);
- printf("Gravity in Z %d.%d\n", z_g_int/100, z_g_int%100);
-
- //printf("X: %06d, Y: %06d, Z: %06d\n", x_accel, y_accel, z_accel);
-
- wait_ms(100);
- }
-
- return 0;
-}
diff --git a/software/led_fade/.unsupported-boards b/software/led_fade/.unsupported-boards
deleted file mode 100644
index f9e9897..0000000
--- a/software/led_fade/.unsupported-boards
+++ /dev/null
@@ -1,4 +0,0 @@
-freedom-e300-arty
-coreplexip-e31-arty
-coreplexip-e51-arty
-freedom-e300-arty
diff --git a/software/led_fade/Makefile b/software/led_fade/Makefile
deleted file mode 100644
index bbdba66..0000000
--- a/software/led_fade/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-TARGET = led_fade
-C_SRCS += led_fade.c
-CFLAGS += -O2 -fno-builtin-printf -DNO_INIT
-
-BSP_BASE = ../../bsp
-include $(BSP_BASE)/env/common.mk
diff --git a/software/led_fade/led_fade.c b/software/led_fade/led_fade.c
deleted file mode 100644
index 9b50eda..0000000
--- a/software/led_fade/led_fade.c
+++ /dev/null
@@ -1,167 +0,0 @@
-// See LICENSE for license details.
-
-// This is the program which ships on the HiFive1
-// board, executing out of SPI Flash at 0x20400000.
-
-#include <stdint.h>
-#include "platform.h"
-
-#ifndef _SIFIVE_HIFIVE1_H
-#error "'led_fade' is designed to run on HiFive1 and/or E300 Arty Dev Kit."
-#endif
-
-static const char led_msg[] = "\a\n\r\n\r\
-55555555555555555555555555555555555555555555555\n\r\
-5555555 Are the LEDs Changing? [y/n] 555555555\n\r\
-55555555555555555555555555555555555555555555555\n\r";
-
-static const char sifive_msg[] = "\n\r\
-\n\r\
- SIFIVE, INC.\n\r\
-\n\r\
- 5555555555555555555555555\n\r\
- 5555 5555\n\r\
- 5555 5555\n\r\
- 5555 5555\n\r\
- 5555 5555555555555555555555\n\r\
- 5555 555555555555555555555555\n\r\
- 5555 5555\n\r\
- 5555 5555\n\r\
- 5555 5555\n\r\
-5555555555555555555555555555 55555\n\r\
- 55555 555555555 55555\n\r\
- 55555 55555 55555\n\r\
- 55555 5 55555\n\r\
- 55555 55555\n\r\
- 55555 55555\n\r\
- 55555 55555\n\r\
- 55555 55555\n\r\
- 55555 55555\n\r\
- 555555555\n\r\
- 55555\n\r\
- 5\n\r\
-\n\r\
- 'led_fade' Demo \n\r\
-\n\r";
-
-static void _putc(char c) {
- while ((int32_t) UART0_REG(UART_REG_TXFIFO) < 0);
- UART0_REG(UART_REG_TXFIFO) = c;
-}
-
-int _getc(char * c){
- int32_t val = (int32_t) UART0_REG(UART_REG_RXFIFO);
- if (val > 0) {
- *c = val & 0xFF;
- return 1;
- }
- return 0;
-}
-
-
-static void _puts(const char * s) {
- while (*s != '\0'){
- _putc(*s++);
- }
-}
-
-
-int main (void){
-
- // Make sure the HFROSC is on before the next line:
- PRCI_REG(PRCI_HFROSCCFG) |= ROSC_EN(1);
- // Run off 16 MHz Crystal for accuracy. Note that the
- // first line is
- PRCI_REG(PRCI_PLLCFG) = (PLL_REFSEL(1) | PLL_BYPASS(1));
- PRCI_REG(PRCI_PLLCFG) |= (PLL_SEL(1));
- // Turn off HFROSC to save power
- PRCI_REG(PRCI_HFROSCCFG) &= ~(ROSC_EN(1));
-
- // Configure UART to print
- GPIO_REG(GPIO_OUTPUT_VAL) |= IOF0_UART0_MASK;
- GPIO_REG(GPIO_OUTPUT_EN) |= IOF0_UART0_MASK;
- GPIO_REG(GPIO_IOF_SEL) &= ~IOF0_UART0_MASK;
- GPIO_REG(GPIO_IOF_EN) |= IOF0_UART0_MASK;
-
- // 115200 Baud Rate
- UART0_REG(UART_REG_DIV) = 138;
- UART0_REG(UART_REG_TXCTRL) = UART_TXEN;
- UART0_REG(UART_REG_RXCTRL) = UART_RXEN;
-
- // Wait a bit to avoid corruption on the UART.
- // (In some cases, switching to the IOF can lead
- // to output glitches, so need to let the UART
- // reciever time out and resynchronize to the real
- // start of the stream.
- volatile int i=0;
- while(i < 10000){i++;}
-
- _puts(sifive_msg);
- //_puts("Config String:\n\r");
- //_puts(*((const char **) 0x100C));
- //_puts("\n\r");
- _puts(led_msg);
-
- uint16_t r=0xFF;
- uint16_t g=0;
- uint16_t b=0;
- char c = 0;
-
- // Set up RGB PWM
-
- PWM1_REG(PWM_CFG) = 0;
- // To balance the power consumption, make one left, one right, and one center aligned.
- PWM1_REG(PWM_CFG) = (PWM_CFG_ENALWAYS) | (PWM_CFG_CMP2CENTER);
- PWM1_REG(PWM_COUNT) = 0;
-
- // Period is approximately 244 Hz
- // the LEDs are intentionally left somewhat dim,
- // as the full brightness can be painful to look at.
- PWM1_REG(PWM_CMP0) = 0;
-
- GPIO_REG(GPIO_IOF_SEL) |= ( (1 << GREEN_LED_OFFSET) | (1 << BLUE_LED_OFFSET) | (1 << RED_LED_OFFSET));
- GPIO_REG(GPIO_IOF_EN ) |= ( (1 << GREEN_LED_OFFSET) | (1 << BLUE_LED_OFFSET) | (1 << RED_LED_OFFSET));
- GPIO_REG(GPIO_OUTPUT_XOR) &= ~( (1 << GREEN_LED_OFFSET) | (1 << BLUE_LED_OFFSET));
- GPIO_REG(GPIO_OUTPUT_XOR) |= (1 << RED_LED_OFFSET);
-
- while(1){
- volatile uint64_t * now = (volatile uint64_t*)(CLINT_CTRL_ADDR + CLINT_MTIME);
- volatile uint64_t then = *now + 100;
- while (*now < then) { }
-
- if(r > 0 && b == 0){
- r--;
- g++;
- }
- if(g > 0 && r == 0){
- g--;
- b++;
- }
- if(b > 0 && g == 0){
- r++;
- b--;
- }
-
- uint32_t G = g;
- uint32_t R = r;
- uint32_t B = b;
-
- PWM1_REG(PWM_CMP1) = G << 4; // PWM is low on the left, GPIO is low on the left side, LED is ON on the left.
- PWM1_REG(PWM_CMP2) = (B << 1) << 4; // PWM is high on the middle, GPIO is low in the middle, LED is ON in the middle.
- PWM1_REG(PWM_CMP3) = 0xFFFF - (R << 4); // PWM is low on the left, GPIO is low on the right, LED is on on the right.
-
- // Check for user input
- if (c == 0){
- if (_getc(&c) != 0){
- _putc(c);
- _puts("\n\r");
-
- if ((c == 'y') || (c == 'Y')){
- _puts("PASS\n\r");
- } else{
- _puts("FAIL\n\r");
- }
- }
- }
- }
-}
diff --git a/software/local_interrupts/.unsupported-boards b/software/local_interrupts/.unsupported-boards
deleted file mode 100644
index 33cea3a..0000000
--- a/software/local_interrupts/.unsupported-boards
+++ /dev/null
@@ -1,2 +0,0 @@
-freedom-e300-arty
-freedom-e300-hifive1
diff --git a/software/local_interrupts/Makefile b/software/local_interrupts/Makefile
deleted file mode 100644
index 4605ee9..0000000
--- a/software/local_interrupts/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-TARGET = local_interrupts
-CFLAGS += -O2 -fno-builtin-printf -DUSE_LOCAL_ISR
-
-BSP_BASE = ../../bsp
-
-C_SRCS += local_interrupts.c
-
-include $(BSP_BASE)/env/common.mk
diff --git a/software/local_interrupts/local_interrupts.c b/software/local_interrupts/local_interrupts.c
deleted file mode 100644
index cc9bfe7..0000000
--- a/software/local_interrupts/local_interrupts.c
+++ /dev/null
@@ -1,216 +0,0 @@
-// See LICENSE for license details.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "platform.h"
-#include <string.h>
-#include "encoding.h"
-#include <unistd.h>
-
-#ifndef _SIFIVE_COREPLEXIP_ARTY_H
-#error 'local_interrupts' demo only supported for Coreplex IP Eval Kits
-#endif
-
-// Global Variable used to show
-// software interrupts.
-volatile uint32_t g_debouncing;
-
-void debounce();
-
-// Structures for registering different interrupt handlers
-// for different parts of the application.
-typedef void (*interrupt_function_ptr_t) (void);
-
-// This function enables some of the local interrupts sources
-// used in this demo -- just those for the buttons and
-// Switch 3.
-
-void enable_local_interrupts(){
-
- // lowest priority
- set_csr(mie, MIP_MLIP(LOCAL_INT_SW_3 ));
- set_csr(mie, MIP_MLIP(LOCAL_INT_BTN_0));
- set_csr(mie, MIP_MLIP(LOCAL_INT_BTN_1));
- set_csr(mie, MIP_MLIP(LOCAL_INT_BTN_2));
- set_csr(mie, MIP_MLIP(LOCAL_INT_BTN_3));
- // highest priority
-
-}
-
-void disable_local_interrupts() {
-
- // lowest priority
- clear_csr(mie, MIP_MLIP(LOCAL_INT_SW_3 ));
- clear_csr(mie, MIP_MLIP(LOCAL_INT_BTN_0));
- clear_csr(mie, MIP_MLIP(LOCAL_INT_BTN_1));
- clear_csr(mie, MIP_MLIP(LOCAL_INT_BTN_2));
- clear_csr(mie, MIP_MLIP(LOCAL_INT_BTN_3));
- // highest priority
-
-}
-
-/*Entry Point for Machine Software Interrupt Handler*/
-void msi_isr() {
-
- const char msi_msg[] = " Debouncing: (this message due to Software Interrupt))\n\n";
- write (STDOUT_FILENO, msi_msg, strlen(msi_msg));
-
- //clear the SW interrupt
- CLINT_REG(CLINT_MSIP) = 0;
-
-}
-
-/*Entry Point for Machine Timer Interrupt Handler*/
-void mti_isr(){
-
- // Disable the timer interrupt. The Debounce logic sets it.
- clear_csr(mie, MIP_MTIP);
-
- // Enable all the local interrupts
- enable_local_interrupts();
-}
-
-
-const char * instructions_msg = " \
-\n\
- SiFive, Inc\n\
- E31/E51 Coreplex IP Eval Kit 'local_interrupts' demo.\n\
-\n\
-The Buttons 0-3 and Switch 3 are enabled as local\n\
-interrupts sources. A .5 s 'debounce' timer is used \n\
-between these interrupts. Software interrupts are\n\
-used to print a message while debouncing.\n\
-Note the priority of the interrupts sources.\n\
-\n";
-
-void print_instructions() {
-
- write (STDERR_FILENO, instructions_msg, strlen(instructions_msg));
-
-}
-
-void button_0_isr(void) {
-
- // Toggle Red LED
- const char button_0_msg[] = "Button 0 was pressed. Toggle Red.\n";
- write (STDOUT_FILENO, button_0_msg, strlen(button_0_msg));
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << RED_LED_OFFSET);
- debounce();
-};
-
-void button_1_isr(void) {
-
- // Toggle Green LED
- const char button_1_msg[] = "Button 1 was pressed. Toggle Green.\n";
- write (STDOUT_FILENO, button_1_msg, strlen(button_1_msg));
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << GREEN_LED_OFFSET);
- debounce();
-};
-
-
-void button_2_isr(void) {
-
- // Toggle Blue LED
- const char button_2_msg[] = "Button 2 was pressed. Toggle Blue.\n";
- write (STDOUT_FILENO, button_2_msg, strlen(button_2_msg));
- GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << BLUE_LED_OFFSET);
- debounce();
-
-};
-
-void button_3_isr(void) {
- const char button_3_msg[] = "Button 3 was pressed! (No LEDs change).\n";
- write (STDOUT_FILENO, button_3_msg, strlen(button_3_msg));
- debounce();
-}
-
-void switch_3_isr(void) {
- const char sw_3_msg[] = "Switch 3 is on! But buttons have higher priority.\n";
- write (STDOUT_FILENO, sw_3_msg, strlen(sw_3_msg));
- debounce();
-}
-
-void debounce(int local_interrupt_num) {
-
- // Disable the most recent interrupt.
- // Don't enable it again until the timer goes off,
- // in .5 second.
-
- // Set the machine timer to go off in .5 seconds.
- // If the timer was already set to go off, this "cancels"
- // the current one.
-
- volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
- volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
- uint64_t now = *mtime;
- uint64_t then = now + .5*RTC_FREQ;
- *mtimecmp = then;
-
- disable_local_interrupts();
- g_debouncing = 1;
-
- // Enable the Machine-Timer bit in MIE
- set_csr(mie, MIP_MTIP);
-
-}
-
-// See bsp/env/<BOARD>/init.c for how this
-// interrupt vector is used.
-
-interrupt_function_ptr_t localISR[32];
-
-int main(int argc, char **argv)
-{
-
- // Configure LEDs as outputs.
- GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
- GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << BLUE_LED_OFFSET) ;
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET)) ;
-
- // The Buttons and Switches which are used as local interrupt sources
- // do not go through the GPIO peripheral, so they do not need to
- // be configured as inputs.
-
- // Disable the timer & local interrupts until setup is done (they're
- // not reset by default)
-
- // Disable all interrupts. MIE is not reset.
- write_csr(mie, 0);
-
- for (int isr = 0; isr < 32; isr++){
- localISR[isr] = 0;
- }
-
- localISR[IRQ_M_SOFT] = msi_isr;
- localISR[IRQ_M_TIMER] = mti_isr;
- localISR[IRQ_M_LOCAL + LOCAL_INT_SW_3] = switch_3_isr;
- localISR[IRQ_M_LOCAL + LOCAL_INT_BTN_0] = button_0_isr;
- localISR[IRQ_M_LOCAL + LOCAL_INT_BTN_1] = button_1_isr;
- localISR[IRQ_M_LOCAL + LOCAL_INT_BTN_2] = button_2_isr;
- localISR[IRQ_M_LOCAL + LOCAL_INT_BTN_3] = button_3_isr;
-
- print_instructions();
-
- enable_local_interrupts();
-
- g_debouncing = 0;
-
- // Enable SW interrupts as well in this demo.
- set_csr(mie, MIP_MSIP);
-
- // Enable all global interrupts
- set_csr(mstatus, MSTATUS_MIE);
-
- volatile int foo = 1;
- while(foo){
- if (g_debouncing){
- //Trigger a SW interrupt
- CLINT_REG(CLINT_MSIP) = 1;
- g_debouncing = 0;
- }
- }
-
- return 0;
-
-}
diff --git a/software/performance_counters/Makefile b/software/performance_counters/Makefile
deleted file mode 100644
index eb3e8f1..0000000
--- a/software/performance_counters/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-TARGET = performance_counters
-C_SRCS += performance_counters.c
-CFLAGS += -O2 -fno-builtin-printf
-
-BSP_BASE = ../../bsp
-include $(BSP_BASE)/env/common.mk
diff --git a/software/performance_counters/performance_counters.c b/software/performance_counters/performance_counters.c
deleted file mode 100644
index 8094128..0000000
--- a/software/performance_counters/performance_counters.c
+++ /dev/null
@@ -1,133 +0,0 @@
-// See LICENSE for license details.
-
-// This demo shows how to use basic
-// RISC-V profiling counters, mcycle
-// (counts the number of processor cycles)
-// and minstret (counts the number of retired instructions).
-// Note that both are writable as well.
-
-#include <stdio.h>
-
-// The CSR encodings are in this header.
-#include "encoding.h"
-
-// The mcycle counter is 64-bit counter, but since
-// Freedom E platforms use RV32, we must access it as
-// 2 32-bit registers. At 256MHz, the lower bits will
-// roll over approx. every 5 seconds, so we check for
-// rollover with this routine as suggested by the
-// RISC-V Priviledged Architecture Specification.
-
-#if __riscv_xlen == 64
-#define rdmcycle(x) { \
- uint64_t hi; \
- __asm__ __volatile__ ("1:\n\t" \
- "csrr %0, mcycle\n\t" \
- : "=r" (hi)) ; \
- *(x) = hi; \
- }
-#else
-#define rdmcycle(x) { \
- uint32_t lo, hi, hi2; \
- __asm__ __volatile__ ("1:\n\t" \
- "csrr %0, mcycleh\n\t" \
- "csrr %1, mcycle\n\t" \
- "csrr %2, mcycleh\n\t" \
- "bne %0, %2, 1b\n\t" \
- : "=r" (hi), "=r" (lo), "=r" (hi2)) ; \
- *(x) = lo | ((uint64_t) hi << 32); \
- }
-#endif
-
-
-// The minstret counter is 64-bit counter, but
-// Freedom E platforms use RV32, we must access it as
-// 2 32-bit registers, same as for mcycle.
-
-#if __riscv_xlen == 64
-#define rdminstret(x) { \
- uint64_t hi; \
- __asm__ __volatile__ ("1:\n\t" \
- "csrr %0, minstret\n\t" \
- : "=r" (hi)) ; \
- *(x) = hi; \
- }
-#else
-#define rdminstret(x) { \
- uint32_t lo, hi, hi2; \
- __asm__ __volatile__ ("1:\n\t" \
- "csrr %0, minstreth\n\t" \
- "csrr %1, minstret\n\t" \
- "csrr %2, minstreth\n\t" \
- "bne %0, %2, 1b\n\t" \
- : "=r" (hi), "=r" (lo), "=r" (hi2)) ; \
- *(x) = lo | ((uint64_t) hi << 32); \
- }
-#endif
-
-// Simple program to measure the performance of.
-
-int factorial(int i){
-
- int result = 1;
- for (int ii = 1; ii <= i; ii++) {
- result = result * i;
- }
-
- return result;
-
-}
-
-
-int main()
-{
-
- uint64_t before_cycle;
- uint64_t before_instret;
-
- uint64_t after_cycle;
- uint64_t after_instret;
-
- printf("\n\nDemo 1: Using Counter Differences.\n");
-
- for (int ii = 0; ii < 3; ii++){
- rdmcycle(&before_cycle);
- rdminstret(&before_instret);
-
- volatile int result = factorial (100);
-
- rdmcycle(&after_cycle);
- rdminstret(&after_instret);
-
- printf("Loop %d: Retired %d instructions in %d cycles\n",
- ii,
- (uint32_t)(after_instret - before_instret),
- (uint32_t)(after_cycle - before_cycle));
- }
-
- printf("\n\nDemo 2: Clearing Counters, Using Values Directly.\n");
-
- for (int ii = 0; ii < 3; ii++){
-
- write_csr(mcycle, 0);
- write_csr(minstret, 0);
-#if __riscv_xlen == 32
- write_csr(mcycleh, 0);
- write_csr(minstreth, 0);
-#endif
-
- volatile int result = factorial (100);
-
- rdmcycle(&after_cycle);
- rdminstret(&after_instret);
-
- printf("Loop %d: Retired %d instructions in %d cycles\n",
- ii,
- (uint32_t)(after_instret),
- (uint32_t)(after_cycle));
-
- }
-
- return 0;
-
-}
diff --git a/software/smp/Makefile b/software/smp/Makefile
deleted file mode 100644
index 4131ffc..0000000
--- a/software/smp/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-TARGET = smp
-C_SRCS += smp.c
-CFLAGS += -O2 -fno-builtin-printf -DENABLE_SMP
-
-BSP_BASE = ../../bsp
-include $(BSP_BASE)/env/common.mk
diff --git a/software/smp/atomic.h b/software/smp/atomic.h
deleted file mode 100644
index 074c6a2..0000000
--- a/software/smp/atomic.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SIFIVE_ATOMIC_H
-#define SIFIVE_ATOMIC_H
-
-#define ATOMIC_INIT(x) \
- { \
- .counter = (x), \
- }
-
-typedef struct {
- int counter;
-} atomic_t;
-
-static inline int atomic_xchg(atomic_t *v, int n)
-{
- register int c;
-
- __asm__ __volatile__ (
- "amoswap.w.aqrl %0, %2, %1"
- : "=r" (c), "+A" (v->counter)
- : "r" (n));
- return c;
-}
-
-static inline void mb(void)
-{
- __asm__ __volatile__ ("fence");
-}
-
-#endif
diff --git a/software/smp/smp.c b/software/smp/smp.c
deleted file mode 100644
index 36c9db9..0000000
--- a/software/smp/smp.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include "atomic.h"
-void write_hex(int, unsigned long);
-
-atomic_t tty_lock = ATOMIC_INIT(0);
-
-void get_lock(atomic_t *lock)
-{
- while (atomic_xchg(lock, 1) == 1);
- mb();
-}
-
-void put_lock(atomic_t *lock)
-{
- mb();
- atomic_xchg(lock, 0);
-}
-
-int secondary_main(int hartid)
-{
- volatile int counter;
-
- while (1) {
- get_lock(&tty_lock);
- write(1, "hello world from hart ", 22);
- char s[] = {'0', '\n', '\0'};
- s[0] += hartid;
- write(1, s, 2);
- put_lock(&tty_lock);
-
- for (counter = 0; counter < 10000 + 100*hartid; ++counter)
- mb();
- }
-}
-
-int main()
-{
- return secondary_main(0);
-}
diff --git a/software/vectored_interrupts/Makefile b/software/vectored_interrupts/Makefile
deleted file mode 100644
index 4365038..0000000
--- a/software/vectored_interrupts/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-TARGET = vectored_interrupts
-CFLAGS += -O2 -fno-builtin-printf -DVECT_IRQ
-
-BSP_BASE = ../../bsp
-
-ASM_SRCS += $(ENV_DIR)/ventry.S
-C_SRCS += vectored_interrupts.c
-C_SRCS += $(BSP_BASE)/drivers/plic/plic_driver.c
-
-include $(BSP_BASE)/env/common.mk
diff --git a/software/vectored_interrupts/vectored_interrupts.c b/software/vectored_interrupts/vectored_interrupts.c
deleted file mode 100644
index cb6a864..0000000
--- a/software/vectored_interrupts/vectored_interrupts.c
+++ /dev/null
@@ -1,270 +0,0 @@
-// See LICENSE for license details.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "platform.h"
-#include <string.h>
-#include "plic/plic_driver.h"
-#include "encoding.h"
-#include <unistd.h>
-
-#ifndef _SIFIVE_COREPLEXIP_ARTY_H
-#error 'global_interrupts' demo only supported for Coreplex IP Eval Kits
-#endif
-
-// Global Instance data for the PLIC
-// for use by the PLIC Driver.
-plic_instance_t g_plic;
-
-// Structures for registering different interrupt handlers
-// for different parts of the application.
-typedef void (*interrupt_function_ptr_t) (void);
-//array of function pointers which contains the PLIC
-//interrupt handlers
-interrupt_function_ptr_t g_ext_interrupt_handlers[PLIC_NUM_INTERRUPTS];
-
-//ecall countdown
-uint32_t ecall_countdown;
-//ecall macro used to store argument in a0
-#define ECALL(arg) ({ \
- register uintptr_t a0 asm ("a0") = (uintptr_t)(arg); \
- asm volatile ("ecall" \
- : "+r" (a0) \
- : \
- : "memory"); \
- a0; \
-})
-
-
-const char * instructions_msg = " \
-\n\
- SIFIVE, INC.\n\
-E31/E51 Coreplex IP Eval Kit 'vectored_interrupts' demo. \n\
-\n\
-This demo demonstrates Vectored Interrupts capabilities of\n\
-the E31/E51 Coreplex. The vector table is defined in \n\
-bsp/env/ventry.S \n\
-Button 0 is a global external interrupt routed to the PLIC.\n\
-Button 1 is a local interrupt.\n\
-Every 10 seconds, an ECALL is made. \n\
-\n";
-
-void print_instructions() {
-
- write (STDOUT_FILENO, instructions_msg, strlen(instructions_msg));
-
-}
-
-void set_timer() {
- static uint64_t then = 0;
-
- volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
- volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
- if(then != 0) {
- //next timer irq is 1 second from previous
- then += 1*RTC_FREQ;
- } else{ //first time setting the timer
- uint64_t now = *mtime;
- then = now + 1*RTC_FREQ;
- }
- *mtimecmp = then;
-
- set_csr(mie, MIP_MTIP);
-}
-
-/*Entry Point for Machine Timer Interrupt Handler*/
-/*called from bsp/env/ventry.s */
-void handle_m_time_interrupt(){
- static uint32_t onoff=1;
-
- clear_csr(mie, MIP_MTIP);
-
- //increment ecall_countdown
- ecall_countdown++;
-
- // Set Green LED
- if(onoff) {
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << GREEN_LED_OFFSET) ;
- onoff=0;
- }else {
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1 << GREEN_LED_OFFSET)) ;
- onoff=1;
- }
-
- set_timer();
- //re-enable button1 irq
- set_csr(mie, MIP_MLIP(LOCAL_INT_BTN_1));
-
-}
-
-/*Synchronous Trap Handler*/
-/*called from bsp/env/ventry.s */
-void handle_sync_trap(uint32_t arg0) {
- uint32_t exception_code = read_csr(mcause);
-
- //check for machine mode ecall
- if(exception_code == CAUSE_MACHINE_ECALL) {
- //reset ecall_countdown
- ecall_countdown = 0;
-
- //ecall argument is stored in a0 prior to
- //ECALL instruction.
- printf("ecall from M-mode: %d\n",arg0);
-
- //on exceptions, mepc points to the instruction
- //which triggered the exception, in order to
- //return to the next instruction, increment
- //mepc
- unsigned long epc = read_csr(mepc);
- epc += 4; //return to next instruction
- write_csr(mepc, epc);
-
- } else{
- printf("vUnhandled Trap:\n");
- _exit(1 + read_csr(mcause));
- }
-}
-
-/*Entry Point for PLIC Interrupt Handler*/
-/*called from bsp/env/ventry.s */
-void handle_m_external_interrupt(){
- printf("In PLIC handler\n");
- plic_source int_num = PLIC_claim_interrupt(&g_plic);
- if ((int_num >=1 ) && (int_num < PLIC_NUM_INTERRUPTS)) {
- g_ext_interrupt_handlers[int_num]();
- }
- else {
- exit(1 + (uintptr_t) int_num);
- }
- PLIC_complete_interrupt(&g_plic, int_num);
-}
-
-//default empty PLIC handler
-void invalid_global_isr() {
- printf("Unexpected global interrupt!\n");
-}
-
-/* b0 global interrupt isr */
-/*called from handle_m_external_interrupt */
-void button_0_handler() {
- static uint32_t onoff=1;
- // Set Green LED
-
- printf("In Button 0 handler\n");
-
- if(onoff) {
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << BLUE_LED_OFFSET) ;
- onoff=0;
- }else {
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1 << BLUE_LED_OFFSET)) ;
- onoff=1;
- }
-
- //clear irq - interrupt pending register is write 1 to clear
- GPIO_REG(GPIO_FALL_IP) |= (1<<BUTTON_0_OFFSET);
-}
-
-/*b1 local vectored irq handler */
-/*called from bsp/env/ventry.s */
-void handle_local_interrupt5() {
- static uint32_t onoff=1;
- // Set Green LED
-
- printf("In Button 1 handler\n");
-
- if(onoff) {
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << RED_LED_OFFSET) ;
- onoff=0;
- }else {
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1 << RED_LED_OFFSET)) ;
- onoff=1;
- }
-
- //debounce by turning off until next timer tick
- clear_csr(mie, MIP_MLIP(LOCAL_INT_BTN_1));
-}
-
-/*configures Button0 as a global gpio irq*/
-void b0_irq_init() {
-
- //dissable hw io function
- GPIO_REG(GPIO_IOF_EN ) &= ~(1 << BUTTON_0_OFFSET);
-
- //set to input
- GPIO_REG(GPIO_INPUT_EN) |= (1<<BUTTON_0_OFFSET);
- GPIO_REG(GPIO_PULLUP_EN) |= (1<<BUTTON_0_OFFSET);
-
- //set to interrupt on falling edge
- GPIO_REG(GPIO_FALL_IE) |= (1<<BUTTON_0_OFFSET);
-
- PLIC_init(&g_plic,
- PLIC_CTRL_ADDR,
- PLIC_NUM_INTERRUPTS,
- PLIC_NUM_PRIORITIES);
-
- PLIC_enable_interrupt (&g_plic, INT_DEVICE_BUTTON_0);
- PLIC_set_priority(&g_plic, INT_DEVICE_BUTTON_0, 2);
- g_ext_interrupt_handlers[INT_DEVICE_BUTTON_0] = button_0_handler;
-}
-
-/*configures Button1 as a local interrupt*/
-void b1_irq_init() {
-
- //enable the interrupt
- set_csr(mie, MIP_MLIP(LOCAL_INT_BTN_1));
-
-}
-
-/*turn down the brightness, and configure GPIO */
-void led_init() {
- // Make sure people aren't blinded by LEDs connected here.
- PWM0_REG(PWM_CMP0) = 0xFE;
- PWM0_REG(PWM_CMP1) = 0xFF;
- PWM0_REG(PWM_CMP2) = 0xFF;
- PWM0_REG(PWM_CMP3) = 0xFF;
- // Set up RGB LEDs for a visual.
- GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET)| (0x1<< BLUE_LED_OFFSET));
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1<< BLUE_LED_OFFSET));
-
-}
-
-int main(int argc, char **argv)
-{
- uint32_t ecall_count = 0;
-
- //setup default global interrupt handler
- for (int gisr = 0; gisr < PLIC_NUM_INTERRUPTS; gisr++){
- g_ext_interrupt_handlers[PLIC_NUM_INTERRUPTS] = invalid_global_isr;
- }
-
- print_instructions();
-
- led_init();
- b0_irq_init();
- b1_irq_init();
-
- //initialize ecall_countdown
- ecall_countdown = 0;
-
- // Set up machine timer interrupt.
- set_timer();
-
- // Enable Global (PLIC) interrupts.
- set_csr(mie, MIP_MEIP);
-
- // Enable all interrupts
- set_csr(mstatus, MSTATUS_MIE);
-
-
- while(1){
- asm volatile ("wfi");
- //check if ecall_countdown is 10
- if(ecall_countdown == 10) {
- ECALL(ecall_count++);
- }
- //otherwise wfi
- }
-
- return 0;
-
-}
diff --git a/software/watchdog/.gitignore b/software/watchdog/.gitignore
deleted file mode 100644
index 35566c7..0000000
--- a/software/watchdog/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-demo_gpio
diff --git a/software/watchdog/.unsupported-boards b/software/watchdog/.unsupported-boards
deleted file mode 100644
index 1e65df5..0000000
--- a/software/watchdog/.unsupported-boards
+++ /dev/null
@@ -1 +0,0 @@
-coreplexip-e51-arty
diff --git a/software/watchdog/Makefile b/software/watchdog/Makefile
deleted file mode 100644
index f614a4e..0000000
--- a/software/watchdog/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = watchdog
-CFLAGS += -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME
-
-BSP_BASE = ../../bsp
-
-C_SRCS += watchdog.c
-C_SRCS += $(BSP_BASE)/drivers/plic/plic_driver.c
-
-include $(BSP_BASE)/env/common.mk
diff --git a/software/watchdog/watchdog.c b/software/watchdog/watchdog.c
deleted file mode 100644
index 672ed68..0000000
--- a/software/watchdog/watchdog.c
+++ /dev/null
@@ -1,221 +0,0 @@
-// See LICENSE for license details.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "platform.h"
-#include <string.h>
-#include "plic/plic_driver.h"
-#include "encoding.h"
-#include <unistd.h>
-#include "stdatomic.h"
-
-void reset_demo (void);
-
-// Structures for registering different interrupt handlers
-// for different parts of the application.
-typedef void (*function_ptr_t) (void);
-void no_interrupt_handler (void) {};
-function_ptr_t g_ext_interrupt_handlers[PLIC_NUM_INTERRUPTS];
-
-
-// Instance data for the PLIC.
-plic_instance_t g_plic;
-
-
-/**
-* use mtime to wait for a specified number of ticks.
-* async determins if this is a busy wait, or if
-* an irq is scheduled
-*/
-void mtime_wait( uint64_t ticks, uint32_t async)
-{
-
- volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
- uint64_t now = *mtime;
-
- //if async, schedule irq
- if(async) {
- volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
- uint64_t then = now + ticks;
- *mtimecmp = then;
- set_csr(mie, MIP_MTIP);
-
- } else {
- //else busy wait
- uint64_t then = now + ticks;
- while(*mtime<then) {}
-
- }
-
-}
-
-/*Entry Point for PLIC Interrupt Handler*/
-void handle_m_ext_interrupt(){
- plic_source int_num = PLIC_claim_interrupt(&g_plic);
- if ((int_num >=1 ) && (int_num < PLIC_NUM_INTERRUPTS)) {
- g_ext_interrupt_handlers[int_num]();
- }
- else {
- exit(1 + (uintptr_t) int_num);
- }
- PLIC_complete_interrupt(&g_plic, int_num);
-}
-
-//global countdown timer
-static uint32_t countdown = 10;
-/*Entry Point for Machine Timer Interrupt Handler*/
-void handle_m_time_interrupt(){
-
- //cleare the timer irq
- clear_csr(mie, MIP_MTIP);
-
- //schedule next timer irq for 1 second
- mtime_wait(1*RTC_FREQ, 1);
-
- //flash a led
- GPIO_REG(GPIO_OUTPUT_VAL) ^= (0x1 << BLUE_LED_OFFSET);
-
- //print the count
- printf("watchdog reset in %d\n", countdown--);
-}
-
-
-const char * instructions_msg = " \
-\n\
- SIFIVE, INC.\n\
-\n\
- 5555555555555555555555555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555555555555555555555\n\
- 5555 555555555555555555555555\n\
- 5555 5555\n\
- 5555 5555\n\
- 5555 5555\n\
-5555555555555555555555555555 55555\n\
- 55555 555555555 55555\n\
- 55555 55555 55555\n\
- 55555 5 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 55555 55555\n\
- 555555555\n\
- 55555\n\
- 5\n\
-\n\
-This application demonstrates the functionality of\n\
-the watchdog timer present in the HiFive1 AON peripheral.\n\
-\n\
-The Watchdog timer will expire in 10 seconds resulting in\n\
-a software reset.\n\
-\n\
-Press a key to prevent a reset\n\
-";
-
-void print_instructions() {
-
- write (STDOUT_FILENO, instructions_msg, strlen(instructions_msg));
-
-}
-
-
-/**
-* Flash the red led for a second, then set up
-* blue for blinking during mtime irq
-*/
-void led_init() {
-
-
- // Set up the GPIOs such that the LED GPIO
- // can be used as both Inputs and Outputs.
- GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
- GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET)| (0x1<< BLUE_LED_OFFSET));
- GPIO_REG(GPIO_OUTPUT_VAL) |= ((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1<< BLUE_LED_OFFSET));
-
- //flash red led to indicate reset
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << RED_LED_OFFSET) ;
- mtime_wait(1*RTC_FREQ,0);
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << RED_LED_OFFSET) ;
-}
-
-/**
-* initialize the watchdog to reset in
-* 5 seconds
-**/
-void watchdog_init() {
-
-
-//reset in 10 seconds
-AON_REG(AON_WDOGKEY) = AON_WDOGKEY_VALUE;
-AON_REG(AON_WDOGCMP) = 11;
-//wdogconfig: : wdogrsten | enablealways | reset to 0 | max scale
-AON_REG(AON_WDOGKEY) = AON_WDOGKEY_VALUE;
-AON_REG(AON_WDOGCFG) |= (AON_WDOGCFG_RSTEN | AON_WDOGCFG_ENALWAYS |\
- AON_WDOGCFG_ZEROCMP | AON_WDOGCFG_SCALE) ;
-
-}
-
-void reset_demo () {
-
- // Disable the machine & timer interrupts until setup is done.
- clear_csr(mie, MIP_MEIP);
- clear_csr(mie, MIP_MTIP);
-
- //enable uart input
- UART0_REG(UART_REG_RXCTRL) = UART_RXEN;
-
- /**************************************************************************
- * Set up the PLIC
- *************************************************************************/
- PLIC_init(&g_plic,
- PLIC_CTRL_ADDR,
- PLIC_NUM_INTERRUPTS,
- PLIC_NUM_PRIORITIES);
-
- for (int ii = 0; ii < PLIC_NUM_INTERRUPTS; ii ++){
- g_ext_interrupt_handlers[ii] = no_interrupt_handler;
- }
-
-
- led_init();
- print_instructions();
- watchdog_init();
-
- // Enable the Machine-External bit in MIE
- set_csr(mie, MIP_MEIP);
- // Enable interrupts in general.
- set_csr(mstatus, MSTATUS_MIE);
-}
-
-int main(int argc, char **argv)
-{
-
- reset_demo();
- //schedule a 1 second timer
- mtime_wait(1*RTC_FREQ,1);
-
-
- while (1){
- char c;
- if(((int32_t) UART0_REG(UART_REG_RXFIFO)) > 0){
- //flash green led to indicate Kick
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~(0x1 << GREEN_LED_OFFSET) ;
-
- printf("Feeding Watchdog.\nHiFive1 will reset in 10 seconds.\n");
- countdown = 10;
- AON_REG(AON_WDOGKEY) = AON_WDOGKEY_VALUE;
- AON_REG(AON_WDOGFEED) = AON_WDOGFEED_VALUE;
-
- //busy wait a bit so the user sees the led blink
- mtime_wait(5000, 0);
- //turn off led
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << GREEN_LED_OFFSET) ;
- }
- }
-
- return 0;
-
-}