aboutsummaryrefslogtreecommitdiffstats
path: root/lib/lufa/Projects/TempDataLogger/Lib/DataflashManager.h
diff options
context:
space:
mode:
authorKlemen Košir <klemen.kosir@kream.io>2019-05-29 03:05:07 +0900
committerDrashna Jaelre <drashna@live.com>2019-05-28 11:05:07 -0700
commitff6a57c3c320a2c73c0040337c677d8b2455c3ff (patch)
tree858352b935d9686fd3627705160b5e470fe3ca23 /lib/lufa/Projects/TempDataLogger/Lib/DataflashManager.h
parent7a7e3848c75536463fd5fea44620c3eb8085cc91 (diff)
downloadfirmware-ff6a57c3c320a2c73c0040337c677d8b2455c3ff.tar.gz
firmware-ff6a57c3c320a2c73c0040337c677d8b2455c3ff.tar.bz2
firmware-ff6a57c3c320a2c73c0040337c677d8b2455c3ff.zip
[Kenyboard] Add ansi_split_space_rshift layout to DZ60 (#6004)
* [DZ60] Add ansi_split_space_rshift layout * [DZ60] Add kream keymap * Revert spacebar sizes
Diffstat (limited to 'lib/lufa/Projects/TempDataLogger/Lib/DataflashManager.h')
0 files changed, 0 insertions, 0 deletions
ref='#n130'>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
/*
 * Intel CPU Microcode Update Driver for Linux
 *
 * Copyright (C) 2000-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
 *               2006      Shaohua Li <shaohua.li@intel.com> *
 * This driver allows to upgrade microcode on Intel processors
 * belonging to IA-32 family - PentiumPro, Pentium II,
 * Pentium III, Xeon, Pentium 4, etc.
 *
 * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture
 * Software Developer's Manual
 * Order Number 253668 or free download from:
 *
 * http://developer.intel.com/design/pentium4/manuals/253668.htm
 *
 * For more information, go to http://www.urbanmyth.org/microcode
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#include <xen/config.h>
#include <xen/lib.h>
#include <xen/kernel.h>
#include <xen/init.h>
#include <xen/sched.h>
#include <xen/smp.h>
#include <xen/spinlock.h>
#include <xen/guest_access.h>

#include <asm/current.h>
#include <asm/msr.h>
#include <asm/uaccess.h>
#include <asm/processor.h>
#include <asm/microcode.h>

const struct microcode_ops *microcode_ops;

static DEFINE_SPINLOCK(microcode_mutex);

struct ucode_cpu_info ucode_cpu_info[NR_CPUS];

struct microcode_info {
    unsigned int cpu;
    uint32_t buffer_size;
    int error;
    char buffer[1];
};

static void __microcode_fini_cpu(int cpu)
{
    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;

    xfree(uci->mc.mc_valid);
    memset(uci, 0, sizeof(*uci));
}

static void microcode_fini_cpu(int cpu)
{
    spin_lock(&microcode_mutex);
    __microcode_fini_cpu(cpu);
    spin_unlock(&microcode_mutex);
}

int microcode_resume_cpu(int cpu)
{
    int err = 0;
    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    struct cpu_signature nsig;

    gdprintk(XENLOG_INFO, "microcode: CPU%d resumed\n", cpu);

    if ( !uci->mc.mc_valid )
        return -EIO;

    /*
     * Let's verify that the 'cached' ucode does belong
     * to this cpu (a bit of paranoia):
     */
    err = microcode_ops->collect_cpu_info(cpu, &nsig);
    if ( err )
    {
        microcode_fini_cpu(cpu);
        return err;
    }

    if ( microcode_ops->microcode_resume_match(cpu, &nsig) )
    {
        return microcode_ops->apply_microcode(cpu);
    }
    else
    {
        microcode_fini_cpu(cpu);
        return -EIO;
    }
}

static int microcode_update_cpu(const void *buf, size_t size)
{
    int err;
    unsigned int cpu = smp_processor_id();
    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;

    spin_lock(&microcode_mutex);

    err = microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig);
    if ( likely(!err) )
        err = microcode_ops->cpu_request_microcode(cpu, buf, size);
    else
        __microcode_fini_cpu(cpu);

    spin_unlock(&microcode_mutex);

    return err;