kernel_optimize_test/arch/csky/mm
Guo Ren f525bb2c9e 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>
2020-02-21 15:43:24 +08:00
..
asid.c csky: Add new asid lib code from arm 2019-07-19 14:21:36 +08:00
cachev1.c csky: Optimize arch_sync_dma_for_cpu/device with dma_inv_range 2019-08-06 15:15:34 +08:00
cachev2.c csky: Optimize arch_sync_dma_for_cpu/device with dma_inv_range 2019-08-06 15:15:34 +08:00
context.c csky: Use generic asid algorithm to implement switch_mm 2019-07-19 14:21:36 +08:00
dma-mapping.c dma-mapping: drop the dev argument to arch_sync_dma_for_* 2019-11-20 20:31:38 +01:00
fault.c signal: Remove the task parameter from force_sig_fault 2019-05-29 09:31:43 -05:00
highmem.c treewide: add checks for the return value of memblock_alloc*() 2019-03-12 10:04:02 -07:00
init.c csky: Use generic free_initrd_mem() 2019-09-30 10:26:24 +08:00
ioremap.c csky: use generic ioremap 2019-11-12 11:37:52 +01:00
Makefile csky: Tightly-Coupled Memory or Sram support 2020-02-21 15:43:24 +08:00
syscache.c csky: Cache and TLB routines 2018-10-25 23:36:19 +08:00
tcm.c csky: Tightly-Coupled Memory or Sram support 2020-02-21 15:43:24 +08:00
tlb.c csky: Improve tlb operation with help of asid 2019-07-19 14:21:36 +08:00