Commit 85d9d7a9 authored by James Hogan's avatar James Hogan

metag: Boot

Add boot code for metag. Due to the multi-threaded nature of Meta it is
not uncommon for an RTOS or bare metal application to be started on
other hardware threads by the bootloader. Since there is a single MMU
switch which affects all threads, the MMU is traditionally configured by
the bootloader prior to starting Linux. The bootloader passes a
structure to Linux which among other things contains information about
memory regions which have been mapped. Linux then assumes control of the
local heap memory region.

A kernel arguments string pointer or a flattened device tree pointer can
be provided in the third argument.
Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
parent 87aa1328
vmlinux*
uImage*
ramdisk.*
*.dtb
/*
* arch/metag/include/asm/mach/arch.h
*
* Copyright (C) 2012 Imagination Technologies Ltd.
*
* based on the ARM version:
* Copyright (C) 2000 Russell King
*
* 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 _METAG_MACH_ARCH_H_
#define _METAG_MACH_ARCH_H_
#include <linux/stddef.h>
/**
* struct machine_desc - Describes a board controlled by a Meta.
* @name: Board/SoC name.
* @dt_compat: Array of device tree 'compatible' strings.
*
* @nr_irqs: Maximum number of IRQs.
* If 0, defaults to NR_IRQS in asm-generic/irq.h.
*
* @init_early: Early init callback.
* @init_irq: IRQ init callback for setting up IRQ controllers.
* @init_machine: Arch init callback for setting up devices.
* @init_late: Late init callback.
*
* This structure is provided by each board which can be controlled by a Meta.
* It is chosen by matching the compatible strings in the device tree provided
* by the bootloader with the strings in @dt_compat, and sets up any aspects of
* the machine that aren't configured with device tree (yet).
*/
struct machine_desc {
const char *name;
const char **dt_compat;
unsigned int nr_irqs;
void (*init_early)(void);
void (*init_irq)(void);
void (*init_machine)(void);
void (*init_late)(void);
};
/*
* Current machine - only accessible during boot.
*/
extern struct machine_desc *machine_desc;
/*
* Machine type table - also only accessible during boot
*/
extern struct machine_desc __arch_info_begin[], __arch_info_end[];
#define for_each_machine_desc(p) \
for (p = __arch_info_begin; p < __arch_info_end; p++)
static inline struct machine_desc *default_machine_desc(void)
{
/* the default machine is the last one linked in */
if (__arch_info_end - 1 < __arch_info_begin)
return NULL;
return __arch_info_end - 1;
}
/*
* Set of macros to define architecture features. This is built into
* a table by the linker.
*/
#define MACHINE_START(_type, _name) \
static const struct machine_desc __mach_desc_##_type \
__used \
__attribute__((__section__(".arch.info.init"))) = { \
.name = _name,
#define MACHINE_END \
};
#endif /* _METAG_MACH_ARCH_H_ */
#ifndef _ASM_METAG_SETUP_H
#define _ASM_METAG_SETUP_H
#include <uapi/asm/setup.h>
void per_cpu_trap_init(unsigned long);
extern void __init dump_machine_table(void);
#endif /* _ASM_METAG_SETUP_H */
! Copyright 2005,2006,2007,2009 Imagination Technologies
#include <linux/init.h>
#include <generated/asm-offsets.h>
#undef __exit
__HEAD
! Setup the stack and get going into _metag_start_kernel
.global __start
.type __start,function
__start:
! D1Ar1 contains pTBI (ISTAT)
! D0Ar2 contains pTBI
! D1Ar3 contains __pTBISegs
! D0Ar4 contains kernel arglist pointer
MOVT D0Re0,#HI(___pTBIs)
ADD D0Re0,D0Re0,#LO(___pTBIs)
SETL [D0Re0],D0Ar2,D1Ar1
MOVT D0Re0,#HI(___pTBISegs)
ADD D0Re0,D0Re0,#LO(___pTBISegs)
SETD [D0Re0],D1Ar3
MOV A0FrP,#0
MOV D0Re0,#0
MOV D1Re0,#0
MOV D1Ar3,#0
MOV D1Ar1,D0Ar4 !Store kernel boot params
MOV D1Ar5,#0
MOV D0Ar6,#0
#ifdef CONFIG_METAG_DSP
MOV D0.8,#0
#endif
MOVT A0StP,#HI(_init_thread_union)
ADD A0StP,A0StP,#LO(_init_thread_union)
ADD A0StP,A0StP,#THREAD_INFO_SIZE
MOVT D1RtP,#HI(_metag_start_kernel)
CALL D1RtP,#LO(_metag_start_kernel)
.size __start,.-__start
!! Needed by TBX
.global __exit
.type __exit,function
__exit:
XOR TXENABLE,D0Re0,D0Re0
.size __exit,.-__exit
/*
* arch/metag/kernel/machines.c
*
* Copyright (C) 2012 Imagination Technologies Ltd.
*
* Generic Meta Boards.
*/
#include <linux/init.h>
#include <asm/irq.h>
#include <asm/mach/arch.h>
static const char *meta_boards_compat[] __initdata = {
"img,meta",
NULL,
};
MACHINE_START(META, "Generic Meta")
.dt_compat = meta_boards_compat,
MACHINE_END
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment