rthw.h 3.0 KB
Newer Older
1
/*
2
 * Copyright (c) 2006-2018, RT-Thread Development Team
B
Bernard Xiong 已提交
3
 *
4
 * SPDX-License-Identifier: Apache-2.0
5 6 7 8 9 10
 *
 * Change Logs:
 * Date           Author       Notes
 * 2006-03-18     Bernard      the first version
 * 2006-04-25     Bernard      add rt_hw_context_switch_interrupt declaration
 * 2006-09-24     Bernard      add rt_hw_context_switch_to declaration
11
 * 2012-12-29     Bernard      add rt_hw_exception_install declaration
H
hichard 已提交
12
 * 2017-10-17     Hichard      add some micros
13 14 15 16 17 18 19 20 21 22 23
 */

#ifndef __RT_HW_H__
#define __RT_HW_H__

#include <rtthread.h>

#ifdef __cplusplus
extern "C" {
#endif

H
hichard 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36
/*
 * Some macros define
 */
#ifndef HWREG32
#define HWREG32(x)          (*((volatile rt_uint32_t *)(x)))
#endif
#ifndef HWREG16
#define HWREG16(x)          (*((volatile rt_uint16_t *)(x)))
#endif
#ifndef HWREG8
#define HWREG8(x)           (*((volatile rt_uint8_t *)(x)))
#endif

T
tanek liang 已提交
37 38 39 40 41 42 43 44 45 46
#ifndef RT_CPU_CACHE_LINE_SZ
#define RT_CPU_CACHE_LINE_SZ	32
#endif

enum RT_HW_CACHE_OPS
{
    RT_HW_CACHE_FLUSH      = 0x01,
    RT_HW_CACHE_INVALIDATE = 0x02,
};

47 48 49
/*
 * CPU interfaces
 */
50 51 52
void rt_hw_cpu_icache_enable(void);
void rt_hw_cpu_icache_disable(void);
rt_base_t rt_hw_cpu_icache_status(void);
T
tanek liang 已提交
53 54
void rt_hw_cpu_icache_ops(int ops, void* addr, int size);

55 56 57
void rt_hw_cpu_dcache_enable(void);
void rt_hw_cpu_dcache_disable(void);
rt_base_t rt_hw_cpu_dcache_status(void);
T
tanek liang 已提交
58 59
void rt_hw_cpu_dcache_ops(int ops, void* addr, int size);

60 61 62
void rt_hw_cpu_reset(void);
void rt_hw_cpu_shutdown(void);

63 64 65 66
rt_uint8_t *rt_hw_stack_init(void       *entry,
                             void       *parameter,
                             rt_uint8_t *stack_addr,
                             void       *exit);
67

68 69 70 71 72
/*
 * Interrupt handler definition
 */
typedef void (*rt_isr_handler_t)(int vector, void *param);

Y
yiyue.fang 已提交
73 74 75 76
struct rt_irq_desc
{
    rt_isr_handler_t handler;
    void            *param;
77 78

#ifdef RT_USING_INTERRUPT_INFO
Y
yiyue.fang 已提交
79 80
    char             name[RT_NAME_MAX];
    rt_uint32_t      counter;
81 82 83 84 85 86
#endif
};

/*
 * Interrupt interfaces
 */
87 88 89
void rt_hw_interrupt_init(void);
void rt_hw_interrupt_mask(int vector);
void rt_hw_interrupt_umask(int vector);
Y
yiyue.fang 已提交
90 91 92 93
rt_isr_handler_t rt_hw_interrupt_install(int              vector,
                                         rt_isr_handler_t handler,
                                         void            *param,
                                         char            *name);
94 95 96

rt_base_t rt_hw_interrupt_disable(void);
void rt_hw_interrupt_enable(rt_base_t level);
97 98 99 100

/*
 * Context interfaces
 */
101 102 103 104
void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to);
void rt_hw_context_switch_to(rt_uint32_t to);
void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to);

D
dzzxzz 已提交
105
void rt_hw_console_output(const char *str);
106 107 108 109

void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry);
void rt_hw_show_memory(rt_uint32_t addr, rt_uint32_t size);

110
/*
111
 * Exception interfaces
112
 */
Y
yiyue.fang 已提交
113
void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context));
114

H
hichard 已提交
115 116 117 118 119
/*
 * delay interfaces
 */
void rt_hw_us_delay(rt_uint32_t us);

120 121 122 123 124
#ifdef __cplusplus
}
#endif

#endif