aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/intel/cycloneiv
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2020-04-22 12:02:30 -0700
committerEddie Hung <eddie@fpgeh.com>2020-04-22 12:02:30 -0700
commit7f33a0294b7e6a299033cb4ee19bd86317737c08 (patch)
treeca0b9b1fcd28775c828c7be8dda1aec3d2ca97f7 /techlibs/intel/cycloneiv
parentdb27f2f3786fa867bf7524aff6a5b72c89932620 (diff)
downloadyosys-7f33a0294b7e6a299033cb4ee19bd86317737c08.tar.gz
yosys-7f33a0294b7e6a299033cb4ee19bd86317737c08.tar.bz2
yosys-7f33a0294b7e6a299033cb4ee19bd86317737c08.zip
Cleanup use of hard-coded default parameters in light of #1945
Diffstat (limited to 'techlibs/intel/cycloneiv')
0 files changed, 0 insertions, 0 deletions
='#n104'>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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
/******************************************************************************
 * kernel.c
 * 
 * Copyright (c) 2002-2005 K A Fraser
 */

#include <xen/config.h>
#include <xen/init.h>
#include <xen/lib.h>
#include <xen/errno.h>
#include <xen/compile.h>
#include <xen/sched.h>
#include <xen/shadow.h>
#include <xen/guest_access.h>
#include <asm/current.h>
#include <public/nmi.h>
#include <public/version.h>

int tainted;

void cmdline_parse(char *cmdline)
{
    char opt[100], *optval, *p = cmdline, *q;
    struct kernel_param *param;
    
    if ( p == NULL )
        return;

    /* Skip whitespace and the image name. */
    while ( *p == ' ' )
        p++;
    if ( (p = strchr(p, ' ')) == NULL )
        return;

    for ( ; ; )
    {
        /* Skip whitespace. */
        while ( *p == ' ' )
            p++;
        if ( *p == '\0' )
            break;

        /* Grab the next whitespace-delimited option. */
        q = opt;
        while ( (*p != ' ') && (*p != '\0') )
            *q++ = *p++;
        *q = '\0';

        /* Search for value part of a key=value option. */
        optval = strchr(opt, '=');
        if ( optval != NULL )
            *optval++ = '\0';

        for ( param = &__setup_start; param <= &__setup_end; param++ )
        {
            if ( strcmp(param->name, opt ) != 0 )
                continue;

            switch ( param->type )
            {
            case OPT_STR:
                if ( optval != NULL )
                {
                    strncpy(param->var, optval, param->len);
                    ((char *)param->var)[param->len-1] = '\0';
                }
                break;
            case OPT_UINT:
                if ( optval != NULL )
                    *(unsigned int *)param->var =
                        simple_strtol(optval, (char **)&optval, 0);
                break;
            case OPT_BOOL:
                *(int *)param->var = 1;
                break;
            case OPT_CUSTOM:
                if ( optval != NULL )
                    ((void (*)(char *))param->var)(optval);
                break;
            }
        }
    }
}

/**
 *      print_tainted - return a string to represent the kernel taint state.
 *
 *  'S' - SMP with CPUs not designed for SMP.
 *  'M' - Machine had a machine check experience.
 *  'B' - System has hit bad_page.
 *
 *      The string is overwritten by the next call to print_taint().
 */
char *print_tainted(char *str)
{
    if ( tainted )
    {
        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c",
                 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
                 tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
                 tainted & TAINT_BAD_PAGE ? 'B' : ' ');
    }
    else
    {
        snprintf(str, TAINT_STRING_MAX_LEN, "Not tainted");
    }

    return str;
}

void add_taint(unsigned flag)
{
    tainted |= flag;
}

/*
 * Simple hypercalls.
 */

long do_xen_version(int cmd, GUEST_HANDLE(void) arg)
{
    switch ( cmd )
    {
    case XENVER_version:
    {
        return (XEN_VERSION<<16) | (XEN_SUBVERSION);
    }

    case XENVER_extraversion:
    {
        xen_extraversion_t extraversion;
        safe_strcpy(extraversion, XEN_EXTRAVERSION);
        if ( copy_to_guest(arg, (char *)extraversion, sizeof(extraversion)) )
            return -EFAULT;
        return 0;
    }

    case XENVER_compile_info:
    {
        struct xen_compile_info info;
        safe_strcpy(info.compiler,       XEN_COMPILER);
        safe_strcpy(info.compile_by,     XEN_COMPILE_BY);
        safe_strcpy(info.compile_domain, XEN_COMPILE_DOMAIN);
        safe_strcpy(info.compile_date,   XEN_COMPILE_DATE);
        if ( copy_to_guest(arg, &info, 1) )
            return -EFAULT;
        return 0;
    }

    case XENVER_capabilities:
    {
        xen_capabilities_info_t info;
        extern void arch_get_xen_caps(xen_capabilities_info_t info);

        memset(info, 0, sizeof(info));
        arch_get_xen_caps(info);

        if ( copy_to_guest(arg, (char *)info, sizeof(info)) )
            return -EFAULT;
        return 0;
    }
    
    case XENVER_platform_parameters:
    {
        xen_platform_parameters_t params = {
            .virt_start = HYPERVISOR_VIRT_START
        };
        if ( copy_to_guest(arg, &params, 1) )
            return -EFAULT;
        return 0;
        
    }
    
    case XENVER_changeset:
    {
        xen_changeset_info_t chgset;
        safe_strcpy(chgset, XEN_CHANGESET);
        if ( copy_to_guest(arg, (char *)chgset, sizeof(chgset)) )
            return -EFAULT;
        return 0;
    }

    case XENVER_get_features:
    {
        xen_feature_info_t fi;

        if ( copy_from_guest(&fi, arg, 1) )
            return -EFAULT;

        switch ( fi.submap_idx )
        {
        case 0:
            fi.submap = 0;
            if ( shadow_mode_translate(current->domain) )
                fi.submap |= 
                    (1U << XENFEAT_writable_page_tables) |
                    (1U << XENFEAT_auto_translated_physmap) |
                    (1U << XENFEAT_pae_pgdir_above_4gb);
            if ( supervisor_mode_kernel )
                fi.submap |= 1U << XENFEAT_supervisor_mode_kernel;
            break;
        default:
            return -EINVAL;
        }

        if ( copy_to_guest(arg, &fi, 1) )
            return -EFAULT;
        return 0;
    }

    }

    return -ENOSYS;
}

long register_guest_nmi_callback(unsigned long address)
{
    struct vcpu *v = current;
    struct domain *d = current->domain;

    if ( (d->domain_id != 0) || (v->vcpu_id != 0) )
        return -EINVAL;

    v->nmi_addr = address;
#ifdef CONFIG_X86
    /*
     * If no handler was registered we can 'lose the NMI edge'. Re-assert it
     * now.
     */
    if ( d->shared_info->arch.nmi_reason != 0 )
        set_bit(_VCPUF_nmi_pending, &v->vcpu_flags);
#endif

    return 0;
}

long unregister_guest_nmi_callback(void)
{
    struct vcpu *v = current;

    v->nmi_addr = 0;

    return 0;
}

long do_nmi_op(unsigned int cmd, GUEST_HANDLE(void) arg)
{
    struct xennmi_callback cb;
    long rc = 0;