aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/linux/modules/input.mk
diff options
context:
space:
mode:
authorMichal Cieslakiewicz <michal.cieslakiewicz@wp.pl>2019-10-30 12:32:21 +0100
committerJohn Crispin <john@phrozen.org>2019-11-02 20:51:56 +0100
commitcd87272eb241b1ea7955c1631ad2bb8d38e9fae9 (patch)
tree6b92ef0a989c57c785d9adf6146781904cd4c667 /package/kernel/linux/modules/input.mk
parent87f9292300cf56ad17f44363ced213c59a95ef44 (diff)
downloadupstream-cd87272eb241b1ea7955c1631ad2bb8d38e9fae9.tar.gz
upstream-cd87272eb241b1ea7955c1631ad2bb8d38e9fae9.tar.bz2
upstream-cd87272eb241b1ea7955c1631ad2bb8d38e9fae9.zip
ath79: add support for Netgear WNDR4300
This patch adds ath79 support for Netgear WNDR4300. Router was previously supported by ar71xx target only. Note: device requires 'ar934x-nand' driver in kernel. Specification ============= * Description: Netgear WNDR4300 * Loader: U-boot * SOC: Atheros AR9344 (560 MHz) * RAM: 128 MiB * Flash: 128 MiB (NAND) - U-boot binary: 256 KiB - U-boot environment: 256 KiB - ART: 256 KiB - POT: 512 KiB - Language: 2 MiB - Config: 512 KiB - Traffic Meter: 3 MiB - Firmware: 25 MiB - ART Backup: 256 KiB - Reserved: 96 MiB * Ethernet: 5 x 10/100/1000 (4 x LAN, 1 x WAN) (AR8327) * Wireless: - 2.4 GHz b/g/n (internal) - 5 GHz a/n (AR9580) * USB: yes, 1 x USB 2.0 * Buttons: - Reset - WiFi (rfkill) - WPS * LEDs: - Power (amber/green) - WAN (amber/green) - WLAN 2G (green) - WLAN 5G (blue) - 4 x LAN (amber/green) - USB (green) - WPS (amber/green) * UART: 4-pin connector JP1, 3.3V (Vcc, TX, RX, GND), 115200 8N1 * Power supply: DC 12V 2.5A * MAC addresses: LAN=WLAN2G on case label, WAN +1, WLAN5G +2 Installation ============ * TFTP recovery * TFTP via U-boot prompt * sysupgrade * Web interface Note about partitioning: firmware partition offset (0x6c0000) is hardcoded into vendor's u-boot, so this partition cannot be moved and resized to include Netgear-specific flash areas (pot, language, config, traffic_meter) not used by OpenWrt. Test build configuration ======================== CONFIG_TARGET_ath79=y CONFIG_TARGET_ath79_nand=y CONFIG_TARGET_ath79_nand_DEVICE_netgear_wndr4300=y CONFIG_ALL_KMODS=y CONFIG_DEVEL=y CONFIG_CCACHE=y CONFIG_COLLECT_KERNEL_DEBUG=y CONFIG_IMAGEOPT=y Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
Diffstat (limited to 'package/kernel/linux/modules/input.mk')
0 files changed, 0 insertions, 0 deletions
'#n178'>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 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
/******************************************************************************
 * arch/x86/x86_32/seg_fixup.c
 * 
 * Support for -ve accesses to pseudo-4GB segments.
 * 
 * Copyright (c) 2004, K A Fraser
 * 
 * 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.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <xen/config.h>
#include <xen/init.h>
#include <xen/sched.h>
#include <xen/lib.h>
#include <xen/errno.h>
#include <xen/mm.h>
#include <xen/perfc.h>
#include <asm/processor.h>
#include <asm/x86_emulate.h>

/* Make the scary benign errors go away. */
#undef  DPRINTK
#define DPRINTK(_f, _a...) ((void)0)

/* General instruction properties. */
#define INSN_SUFFIX_BYTES (7)
#define OPCODE_BYTE       (1<<4)  
#define HAS_MODRM         (1<<5)

/* Short forms for the table. */
#define X  0 /* invalid for some random reason */
#define O  OPCODE_BYTE
#define M  HAS_MODRM

static unsigned char insn_decode[256] = {
    /* 0x00 - 0x0F */
    O|M, O|M, O|M, O|M, X, X, X, X,
    O|M, O|M, O|M, O|M, X, X, X, X,
    /* 0x10 - 0x1F */
    O|M, O|M, O|M, O|M, X, X, X, X,
    O|M, O|M, O|M, O|M, X, X, X, X,
    /* 0x20 - 0x2F */
    O|M, O|M, O|M, O|M, X, X, X, X,
    O|M, O|M, O|M, O|M, X, X, X, X,
    /* 0x30 - 0x3F */
    O|M, O|M, O|M, O|M, X, X, X, X,
    O|M, O|M, O|M, O|M, X, X, X, X,
    /* 0x40 - 0x4F */
    X, X, X, X, X, X, X, X,
    X, X, X, X, X, X, X, X,
    /* 0x50 - 0x5F */
    X, X, X, X, X, X, X, X,
    X, X, X, X, X, X, X, X,
    /* 0x60 - 0x6F */
    X, X, X, X, X, X, X, X,
    X, O|M|4, X, O|M|1, X, X, X, X,
    /* 0x70 - 0x7F */
    X, X, X, X, X, X, X, X,
    X, X, X, X, X, X, X, X,
    /* 0x80 - 0x8F */
    O|M|1, O|M|4, O|M|1, O|M|1, O|M, O|M, O|M, O|M,
    O|M, O|M, O|M, O|M, O|M, O|M, O|M, X,
    /* 0x90 - 0x9F */
    X, X, X, X, X, X, X, X,
    X, X, X, X, X, X, X, X,
    /* 0xA0 - 0xAF */
    O|4, O|4, O|4, O|4, X, X, X, X,
    X, X, X, X, X, X, X, X,
    /* 0xB0 - 0xBF */
    X, X, X, X, X, X, X, X,
    X, X, X, X, X, X, X, X,
    /* 0xC0 - 0xCF */
    O|M|1, O|M|1, X, X, X, X, O|M|1, O|M|4,
    X, X, X, X, X, X, X, X,
    /* 0xD0 - 0xDF */
    O|M, O|M, O|M, O|M, X, X, X, X,
    X, X, X, X, X, X, X, X,
    /* 0xE0 - 0xEF */
    X, X, X, X, X, X, X, X,
    X, X, X, X, X, X, X, X,
    /* 0xF0 - 0xFF */
    X, X, X, X, X, X, X, X,
    X, X, X, X, X, X, O|M, O|M
};

/*
 * Obtain the base and limit associated with the given segment selector.
 * The selector must identify a 32-bit code or data segment. Any segment that
 * appears to be truncated to not overlap with Xen is assumed to be a truncated
 * 4GB segment, and the returned limit reflects this.
 *  @seg   (IN) : Segment selector to decode.
 *  @base  (OUT): Decoded linear base address.
 *  @limit (OUT): Decoded segment limit, in bytes. 0 == unlimited (4GB).
 */
int get_baselimit(u16 seg, unsigned long *base, unsigned long *limit)
{
    struct exec_domain *d = current;
    unsigned long *table, a, b;
    int            ldt = !!(seg & 4);
    int            idx = (seg >> 3) & 8191;

    /* Get base and check limit. */
    if ( ldt )
    {
        table = (unsigned long *)LDT_VIRT_START(d);
        if ( idx >= d->arch.ldt_ents )
            goto fail;
    }
    else /* gdt */
    {
        table = (unsigned long *)GET_GDT_ADDRESS(d);
        if ( idx >= GET_GDT_ENTRIES(d) )
            goto fail;
    }

    /* Grab the segment descriptor. */
    if ( __get_user(a, &table[2*idx+0]) ||
         __get_user(b, &table[2*idx+1]) )
        goto fail; /* Barking up the wrong tree. Decode needs a page fault.*/

    /* We only parse 32-bit code and data segments. */
    if ( (b & (_SEGMENT_P|_SEGMENT_S|_SEGMENT_DB)) != 
         (_SEGMENT_P|_SEGMENT_S|_SEGMENT_DB) )
        goto fail;

    /* Decode base and limit. */
    *base  = (b&(0xff<<24)) | ((b&0xff)<<16) | (a>>16);
    *limit = ((b & 0xf0000) | (a & 0x0ffff)) + 1;
    if ( (b & _SEGMENT_G) )
        *limit <<= 12;

    /*
     * Anything that looks like a truncated segment we assume ought really
     * to be a 4GB segment. DANGER!
     */
    if ( (GUEST_SEGMENT_MAX_ADDR - (*base + *limit)) < PAGE_SIZE )
        *limit = 0;

    return 1;

 fail:
    return 0;
}

/* Turn a segment+offset into a linear address. */
int linearise_address(u16 seg, unsigned long off, unsigned long *linear)
{
    unsigned long base, limit;

    if ( !get_baselimit(seg, &base, &limit) )
        return 0;

    if ( off > (limit-1) )
        return 0;

    *linear = base + off;

    return 1;
}

int fixup_seg(u16 seg, unsigned long offset)
{
    struct exec_domain *d = current;
    unsigned long *table, a, b, base, limit;
    int            ldt = !!(seg & 4);
    int            idx = (seg >> 3) & 8191;

    /* Get base and check limit. */
    if ( ldt )
    {
        table = (unsigned long *)LDT_VIRT_START(d);
        if ( idx >= d->arch.ldt_ents )
        {
            DPRINTK("Segment %04x out of LDT range (%ld)\n",
                    seg, d->arch.ldt_ents);
            goto fail;
        }
    }
    else /* gdt */
    {
        table = (unsigned long *)GET_GDT_ADDRESS(d);
        if ( idx >= GET_GDT_ENTRIES(d) )
        {
            DPRINTK("Segment %04x out of GDT range (%d)\n",
                    seg, GET_GDT_ENTRIES(d));
            goto fail;
        }
    }

    /* Grab the segment descriptor. */
    if ( __get_user(a, &table[2*idx+0]) ||
         __get_user(b, &table[2*idx+1]) )
    {
        DPRINTK("Fault while reading segment %04x\n", seg);
        goto fail; /* Barking up the wrong tree. Decode needs a page fault.*/
    }

    /* We only parse 32-bit page-granularity non-privileged data segments. */
    if ( (b & (_SEGMENT_P|_SEGMENT_S|_SEGMENT_DB|
               _SEGMENT_G|_SEGMENT_CODE|_SEGMENT_DPL)) != 
         (_SEGMENT_P|_SEGMENT_S|_SEGMENT_DB|_SEGMENT_G|_SEGMENT_DPL) )
    {
        DPRINTK("Bad segment %08lx:%08lx\n", a, b);
        goto fail;
    }

    /* Decode base and limit. */
    base  = (b&(0xff<<24)) | ((b&0xff)<<16) | (a>>16);
    limit = (((b & 0xf0000) | (a & 0x0ffff)) + 1) << 12;

    if ( b & _SEGMENT_EC )
    {
        /* Expands-down: All the way to zero? Assume 4GB if so. */
        if ( ((base + limit) < PAGE_SIZE) && (offset <= limit)  )
        {
            /* Flip to expands-up. */
            limit = GUEST_SEGMENT_MAX_ADDR - base;
            goto flip;
        }
    }
    else
    {
        /* Expands-up: All the way to Xen space? Assume 4GB if so. */
        if ( ((GUEST_SEGMENT_MAX_ADDR - (base + limit)) < PAGE_SIZE) &&
             (offset > limit) )
        {
            /* Flip to expands-down. */
            limit = -(base & PAGE_MASK);
            goto flip;
        }
    }

    DPRINTK("None of the above! (%08lx:%08lx, %08lx, %08lx, %08lx)\n", 
            a, b, base, limit, base+limit);

 fail:
    return 0;

 flip:
    limit = (limit >> 12) - 1;
    a &= ~0x0ffff; a |= limit & 0x0ffff;
    b &= ~0xf0000; b |= limit & 0xf0000;
    b ^= _SEGMENT_EC; /* grows-up <-> grows-down */
    /* NB. These can't fault. Checked readable above; must also be writable. */
    table[2*idx+0] = a;
    table[2*idx+1] = b;
    return 1;
}

/*
 * Called from the general-protection fault handler to attempt to decode
 * and emulate an instruction that depends on 4GB segments.
 */
int gpf_emulate_4gb(struct xen_regs *regs)
{
    struct exec_domain *d = current;
    trap_info_t   *ti;
    struct trap_bounce *tb;
    u8            modrm, mod, reg, rm, decode;
    void         *memreg, *regreg;
    unsigned long offset;
    u8            disp8;
    u32           disp32 = 0;
    u8            *eip;         /* ptr to instruction start */
    u8            *pb, b;       /* ptr into instr. / current instr. byte */
    u32           *pseg = NULL; /* segment for memory operand (NULL=default) */

    /* WARNING: We only work for ring-3 segments. */
    if ( unlikely(VM86_MODE(regs)) || unlikely(!RING_3(regs)) )
    {
        DPRINTK("Taken fault at bad CS %04x\n", regs->cs);
        goto fail;
    }

    if ( !linearise_address((u16)regs->cs, regs->eip, (unsigned long *)&eip) )
    {
        DPRINTK("Cannot linearise %04x:%08x\n", regs->cs, regs->eip);
        goto fail;
    }

    /* Parse prefix bytes. We're basically looking for segment override. */
    for ( pb = eip; ; pb++ )
    {
        if ( get_user(b, pb) )
        {
            DPRINTK("Fault while accessing byte %d of instruction\n", pb-eip);
            goto page_fault;
        }

        if ( (pb - eip) >= 15 )
        {
            DPRINTK("Too many instruction prefixes for a legal instruction\n");
            goto fail;
        }

        switch ( b )
        {
        case 0x67: /* Address-size override */
            DPRINTK("Unhandleable prefix byte %02x\n", b);
            goto fixme;
        case 0x66: /* Operand-size override */
        case 0xf0: /* LOCK */
        case 0xf2: /* REPNE/REPNZ */
        case 0xf3: /* REP/REPE/REPZ */
            break;
        case 0x2e: /* CS override */
            pseg = &regs->cs;
            break;
        case 0x3e: /* DS override */
            pseg = &regs->ds;
            break;
        case 0x26: /* ES override */
            pseg = &regs->es;
            break;
        case 0x64: /* FS override */
            pseg = &regs->fs;
            break;
        case 0x65: /* GS override */
            pseg = &regs->gs;
            break;
        case 0x36: /* SS override */
            pseg = &regs->ss;
            break;
        default: /* Not a prefix byte */
            goto done_prefix;
        }
    }
 done_prefix:

    decode = insn_decode[b]; /* opcode byte */
    pb++;
    if ( decode == 0 )
    {
        DPRINTK("Unsupported opcode %02x\n", b);
        goto fail;
    }
    
    if ( !(decode & HAS_MODRM) )
    {
        if ( (decode & 7) != 4 )
            goto fail;

        if ( get_user(offset, (u32 *)pb) )
        {
            DPRINTK("Fault while extracting <disp8>.\n");
            goto page_fault;
        }
        pb += 4;

        goto skip_modrm;
    }

    /*
     * Mod/RM processing.
     */

    if ( get_user(modrm, pb) )
    {
        DPRINTK("Fault while extracting modrm byte\n");
        goto page_fault;
    }

    pb++;

    mod = (modrm >> 6) & 3;
    reg = (modrm >> 3) & 7;
    rm  = (modrm >> 0) & 7;

    if ( rm == 4 )
    {
        DPRINTK("FIXME: Add decoding for the SIB byte.\n");
        goto fixme;
    }

    /* Decode Reg and R/M fields. */
    regreg = decode_register(reg, regs, 0);
    memreg = decode_register(rm,  regs, 0);

    /* Decode Mod field. */
    switch ( modrm >> 6 )
    {
    case 0:
        if ( pseg == NULL )
            pseg = &regs->ds;
        disp32 = 0;
        if ( rm == 5 ) /* disp32 rather than (EBP) */
        {
            memreg = NULL;
            if ( get_user(disp32, (u32 *)pb) )
            {
                DPRINTK("Fault while extracting <disp8>.\n");
                goto page_fault;
            }
            pb += 4;
        }
        break;

    case 1:
        if ( pseg == NULL ) /* NB. EBP defaults to SS */
            pseg = (rm == 5) ? &regs->ss : &regs->ds;
        if ( get_user(disp8, pb) )
        {
            DPRINTK("Fault while extracting <disp8>.\n");
            goto page_fault;
        }
        pb++;
        disp32 = (disp8 & 0x80) ? (disp8 | ~0xff) : disp8;;
        break;

    case 2:
        if ( pseg == NULL ) /* NB. EBP defaults to SS */
            pseg = (rm == 5) ? &regs->ss : &regs->ds;
        if ( get_user(disp32, (u32 *)pb) )
        {
            DPRINTK("Fault while extracting <disp8>.\n");
            goto page_fault;
        }
        pb += 4;
        break;

    case 3:
        DPRINTK("Not a memory operand!\n");
        goto fail;
    }

    offset = disp32;
    if ( memreg != NULL )
        offset += *(u32 *)memreg;

 skip_modrm:
    if ( !fixup_seg((u16)(*pseg), offset) )
        goto fail;

    /* Success! */
    perfc_incrc(seg_fixups);

    /* If requested, give a callback on otherwise unused vector 15. */
    if ( VM_ASSIST(d->domain, VMASST_TYPE_4gb_segments_notify) )
    {
        ti  = &d->arch.traps[15];
        tb  = &d->arch.trap_bounce;
        tb->flags      = TBF_EXCEPTION | TBF_EXCEPTION_ERRCODE;
        tb->error_code = pb - eip;
        tb->cs         = ti->cs;
        tb->eip        = ti->address;
        if ( TI_GET_IF(ti) )
            d->vcpu_info->evtchn_upcall_mask = 1;
    }

    return EXCRET_fault_fixed;

 fixme:
    DPRINTK("Undecodable instruction %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x "
            "caused GPF(0) at %04x:%08x\n",
            eip[0], eip[1], eip[2], eip[3],
            eip[4], eip[5], eip[6], eip[7],
            regs->cs, regs->eip);
 fail:
    return 0;

 page_fault:
    propagate_page_fault((unsigned long)pb, 4);
    return EXCRET_fault_fixed;
}

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