Skip to content

Commit

Permalink
metag: Various other headers
Browse files Browse the repository at this point in the history
Add the remaining metag header files:
 - byteorder.h, swab.h (byte order and swapping)
 - barrier.h, cpu.h. hwthread.h, processor.h (hardware thread related)
 - bug.h, elf.h, gpio.h, linkage.h, resource.h (other)

Signed-off-by: James Hogan <james.hogan@imgtec.com>
  • Loading branch information
James Hogan committed Mar 2, 2013
1 parent e8de348 commit 1e57372
Show file tree
Hide file tree
Showing 11 changed files with 526 additions and 0 deletions.
85 changes: 85 additions & 0 deletions arch/metag/include/asm/barrier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#ifndef _ASM_METAG_BARRIER_H
#define _ASM_METAG_BARRIER_H

#include <asm/metag_mem.h>

#define nop() asm volatile ("NOP")
#define mb() wmb()
#define rmb() barrier()

#ifdef CONFIG_METAG_META21

/* HTP and above have a system event to fence writes */
static inline void wr_fence(void)
{
volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_FENCE;
barrier();
*flushptr = 0;
}

#else /* CONFIG_METAG_META21 */

/*
* ATP doesn't have system event to fence writes, so it is necessary to flush
* the processor write queues as well as possibly the write combiner (depending
* on the page being written).
* To ensure the write queues are flushed we do 4 writes to a system event
* register (in this case write combiner flush) which will also flush the write
* combiner.
*/
static inline void wr_fence(void)
{
volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_COMBINE_FLUSH;
barrier();
*flushptr = 0;
*flushptr = 0;
*flushptr = 0;
*flushptr = 0;
}

#endif /* !CONFIG_METAG_META21 */

static inline void wmb(void)
{
/* flush writes through the write combiner */
wr_fence();
}

#define read_barrier_depends() do { } while (0)

#ifndef CONFIG_SMP
#define fence() do { } while (0)
#define smp_mb() barrier()
#define smp_rmb() barrier()
#define smp_wmb() barrier()
#else

#ifdef CONFIG_METAG_SMP_WRITE_REORDERING
/*
* Write to the atomic memory unlock system event register (command 0). This is
* needed before a write to shared memory in a critical section, to prevent
* external reordering of writes before the fence on other threads with writes
* after the fence on this thread (and to prevent the ensuing cache-memory
* incoherence). It is therefore ineffective if used after and on the same
* thread as a write.
*/
static inline void fence(void)
{
volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
barrier();
*flushptr = 0;
}
#define smp_mb() fence()
#define smp_rmb() fence()
#define smp_wmb() barrier()
#else
#define fence() do { } while (0)
#define smp_mb() barrier()
#define smp_rmb() barrier()
#define smp_wmb() barrier()
#endif
#endif
#define smp_read_barrier_depends() do { } while (0)
#define set_mb(var, value) do { var = value; smp_mb(); } while (0)

#endif /* _ASM_METAG_BARRIER_H */
12 changes: 12 additions & 0 deletions arch/metag/include/asm/bug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _ASM_METAG_BUG_H
#define _ASM_METAG_BUG_H

#include <asm-generic/bug.h>

struct pt_regs;

extern const char *trap_name(int trapno);
extern void die(const char *str, struct pt_regs *regs, long err,
unsigned long addr) __attribute__ ((noreturn));

#endif
14 changes: 14 additions & 0 deletions arch/metag/include/asm/cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef _ASM_METAG_CPU_H
#define _ASM_METAG_CPU_H

#include <linux/percpu.h>

struct cpuinfo_metag {
struct cpu cpu;
#ifdef CONFIG_SMP
unsigned long loops_per_jiffy;
#endif
};

DECLARE_PER_CPU(struct cpuinfo_metag, cpu_data);
#endif /* _ASM_METAG_CPU_H */
128 changes: 128 additions & 0 deletions arch/metag/include/asm/elf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#ifndef __ASM_METAG_ELF_H
#define __ASM_METAG_ELF_H

#define EM_METAG 174

/* Meta relocations */
#define R_METAG_HIADDR16 0
#define R_METAG_LOADDR16 1
#define R_METAG_ADDR32 2
#define R_METAG_NONE 3
#define R_METAG_RELBRANCH 4
#define R_METAG_GETSETOFF 5

/* Backward compatability */
#define R_METAG_REG32OP1 6
#define R_METAG_REG32OP2 7
#define R_METAG_REG32OP3 8
#define R_METAG_REG16OP1 9
#define R_METAG_REG16OP2 10
#define R_METAG_REG16OP3 11
#define R_METAG_REG32OP4 12

#define R_METAG_HIOG 13
#define R_METAG_LOOG 14

/* GNU */
#define R_METAG_GNU_VTINHERIT 30
#define R_METAG_GNU_VTENTRY 31

/* PIC relocations */
#define R_METAG_HI16_GOTOFF 32
#define R_METAG_LO16_GOTOFF 33
#define R_METAG_GETSET_GOTOFF 34
#define R_METAG_GETSET_GOT 35
#define R_METAG_HI16_GOTPC 36
#define R_METAG_LO16_GOTPC 37
#define R_METAG_HI16_PLT 38
#define R_METAG_LO16_PLT 39
#define R_METAG_RELBRANCH_PLT 40
#define R_METAG_GOTOFF 41
#define R_METAG_PLT 42
#define R_METAG_COPY 43
#define R_METAG_JMP_SLOT 44
#define R_METAG_RELATIVE 45
#define R_METAG_GLOB_DAT 46

/*
* ELF register definitions.
*/

#include <asm/page.h>
#include <asm/processor.h>
#include <asm/ptrace.h>
#include <asm/user.h>

typedef unsigned long elf_greg_t;

#define ELF_NGREG (sizeof(struct user_gp_regs) / sizeof(elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];

typedef unsigned long elf_fpregset_t;

/*
* This is used to ensure we don't load something for the wrong architecture.
*/
#define elf_check_arch(x) ((x)->e_machine == EM_METAG)

/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_METAG

#define ELF_PLAT_INIT(_r, load_addr) \
do { _r->ctx.AX[0].U0 = 0; } while (0)

#define USE_ELF_CORE_DUMP
#define CORE_DUMP_USE_REGSET
#define ELF_EXEC_PAGESIZE PAGE_SIZE

/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
use of this is to invoke "./ld.so someprog" to test out a new version of
the loader. We need to make sure that it is out of the way of the program
that it will "exec", and that there is sufficient room for the brk. */

#define ELF_ET_DYN_BASE 0x08000000UL

#define ELF_CORE_COPY_REGS(_dest, _regs) \
memcpy((char *)&_dest, (char *)_regs, sizeof(struct pt_regs));

/* This yields a mask that user programs can use to figure out what
instruction set this cpu supports. */

#define ELF_HWCAP (0)

/* This yields a string that ld.so will use to load implementation
specific libraries for optimization. This is more specific in
intent than poking at uname or /proc/cpuinfo. */

#define ELF_PLATFORM (NULL)

#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))

#define STACK_RND_MASK (0)

#ifdef CONFIG_METAG_USER_TCM

struct elf32_phdr;
struct file;

unsigned long __metag_elf_map(struct file *filep, unsigned long addr,
struct elf32_phdr *eppnt, int prot, int type,
unsigned long total_size);

static inline unsigned long metag_elf_map(struct file *filep,
unsigned long addr,
struct elf32_phdr *eppnt, int prot,
int type, unsigned long total_size)
{
return __metag_elf_map(filep, addr, eppnt, prot, type, total_size);
}
#define elf_map metag_elf_map

#endif

#endif
4 changes: 4 additions & 0 deletions arch/metag/include/asm/gpio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef __LINUX_GPIO_H
#warning Include linux/gpio.h instead of asm/gpio.h
#include <linux/gpio.h>
#endif
40 changes: 40 additions & 0 deletions arch/metag/include/asm/hwthread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2008 Imagination Technologies
*/
#ifndef __METAG_HWTHREAD_H
#define __METAG_HWTHREAD_H

#include <linux/bug.h>
#include <linux/io.h>

#include <asm/metag_mem.h>

#define BAD_HWTHREAD_ID (0xFFU)
#define BAD_CPU_ID (0xFFU)

extern u8 cpu_2_hwthread_id[];
extern u8 hwthread_id_2_cpu[];

/*
* Each hardware thread's Control Unit registers are memory-mapped
* and can therefore be accessed by any other hardware thread.
*
* This helper function returns the memory address where "thread"'s
* register "regnum" is mapped.
*/
static inline
void __iomem *__CU_addr(unsigned int thread, unsigned int regnum)
{
unsigned int base, thread_offset, thread_regnum;

WARN_ON(thread == BAD_HWTHREAD_ID);

base = T0UCTREG0; /* Control unit base */

thread_offset = TnUCTRX_STRIDE * thread;
thread_regnum = TXUCTREGn_STRIDE * regnum;

return (void __iomem *)(base + thread_offset + thread_regnum);
}

#endif /* __METAG_HWTHREAD_H */
7 changes: 7 additions & 0 deletions arch/metag/include/asm/linkage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __ASM_LINKAGE_H
#define __ASM_LINKAGE_H

#define __ALIGN .p2align 2
#define __ALIGN_STR ".p2align 2"

#endif
Loading

0 comments on commit 1e57372

Please sign in to comment.