aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32/STM32F37x/ADC/chconf.h
diff options
context:
space:
mode:
Diffstat (limited to 'testhal/STM32/STM32F37x/ADC/chconf.h')
0 files changed, 0 insertions, 0 deletions
53'>53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
/******************************************************************************
 * machine_kexec.c
 *
 * Based on arch/ia64/kernel/machine_kexec.c from Linux 2.6.20-rc1
 *
 * Xen port written by:
 * - Simon 'Horms' Horman <horms@verge.net.au>
 * - Magnus Damm <magnus@valinux.co.jp>
 */

#include <asm/smp.h>
#include <xen/lib.h>
#include <xen/types.h>
#include <xen/smp.h>
#include <xen/acpi.h>
#include <public/kexec.h>
#include <linux/efi.h>
#include <asm/delay.h>
#include <asm/meminit.h>
#include <asm/hw_irq.h>
#include <asm/kexec.h>
#include <asm/vhpt.h>
#include <linux/cpu.h>
#include <linux/cpu.h>
#include <linux/notifier.h>
#include <asm/dom_fw_dom0.h>
#include <asm-generic/sections.h>

#define kexec_flush_icache_page(page)					\
do {									\
	unsigned long page_addr = (unsigned long)page_address(page);	\
	flush_icache_range(page_addr, page_addr + PAGE_SIZE);		\
} while(0)

int machine_kexec_load(int type, int slot, xen_kexec_image_t *image)
{
	return 0;
}

void machine_kexec_unload(int type, int slot, xen_kexec_image_t *image)
{
}

static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
{
	xen_kexec_image_t *image = arg;
	int ii;

	/* Interrupts aren't acceptable while we reboot */
	local_irq_disable();

	/* Mask CMC and Performance Monitor interrupts */
	ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
	ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);

	/* Mask ITV and Local Redirect Registers */
	ia64_set_itv(1 << 16);
	ia64_set_lrr0(1 << 16);
	ia64_set_lrr1(1 << 16);

	/* terminate possible nested in-service interrupts */
	for (ii = 0; ii < 16; ii++)
		ia64_eoi();

	/* unmask TPR and clear any pending interrupts */
	ia64_setreg(_IA64_REG_CR_TPR, 0);
	ia64_srlz_d();
	while (ia64_get_ivr() != IA64_SPURIOUS_INT_VECTOR)
		ia64_eoi();
	platform_kernel_launch_event();
	relocate_new_kernel(image->indirection_page, image->start_address,
			    __pa(ia64_boot_param), image->reboot_code_buffer);
	BUG();
}

#if CONFIG_SMP
/* Need to implement some subset of hotplug-cpu - enough to
 * send a cpu into rendevouz */

/* N.B: The tasks frozen parameter can probably be dropped
 *      This can probably be rolled into cpu_down
 */
static int _cpu_down(unsigned int cpu, int tasks_frozen)
{
	if (num_online_cpus() == 1)
		return -EBUSY;

	if (!cpu_online(cpu))
		return -EINVAL;

#ifndef XEN
	/* XXX: What, if anything, should Xen do here? */
	/* Ensure that we are not runnable on dying cpu */
	old_affinity = current->cpus_allowed;
	tmp = CPU_MASK_ALL;
	cpu_clear(cpu, tmp);
       set_cpus_allowed(current, tmp);
#endif

	cpu_clear(cpu, cpu_online_map);

	__cpu_die(cpu);

	return 0;
}

static int cpu_down(unsigned int cpu)
{
	int err;

	/* Unlike Linux there is no lock, as there are no other callers
	 * and no other CPUS. */
	err = _cpu_down(cpu, 0);

	return 0;
}
#endif /* SMP */

/* This should probably be an arch-hook called from kexec_exec()
 * Its also likely that it should be in the xen equivalent of
 * arch/ia64/kernel/process.c */
static void machine_shutdown(void)
{
#ifdef CONFIG_SMP
	unsigned int cpu;

	for_each_online_cpu(cpu) {
		if (cpu != smp_processor_id())
			cpu_down(cpu);
	}
#endif
	kexec_disable_iosapic();
	acpi_restore_tables();
}

void machine_kexec(xen_kexec_image_t *image)
{
	machine_shutdown();
	unw_init_running(ia64_machine_kexec, image);
	for(;;);
}

void machine_reboot_kexec(xen_kexec_image_t *image)
{
	machine_kexec(image);
}

static int machine_kexec_get_xen(xen_kexec_range_t *range)
{
	range->start = range->start = ia64_tpa(_text);
	range->size = (unsigned long)_end - (unsigned long)_text;
	return 0;
}

#define ELF_PAGE_SHIFT 16
#define ELF_PAGE_SIZE  (__IA64_UL_CONST(1) << ELF_PAGE_SHIFT)
#define ELF_PAGE_MASK  (~(ELF_PAGE_SIZE - 1))

static int machine_kexec_get_xenheap(xen_kexec_range_t *range)
{
	range->start = (ia64_tpa(_end) + (ELF_PAGE_SIZE - 1)) & ELF_PAGE_MASK;
	range->size = (unsigned long)xenheap_phys_end -
		      (unsigned long)range->start;
	return 0;
}

static int machine_kexec_get_boot_param(xen_kexec_range_t *range)
{
	range->start = __pa(ia64_boot_param);
	range->size = sizeof(*ia64_boot_param);
	return 0;
}

static int machine_kexec_get_efi_memmap(xen_kexec_range_t *range)
{
	range->start = ia64_boot_param->efi_memmap;
	range->size = ia64_boot_param->efi_memmap_size;
	return 0;
}

int machine_kexec_get(xen_kexec_range_t *range)
{
	switch (range->range) {
	case KEXEC_RANGE_MA_XEN:
		return machine_kexec_get_xen(range);
	case KEXEC_RANGE_MA_XENHEAP:
		return machine_kexec_get_xenheap(range);
	case KEXEC_RANGE_MA_BOOT_PARAM:
		return machine_kexec_get_boot_param(range);
	case KEXEC_RANGE_MA_EFI_MEMMAP:
		return machine_kexec_get_efi_memmap(range);
	}
	return -EINVAL;
}

/*
 * Local variables:
 * mode: C
 * c-set-style: "BSD"
 * c-basic-offset: 4
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:
 */