Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79725df5 authored by GuanXuetao's avatar GuanXuetao
Browse files

unicore32 core architecture: processor and system headers



This patch includes processor and system headers. System call interface is here.
We used the syscall interface the same as asm-generic version.

Signed-off-by: default avatarGuan Xuetao <gxt@mprc.pku.edu.cn>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 87c1a3fb
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
/*
 * linux/arch/unicore32/include/asm/byteorder.h
 *
 * Code specific to PKUnity SoC and UniCore ISA
 *
 * Copyright (C) 2001-2010 GUAN Xue-tao
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * UniCore ONLY support Little Endian mode, the data bus is connected such
 * that byte accesses appear as:
 *  0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
 * and word accesses (data or instruction) appear as:
 *  d0...d31
 */
#ifndef __UNICORE_BYTEORDER_H__
#define __UNICORE_BYTEORDER_H__

#include <linux/byteorder/little_endian.h>

#endif
+45 −0
Original line number Diff line number Diff line
/*
 * linux/arch/unicore32/include/asm/cpu-single.h
 *
 * Code specific to PKUnity SoC and UniCore ISA
 *
 * Copyright (C) 2001-2010 GUAN Xue-tao
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef __UNICORE_CPU_SINGLE_H__
#define __UNICORE_CPU_SINGLE_H__

#include <asm/page.h>
#include <asm/memory.h>

#ifdef __KERNEL__
#ifndef __ASSEMBLY__

#define cpu_switch_mm(pgd, mm) cpu_do_switch_mm(virt_to_phys(pgd), mm)

#define cpu_get_pgd()					\
	({						\
		unsigned long pg;			\
		__asm__("movc	%0, p0.c2, #0"		\
			 : "=r" (pg) : : "cc");		\
		pg &= ~0x0fff;				\
		(pgd_t *)phys_to_virt(pg);		\
	})

struct mm_struct;

/* declare all the functions as extern */
extern void cpu_proc_fin(void);
extern int cpu_do_idle(void);
extern void cpu_dcache_clean_area(void *, int);
extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm);
extern void cpu_set_pte(pte_t *ptep, pte_t pte);
extern void cpu_reset(unsigned long addr) __attribute__((noreturn));

#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */

#endif /* __UNICORE_CPU_SINGLE_H__ */
+33 −0
Original line number Diff line number Diff line
/*
 * linux/arch/unicore32/include/asm/cputype.h
 *
 * Code specific to PKUnity SoC and UniCore ISA
 *
 * Copyright (C) 2001-2010 GUAN Xue-tao
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef __UNICORE_CPUTYPE_H__
#define __UNICORE_CPUTYPE_H__

#include <linux/stringify.h>

#define CPUID_CPUID	0
#define CPUID_CACHETYPE	1

#define read_cpuid(reg)							\
	({								\
		unsigned int __val;					\
		asm("movc	%0, p0.c0, #" __stringify(reg)		\
		    : "=r" (__val)					\
		    :							\
		    : "cc");						\
		__val;							\
	})

#define uc32_cpuid		read_cpuid(CPUID_CPUID)
#define uc32_cachetype		read_cpuid(CPUID_CACHETYPE)

#endif
+32 −0
Original line number Diff line number Diff line
/*
 * linux/arch/unicore32/include/asm/hwcap.h
 *
 * Code specific to PKUnity SoC and UniCore ISA
 *
 * Copyright (C) 2001-2010 GUAN Xue-tao
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef __UNICORE_HWCAP_H__
#define __UNICORE_HWCAP_H__

/*
 * HWCAP flags
 */
#define HWCAP_MSP		1
#define HWCAP_UNICORE16		2
#define HWCAP_CMOV		4
#define HWCAP_UNICORE_F64       8
#define HWCAP_TLS		0x80

#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
/*
 * This yields a mask that user programs can use to figure out what
 * instruction set this cpu supports.
 */
#define ELF_HWCAP		(HWCAP_CMOV | HWCAP_UNICORE_F64)
#endif

#endif
+92 −0
Original line number Diff line number Diff line
/*
 * linux/arch/unicore32/include/asm/processor.h
 *
 * Code specific to PKUnity SoC and UniCore ISA
 *
 * Copyright (C) 2001-2010 GUAN Xue-tao
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef __UNICORE_PROCESSOR_H__
#define __UNICORE_PROCESSOR_H__

/*
 * Default implementation of macro that returns current
 * instruction pointer ("program counter").
 */
#define current_text_addr() ({ __label__ _l; _l: &&_l; })

#ifdef __KERNEL__

#include <asm/ptrace.h>
#include <asm/types.h>

#ifdef __KERNEL__
#define STACK_TOP	TASK_SIZE
#define STACK_TOP_MAX	TASK_SIZE
#endif

struct debug_entry {
	u32			address;
	u32			insn;
};

struct debug_info {
	int			nsaved;
	struct debug_entry	bp[2];
};

struct thread_struct {
							/* fault info	  */
	unsigned long		address;
	unsigned long		trap_no;
	unsigned long		error_code;
							/* debugging	  */
	struct debug_info	debug;
};

#define INIT_THREAD  {	}

#define start_thread(regs, pc, sp)					\
({									\
	unsigned long *stack = (unsigned long *)sp;			\
	set_fs(USER_DS);						\
	memset(regs->uregs, 0, sizeof(regs->uregs));			\
	regs->UCreg_asr = USER_MODE;					\
	regs->UCreg_pc = pc & ~1;	/* pc */                        \
	regs->UCreg_sp = sp;		/* sp */                        \
	regs->UCreg_02 = stack[2];	/* r2 (envp) */                 \
	regs->UCreg_01 = stack[1];	/* r1 (argv) */                 \
	regs->UCreg_00 = stack[0];	/* r0 (argc) */                 \
})

/* Forward declaration, a strange C thing */
struct task_struct;

/* Free all resources held by a thread. */
extern void release_thread(struct task_struct *);

/* Prepare to copy thread state - unlazy all lazy status */
#define prepare_to_copy(tsk)	do { } while (0)

unsigned long get_wchan(struct task_struct *p);

#define cpu_relax()			barrier()

/*
 * Create a new kernel thread
 */
extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);

#define task_pt_regs(p) \
	((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)

#define KSTK_EIP(tsk)	(task_pt_regs(tsk)->UCreg_pc)
#define KSTK_ESP(tsk)	(task_pt_regs(tsk)->UCreg_sp)

#endif

#endif /* __UNICORE_PROCESSOR_H__ */
Loading