mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-05-15 11:07:34 +08:00
style: format code with clang-format [skip ci]
This commit is contained in:
@@ -33,9 +33,9 @@ enum rt_vdso_binary_id
|
||||
|
||||
struct rt_vdso_binary_info
|
||||
{
|
||||
const char *name;
|
||||
const char *image_start;
|
||||
const char *image_end;
|
||||
const char *name;
|
||||
const char *image_start;
|
||||
const char *image_end;
|
||||
unsigned long page_count;
|
||||
};
|
||||
|
||||
@@ -47,15 +47,16 @@ static struct rt_vdso_binary_info rt_vdso_binaries[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static union {
|
||||
static union
|
||||
{
|
||||
struct rt_vdso_data_page data_page;
|
||||
uint8_t raw[RT_VDSO_DATA_PAGE_COUNT * ARCH_PAGE_SIZE];
|
||||
uint8_t raw[RT_VDSO_DATA_PAGE_COUNT * ARCH_PAGE_SIZE];
|
||||
} rt_vdso_data_page_store RT_VDSO_DATA_PAGE_ALIGNED;
|
||||
struct rt_vdso_data_page *rt_vdso_kernel_data_page = &rt_vdso_data_page_store.data_page;
|
||||
static int rt_vdso_runtime_status = RT_EOK;
|
||||
|
||||
static struct timespec rt_vdso_realtime_offset;
|
||||
static rt_bool_t rt_vdso_realtime_offset_ready;
|
||||
static rt_bool_t rt_vdso_realtime_offset_ready;
|
||||
|
||||
#ifndef MMU_MAP_U_ROCB
|
||||
#define MMU_MAP_U_ROCB MMU_MAP_U_RWCB
|
||||
@@ -113,8 +114,8 @@ static struct timespec rt_vdso_add_timespec(const struct timespec *lhs,
|
||||
}
|
||||
|
||||
static int rt_vdso_read_monotonic_snapshot(struct timespec *monotonic_time,
|
||||
rt_uint64_t *counter_value,
|
||||
rt_uint64_t *counter_freq)
|
||||
rt_uint64_t *counter_value,
|
||||
rt_uint64_t *counter_freq)
|
||||
{
|
||||
*counter_value = rt_clock_time_get_counter();
|
||||
*counter_freq = rt_clock_time_get_freq();
|
||||
@@ -129,8 +130,8 @@ static int rt_vdso_read_monotonic_snapshot(struct timespec *monotonic_time,
|
||||
}
|
||||
|
||||
static void rt_vdso_store_clock_snapshot(const struct timespec *monotonic_time,
|
||||
rt_uint64_t counter_value,
|
||||
rt_uint64_t counter_freq)
|
||||
rt_uint64_t counter_value,
|
||||
rt_uint64_t counter_freq)
|
||||
{
|
||||
rt_vdso_kernel_data_page->counter_last = counter_value;
|
||||
rt_vdso_kernel_data_page->counter_freq = counter_freq;
|
||||
@@ -190,10 +191,10 @@ static void *rt_vdso_map_physical_pages(struct rt_lwp *lwp, void *user_va,
|
||||
|
||||
|
||||
static int rt_vdso_map_binary_pages(enum rt_vdso_binary_id binary_id,
|
||||
struct rt_lwp *lwp)
|
||||
struct rt_lwp *lwp)
|
||||
{
|
||||
void *data_page_base = RT_NULL;
|
||||
void *image_base = RT_NULL;
|
||||
void *data_page_base = RT_NULL;
|
||||
void *image_base = RT_NULL;
|
||||
unsigned long data_page_len;
|
||||
unsigned long image_len;
|
||||
|
||||
|
||||
+30
-30
@@ -37,27 +37,27 @@
|
||||
#endif
|
||||
#include <rtdbg.h>
|
||||
|
||||
#define ELF_INVALID_FD -1
|
||||
#define ELF_INVALID_FD -1
|
||||
#define ELF_PHDR_NUM_MAX 128
|
||||
#define FILE_LENGTH_MAX 0xC0000000
|
||||
#define MEM_SIZE_MAX 0xC0000000
|
||||
#define ELF_PATH_MAX 256
|
||||
#define FLF_PATH_MIN 1
|
||||
#define FILE_LENGTH_MAX 0xC0000000
|
||||
#define MEM_SIZE_MAX 0xC0000000
|
||||
#define ELF_PATH_MAX 256
|
||||
#define FLF_PATH_MIN 1
|
||||
|
||||
#define ELF_PAGESTART(_v) ((_v) & ~(rt_ubase_t)(ARCH_PAGE_SIZE - 1))
|
||||
#define ELF_PAGESTART(_v) ((_v) & ~(rt_ubase_t)(ARCH_PAGE_SIZE - 1))
|
||||
#define ELF_PAGEOFFSET(_v) ((_v) & (ARCH_PAGE_SIZE - 1))
|
||||
#define ELF_PAGEALIGN(_v) (((_v) + ARCH_PAGE_SIZE - 1) & ~(ARCH_PAGE_SIZE - 1))
|
||||
#define ELF_PAGEALIGN(_v) (((_v) + ARCH_PAGE_SIZE - 1) & ~(ARCH_PAGE_SIZE - 1))
|
||||
|
||||
#define ELF_EXEC_LOAD_ADDR USER_VADDR_START
|
||||
#define ELF_EXEC_LOAD_ADDR USER_VADDR_START
|
||||
#define ELF_INTERP_LOAD_ADDR LDSO_LOAD_VADDR
|
||||
|
||||
#define ELF_AUX_ENT(aux, id, val) \
|
||||
do \
|
||||
{ \
|
||||
rt_base_t a = id; \
|
||||
lwp_data_put(lwp, aux++, &a, sizeof(rt_ubase_t)); \
|
||||
a = val; \
|
||||
lwp_data_put(lwp, aux++, &a, sizeof(rt_ubase_t)); \
|
||||
#define ELF_AUX_ENT(aux, id, val) \
|
||||
do \
|
||||
{ \
|
||||
rt_base_t a = id; \
|
||||
lwp_data_put(lwp, aux++, &a, sizeof(rt_ubase_t)); \
|
||||
a = val; \
|
||||
lwp_data_put(lwp, aux++, &a, sizeof(rt_ubase_t)); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
@@ -127,10 +127,10 @@ static void elf_user_dump(struct rt_lwp *lwp, void *va, size_t len)
|
||||
|
||||
for (size_t i = 0; i < len; i += 16)
|
||||
{
|
||||
rt_kprintf(" %02x %02x %02x %02x %02x %02x %02x %02x ", k_va[i], k_va[i+1], k_va[i+2], k_va[i+3],
|
||||
k_va[i+4], k_va[i+5], k_va[i+6], k_va[i+7]);
|
||||
rt_kprintf(" %02x %02x %02x %02x %02x %02x %02x %02x \n", k_va[i+8], k_va[i+9], k_va[i+10], k_va[i+11],
|
||||
k_va[i+12], k_va[i+13], k_va[i+14], k_va[i+15]);
|
||||
rt_kprintf(" %02x %02x %02x %02x %02x %02x %02x %02x ", k_va[i], k_va[i + 1], k_va[i + 2], k_va[i + 3],
|
||||
k_va[i + 4], k_va[i + 5], k_va[i + 6], k_va[i + 7]);
|
||||
rt_kprintf(" %02x %02x %02x %02x %02x %02x %02x %02x \n", k_va[i + 8], k_va[i + 9], k_va[i + 10], k_va[i + 11],
|
||||
k_va[i + 12], k_va[i + 13], k_va[i + 14], k_va[i + 15]);
|
||||
}
|
||||
rt_kprintf("\r\n");
|
||||
rt_free(k_va);
|
||||
@@ -169,7 +169,7 @@ rt_ubase_t elf_random_offset(void)
|
||||
* @return Virtual address where the file is mapped on success, NULL on failure.
|
||||
*/
|
||||
static void *file_mmap(struct rt_lwp *lwp, int fd, rt_ubase_t load_addr,
|
||||
rt_ubase_t map_size, size_t prot, size_t flags, rt_ubase_t offset)
|
||||
rt_ubase_t map_size, size_t prot, size_t flags, rt_ubase_t offset)
|
||||
{
|
||||
uint8_t *map_va;
|
||||
|
||||
@@ -478,7 +478,7 @@ static int elf_load_interp(elf_load_info_t *load_info)
|
||||
}
|
||||
|
||||
ret = elf_file_read(load_info->exec_info.fd, (rt_uint8_t *)load_info->interp_info.filename,
|
||||
phdr->p_filesz, phdr->p_offset);
|
||||
phdr->p_filesz, phdr->p_offset);
|
||||
if (ret != RT_EOK)
|
||||
{
|
||||
LOG_E("%s : elf_file_read failed, ret = %d", __func__, ret);
|
||||
@@ -543,7 +543,7 @@ static int total_mapping_size(elf_info_t *elf_info)
|
||||
return -1;
|
||||
|
||||
elf_info->map_size = elf_info->phdr[last_idx].p_vaddr + elf_info->phdr[last_idx].p_memsz -
|
||||
ELF_PAGESTART(elf_info->phdr[first_idx].p_vaddr);
|
||||
ELF_PAGESTART(elf_info->phdr[first_idx].p_vaddr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -592,7 +592,7 @@ static rt_ubase_t elf_map(struct rt_lwp *lwp, const Elf_Phdr *elf_phdr, int fd,
|
||||
}
|
||||
|
||||
static int elf_zero_bss(struct rt_lwp *lwp, int fd, const Elf_Phdr *phdr, rt_ubase_t bss_start,
|
||||
rt_ubase_t bss_end)
|
||||
rt_ubase_t bss_end)
|
||||
{
|
||||
lwp_data_set(lwp, (void *)bss_start, 0, bss_end - bss_start);
|
||||
|
||||
@@ -617,7 +617,7 @@ static int elf_zero_bss(struct rt_lwp *lwp, int fd, const Elf_Phdr *phdr, rt_uba
|
||||
* @return -ENOMEM if memory allocation fails.
|
||||
*/
|
||||
static int elf_file_mmap(elf_load_info_t *load_info, elf_info_t *elf_info, rt_ubase_t *elfload_addr,
|
||||
rt_uint32_t map_size, rt_ubase_t *load_base)
|
||||
rt_uint32_t map_size, rt_ubase_t *load_base)
|
||||
{
|
||||
int ret, i;
|
||||
rt_ubase_t map_va, bss_start, bss_end;
|
||||
@@ -688,7 +688,7 @@ static int elf_file_mmap(elf_load_info_t *load_info, elf_info_t *elf_info, rt_ub
|
||||
{
|
||||
*elfload_addr = map_va + ELF_PAGEOFFSET(tmp_phdr->p_vaddr);
|
||||
LOG_D("%s elf_load_addr : %p, vAddr : %p, load_base : %p, map_va : %p", __func__,
|
||||
*elfload_addr, tmp_phdr->p_vaddr, *load_base, map_va);
|
||||
*elfload_addr, tmp_phdr->p_vaddr, *load_base, map_va);
|
||||
}
|
||||
|
||||
if ((*load_base == 0) && (ehdr->e_type == ET_DYN))
|
||||
@@ -722,7 +722,7 @@ static int load_elf_interp(elf_load_info_t *load_info, rt_ubase_t *interp_base)
|
||||
LOG_D("%s : total_mapping_size 0x%x", __func__, load_info->interp_info.map_size);
|
||||
|
||||
return elf_file_mmap(load_info, &load_info->interp_info, interp_base,
|
||||
load_info->interp_info.map_size, &load_base);
|
||||
load_info->interp_info.map_size, &load_base);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -783,7 +783,7 @@ static int elf_aux_fill(elf_load_info_t *load_info)
|
||||
ELF_AUX_ENT(aux_info, AT_SECURE, 0);
|
||||
|
||||
#ifdef RT_USING_VDSO
|
||||
if(RT_EOK == rt_vdso_map_process_image(load_info->lwp))
|
||||
if (RT_EOK == rt_vdso_map_process_image(load_info->lwp))
|
||||
{
|
||||
ELF_AUX_ENT(aux_info, AT_SYSINFO_EHDR, (size_t)load_info->lwp->vdso_vbase);
|
||||
}
|
||||
@@ -834,7 +834,7 @@ static int elf_load_segment(elf_load_info_t *load_info)
|
||||
|
||||
/* Map the segments of the ELF file into memory */
|
||||
ret = elf_file_mmap(load_info, &load_info->exec_info, &load_info->load_addr,
|
||||
load_info->exec_info.map_size, &app_load_base);
|
||||
load_info->exec_info.map_size, &app_load_base);
|
||||
elf_file_close(load_info->exec_info.fd);
|
||||
if (ret != RT_EOK)
|
||||
{
|
||||
@@ -1015,7 +1015,7 @@ OUT:
|
||||
* @see dfs_normalize_path, elf_file_load
|
||||
*/
|
||||
int lwp_load(const char *filename, struct rt_lwp *lwp, uint8_t *load_addr, size_t addr_size,
|
||||
struct process_aux *aux_ua)
|
||||
struct process_aux *aux_ua)
|
||||
{
|
||||
elf_load_info_t load_info = { 0 };
|
||||
int len;
|
||||
@@ -1072,4 +1072,4 @@ int lwp_load(const char *filename, struct rt_lwp *lwp, uint8_t *load_addr, size_
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -22,9 +22,9 @@ extern "C" {
|
||||
extern char __rt_vdso_image_start[];
|
||||
extern char __rt_vdso_image_end[];
|
||||
|
||||
#define RT_VDSO_IMAGE_ELF_MAGIC "\177ELF"
|
||||
#define RT_VDSO_IMAGE_ELF_MAGIC "\177ELF"
|
||||
#define RT_VDSO_IMAGE_ELF_MAGIC_LEN 4
|
||||
#define RT_VDSO_DATA_PAGE_ALIGNED \
|
||||
#define RT_VDSO_DATA_PAGE_ALIGNED \
|
||||
__attribute__((section(".data.vdso.datapage"))) \
|
||||
__attribute__((aligned(RT_VDSO_PAGE_SIZE)))
|
||||
|
||||
|
||||
@@ -20,21 +20,18 @@ extern "C" {
|
||||
|
||||
extern struct rt_vdso_data_page *rt_vdso_kernel_data_page;
|
||||
|
||||
rt_inline
|
||||
struct rt_vdso_data_page *rt_vdso_get_kernel_data_page(void)
|
||||
rt_inline struct rt_vdso_data_page *rt_vdso_get_kernel_data_page(void)
|
||||
{
|
||||
return rt_vdso_kernel_data_page;
|
||||
}
|
||||
|
||||
rt_inline
|
||||
void rt_vdso_data_page_write_begin(struct rt_vdso_data_page *data_page)
|
||||
rt_inline void rt_vdso_data_page_write_begin(struct rt_vdso_data_page *data_page)
|
||||
{
|
||||
rt_atomic_add(&data_page->seq_counter, 1);
|
||||
rt_hw_dmb();
|
||||
}
|
||||
|
||||
rt_inline
|
||||
void rt_vdso_data_page_write_end(struct rt_vdso_data_page *data_page)
|
||||
rt_inline void rt_vdso_data_page_write_end(struct rt_vdso_data_page *data_page)
|
||||
{
|
||||
rt_hw_dmb();
|
||||
rt_atomic_add(&data_page->seq_counter, 1);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define RT_STRINGIFY(x...) __RT_STRINGIFY(x)
|
||||
|
||||
#define rt_vdso_arch_barrier(cmd, ...) \
|
||||
__asm__ volatile(RT_STRINGIFY(cmd) " " RT_STRINGIFY(__VA_ARGS__) ::: "memory")
|
||||
__asm__ volatile(RT_STRINGIFY(cmd) " " RT_STRINGIFY(__VA_ARGS__)::: "memory")
|
||||
|
||||
static inline uint64_t rt_vdso_arch_read_counter(void)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#define RT_STRINGIFY(x...) __RT_STRINGIFY(x)
|
||||
|
||||
#define rt_vdso_arch_barrier(cmd, ...) \
|
||||
__asm__ volatile(RT_STRINGIFY(cmd) " " RT_STRINGIFY(__VA_ARGS__) ::: "memory")
|
||||
__asm__ volatile(RT_STRINGIFY(cmd) " " RT_STRINGIFY(__VA_ARGS__)::: "memory")
|
||||
|
||||
static inline uint64_t rt_vdso_arch_read_counter(void)
|
||||
{
|
||||
|
||||
@@ -51,15 +51,15 @@ static inline void rt_vdso_read_once_size(const volatile void *ptr, void *dst, i
|
||||
}
|
||||
}
|
||||
|
||||
#define READ_ONCE(x) \
|
||||
({ \
|
||||
union \
|
||||
{ \
|
||||
typeof(x) value; \
|
||||
char bytes[sizeof(x)]; \
|
||||
} once; \
|
||||
rt_vdso_read_once_size(&(x), once.bytes, sizeof(x)); \
|
||||
once.value; \
|
||||
#define READ_ONCE(x) \
|
||||
({ \
|
||||
union \
|
||||
{ \
|
||||
typeof(x) value; \
|
||||
char bytes[sizeof(x)]; \
|
||||
} once; \
|
||||
rt_vdso_read_once_size(&(x), once.bytes, sizeof(x)); \
|
||||
once.value; \
|
||||
})
|
||||
|
||||
extern const struct rt_vdso_data_page __rt_vdso_data_page[] __attribute__((visibility("hidden")));
|
||||
@@ -83,7 +83,7 @@ static inline uint32_t rt_vdso_data_read_begin(const struct rt_vdso_data_page *d
|
||||
}
|
||||
|
||||
static inline uint32_t rt_vdso_data_read_retry(const struct rt_vdso_data_page *data_page,
|
||||
uint32_t start)
|
||||
uint32_t start)
|
||||
{
|
||||
rt_vdso_arch_rmb();
|
||||
return READ_ONCE(data_page->seq_counter) != start;
|
||||
|
||||
@@ -20,11 +20,14 @@ extern "C" {
|
||||
#define RT_VDSO_PAGE_SIZE (1 << RT_VDSO_PAGE_SHIFT)
|
||||
|
||||
#ifndef read_barrier_depends
|
||||
#define read_barrier_depends() do { } while (0)
|
||||
#define read_barrier_depends() \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef smp_read_barrier_depends
|
||||
#define smp_read_barrier_depends() read_barrier_depends()
|
||||
#define smp_read_barrier_depends() read_barrier_depends()
|
||||
#endif
|
||||
|
||||
#if defined(__aarch64__)
|
||||
|
||||
@@ -32,10 +32,10 @@ enum rt_vdso_clock_data_index
|
||||
|
||||
struct rt_vdso_data_page
|
||||
{
|
||||
uint32_t seq_counter;
|
||||
uint32_t flags;
|
||||
uint64_t counter_last;
|
||||
uint64_t counter_freq;
|
||||
uint32_t seq_counter;
|
||||
uint32_t flags;
|
||||
uint64_t counter_last;
|
||||
uint64_t counter_freq;
|
||||
struct timespec base_time[RT_VDSO_CLOCK_DATA_COUNT];
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -252,7 +252,7 @@ rt_weak rt_tick_t rt_tick_get_millisecond(void)
|
||||
#if 1000 % RT_TICK_PER_SECOND == 0u
|
||||
return rt_tick_get() * (1000u / RT_TICK_PER_SECOND);
|
||||
#else
|
||||
#warning "rt-thread cannot provide a correct 1ms-based tick any longer,\
|
||||
#warning "rt-thread cannot provide a correct 1ms-based tick any longer,\
|
||||
please redefine this function in another file by using a high-precision hard-timer."
|
||||
return 0;
|
||||
#endif /* 1000 % RT_TICK_PER_SECOND == 0u */
|
||||
|
||||
Reference in New Issue
Block a user