rt-thread-official/include/rthw.h

125 lines
3.0 KiB
C
Raw Normal View History

/*
* Copyright (c) 2006-2018, RT-Thread Development Team
2013-06-24 17:06:09 +08:00
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
* 2012-12-29 Bernard add rt_hw_exception_install declaration
2017-10-18 09:08:21 +08:00
* 2017-10-17 Hichard add some micros
*/
#ifndef __RT_HW_H__
#define __RT_HW_H__
#include <rtthread.h>
#ifdef __cplusplus
extern "C" {
#endif
2017-10-18 09:08:21 +08:00
/*
* 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
2017-11-01 21:23:14 +08:00
#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,
};
2013-03-26 08:52:33 +08:00
/*
* CPU interfaces
*/
void rt_hw_cpu_icache_enable(void);
void rt_hw_cpu_icache_disable(void);
rt_base_t rt_hw_cpu_icache_status(void);
2017-11-01 21:23:14 +08:00
void rt_hw_cpu_icache_ops(int ops, void* addr, int size);
void rt_hw_cpu_dcache_enable(void);
void rt_hw_cpu_dcache_disable(void);
rt_base_t rt_hw_cpu_dcache_status(void);
2017-11-01 21:23:14 +08:00
void rt_hw_cpu_dcache_ops(int ops, void* addr, int size);
void rt_hw_cpu_reset(void);
void rt_hw_cpu_shutdown(void);
rt_uint8_t *rt_hw_stack_init(void *entry,
void *parameter,
rt_uint8_t *stack_addr,
void *exit);
2013-03-26 08:52:33 +08:00
/*
* Interrupt handler definition
*/
typedef void (*rt_isr_handler_t)(int vector, void *param);
2013-06-29 13:33:06 +08:00
struct rt_irq_desc
{
rt_isr_handler_t handler;
void *param;
2013-03-26 08:52:33 +08:00
#ifdef RT_USING_INTERRUPT_INFO
2013-06-29 13:33:06 +08:00
char name[RT_NAME_MAX];
rt_uint32_t counter;
2013-03-26 08:52:33 +08:00
#endif
};
/*
* Interrupt interfaces
*/
void rt_hw_interrupt_init(void);
void rt_hw_interrupt_mask(int vector);
void rt_hw_interrupt_umask(int vector);
2013-06-29 13:33:06 +08:00
rt_isr_handler_t rt_hw_interrupt_install(int vector,
rt_isr_handler_t handler,
void *param,
char *name);
rt_base_t rt_hw_interrupt_disable(void);
void rt_hw_interrupt_enable(rt_base_t level);
2013-03-26 08:52:33 +08:00
/*
* Context interfaces
*/
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);
void rt_hw_console_output(const char *str);
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);
/*
2013-03-26 08:52:33 +08:00
* Exception interfaces
*/
2013-06-29 13:33:06 +08:00
void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context));
2017-10-18 09:08:21 +08:00
/*
* delay interfaces
*/
void rt_hw_us_delay(rt_uint32_t us);
#ifdef __cplusplus
}
#endif
#endif