2018-09-04 23:25:07 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
#include <asm/vmlinux.lds.h>
|
|
|
|
#include <asm/page.h>
|
csky: Tightly-Coupled Memory or Sram support
The implementation are not only used by TCM but also used by sram on
SOC bus. It follow existed linux tcm software interface, so that old
tcm application codes could be re-used directly.
Software interface list in asm/tcm.h:
- Variables/Const: __tcmdata, __tcmconst
- Functions: __tcmfunc, __tcmlocalfunc
- Malloc/Free: tcm_alloc, tcm_free
In linux menuconfig:
- Choose a TCM contain instrctions + data or separated in ITCM/DTCM.
- Determine TCM_BASE (DTCM_BASE) in phyiscal address.
- Determine size of TCM or ITCM(DTCM) in page counts.
Here is hello tcm example from Documentation/arm/tcm.rst which could
be directly used:
/* Uninitialized data */
static u32 __tcmdata tcmvar;
/* Initialized data */
static u32 __tcmdata tcmassigned = 0x2BADBABEU;
/* Constant */
static const u32 __tcmconst tcmconst = 0xCAFEBABEU;
static void __tcmlocalfunc tcm_to_tcm(void)
{
int i;
for (i = 0; i < 100; i++)
tcmvar ++;
}
static void __tcmfunc hello_tcm(void)
{
/* Some abstract code that runs in ITCM */
int i;
for (i = 0; i < 100; i++) {
tcmvar ++;
}
tcm_to_tcm();
}
static void __init test_tcm(void)
{
u32 *tcmem;
int i;
hello_tcm();
printk("Hello TCM executed from ITCM RAM\n");
printk("TCM variable from testrun: %u @ %p\n", tcmvar, &tcmvar);
tcmvar = 0xDEADBEEFU;
printk("TCM variable: 0x%x @ %p\n", tcmvar, &tcmvar);
printk("TCM assigned variable: 0x%x @ %p\n", tcmassigned, &tcmassigned);
printk("TCM constant: 0x%x @ %p\n", tcmconst, &tcmconst);
/* Allocate some TCM memory from the pool */
tcmem = tcm_alloc(20);
if (tcmem) {
printk("TCM Allocated 20 bytes of TCM @ %p\n", tcmem);
tcmem[0] = 0xDEADBEEFU;
tcmem[1] = 0x2BADBABEU;
tcmem[2] = 0xCAFEBABEU;
tcmem[3] = 0xDEADBEEFU;
tcmem[4] = 0x2BADBABEU;
for (i = 0; i < 5; i++)
printk("TCM tcmem[%d] = %08x\n", i, tcmem[i]);
tcm_free(tcmem, 20);
}
}
TODO:
- Separate fixup mapping from highmem
- Support abiv1
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
2019-11-26 17:44:33 -07:00
|
|
|
#include <asm/memory.h>
|
2018-09-04 23:25:07 -07:00
|
|
|
|
|
|
|
OUTPUT_ARCH(csky)
|
|
|
|
ENTRY(_start)
|
|
|
|
|
|
|
|
#ifndef __cskyBE__
|
|
|
|
jiffies = jiffies_64;
|
|
|
|
#else
|
|
|
|
jiffies = jiffies_64 + 4;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define VBR_BASE \
|
|
|
|
. = ALIGN(1024); \
|
|
|
|
vec_base = .; \
|
|
|
|
. += 512;
|
|
|
|
|
|
|
|
SECTIONS
|
|
|
|
{
|
|
|
|
. = PAGE_OFFSET + PHYS_OFFSET_OFFSET;
|
|
|
|
|
2022-07-04 23:00:15 -07:00
|
|
|
_start = .;
|
2018-09-04 23:25:07 -07:00
|
|
|
HEAD_TEXT_SECTION
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
|
|
|
|
.text : AT(ADDR(.text) - LOAD_OFFSET) {
|
|
|
|
_text = .;
|
2022-07-04 23:00:15 -07:00
|
|
|
_stext = .;
|
2020-09-06 23:20:18 -07:00
|
|
|
VBR_BASE
|
2018-09-04 23:25:07 -07:00
|
|
|
IRQENTRY_TEXT
|
|
|
|
SOFTIRQENTRY_TEXT
|
|
|
|
TEXT_TEXT
|
|
|
|
SCHED_TEXT
|
|
|
|
LOCK_TEXT
|
|
|
|
KPROBES_TEXT
|
|
|
|
*(.fixup)
|
|
|
|
*(.gnu.warning)
|
|
|
|
} = 0
|
|
|
|
_etext = .;
|
|
|
|
|
|
|
|
/* __init_begin __init_end must be page aligned for free_initmem */
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
2022-07-04 23:16:21 -07:00
|
|
|
__init_begin = .;
|
|
|
|
INIT_TEXT_SECTION(PAGE_SIZE)
|
|
|
|
INIT_DATA_SECTION(PAGE_SIZE)
|
|
|
|
PERCPU_SECTION(L1_CACHE_BYTES)
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
__init_end = .;
|
2018-09-04 23:25:07 -07:00
|
|
|
|
|
|
|
_sdata = .;
|
2019-10-29 14:13:34 -07:00
|
|
|
RO_DATA(PAGE_SIZE)
|
2019-10-29 14:13:35 -07:00
|
|
|
RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
|
2018-09-04 23:25:07 -07:00
|
|
|
_edata = .;
|
|
|
|
|
csky: Tightly-Coupled Memory or Sram support
The implementation are not only used by TCM but also used by sram on
SOC bus. It follow existed linux tcm software interface, so that old
tcm application codes could be re-used directly.
Software interface list in asm/tcm.h:
- Variables/Const: __tcmdata, __tcmconst
- Functions: __tcmfunc, __tcmlocalfunc
- Malloc/Free: tcm_alloc, tcm_free
In linux menuconfig:
- Choose a TCM contain instrctions + data or separated in ITCM/DTCM.
- Determine TCM_BASE (DTCM_BASE) in phyiscal address.
- Determine size of TCM or ITCM(DTCM) in page counts.
Here is hello tcm example from Documentation/arm/tcm.rst which could
be directly used:
/* Uninitialized data */
static u32 __tcmdata tcmvar;
/* Initialized data */
static u32 __tcmdata tcmassigned = 0x2BADBABEU;
/* Constant */
static const u32 __tcmconst tcmconst = 0xCAFEBABEU;
static void __tcmlocalfunc tcm_to_tcm(void)
{
int i;
for (i = 0; i < 100; i++)
tcmvar ++;
}
static void __tcmfunc hello_tcm(void)
{
/* Some abstract code that runs in ITCM */
int i;
for (i = 0; i < 100; i++) {
tcmvar ++;
}
tcm_to_tcm();
}
static void __init test_tcm(void)
{
u32 *tcmem;
int i;
hello_tcm();
printk("Hello TCM executed from ITCM RAM\n");
printk("TCM variable from testrun: %u @ %p\n", tcmvar, &tcmvar);
tcmvar = 0xDEADBEEFU;
printk("TCM variable: 0x%x @ %p\n", tcmvar, &tcmvar);
printk("TCM assigned variable: 0x%x @ %p\n", tcmassigned, &tcmassigned);
printk("TCM constant: 0x%x @ %p\n", tcmconst, &tcmconst);
/* Allocate some TCM memory from the pool */
tcmem = tcm_alloc(20);
if (tcmem) {
printk("TCM Allocated 20 bytes of TCM @ %p\n", tcmem);
tcmem[0] = 0xDEADBEEFU;
tcmem[1] = 0x2BADBABEU;
tcmem[2] = 0xCAFEBABEU;
tcmem[3] = 0xDEADBEEFU;
tcmem[4] = 0x2BADBABEU;
for (i = 0; i < 5; i++)
printk("TCM tcmem[%d] = %08x\n", i, tcmem[i]);
tcm_free(tcmem, 20);
}
}
TODO:
- Separate fixup mapping from highmem
- Support abiv1
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
2019-11-26 17:44:33 -07:00
|
|
|
#ifdef CONFIG_HAVE_TCM
|
|
|
|
.tcm_start : {
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
__tcm_start = .;
|
|
|
|
}
|
|
|
|
|
|
|
|
.text_data_tcm FIXADDR_TCM : AT(__tcm_start)
|
|
|
|
{
|
|
|
|
. = ALIGN(4);
|
|
|
|
__stcm_text_data = .;
|
|
|
|
*(.tcm.text)
|
|
|
|
*(.tcm.rodata)
|
|
|
|
#ifndef CONFIG_HAVE_DTCM
|
|
|
|
*(.tcm.data)
|
|
|
|
#endif
|
|
|
|
. = ALIGN(4);
|
|
|
|
__etcm_text_data = .;
|
|
|
|
}
|
|
|
|
|
|
|
|
. = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_data_tcm);
|
|
|
|
|
|
|
|
#ifdef CONFIG_HAVE_DTCM
|
|
|
|
#define ITCM_SIZE CONFIG_ITCM_NR_PAGES * PAGE_SIZE
|
|
|
|
|
|
|
|
.dtcm_start : {
|
|
|
|
__dtcm_start = .;
|
|
|
|
}
|
|
|
|
|
|
|
|
.data_tcm FIXADDR_TCM + ITCM_SIZE : AT(__dtcm_start)
|
|
|
|
{
|
|
|
|
. = ALIGN(4);
|
|
|
|
__stcm_data = .;
|
|
|
|
*(.tcm.data)
|
|
|
|
. = ALIGN(4);
|
|
|
|
__etcm_data = .;
|
|
|
|
}
|
|
|
|
|
|
|
|
. = ADDR(.dtcm_start) + SIZEOF(.data_tcm);
|
|
|
|
|
|
|
|
.tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_tcm)) {
|
|
|
|
#else
|
|
|
|
.tcm_end : AT(ADDR(.tcm_start) + SIZEOF(.text_data_tcm)) {
|
|
|
|
#endif
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
__tcm_end = .;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-04 23:25:07 -07:00
|
|
|
EXCEPTION_TABLE(L1_CACHE_BYTES)
|
|
|
|
BSS_SECTION(L1_CACHE_BYTES, PAGE_SIZE, L1_CACHE_BYTES)
|
|
|
|
_end = . ;
|
|
|
|
|
|
|
|
STABS_DEBUG
|
|
|
|
DWARF_DEBUG
|
2020-08-21 12:42:45 -07:00
|
|
|
ELF_DETAILS
|
2018-09-04 23:25:07 -07:00
|
|
|
|
|
|
|
DISCARDS
|
|
|
|
}
|