1 |
13 |
serginhofr |
/* file: hf_risc.h
|
2 |
|
|
* description: basic C type abstraction and HAL for HF-RISC
|
3 |
|
|
* date: 09/2015
|
4 |
|
|
* author: Sergio Johann Filho <sergio.filho@pucrs.br>
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/* C type extensions */
|
8 |
|
|
typedef unsigned char uint8_t;
|
9 |
|
|
typedef char int8_t;
|
10 |
|
|
typedef unsigned short int uint16_t;
|
11 |
|
|
typedef short int int16_t;
|
12 |
|
|
typedef unsigned int uint32_t;
|
13 |
|
|
typedef int int32_t;
|
14 |
|
|
typedef unsigned long long uint64_t;
|
15 |
|
|
typedef long long int64_t;
|
16 |
|
|
|
17 |
|
|
typedef void (*funcptr)();
|
18 |
|
|
|
19 |
|
|
/* disable interrupts, return previous int status / enable interrupts */
|
20 |
|
|
#define _di interrupt_set(0)
|
21 |
|
|
#define _ei(S) interrupt_set(S)
|
22 |
|
|
|
23 |
|
|
/* memory address map */
|
24 |
|
|
#define ADDR_ROM_BASE 0x00000000
|
25 |
|
|
#define ADDR_RAM_BASE 0x40000000
|
26 |
|
|
#define ADDR_RESERVED_BASE 0x80000000
|
27 |
|
|
|
28 |
|
|
/* peripheral addresses and irq lines */
|
29 |
|
|
#define PERIPHERALS_BASE 0xf0000000
|
30 |
|
|
#define IRQ_VECTOR (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x000))
|
31 |
|
|
#define IRQ_CAUSE (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x010))
|
32 |
|
|
#define IRQ_MASK (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x020))
|
33 |
|
|
#define IRQ_STATUS (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x030))
|
34 |
|
|
#define IRQ_EPC (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x040))
|
35 |
|
|
#define COUNTER (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x050))
|
36 |
|
|
#define COMPARE (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x060))
|
37 |
|
|
#define COMPARE2 (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x070))
|
38 |
|
|
#define EXTIO_IN (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x080))
|
39 |
|
|
#define EXTIO_OUT (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x090))
|
40 |
|
|
#define EXTIO_DIR (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x0a0))
|
41 |
|
|
#define DEBUG_ADDR (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x0d0))
|
42 |
|
|
#define UART (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x0e0))
|
43 |
|
|
#define UART_DIVISOR (*(volatile uint32_t *)(PERIPHERALS_BASE + 0x0f0))
|
44 |
|
|
|
45 |
|
|
#define IRQ_COUNTER 0x0001
|
46 |
|
|
#define IRQ_COUNTER_NOT 0x0002
|
47 |
|
|
#define IRQ_COUNTER2 0x0004
|
48 |
|
|
#define IRQ_COUNTER2_NOT 0x0008
|
49 |
|
|
#define IRQ_COMPARE 0x0010
|
50 |
|
|
#define IRQ_COMPARE2 0x0020
|
51 |
|
|
#define IRQ_UART_READ_AVAILABLE 0x0040
|
52 |
|
|
#define IRQ_UART_WRITE_AVAILABLE 0x0080
|
53 |
|
|
|
54 |
|
|
#define EXT_IRQ0 0x0100
|
55 |
|
|
#define EXT_IRQ1 0x0200
|
56 |
|
|
#define EXT_IRQ2 0x0400
|
57 |
|
|
#define EXT_IRQ3 0x0800
|
58 |
|
|
#define EXT_IRQ4 0x1000
|
59 |
|
|
#define EXT_IRQ5 0x2000
|
60 |
|
|
#define EXT_IRQ6 0x4000
|
61 |
|
|
#define EXT_IRQ7 0x8000
|
62 |
|
|
|
63 |
|
|
#define PERIPHERALS_BASE_EXT 0xf8000000
|
64 |
|
|
#define XTEA_BASE 0xfa000000
|
65 |
|
|
#define XTEA_CONTROL (*(volatile uint32_t *)(XTEA_BASE + 0x000))
|
66 |
|
|
#define XTEA_KEY0 (*(volatile uint32_t *)(XTEA_BASE + 0x010))
|
67 |
|
|
#define XTEA_KEY1 (*(volatile uint32_t *)(XTEA_BASE + 0x020))
|
68 |
|
|
#define XTEA_KEY2 (*(volatile uint32_t *)(XTEA_BASE + 0x030))
|
69 |
|
|
#define XTEA_KEY3 (*(volatile uint32_t *)(XTEA_BASE + 0x040))
|
70 |
|
|
#define XTEA_IN0 (*(volatile uint32_t *)(XTEA_BASE + 0x050))
|
71 |
|
|
#define XTEA_IN1 (*(volatile uint32_t *)(XTEA_BASE + 0x060))
|
72 |
|
|
#define XTEA_OUT0 (*(volatile uint32_t *)(XTEA_BASE + 0x070))
|
73 |
|
|
#define XTEA_OUT1 (*(volatile uint32_t *)(XTEA_BASE + 0x080))
|
74 |
|
|
|
75 |
|
|
#include <libc.h>
|