Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare some api for DM #7894

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions components/drivers/ofw/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <rtthread.h>

#include <string.h>
#include <drivers/ofw.h>
#include <drivers/ofw_io.h>
#include <drivers/ofw_fdt.h>
Expand Down Expand Up @@ -249,7 +250,7 @@ rt_bool_t rt_ofw_node_tag_equ(const struct rt_ofw_node *np, const char *tag)
if (np && tag)
{
const char *node_name = rt_fdt_node_name(np->full_name);
rt_size_t tag_len = rt_strchrnul(node_name, '@') - node_name;
rt_size_t tag_len = strchrnul(node_name, '@') - node_name;

ret = (rt_strlen(tag) == tag_len && !rt_strncmp(node_name, tag, tag_len));
}
Expand Down Expand Up @@ -569,7 +570,7 @@ struct rt_ofw_node *rt_ofw_find_node_by_ids_r(struct rt_ofw_node *from, const st

struct rt_ofw_node *rt_ofw_find_node_by_path(const char *path)
{
struct rt_ofw_node *np, *parent, *tmp;
struct rt_ofw_node *np = RT_NULL, *parent, *tmp = RT_NULL;

if (path)
{
Expand All @@ -584,7 +585,7 @@ struct rt_ofw_node *rt_ofw_find_node_by_path(const char *path)

while (*path)
{
const char *next = rt_strchrnul(path, '/');
const char *next = strchrnul(path, '/');
rt_size_t len = next - path;

tmp = RT_NULL;
Expand Down
9 changes: 5 additions & 4 deletions components/drivers/ofw/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <rthw.h>
#include <rtthread.h>

#include <string.h>
#include <drivers/ofw_fdt.h>
#include <drivers/ofw_raw.h>
#include <drivers/core/dm.h>
Expand Down Expand Up @@ -40,7 +41,7 @@ static rt_size_t _root_addr_cells;

const char *rt_fdt_node_name(const char *full_name)
{
const char *node_name = rt_strrchr(full_name, '/');
const char *node_name = strrchr(full_name, '/');

return node_name ? node_name + 1 : full_name;
}
Expand Down Expand Up @@ -701,7 +702,7 @@ rt_err_t rt_fdt_scan_chosen_stdout(void)

if (stdout_path && len)
{
const char *path_split = rt_strchrnul(stdout_path, ':');
const char *path_split = strchrnul(stdout_path, ':');

if (*path_split != '\0')
{
Expand Down Expand Up @@ -780,13 +781,13 @@ rt_err_t rt_fdt_scan_chosen_stdout(void)

if (*options)
{
type_len = rt_strchrnul(options, ',') - options;
type_len = strchrnul(options, ',') - options;
}
}

if (options && *options && *options != ' ')
{
options_len = rt_strchrnul(options, ' ') - options;
options_len = strchrnul(options, ' ') - options;
}

/* console > stdout-path */
Expand Down
3 changes: 2 additions & 1 deletion components/drivers/ofw/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <rtthread.h>

#include <string.h>
#include <drivers/pic.h>
#include <drivers/ofw.h>
#include <drivers/ofw_io.h>
Expand Down Expand Up @@ -130,7 +131,7 @@ static rt_err_t ofw_parse_irq_map(struct rt_ofw_node *np, struct rt_ofw_cell_arg
* <0x1800 0 0 4 &gic 0 0 GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>; // INTD
* };
*
* In fact, basically no SoC will be use multi ic to implemented INTx.
* In fact, almost no SoC will be use multi IC to implement INTx.
* before call ofw_parse_irq_map(np, &args):
*
* args.data = addr;
Expand Down
10 changes: 10 additions & 0 deletions components/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ static void *_ioremap_type(void *paddr, size_t size, enum ioremap_type type)
return v_addr;
}

rt_weak void *rt_ioremap_early(void *paddr, size_t size)
{
if (!size)
{
return RT_NULL;
}

return paddr;
}

void *rt_ioremap(void *paddr, size_t size)
{
return _ioremap_type(paddr, size, MM_AREA_TYPE_PHY);
Expand Down
1 change: 1 addition & 0 deletions components/mm/ioremap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" {
* | Currently as non-cacheable
*/

void *rt_ioremap_early(void *paddr, size_t size);
void *rt_ioremap(void *paddr, size_t size);
void *rt_ioremap_nocache(void *paddr, size_t size);
void *rt_ioremap_cached(void *paddr, size_t size);
Expand Down
2 changes: 2 additions & 0 deletions components/mm/mm_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ typedef struct tag_region
{
rt_size_t start;
rt_size_t end;

const char *name;
} rt_region_t;

extern const rt_size_t rt_mpr_size;
Expand Down
8 changes: 3 additions & 5 deletions libcpu/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
menu "RT-Thread Architecture"

config ARCH_CPU_64BIT
bool

Expand Down Expand Up @@ -234,6 +232,6 @@ config ARCH_CPU_STACK_GROWS_UPWARD
bool
default n

source "$RTT_DIR/libcpu/aarch64/Kconfig"

endmenu
if ARCH_ARMV8 && ARCH_CPU_64BIT
source "$RTT_DIR/libcpu/aarch64/Kconfig"
endif
4 changes: 2 additions & 2 deletions libcpu/aarch64/Kconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ARCH_ARMV8 && ARCH_CPU_64BIT
menu "AArch64 Architecture Configuration"

config ARCH_TEXT_OFFSET
hex "Text offset"
Expand All @@ -16,4 +16,4 @@ config ARCH_HAVE_EFFICIENT_UNALIGNED_ACCESS
bool
default y

endif
endmenu
38 changes: 14 additions & 24 deletions libcpu/aarch64/common/cpuport.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,20 @@ typedef union {
} rt_hw_spinlock_t;
#endif

rt_inline void rt_hw_isb(void)
{
__asm__ volatile ("isb":::"memory");
}

rt_inline void rt_hw_dmb(void)
{
__asm__ volatile ("dmb ish":::"memory");
}

rt_inline void rt_hw_wmb(void)
{
__asm__ volatile ("dmb ishst":::"memory");
}

rt_inline void rt_hw_rmb(void)
{
__asm__ volatile ("dmb ishld":::"memory");
}

rt_inline void rt_hw_dsb(void)
{
__asm__ volatile ("dsb ish":::"memory");
}
#define rt_hw_barrier(cmd, ...) \
__asm__ volatile (RT_STRINGIFY(cmd) " "RT_STRINGIFY(__VA_ARGS__):::"memory")

#define rt_hw_isb() rt_hw_barrier(isb)
#define rt_hw_dmb() rt_hw_barrier(dmb, ish)
#define rt_hw_wmb() rt_hw_barrier(dmb, ishst)
#define rt_hw_rmb() rt_hw_barrier(dmb, ishld)
#define rt_hw_dsb() rt_hw_barrier(dsb, ish)

#define rt_hw_wfi() rt_hw_barrier(wfi)
#define rt_hw_wfe() rt_hw_barrier(wfe)
#define rt_hw_sev() rt_hw_barrier(sev)

#define rt_hw_cpu_relax() rt_hw_barrier(yield)

void _thread_start(void);
#endif /*CPUPORT_H__*/
25 changes: 25 additions & 0 deletions libcpu/aarch64/common/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,31 @@ static int _map_single_page_2M(unsigned long *lv0_tbl, unsigned long va,
return 0;
}

void *rt_ioremap_early(void *paddr, size_t size)
{
size_t count;
static void *tbl = RT_NULL;

if (!size)
{
return RT_NULL;
}

if (!tbl)
{
tbl = rt_hw_mmu_tbl_get();
}

count = (size + ARCH_SECTION_MASK) >> ARCH_SECTION_SHIFT;

while (count --> 0)
{
_map_single_page_2M(tbl, (unsigned long)paddr, (unsigned long)paddr, MMU_MAP_K_DEVICE);
}

return paddr;
}

static int _init_map_2M(unsigned long *lv0_tbl, unsigned long va,
unsigned long pa, unsigned long count,
unsigned long attr)
Expand Down
Loading