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LDB9LCAvKiAxMTAgKi8KKwl7MCwwfSwgLyogMTM0ICovCisJezAsMH0sIC8qIDE1MCAqLworCXswLDB9LCAvKiAyMDAgKi8KKwl7NywweDI2fSwgLyogMzAwICovCisJezYsMHgyNn0sIC8qIDYwMCAqLworCXs1LDB4MjZ9LCAvKiAxMjAwICovCisJezAsMH0sIC8qIDE4MDAgKi8KKwl7NCwweDI2fSwgLyogMjQwMCAqLworCXszLDB4MjZ9LCAvKiA0ODAwICovCisJezIsMHgyNn0sIC8qIDk2MDAgKi8KKwl7MSwweDI2fSwgLyogMTkyMDAgKi8KKwl7MCwweDI2fSwgLyogMzg0MDAgKi8KKwl7MSwweDM4fSwgLyogNTc2MDAgKi8KKwl7MCwweDM4fSwgLyogMTE1MjAwICovCit9OworI2Vsc2UKKyBod19iYXVkX3RhYmxlWzE4XSA9IHsKKyAgICAgICAgICAgICAgICAgezAsMH0sIC8qIDAgKi8KKyAgICAgICAgICAgICAgICAgezAsMH0sIC8qIDUwICovCisgICAgICAgICAgICAgICAgIHswLDB9LCAvKiA3NSAqLworICAgICAgICAgICAgICAgICB7MCwwfSwgLyogMTEwICovCisgICAgICAgICAgICAgICAgIHswLDB9LCAvKiAxMzQgKi8KKyAgICAgICAgICAgICAgICAgezAsMH0sIC8qIDE1MCAqLworICAgICAgICAgICAgICAgICB7MCwwfSwgLyogMjAwICovCisgICAgICAgICAgICAgICAgIHswLDB9LCAvKiAzMDAgKi8KKyAgICAgICAgICAgICAgICAgezcsMHgyNn0sIC8qIDYwMCAqLworICAgICAgICAgICAgICAgICB7NiwweDI2fSwgLyogMTIwMCAqLworICAgICAgICAgICAgICAgICB7MCwwfSwgLyogMTgwMCAqLworICAgICAgICAgICAgICAgICB7NSwweDI2fSwgLyogMjQwMCAqLworICAgICAgICAgICAgICAgICB7NCwweDI2fSwgLyogNDgwMCAqLworICAgICAgICAgICAgICAgICB7MywweDI2fSwgLyogOTYwMCAqLworICAgICAgICAgICAgICAgICB7MiwweDI2fSwgL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BpbiAyLjAuCisgKiBUcnkgdG8gZ2V0IGJ5IHdpdGggc2VyaWFsX3N0cnVjdAorICovCisvKiAjZGVmaW5lIHNlcmlhbF9zdGF0ZSBzZXJpYWxfc3RydWN0ICovCisKKy8qIDIuNCAtPiAyLjAgcG9ydGFiaWxpdHkgcHJvYmxlbTogYXN5bmNfaWNvdW50IGluIDIuNCBoYXMgYSBmZXcKKyAqIGV4dHJhczogKi8KKworI2lmIDAKK3N0cnVjdCBhc3luY19pY291bnRfMjQgeworCV9fdTMyICAgY3RzLCBkc3IsIHJuZywgZGNkLCB0eCwgcng7CisJX191MzIgICBmcmFtZSwgcGFyaXR5LCBvdmVycnVuLCBicms7CisJX191MzIgICBidWZfb3ZlcnJ1bjsKK30gaWNvdW50OworI2VuZGlmCisKKyNpZiAwCisKK3N0cnVjdCBzZXJpYWxfc3RhdGUgeworICAgICAgICBpbnQgICAgIG1hZ2ljOworICAgICAgICBpbnQgICAgIGJhdWRfYmFzZTsKKyAgICAgICAgdW5zaWduZWQgbG9uZyAgIHBvcnQ7CisgICAgICAgIGludCAgICAgaXJxOworICAgICAgICBpbnQgICAgIGZsYWdzOworICAgICAgICBpbnQgICAgIGh1YjY7CisgICAgICAgIGludCAgICAgdHlwZTsKKyAgICAgICAgaW50ICAgICBsaW5lOworICAgICAgICBpbnQgICAgIHJldmlzaW9uOyAgICAgICAvKiBDaGlwIHJldmlzaW9uICg5NTApICovCisgICAgICAgIGludCAgICAgeG1pdF9maWZvX3NpemU7CisgICAgICAgIGludCAgICAgY3VzdG9tX2Rpdmlzb3I7CisgICAgICAgIGludCAgICAgY291bnQ7CisgICAgICAgIHU4ICAgICAgKmlvbWVtX2Jhc2U7CisgICAgICAgIHUxNiAgICAgaW9tZW1fcmVnX3NoaWZ0OworICAgICAgICB1bnNpZ25lZCBzaG9ydCAgY2xvc2VfZGVsYXk7CisgICAgICAgIHVuc2lnbmVkIHNob3J0ICBjbG9zaW5nX3dhaXQ7IC8qIHRpbWUgdG8gd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HVzICYgQkRfU0NfV1JBUCkgeworCQkJCWJkcCA9IGJkYmFzZTsKKwkJCX0KKwkJCWVsc2UgeworCQkJCWJkcCsrOworCQkJfQorCQl9CisJfQorCisJLyoKKwkgKiBGaW5hbGx5LCBXYWl0IGZvciB0cmFuc21pdHRlciAmIGhvbGRpbmcgcmVnaXN0ZXIgdG8gZW1wdHkKKwkgKiAgYW5kIHJlc3RvcmUgdGhlIElFUgorCSAqLworCXdoaWxlIChiZHAtPnN0YXR1cyAmIEJEX1NDX1JFQURZKTsKKworCWlmIChpbmZvKQorCQlpbmZvLT50eF9jdXIgPSAoUVVJQ0NfQkQgKiliZHA7Cit9CisKK3N0YXRpYyB2b2lkIHNlcmlhbF9jb25zb2xlX3dyaXRlKHN0cnVjdCBjb25zb2xlICpjLCBjb25zdCBjaGFyICpzLAorCQkJCXVuc2lnbmVkIGNvdW50KQoreworI2lmZGVmIENPTkZJR19LR0RCCisJLyogVHJ5IHRvIGxldCBzdHViIGhhbmRsZSBvdXRwdXQuIFJldHVybnMgdHJ1ZSBpZiBpdCBkaWQuICovIAorCWlmIChrZ2RiX291dHB1dF9zdHJpbmcocywgY291bnQpKQorCQlyZXR1cm47CisjZW5kaWYKKwlteV9jb25zb2xlX3dyaXRlKGMtPmluZGV4LCBzLCBjb3VudCk7Cit9CisKKworCisvKnZvaWQgY29uc29sZV9wcmludF82ODM2MChjb25zdCBjaGFyICpwKQoreworCWNvbnN0IGNoYXIgKmNwID0gcDsKKwlpbnQgaTsKKworCWZvciAoaT0wO2NwW2ldIT0wO2krKyk7CisKKwlzZXJpYWxfY29uc29sZV93cml0ZSAocCwgaSk7CisKKwkvL0NvbW1lbnQgdGhpcyBpZiB5b3Ugd2FudCB0byBoYXZlIGEgc3RyaWN0IGludGVycnVwdC1kcml2ZW4gb3V0cHV0CisJLy9yc19mYWlyX291dHB1dCgpOworCisJcmV0dXJuOworfSovCisKKworCisKKworCisjaWZkZWYgQ09ORklHX1hNT04KK2ludAoreG1vbl8z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uIGluaXQgYW5kIHNldHVwIHF1aXJrcy4KKwkgKi8KKwlxdWlyayA9IGZpbmRfcXVpcmsoZGV2KTsKKworCS8qCisJICogUnVuIHRoZSBuZXctc3R5bGUgaW5pdGlhbGl6YXRpb24gZnVuY3Rpb24uCisJICogVGhlIGluaXRpYWxpemF0aW9uIGZ1bmN0aW9uIHJldHVybnM6CisJICogIDwwICAtIGVycm9yCisJICogICAwICAtIHVzZSBib2FyZC0+bnVtX3BvcnRzCisJICogID4wICAtIG51bWJlciBvZiBwb3J0cworCSAqLworCWlmIChxdWlyay0+aW5pdCkgeworCQlyYyA9IHF1aXJrLT5pbml0KGRldik7CisJCWlmIChyYyA8IDApCisJCQlnb3RvIGRpc2FibGU7CisJCWlmIChyYykKKwkJCW5yX3BvcnRzID0gcmM7CisJfQorCisJcHJpdiA9IGttYWxsb2Moc2l6ZW9mKHN0cnVjdCBzZXJpYWxfcHJpdmF0ZSkgKworCQkgICAgICAgc2l6ZW9mKHVuc2lnbmVkIGludCkgKiBucl9wb3J0cywKKwkJICAgICAgIEdGUF9LRVJORUwpOworCWlmICghcHJpdikgeworCQlyYyA9IC1FTk9NRU07CisJCWdvdG8gZGVpbml0OworCX0KKworCW1lbXNldChwcml2LCAwLCBzaXplb2Yoc3RydWN0IHNlcmlhbF9wcml2YXRlKSArCisJCQlzaXplb2YodW5zaWduZWQgaW50KSAqIG5yX3BvcnRzKTsKKworCXByaXYtPnF1aXJrID0gcXVpcms7CisJcGNpX3NldF9kcnZkYXRhKGRldiwgcHJpdik7CisKKwlmb3IgKGkgPSAwOyBpIDwgbnJfcG9ydHM7IGkrKykgeworCQlzdHJ1Y3QgdWFydF9wb3J0IHNlcmlhbF9wb3J0OworCQltZW1zZXQoJnNlcmlhbF9wb3J0LCAwLCBzaXplb2Yoc3RydWN0IHVhcnRfcG9ydCkpOworCisJCXNlcmlhbF9wb3J0LmZsYWdzID0gVVBGX1NLSVBfVEVTVCB8IFVQRl9CT09UX0FVVE9DT05GIHwK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Y250IC09IGNvdW50OworCQlERkxJUChERUJVR19MT0coaW5mby0+bGluZSwiZmxpcDogJWlcbiIsIGxlbmd0aCkpOworCisJCWlmIChjb3VudCA9PSBidWZmZXItPmxlbmd0aCkgeworCQkJaW5mby0+Zmlyc3RfcmVjdl9idWZmZXIgPSBidWZmZXItPm5leHQ7CisJCQlrZnJlZShidWZmZXIpOworCQl9IGVsc2UgeworCQkJYnVmZmVyLT5sZW5ndGggLT0gY291bnQ7CisJCQltZW1tb3ZlKGJ1ZmZlci0+YnVmZmVyLCBidWZmZXItPmJ1ZmZlciArIGNvdW50LCBidWZmZXItPmxlbmd0aCk7CisJCQlidWZmZXItPmVycm9yID0gVFRZX05PUk1BTDsKKwkJfQorCX0KKworCWlmICghaW5mby0+Zmlyc3RfcmVjdl9idWZmZXIpCisJCWluZm8tPmxhc3RfcmVjdl9idWZmZXIgPSBOVUxMOworCisJdHR5LT5mbGlwLmNvdW50ID0gbGVuZ3RoOworCURGTElQKGlmICh0dHktPmxkaXNjLmNoYXJzX2luX2J1ZmZlcih0dHkpID4gMzUwMCkgeworCQlERUJVR19MT0coaW5mby0+bGluZSwgImxkaXNjICVsdVxuIiwKKwkJCSAgdHR5LT5sZGlzYy5jaGFyc19pbl9idWZmZXIodHR5KSk7CisJCURFQlVHX0xPRyhpbmZvLT5saW5lLCAiZmxpcC5jb3VudCAlbHVcbiIsCisJCQkgIHR0eS0+ZmxpcC5jb3VudCk7CisJICAgICAgfQorCSAgICAgICk7CisJcmVzdG9yZV9mbGFncyhmbGFncyk7CisKKwlERkxJUCgKKwkgIGlmICgxKSB7CisKKwkJICBpZiAodGVzdF9iaXQoVFRZX0RPTlRfRkxJUCwgJnR0eS0+ZmxhZ3MpKSB7CisJCQkgIERFQlVHX0xPRyhpbmZvLT5saW5lLCAiKioqIFRUWV9ET05UX0ZMSVAgc2V0IGZsaXAuY291bnQgJWkgKioqXG4iLCB0dHktPmZsaXAuY291bnQpOworCQkJICBERUJVR19MT0coaW5mby0+b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sZVtpXS50dHk7CisgICAgICAgIGlmICh0dHkpICB7CisJCXVuc2lnbmVkIGxvbmcgZmxhZ3M7CisJCWlmIChyZWN1cnNlX2NudCA+IDUpIC8qIFdlIHNraXAgdGhpcyBkZWJ1ZyBvdXRwdXQgKi8KKwkJCXJldHVybiAxOworCisJCWxvY2FsX2lycV9zYXZlKGZsYWdzKTsKKwkJcmVjdXJzZV9jbnQrKzsKKwkJbG9jYWxfaXJxX3Jlc3RvcmUoZmxhZ3MpOworICAgICAgICAgICAgICAgIGRvIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNudCA9IHJzX3dyaXRlKHR0eSwgMCwgYnVmICsgd3JpdHRlbiwgbGVuKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjbnQgPj0gMCkgeworCQkJCXdyaXR0ZW4gKz0gY250OworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWYgKz0gY250OworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gY250OworICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IGNudDsKKyAgICAgICAgICAgICAgICB9IHdoaWxlKGxlbiA+IDApOworCQlsb2NhbF9pcnFfc2F2ZShmbGFncyk7CisJCXJlY3Vyc2VfY250LS07CisJCWxvY2FsX2lycV9yZXN0b3JlKGZsYWdzKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gMTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gMDsKK30KKworLyoKKyAqIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQorICogcnNfY2xvc2UoKQorICoKKyAqIFRoaXMgcm91dGluZSBpcyBjYWxsZWQgd2hlbiB0aGUgc2VyaWFsIHBvcnQgZ2V0cyBjbG9zZWQuICBGaXJzdCwgd2UKKyAqIHdhaXQgZm9yIHRo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dl9jbnQsCisJCSAgICAgICAodW5zaWduZWQgbG9uZylpbmZvLT5tYXhfcmVjdl9jbnQpOworCisjaWYgMQorCWlmIChpbmZvLT50dHkpIHsKKworCQlpZiAoaW5mby0+dHR5LT5zdG9wcGVkKQorCQkJcmV0ICs9IHNwcmludGYoYnVmK3JldCwgIiBzdG9wcGVkOiVpIiwKKwkJCQkgICAgICAgKGludClpbmZvLT50dHktPnN0b3BwZWQpOworCQlpZiAoaW5mby0+dHR5LT5od19zdG9wcGVkKQorCQkJcmV0ICs9IHNwcmludGYoYnVmK3JldCwgIiBod19zdG9wcGVkOiVpIiwKKwkJCQkgICAgICAgKGludClpbmZvLT50dHktPmh3X3N0b3BwZWQpOworCX0KKworCXsKKwkJdW5zaWduZWQgY2hhciByc3RhdCA9IGluZm8tPnBvcnRbUkVHX1NUQVRVU107CisJCWlmIChyc3RhdCAmIElPX01BU0soUl9TRVJJQUwwX1NUQVRVUywgeG9mZl9kZXRlY3QpICkKKwkJCXJldCArPSBzcHJpbnRmKGJ1ZityZXQsICIgeG9mZl9kZXRlY3Q6MSIpOworCX0KKworI2VuZGlmCisKKworCisKKwlpZiAoaW5mby0+aWNvdW50LmZyYW1lKQorCQlyZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiIGZlOiVsdSIsCisJCQkgICAgICAgKHVuc2lnbmVkIGxvbmcpaW5mby0+aWNvdW50LmZyYW1lKTsKKworCWlmIChpbmZvLT5pY291bnQucGFyaXR5KQorCQlyZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiIHBlOiVsdSIsCisJCQkgICAgICAgKHVuc2lnbmVkIGxvbmcpaW5mby0+aWNvdW50LnBhcml0eSk7CisKKwlpZiAoaW5mby0+aWNvdW50LmJyaykKKwkJcmV0ICs9IHNwcmludGYoYnVmK3JldCwgIiBicms6JWx1IiwKKwkJCSAgICAgICAodW5zaWduZWQgbG9uZylpbmZvLT5pY291bnQuYnJrKTsKKworCWlmIChpbmZvLT5pY291bnQub3ZlcnJ1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gREVDU3RhdGlvbnMgZXF1aXBlZCAKKyAqICAgICAgIHdpdGggdGhlIERaIGNoaXBzZXQuCisgKgorICogQ29weXJpZ2h0IChDKSAxOTk4IE9saXZpZXIgQS4gRC4gTGViYWlsbGlmIAorICogICAgICAgICAgICAgCisgKiBFbWFpbDogb2xpdmllci5sZWJhaWxsaWZAaWZyc3lzLmNvbQorICoKKyAqLworI2lmbmRlZiBEWl9TRVJJQUxfSAorI2RlZmluZSBEWl9TRVJJQUxfSAorCisvKgorICogRGVmaW5pdGlvbnMgZm9yIHRoZSBDb250cm9sIGFuZCBTdGF0dXMgUmVjZWl2ZWQuCisgKi8KKyNkZWZpbmUgRFpfVFJEWSAgICAgICAgMHg4MDAwICAgICAgICAgICAgICAgICAvKiBUcmFuc21pdHRlciBlbXB0eSAqLworI2RlZmluZSBEWl9USUUgICAgICAgICAweDQwMDAgICAgICAgICAgICAgICAgIC8qIFRyYW5zbWl0dGVyIEludGVycnVwdCBFbmFibGUgKi8KKyNkZWZpbmUgRFpfUkRPTkUgICAgICAgMHgwMDgwICAgICAgICAgICAgICAgICAvKiBSZWNlaXZlciBkYXRhIHJlYWR5ICovCisjZGVmaW5lIERaX1JJRSAgICAgICAgIDB4MDA0MCAgICAgICAgICAgICAgICAgLyogUmVjZWl2ZSBJbnRlcnJ1cHQgRW5hYmxlICovCisjZGVmaW5lIERaX01TRSAgICAgICAgIDB4MDAyMCAgICAgICAgICAgICAgICAgLyogTWFzdGVyIFNjYW4gRW5hYmxlICovCisjZGVmaW5lIERaX0NMUiAgICAgICAgIDB4MDAxMCAgICAgICAgICAgICAgICAgLyogTWFzdGVyIHJlc2V0ICovCisjZGVmaW5lIERaX01BSU5UICAgICAgIDB4MDAwOCAgICAgICAgICAgICAgICAgLyogTG9vcCBCYWNrIE1vZGUgKi8KKworLyoKKyAqIERlZmluaXRpb25zIGZvciB0aGUgUmVjZWl2ZWQgYnVmZmVyLiAKKyAqLworI2RlZmluZSBEWl9SQlVGX01BU0sgICAweDAwRkYgICAgICAgICAgICAgICAgIC8qIERhdGEgTWFzayBpbiB0aGUgUmVjZWl2ZSBCdWZmZXIgKi8KKyNkZWZpbmUgRFpfTElORV9NQVNLICAgMHgwMzAwICAgICAgICAgICAgICAgICAvKiBMaW5lIE1hc2sgaW4gdGhlIFJlY2VpdmUgQnVmZmVyICovCisjZGVmaW5lIERaX0RWQUwgICAgICAgIDB4ODAwMCAgICAgICAgICAgICAgICAgLyogVmFsaWQgRGF0YSBpbmRpY2F0b3IgKi8KKyNkZWZpbmUgRFpfT0VSUiAgICAgICAgMHg0MDAwICAgICAgICAgICAgICAgICAvKiBPdmVycnVuIGVycm9yIGluZGljYXRvciAqLworI2RlZmluZSBEWl9GRVJSICAgICAgICAweDIwMDAgICAgICAgICAgICAgICAgIC8qIEZyYW1lIGVycm9yIGluZGljYXRvciAqLworI2RlZmluZSBEWl9QRVJSICAgICAgICAweDEwMDAgICAgICAgICAgICAgICAgIC8qIFBhcml0eSBlcnJvciBpbmRpY2F0b3IgKi8KKworI2RlZmluZSBMSU5FKHgpICh4ICYgRFpfTElORV9NQVNLKSA+PiA4ICAgICAgIC8qIEdldCB0aGUgbGluZSBudW1iZXIgZnJvbSB0aGUgaW5wdXQgYnVmZmVyICovCisjZGVmaW5lIFVDSEFSKHgpICh1bnNpZ25lZCBjaGFyKSh4ICYgRFpfUkJVRl9NQVNLKQorCisvKgorICogRGVmaW5pdGlvbnMgZm9yIHRoZSBUcmFuc21pdCBSZWdpc3Rlci4KKyAqLworI2RlZmluZSBEWl9MSU5FX0tFWUJPQVJEIDB4MDAwMQorI2RlZmluZSBEWl9MSU5FX01PVVNFICAgIDB4MDAwMgorI2RlZmluZSBEWl9MSU5FX01PREVNICAgIDB4MDAwNAorI2RlZmluZSBEWl9MSU5FX1BSSU5URVIgIDB4MDAwOAorCisjZGVmaW5lIERaX01PREVNX0RUUiAgICAgMHgwNDAwICAgICAgICAgICAgICAgLyogRFRSIGZvciB0aGUgbW9kZW0gbGluZSAoMikgKi8KKworLyoKKyAqIERlZmluaXRpb25zIGZvciB0aGUgTW9kZW0gU3RhdHVzIFJlZ2lzdGVyLgorICovCisjZGVmaW5lIERaX01PREVNX0RTUiAgICAgMHgwMjAwICAgICAgICAgICAgICAgLyogRFNSIGZvciB0aGUgbW9kZW0gbGluZSAoMikgKi8KKworLyoKKyAqIERlZmluaXRpb25zIGZvciB0aGUgVHJhbnNtaXQgRGF0YSBSZWdpc3Rlci4KKyAqLworI2RlZmluZSBEWl9CUkswICAgICAgICAgIDB4MDEwMCAgICAgICAgICAgICAgIC8qIEJyZWFrIGFzc2VydGlvbiBmb3IgbGluZSAwICovCisjZGVmaW5lIERaX0JSSzEgICAgICAgICAgMHgwMjAwICAgICAgICAgICAgICAgLyogQnJlYWsgYXNzZXJ0aW9uIGZvciBsaW5lIDEgKi8KKyNkZWZpbmUgRFpfQlJLMiAgICAgICAgICAweDA0MDAgICAgICAgICAgICAgICAvKiBCcmVhayBhc3NlcnRpb24gZm9yIGxpbmUgMiAqLworI2RlZmluZSBEWl9CUkszICAgICAgICAgIDB4MDgwMCAgICAgICAgICAgICAgIC8qIEJyZWFrIGFzc2VydGlvbiBmb3IgbGluZSAzICovCisKKy8qCisgKiBEZWZpbml0aW9ucyBmb3IgdGhlIExpbmUgUGFyYW1ldGVyIFJlZ2lzdGVyLgorICovCisjZGVmaW5lIERaX0tFWUJPQVJEICAgICAgMHgwMDAwICAgICAgICAgICAgICAgLyogbGluZSAwID0ga2V5Ym9hcmQgKi8KKyNkZWZpbmUgRFpfTU9VU0UgICAgICAgICAweDAwMDEgICAgICAgICAgICAgICAvKiBsaW5lIDEgPSBtb3VzZSAqLworI2RlZmluZSBEWl9NT0RFTSAgICAgICAgIDB4MDAwMiAgICAgICAgICAgICAgIC8qIGxpbmUgMiA9IG1vZGVtICovCisjZGVmaW5lIERaX1BSSU5URVIgICAgICAgMHgwMDAzICAgICAgICAgICAgICAgLyogbGluZSAzID0gcHJpbnRlciAqLworCisjZGVmaW5lIERaX0NTSVpFICAgICAgICAgMHgwMDE4ICAgICAgICAgICAgICAgLyogTnVtYmVyIG9mIGJpdHMgcGVyIGJ5dGUgKG1hc2spICovCisjZGVmaW5lIERaX0NTNSAgICAgICAgICAgMHgwMDAwICAgICAgICAgICAgICAgLyogNSBiaXRzIHBlciBieXRlICovCisjZGVmaW5lIERaX0NTNiAgICAgICAgICAgMHgwMDA4ICAgICAgICAgICAgICAgLyogNiBiaXRzIHBlciBieXRlICovCisjZGVmaW5lIERaX0NTNyAgICAgICAgICAgMHgwMDEwICAgICAgICAgICAgICAgLyogNyBiaXRzIHBlciBieXRlICovCisjZGVmaW5lIERaX0NTOCAgICAgICAgICAgMHgwMDE4ICAgICAgICAgICAgICAgLyogOCBiaXRzIHBlciBieXRlICovCisKKyNkZWZpbmUgRFpfQ1NUT1BCICAgICAgICAweDAwMjAgICAgICAgICAgICAgICAvKiAyIHN0b3AgYml0cyBpbnN0ZWFkIG9mIG9uZSAqLyAKKworI2RlZmluZSBEWl9QQVJFTkIgICAgICAgIDB4MDA0MCAgICAgICAgICAgICAgIC8qIFBhcml0eSBlbmFibGUgKi8KKyNkZWZpbmUgRFpfUEFST0REICAgICAgICAweDAwODAgICAgICAgICAgICAgICAvKiBPZGQgcGFyaXR5IGluc3RlYWQgb2YgZXZlbiAqLworCisjZGVmaW5lIERaX0NCQVVEICAgICAgICAgMHgwRTAwICAgICAgICAgICAgICAgLyogQmF1ZCBSYXRlIChtYXNrKSAqLworI2RlZmluZSBEWl9CNTAgICAgICAgICAgIDB4MDAwMAorI2RlZmluZSBEWl9CNzUgICAgICAgICAgIDB4MDEwMAorI2RlZmluZSBEWl9CMTEwICAgICAgICAgIDB4MDIwMAorI2RlZmluZSBEWl9CMTM0ICAgICAgICAgIDB4MDMwMAorI2RlZmluZSBEWl9CMTUwICAgICAgICAgIDB4MDQwMAorI2RlZmluZSBEWl9CMzAwICAgICAgICAgIDB4MDUwMAorI2RlZmluZSBEWl9CNjAwICAgICAgICAgIDB4MDYwMAorI2RlZmluZSBEWl9CMTIwMCAgICAgICAgIDB4MDcwMCAKKyNkZWZpbmUgRFpfQjE4MDAgICAgICAgICAweDA4MDAKKyNkZWZpbmUgRFpfQjIwMDAgICAgICAgICAweDA5MDAKKyNkZWZpbmUgRFpfQjI0MDAgICAgICAgICAweDBBMDAKKyNkZWZpbmUgRFpfQjM2MDAgICAgICAgICAweDBCMDAKKyNkZWZpbmUgRFpfQjQ4MDAgICAgICAgICAweDBDMDAKKyNkZWZpbmUgRFpfQjcyMDAgICAgICAgICAweDBEMDAKKyNkZWZpbmUgRFpfQjk2MDAgICAgICAgICAweDBFMDAKKworI2RlZmluZSBEWl9DUkVBRCAgICAgICAgIDB4MTAwMCAgICAgICAgICAgICAgIC8qIEVuYWJsZSByZWNlaXZlciAqLworI2RlZmluZSBEWl9SWEVOQUIgICAgICAgIDB4MTAwMCAgICAgICAgICAgICAgIC8qIGVuYWJsZSByZWNlaXZlIGNoYXIgKi8KKy8qCisgKiBBZGRyZXNzZXMgZm9yIHRoZSBEWiByZWdpc3RlcnMKKyAqLworI2RlZmluZSBEWl9DU1IgICAgICAgMHgwMCAgICAgICAgICAgIC8qIENvbnRyb2wgYW5kIFN0YXR1cyBSZWdpc3RlciAqLworI2RlZmluZSBEWl9SQlVGICAgICAgMHgwOCAgICAgICAgICAgIC8qIFJlY2VpdmUgQnVmZmVyICovCisjZGVmaW5lIERaX0xQUiAgICAgICAweDA4ICAgICAgICAgICAgLyogTGluZSBQYXJhbWV0ZXJzIFJlZ2lzdGVyICovCisjZGVmaW5lIERaX1RDUiAgICAgICAweDEwICAgICAgICAgICAgLyogVHJhbnNtaXR0ZXIgQ29udHJvbCBSZWdpc3RlciAqLworI2RlZmluZSBEWl9NU1IgICAgICAgMHgxOCAgICAgICAgICAgIC8qIE1vZGVtIFN0YXR1cyBSZWdpc3RlciAqLworI2RlZmluZSBEWl9URFIgICAgICAgMHgxOCAgICAgICAgICAgIC8qIFRyYW5zbWl0IERhdG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AwMAorI2RlZmluZSBJQ09NX0lSQU1fU0laRSAgICAgICAgICAgICAgIDB4MEMwMAorI2RlZmluZSBJQ09NX0RDRV9JUkFNX09GRlNFVCAgICAgICAgIDB4MEEwMAorI2RlZmluZSBJQ09NX0NBQkxFX0lEX1ZBTElEICAgICAgICAgIDB4MDEKKyNkZWZpbmUgSUNPTV9DQUJMRV9JRF9NQVNLICAgICAgICAgICAweEYwCisjZGVmaW5lIElDT01fRElTQUJMRSAgICAgICAgICAgICAgICAgMHg4MAorI2RlZmluZSBDTURfWE1JVF9SQ1ZfRU5BQkxFICAgICAgICAgIDB4QzAKKyNkZWZpbmUgQ01EX1hNSVRfRU5BQkxFICAgICAgICAgICAgICAweDQwCisjZGVmaW5lIENNRF9SQ1ZfRElTQUJMRSAgICAgICAgICAgICAgMHgwMAorI2RlZmluZSBDTURfUkNWX0VOQUJMRSAgICAgICAgICAgICAgIDB4ODAKKyNkZWZpbmUgQ01EX1JFU1RBUlQgICAgICAgICAgICAgICAgICAweDAxCisjZGVmaW5lIENNRF9IT0xEX1hNSVQgICAgICAgICAgICAgICAgMHgwMgorI2RlZmluZSBDTURfU05EX0JSRUFLICAgICAgICAgICAgICAgIDB4MDQKKyNkZWZpbmUgUlMyMzJfQ0FCTEUgICAgICAgICAgICAgICAgICAweDA2CisjZGVmaW5lIFYyNF9DQUJMRSAgICAgICAgICAgICAgICAgICAgMHgwRQorI2RlZmluZSBWMzVfQ0FCTEUgICAgICAgICAgICAgICAgICAgIDB4MEMKKyNkZWZpbmUgVjM2X0NBQkxFICAgICAgICAgICAgICAgICAgICAweDAyCisjZGVmaW5lIE5PX0NBQkxFICAgICAgICAgICAgICAgICAgICAgMHgwMAorI2RlZmluZSBTVEFSVF9ET1dOTE9BRCAgICAgICAgICAgICAgIDB4ODAKKyNkZWZpbmUgSUNPTV9JTlRfTUFTS19QUkNfQSAgICAgICAgICAweDAwMDAzRkZGCisjZGVmaW5lIElDT01fSU5UX01BU0tfUFJDX0IgICAgICAgICAgMHgzRkZGMDAwMAorI2RlZmluZSBJQ09NX0lOVF9NQVNLX1BSQ19DICAgICAgICAgIDB4MDAwMDNGRkYKKyNkZWZpbmUgSUNPTV9JTlRfTUFTS19QUkNfRCAgICAgICAgICAweDNGRkYwMDAwCisjZGVmaW5lIElOVF9SQ1ZfQ09NUExFVEVEICAgICAgICAgICAgMHgxMDAwCisjZGVmaW5lIElOVF9YTUlUX0NPTVBMRVRFRCAgICAgICAgICAgMHgyMDAwCisjZGVmaW5lIElOVF9JRExFX0RFVEVDVCAgICAgICAgICAgICAgMHgwODAwCisjZGVmaW5lIElOVF9SQ1ZfRElTQUJMRUQgICAgICAgICAgICAgMHgwNDAwCisjZGVmaW5lIElOVF9YTUlUX0RJU0FCTEVEICAgICAgICAgICAgMHgwMjAwCisjZGVmaW5lIElOVF9SQ1ZfWE1JVF9TSFVURE9XTiAgICAgICAgMHgwMTAwCisjZGVmaW5lIElOVF9GQVRBTF9FUlJPUiAgICAgICAgICAgICAgMHgwMDgwCisjZGVmaW5lIElOVF9DQUJMRV9QVUxMICAgICAgICAgICAgICAgMHgwMDIwCisjZGVmaW5lIElOVF9TSUdOQUxfQ0hBTkdFICAgICAgICAgICAgMHgwMDEwCisjZGVmaW5lIEhETENfUFBQX1BVUkVfQVNZTkMgICAgICAgICAgMHgwMgorI2RlZmluZSBIRExDX0ZGX0ZJTEwgICAgICAgICAgICAgICAgIDB4MDAKKyNkZWZpbmUgSERMQ19IRFdfRkxPVyAgICAgICAgICAgICAgICAweDAxCisjZGVmaW5lIFNUQVJUX1hNSVQgICAgICAgICAgICAgICAgICAgMHg4MAorI2RlZmluZSBJQ09NX0FDRkdfRFJJVkUxICAgICAgICAgICAgIDB4MjAKKyNkZWZpbmUgSUNPTV9BQ0ZHX05PX1BBUklUWSAgICAgICAgICAweDAwCisjZGVmaW5lIElDT01fQUNGR19QQVJJVFlfRU5BQiAgICAgICAgMHgwMgorI2RlZmluZSBJQ09NX0FDRkdfUEFSSVRZX09ERCAgICAgICAgIDB4MDEKKyNkZWZpbmUgSUNPTV9BQ0ZHXzhCUEMgICAgICAgICAgICAgICAweDAwCisjZGVmaW5lIElDT01fQUNGR183QlBDICAgICAgICAgICAgICAgMHgwNAorI2RlZmluZSBJQ09NX0FDRkdfNkJQQyAgICAgICAgICAgICAgIDB4MDgKKyNkZWZpbmUgSUNPTV9BQ0ZHXzVCUEMgICAgICAgICAgICAgICAweDBDCisjZGVmaW5lIElDT01fQUNGR18xU1RPUF9CSVQgICAgICAgICAgMHgwMAorI2RlZmluZSBJQ09NX0FDRkdfMlNUT1BfQklUICAgICAgICAgIDB4MTAKKyNkZWZpbmUgSUNPTV9EVFIgICAgICAgICAgICAgICAgICAgICAweDgwCisjZGVmaW5lIElDT01fUlRTICAgICAgICAgICAgICAgICAgICAgMHg0MAorI2RlZmluZSBJQ09NX1JJICAgICAgICAgICAgICAgICAgICAgIDB4MDgKKyNkZWZpbmUgSUNPTV9EU1IgICAgICAgICAgICAgICAgICAgICAweDgwCisjZGVmaW5lIElDT01fRENEICAgICAgICAgICAgICAgICAgICAgMHgyMAorI2RlZmluZSBJQ09NX0NUUyAgICAgICAgICAgICAgICAgICAgIDB4NDAKKworI2RlZmluZSBOVU1fWEJVRkZTIDEKKyNkZWZpbmUgTlVNX1JCVUZGUyAyCisjZGVmaW5lIFJDVl9CVUZGX1NaIDB4MDIwMAorI2RlZmluZSBYTUlUX0JVRkZfU1ogMHgxMDAwCitzdHJ1Y3Qgc3RhdHVzQXJlYSB7CisgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisJLyogVHJhbnNtaXQgU3RhdHVzIEFyZWEgICAgICAgICAgICAgICAgICAgICAgICovCisgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisJc3RydWN0IHhtaXRfc3RhdHVzX2FyZWF7CisJCXUzMiBsZU5leHQ7CS8qIE5leHQgZW50cnkgaW4gTGl0dGxl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XIgR2xvYmFsIFZhcmlhYmxlcy4KKyAqLworZXh0ZXJuIHN0cnVjdAl1YXJ0X2RyaXZlciBqc21fdWFydF9kcml2ZXI7CitleHRlcm4gc3RydWN0CWJvYXJkX29wcyBqc21fbmVvX29wczsKK2V4dGVybiBpbnQJanNtX2RlYnVnOworZXh0ZXJuIGludAlqc21fcmF3cmVhZG9rOworCitleHRlcm4gaW50CWpzbV9kcml2ZXJfc3RhdGU7CS8qIFRoZSBzdGF0ZSBvZiB0aGUgZHJpdmVyCSovCitleHRlcm4gY2hhcgkqanNtX2RyaXZlcl9zdGF0ZV90ZXh0W107LyogQXJyYXkgb2YgZHJpdmVyIHN0YXRlIHRleHQgKi8KKworZXh0ZXJuIHNwaW5sb2NrX3QganNtX2JvYXJkX2hlYWRfbG9jazsKK2V4dGVybiBzdHJ1Y3QgbGlzdF9oZWFkIGpzbV9ib2FyZF9oZWFkOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICoKKyAqIFByb3RvdHlwZXMgZm9yIG5vbi1zdGF0aWMgZnVuY3Rpb25zIHVzZWQgaW4gbW9yZSB0aGFuIG9uZSBtb2R1bGUKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK2ludCBqc21fdHR5X3dyaXRlKHN0cnVjdCB1YXJ0X3BvcnQgKnBvcnQpOworaW50IGpzbV90dHlfaW5pdChzdHJ1Y3QganNtX2JvYXJkICopOworaW50IGpzbV91YXJ0X3BvcnRfaW5pdChzdHJ1Y3QganNtX2JvYXJkICopOworaW50IGpzbV9yZW1vdmVfdWFydF9wb3J0KHN0cnVjdCBqc21fYm9hcmQgKik7Cit2b2lkIGpzbV9pbnB1dChzdHJ1Y3QganNtX2NoYW5uZWwgKmNoKTsKK3ZvaWQganNtX2NhcnJpZXIoc3RydWN0IGpzb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51bSArIGJyZC0+Ym9hcmRudW0gKiAyOworCQlpZiAodWFydF9hZGRfb25lX3BvcnQgKCZqc21fdWFydF9kcml2ZXIsICZicmQtPmNoYW5uZWxzW2ldLT51YXJ0X3BvcnQpKQorCQkJcHJpbnRrKEtFUk5fSU5GTyAiQWRkZWQgZGV2aWNlIGZhaWxlZFxuIik7CisJCWVsc2UKKwkJCXByaW50ayhLRVJOX0lORk8gIkFkZGVkIGRldmljZSBcbiIpOworCX0KKworCWpzbV9wcmludGsoSU5JVCwgSU5GTywgJmJyZC0+cGNpX2RldiwgImZpbmlzaFxuIik7CisJcmV0dXJuIDA7Cit9CisKK2ludCBqc21fcmVtb3ZlX3VhcnRfcG9ydChzdHJ1Y3QganNtX2JvYXJkICpicmQpCit7CisJaW50IGk7CisJc3RydWN0IGpzbV9jaGFubmVsICpjaDsKKworCWlmICghYnJkKQorCQlyZXR1cm4gLUVOWElPOworCisJanNtX3ByaW50ayhJTklULCBJTkZPLCAmYnJkLT5wY2lfZGV2LCAic3RhcnRcbiIpOworCisJLyoKKwkgKiBJbml0aWFsaXplIGJvYXJkIHN0cnVjdHVyZSBlbGVtZW50cy4KKwkgKi8KKworCWJyZC0+bmFzeW5jID0gYnJkLT5tYXhwb3J0czsKKworCS8qIFNldCB1cCBjaGFubmVsIHZhcmlhYmxlcyAqLworCWZvciAoaSA9IDA7IGkgPCBicmQtPm5hc3luYzsgaSsrKSB7CisKKwkJaWYgKCFicmQtPmNoYW5uZWxzW2ldKQorCQkJY29udGludWU7CisKKwkJY2ggPSBicmQtPmNoYW5uZWxzW2ldOworCisJCXVhcnRfcmVtb3ZlX29uZV9wb3J0KCZqc21fdWFydF9kcml2ZXIsICZicmQtPmNoYW5uZWxzW2ldLT51YXJ0X3BvcnQpOworCX0KKworCWpzbV9wcmludGsoSU5JVCwgSU5GTywgJmJyZC0+cGNpX2RldiwgImZpbmlzaFxuIik7CisJcmV0dXJuIDA7Cit9CisKK3ZvaWQganNtX2lucHV0KHN0cnV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ihQTERfRVNJTzBDUik7CisJX19zaW9fb3V0KDB4MDMwMCwgUExEX0VTSU8wQ1IpOworCV9fc2lvX291dCgweDAwMDMsIFBMRF9FU0lPMENSKTsKK30KKworc3RhdGljIHZvaWQgc2lvX2Vycm9yKGludCAqc3RhdHVzKQoreworCXByaW50aygiU0lPMCBlcnJvclslMDR4XVxuIiwgKnN0YXR1cyk7CisJZG8geworCQlzaW9faW5pdCgpOworCX0gd2hpbGUgKCgqc3RhdHVzID0gX19zaW9faW4oUExEX0VTSU8wQ1IpKSAhPSAzKTsKK30KKworI2Vsc2UgLyogbm90IENPTkZJR19TRVJJQUxfTTMyUl9QTERTSU8gKi8KKworI2RlZmluZSBfX3Npb19pbih4KSBpbmwoeCkKKyNkZWZpbmUgX19zaW9fb3V0KHYseCkgb3V0bCgodiksKHgpKQorCitzdGF0aWMgaW5saW5lIHZvaWQgc2lvX3NldF9iYXVkX3JhdGUodW5zaWduZWQgbG9uZyBiYXVkKQoreworCXVuc2lnbmVkIGxvbmcgaSwgajsKKworCWkgPSBib290X2NwdV9kYXRhLmJ1c19jbG9jayAvIChiYXVkICogMTYpOworCWogPSAoYm9vdF9jcHVfZGF0YS5idXNfY2xvY2sgLSAoaSAqIGJhdWQgKiAxNikpIC8gYmF1ZDsKKwlpIC09IDE7CisJaiA9IChqICsgMSkgPj4gMTsKKworCV9fc2lvX291dChpLCBNMzJSX1NJTzBfQkFVUl9QT1JUTCk7CisJX19zaW9fb3V0KGosIE0zMlJfU0lPMF9SQkFVUl9QT1JUTCk7Cit9CisKK3N0YXRpYyB2b2lkIHNpb19yZXNldCh2b2lkKQoreworCV9fc2lvX291dCgweDAwMDAwMzAwLCBNMzJSX1NJTzBfQ1JfUE9SVEwpOwkvKiBpbml0IHN0YXR1cyAqLworCV9fc2lvX291dCgweDAwMDAwODAwLCBNMzJSX1NJTzBfTU9EMV9QT1JUTCk7CS8qIDhiaXQgICAgICAgICovCisJX19zaW9fb3V0KDB4MDAwMDAwODAsIE0zM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ygmaW5mby0+dHF1ZXVlX2hhbmd1cCwgZG9fc2VyaWFsX2hhbmd1cCwgaW5mbyk7CisJCWluaXRfd2FpdHF1ZXVlX2hlYWQoJmluZm8tPm9wZW5fd2FpdCk7CisJCWluaXRfd2FpdHF1ZXVlX2hlYWQoJmluZm8tPmNsb3NlX3dhaXQpOworCisJCWluZm8tPmltciA9IDA7CisJCW1jZnJzX3NldHNpZ25hbHMoaW5mbywgMCwgMCk7CisJCW1jZnJzX2lycWluaXQoaW5mbyk7CisKKwkJcHJpbnRrKCJ0dHlTJWQgYXQgMHglMDR4IChpcnEgPSAlZCkiLCBpbmZvLT5saW5lLAorCQkJKHVuc2lnbmVkIGludCkgaW5mby0+YWRkciwgaW5mby0+aXJxKTsKKwkJcHJpbnRrKCIgaXMgYSBidWlsdGluIENvbGRGaXJlIFVBUlRcbiIpOworCX0KKworCWxvY2FsX2lycV9yZXN0b3JlKGZsYWdzKTsKKwlyZXR1cm4gMDsKK30KKworbW9kdWxlX2luaXQobWNmcnNfaW5pdCk7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyogICAgICAgICAgICAgICAgICAgICAgICAgIFNlcmlhbCBDb25zb2xlICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyoKKyAqCVF1aWNrIGFuZCBkaXJ0eSBVQVJUIGluaXRpYWxpemF0aW9uLCBmb3IgY29uc29sZSBvdXRwdXQuCisgKi8KKwordm9pZCBtY2Zyc19pbml0X2NvbnNvbGUodm9pZCkKK3sKKwl2b2xhdGlsZSB1bnNpZ25lZCBjaGFyCSp1YXJ0cDsKKwl1bnNpZ25lZCBpbnQJCWNsazsKKworCS8qCisJICoJUmVzZXQgVUFSVCwgZ2V0IGl0IG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LT5saW5lKQorI2Vsc2UKKyNkZWZpbmUgdWFydF9jb25zb2xlKHBvcnQpCSgwKQorI2VuZGlmCisKKworLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ICovCisvKiBVQVJUIG9wZXJhdGlvbnMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKy8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSAqLworCitzdGF0aWMgdW5zaWduZWQgaW50IAorbXBjNTJ4eF91YXJ0X3R4X2VtcHR5KHN0cnVjdCB1YXJ0X3BvcnQgKnBvcnQpCit7CisJaW50IHN0YXR1cyA9IGluX2JlMTYoJlBTQyhwb3J0KS0+bXBjNTJ4eF9wc2Nfc3RhdHVzKTsKKwlyZXR1cm4gKHN0YXR1cyAmIE1QQzUyeHhfUFNDX1NSX1RYRU1QKSA/IFRJT0NTRVJfVEVNVCA6IDA7Cit9CisKK3N0YXRpYyB2b2lkIAorbXBjNTJ4eF91YXJ0X3NldF9tY3RybChzdHJ1Y3QgdWFydF9wb3J0ICpwb3J0LCB1bnNpZ25lZCBpbnQgbWN0cmwpCit7CisJLyogTm90IGltcGxlbWVudGVkICovCit9CisKK3N0YXRpYyB1bnNpZ25lZCBpbnQgCittcGM1Mnh4X3VhcnRfZ2V0X21jdHJsKHN0cnVjdCB1YXJ0X3BvcnQgKnBvcnQpCit7CisJLyogTm90IGltcGxlbWVudGVkICovCisJcmV0dXJuIFRJT0NNX0NUUyB8IFRJT0NNX0RTUiB8IFRJT0NNX0NBUjsKK30KKworc3RhdGljIHZvaWQgCittcGM1Mnh4X3VhcnRfc3RvcF90eChzdHJ1Y3QgdWFydF9wb3J0ICpwb3J0LCB1bnNpZ25lZCBpbnQgdHR5X3N0b3ApCit7CisJLyogcG9ydC0+bG9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3JlbGVhc2VfcG9ydCwKKwkucmVxdWVzdF9wb3J0CT0gbXBjNTJ4eF91YXJ0X3JlcXVlc3RfcG9ydCwKKwkuY29uZmlnX3BvcnQJPSBtcGM1Mnh4X3VhcnRfY29uZmlnX3BvcnQsCisJLnZlcmlmeV9wb3J0CT0gbXBjNTJ4eF91YXJ0X3ZlcmlmeV9wb3J0Cit9OworCisJCisvKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0gKi8KKy8qIEludGVycnVwdCBoYW5kbGluZyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ICovCisJCitzdGF0aWMgaW5saW5lIGludAorbXBjNTJ4eF91YXJ0X2ludF9yeF9jaGFycyhzdHJ1Y3QgdWFydF9wb3J0ICpwb3J0LCBzdHJ1Y3QgcHRfcmVncyAqcmVncykKK3sKKwlzdHJ1Y3QgdHR5X3N0cnVjdCAqdHR5ID0gcG9ydC0+aW5mby0+dHR5OworCXVuc2lnbmVkIGNoYXIgY2g7CisJdW5zaWduZWQgc2hvcnQgc3RhdHVzOworCisJLyogV2hpbGUgd2UgY2FuIHJlYWQsIGRvIHNvICEgKi8KKwl3aGlsZSAoIChzdGF0dXMgPSBpbl9iZTE2KCZQU0MocG9ydCktPm1wYzUyeHhfcHNjX3N0YXR1cykpICYKKwkgICAgICAgIE1QQzUyeHhfUFNDX1NSX1JYUkRZKSB7CisKKwkJLyogSWYgd2UgYXJlIGZ1bGwsIGp1c3Qgc3RvcCByZWFkaW5nICovCisJCWlmICh0dHktPmZsaXAuY291bnQgPj0gVFRZX0ZMSVBCVUZfU0laRSkKKwkJCWJyZWFrOworCQkKKwkJLyogR2V0IHRoZSBjaGFyICovCisJCWNoID0gaW5fOCg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lZCB0byBzZW5kIGNoYXJzID8gKi8KKwkJLyogRm9yIHRoaXMsIFRYIG11c3QgYmUgcmVhZHkgYW5kIFRYIGludGVycnVwdCBlbmFibGVkICovCisJCWlmICggc3RhdHVzICYgTVBDNTJ4eF9QU0NfSU1SX1RYUkRZICkKKwkJCWtlZXBnb2luZyB8PSBtcGM1Mnh4X3VhcnRfaW50X3R4X2NoYXJzKHBvcnQpOworCQkKKwkJLyogTGltaXQgbnVtYmVyIG9mIGl0ZXJhdGlvbiAqLworCQlpZiAoICEoLS1wYXNzKSApCisJCQlrZWVwZ29pbmcgPSAwOworCisJfSB3aGlsZSAoa2VlcGdvaW5nKTsKKwkKKwlzcGluX3VubG9jaygmcG9ydC0+bG9jayk7CisJCisJcmV0dXJuIElSUV9IQU5ETEVEOworfQorCisKKy8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSAqLworLyogQ29uc29sZSAoIGlmIGFwcGxpY2FibGUgKSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisvKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0gKi8KKworI2lmZGVmIENPTkZJR19TRVJJQUxfTVBDNTJ4eF9DT05TT0xFCisKK3N0YXRpYyB2b2lkIF9faW5pdAorbXBjNTJ4eF9jb25zb2xlX2dldF9vcHRpb25zKHN0cnVjdCB1YXJ0X3BvcnQgKnBvcnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ICpiYXVkLCBpbnQgKnBhcml0eSwgaW50ICpiaXRzLCBpbnQgKmZsb3cpCit7CisJc3RydWN0IG1wYzUyeHhfcHNjIF9faW9tZW0gKnBzYyA9IFBTQyhwb3J0KTsKKwl1bnNpZ25lZCBjaGFyIG1yMTsKKworCS8qIFJlYWQgdGhlIG1vZGUgcmVnaXN0Z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T09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0gKi8KKy8qIFVBUlQgRHJpdmVyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ICovCisKK3N0YXRpYyBzdHJ1Y3QgdWFydF9kcml2ZXIgbXBjNTJ4eF91YXJ0X2RyaXZlciA9IHsKKwkub3duZXIJCT0gVEhJU19NT0RVTEUsCisJLmRyaXZlcl9uYW1lCT0gIm1wYzUyeHhfcHNjX3VhcnQiLAorCS5kZXZfbmFtZQk9ICJ0dHlTIiwKKwkuZGV2ZnNfbmFtZQk9ICJ0dHlTIiwKKwkubWFqb3IJCT0gVFRZX01BSk9SLAorCS5taW5vcgkJPSA2NCwKKwkubnIJCT0gTVBDNTJ4eF9QU0NfTUFYTlVNLAorCS5jb25zCQk9IE1QQzUyeHhfUFNDX0NPTlNPTEUsCit9OworCisKKy8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSAqLworLyogUGxhdGZvcm0gRHJpdmVyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisvKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0gKi8KKworc3RhdGljIGludCBfX2RldmluaXQKK21wYzUyeHhfdWFydF9wcm9iZShzdHJ1Y3QgZGV2aWNlICpkZXYpCit7CisJc3RydWN0IHBsYXRmb3JtX2RldmljZSAqcGRldiA9IHRvX3BsYXRmb3JtX2RldmljZShkZXYpOworCXN0cnVjdCByZXNvdXJjZSAqcmVzID0gcGRldi0+cmVzb3VyY2U7CisKKwlzd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VNQRU5EX0RJU0FCTEUpCisJCXVhcnRfc3VzcGVuZF9wb3J0KCZtcGM1Mnh4X3VhcnRfZHJpdmVyLCBwb3J0KTsKKworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50CittcGM1Mnh4X3VhcnRfcmVzdW1lKHN0cnVjdCBkZXZpY2UgKmRldiwgdTMyIGxldmVsKQoreworCXN0cnVjdCB1YXJ0X3BvcnQgKnBvcnQgPSAoc3RydWN0IHVhcnRfcG9ydCAqKSBkZXZfZ2V0X2RydmRhdGEoZGV2KTsKKworCWlmIChwb3J0ICYmIGxldmVsID09IFJFU1VNRV9FTkFCTEUpCisJCXVhcnRfcmVzdW1lX3BvcnQoJm1wYzUyeHhfdWFydF9kcml2ZXIsIHBvcnQpOworCisJcmV0dXJuIDA7Cit9CisjZW5kaWYKKworc3RhdGljIHN0cnVjdCBkZXZpY2VfZHJpdmVyIG1wYzUyeHhfdWFydF9wbGF0Zm9ybV9kcml2ZXIgPSB7CisJLm5hbWUJCT0gIm1wYzUyeHgtcHNjIiwKKwkuYnVzCQk9ICZwbGF0Zm9ybV9idXNfdHlwZSwKKwkucHJvYmUJCT0gbXBjNTJ4eF91YXJ0X3Byb2JlLAorCS5yZW1vdmUJCT0gbXBjNTJ4eF91YXJ0X3JlbW92ZSwKKyNpZmRlZiBDT05GSUdfUE0KKwkuc3VzcGVuZAk9IG1wYzUyeHhfdWFydF9zdXNwZW5kLAorCS5yZXN1bWUJCT0gbXBjNTJ4eF91YXJ0X3Jlc3VtZSwKKyNlbmRpZgorfTsKKworCisvKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0gKi8KKy8qIE1vZHVsZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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gJiAweGZmZmYpOworCisJaWYgKHBpLT5taXJyb3JfcmVncykKKwkJcGktPkJSR19CQ1JfbSA9IHY7CisJd3JpdGVsKHYsIHBpLT5icmdfYmFzZSArIEJSR19CQ1IpOworCW1wc2NfYnJnX2VuYWJsZShwaSk7CisKKwlyZXR1cm47Cit9CisKKy8qCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogU2VyaWFsIERNQSBSb3V0aW5lcyAoU0RNQSkKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKi8KKworc3RhdGljIHZvaWQKK21wc2Nfc2RtYV9idXJzdHNpemUoc3RydWN0IG1wc2NfcG9ydF9pbmZvICpwaSwgdTMyIGJ1cnN0X3NpemUpCit7CisJdTMyCXY7CisKKwlwcl9kZWJ1ZygibXBzY19zZG1hX2J1cnN0c2l6ZVslZF06IGJ1cnN0X3NpemU6ICVkXG4iLAorCSAgICBwaS0+cG9ydC5saW5lLCBidXJzdF9zaXplKTsKKworCWJ1cnN0X3NpemUgPj49IDM7IC8qIERpdmlkZSBieSA4IGIvYyByZWcgdmFsdWVzIGFyZSA4LWJ5dGUgY2h1bmtzICovCisKKwlpZiAoYnVyc3Rfc2l6ZSA8IDIpCisJCXYgPSAweDA7CS8qIDEgNjQtYml0IHdvcmQgKi8KKwllbHNlIGlmIChidXJzdF9zaXplIDwgNCkKKwkJdiA9IDB4MTsJLyogMiA2NC1iaXQgd29yZHMgKi8KKwllbHNlIGlmIChidXJzdF9zaXplIDwgOCkKKwkJdiA9IDB4MjsJLyogNCA2NC1iaXQgd29yZHMgKi8KKwllbHNlCisJCXYgPSAweDM7CS8qIDggNjQtYml0IHdvcmRzICovCisKKwl3cml0ZWwoKHJlYWRsKHBpLT5zZG1hX2Jhc2UgKyBTRE1BX1NEQ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qCisJCQkJCQkJICBNUFNDX1RYUkVfU0laRSkpOworCisJCQltcHNjX3NkbWFfc2V0X3R4X3JpbmcocGksIHR4cmVfcCk7CisJCQltcHNjX3NkbWFfY21kKHBpLCBTRE1BX1NEQ01fU1REIHwgU0RNQV9TRENNX1RYRCk7CisJCX0KKwl9CisKKwlyZXR1cm47Cit9CisKK3N0YXRpYyBpbmxpbmUgdm9pZAorbXBzY19zZG1hX3N0b3Aoc3RydWN0IG1wc2NfcG9ydF9pbmZvICpwaSkKK3sKKwlwcl9kZWJ1ZygibXBzY19zZG1hX3N0b3BbJWRdOiBTdG9wcGluZyBTRE1BXG4iLCBwaS0+cG9ydC5saW5lKTsKKworCS8qIEFib3J0IGFueSBTRE1BIHRyYW5zZmVycyAqLworCW1wc2Nfc2RtYV9jbWQocGksIDApOworCW1wc2Nfc2RtYV9jbWQocGksIFNETUFfU0RDTV9BUiB8IFNETUFfU0RDTV9BVCk7CisKKwkvKiBDbGVhciB0aGUgU0RNQSBjdXJyZW50IGFuZCBmaXJzdCBUWCBhbmQgUlggcG9pbnRlcnMgKi8KKwltcHNjX3NkbWFfc2V0X3R4X3JpbmcocGksIDApOworCW1wc2Nfc2RtYV9zZXRfcnhfcmluZyhwaSwgMCk7CisKKwkvKiBEaXNhYmxlIGludGVycnVwdHMgKi8KKwltcHNjX3NkbWFfaW50cl9tYXNrKHBpLCAweGYpOworCW1wc2Nfc2RtYV9pbnRyX2FjayhwaSk7CisKKwlyZXR1cm47Cit9CisKKy8qCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTXVsdGktUHJvdG9jb2wgU2VyaWFsIENvbnRyb2xsZXIgUm91dGluZXMgKE1QU0MpCisgKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICovCisKK3N0YXRpYy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TQ19DSFJfMl9tIDoKKwkJcmVhZGwocGktPm1wc2NfYmFzZSArIE1QU0NfQ0hSXzIpOworCisJcCAmPSAweDM7CisJdiA9ICh2ICYgfjB4YzAwMGMpIHwgKHAgPDwgMTgpIHwgKHAgPDwgMik7CisKKwlpZiAocGktPm1pcnJvcl9yZWdzKQorCQlwaS0+TVBTQ19DSFJfMl9tID0gdjsKKwl3cml0ZWwodiwgcGktPm1wc2NfYmFzZSArIE1QU0NfQ0hSXzIpOworCXJldHVybjsKK30KKworLyoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqCisgKiBEcml2ZXIgSW5pdCBSb3V0aW5lcworICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqLworCitzdGF0aWMgdm9pZAorbXBzY19pbml0X2h3KHN0cnVjdCBtcHNjX3BvcnRfaW5mbyAqcGkpCit7CisJcHJfZGVidWcoIm1wc2NfaW5pdF9od1slZF06IEluaXRpYWxpemluZ1xuIiwgcGktPnBvcnQubGluZSk7CisKKwltcHNjX2JyZ19pbml0KHBpLCBwaS0+YnJnX2Nsa19zcmMpOworCW1wc2NfYnJnX2VuYWJsZShwaSk7CisJbXBzY19zZG1hX2luaXQocGksIGRtYV9nZXRfY2FjaGVfYWxpZ25tZW50KCkpOwkvKiBidXJzdCBhIGNhY2hlbGluZSAqLworCW1wc2Nfc2RtYV9zdG9wKHBpKTsKKwltcHNjX2h3X2luaXQocGkpOworCisJcmV0dXJuOworfQorCitzdGF0aWMgaW50CittcHNjX2FsbG9jX3JpbmdfbWVtKHN0cnVjdCBtcHNjX3BvcnRfaW5mbyAqcGkpCit7CisJaW50IHJjID0gMDsKKwlzdGF0aWMgdm9pZCBtcHNjX2ZyZWVfcmluZ19tZW0oc3RydWN0IG1wc2NfcG9ydF9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mRtYV9yZWdpb24sCisJCQkJKHVsb25nKXBpLT5kbWFfcmVnaW9uICsgTVBTQ19ETUFfQUxMT0NfU0laRSk7CisjZW5kaWYKKworCXJldHVybjsKK30KKworc3RhdGljIHZvaWQKK21wc2NfdW5pbml0X3JpbmdzKHN0cnVjdCBtcHNjX3BvcnRfaW5mbyAqcGkpCit7CisJcHJfZGVidWcoIm1wc2NfdW5pbml0X3JpbmdzWyVkXTogVW5pbml0aWFsaXppbmcgcmluZ3NcbiIscGktPnBvcnQubGluZSk7CisKKwlCVUdfT04ocGktPmRtYV9yZWdpb24gPT0gTlVMTCk7CisKKwlwaS0+cnhyID0gMDsKKwlwaS0+cnhyX3AgPSAwOworCXBpLT5yeGIgPSBOVUxMOworCXBpLT5yeGJfcCA9IE5VTEw7CisJcGktPnJ4cl9wb3NuID0gMDsKKworCXBpLT50eHIgPSAwOworCXBpLT50eHJfcCA9IDA7CisJcGktPnR4YiA9IE5VTEw7CisJcGktPnR4Yl9wID0gTlVMTDsKKwlwaS0+dHhyX2hlYWQgPSAwOworCXBpLT50eHJfdGFpbCA9IDA7CisKKwlyZXR1cm47Cit9CisKK3N0YXRpYyBpbnQKK21wc2NfbWFrZV9yZWFkeShzdHJ1Y3QgbXBzY19wb3J0X2luZm8gKnBpKQoreworCWludCByYzsKKworCXByX2RlYnVnKCJtcHNjX21ha2VfcmVhZHlbJWRdOiBNYWtpbmcgY2x0ciByZWFkeVxuIiwgcGktPnBvcnQubGluZSk7CisKKwlpZiAoIXBpLT5yZWFkeSkgeworCQltcHNjX2luaXRfaHcocGkpOworCQlpZiAoKHJjID0gbXBzY19hbGxvY19yaW5nX21lbShwaSkpKQorCQkJcmV0dXJuIHJjOworCQltcHNjX2luaXRfcmluZ3MocGkpOworCQlwaS0+cmVhZHkgPSAxOworCX0KKworCXJldHVybiAwOworfQorCisvKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq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Y3RsICAgID0gbXBzY19icmVha19jdGwsCisJLnN0YXJ0dXAgICAgICA9IG1wc2Nfc3RhcnR1cCwKKwkuc2h1dGRvd24gICAgID0gbXBzY19zaHV0ZG93biwKKwkuc2V0X3Rlcm1pb3MgID0gbXBzY19zZXRfdGVybWlvcywKKwkudHlwZSAgICAgICAgID0gbXBzY190eXBlLAorCS5yZWxlYXNlX3BvcnQgPSBtcHNjX3JlbGVhc2VfcG9ydCwKKwkucmVxdWVzdF9wb3J0ID0gbXBzY19yZXF1ZXN0X3BvcnQsCisJLmNvbmZpZ19wb3J0ICA9IG1wc2NfY29uZmlnX3BvcnQsCisJLnZlcmlmeV9wb3J0ICA9IG1wc2NfdmVyaWZ5X3BvcnQsCit9OworCisvKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICoKKyAqIENvbnNvbGUgSW50ZXJmYWNlIFJvdXRpbmVzCisgKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICovCisKKyNpZmRlZiBDT05GSUdfU0VSSUFMX01QU0NfQ09OU09MRQorc3RhdGljIHZvaWQKK21wc2NfY29uc29sZV93cml0ZShzdHJ1Y3QgY29uc29sZSAqY28sIGNvbnN0IGNoYXIgKnMsIHVpbnQgY291bnQpCit7CisJc3RydWN0IG1wc2NfcG9ydF9pbmZvICpwaSA9ICZtcHNjX3BvcnRzW2NvLT5pbmRleF07CisJdTggKmJwLCAqZHAsIGFkZF9jciA9IDA7CisJaW50IGk7CisKKwl3aGlsZSAobXBzY19zZG1hX3R4X2FjdGl2ZShwaSkpCisJCXVkZWxheSgxMDApOworCisJd2hpbGUgKGNvdW50ID4gMCkgeworCQlicCA9IGRwID0gcGktPnR4YiArIChwaS0+dHhyX2hlYWQgKiBNUFNDX1RYQkVfU0laRSk7CisKKwkJZm9yICh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0dXAgID0gbXBzY19jb25zb2xlX3NldHVwLAorCS5mbGFncyAgPSBDT05fUFJJTlRCVUZGRVIsCisJLmluZGV4ICA9IC0xLAorCS5kYXRhICAgPSAmbXBzY19yZWcsCit9OworCitzdGF0aWMgaW50IF9faW5pdAorbXBzY19sYXRlX2NvbnNvbGVfaW5pdCh2b2lkKQoreworCXByX2RlYnVnKCJtcHNjX2xhdGVfY29uc29sZV9pbml0OiBFbnRlclxuIik7CisKKwlpZiAoIShtcHNjX2NvbnNvbGUuZmxhZ3MgJiBDT05fRU5BQkxFRCkpCisJCXJlZ2lzdGVyX2NvbnNvbGUoJm1wc2NfY29uc29sZSk7CisJcmV0dXJuIDA7Cit9CisKK2xhdGVfaW5pdGNhbGwobXBzY19sYXRlX2NvbnNvbGVfaW5pdCk7CisKKyNkZWZpbmUgTVBTQ19DT05TT0xFCSZtcHNjX2NvbnNvbGUKKyNlbHNlCisjZGVmaW5lIE1QU0NfQ09OU09MRQlOVUxMCisjZW5kaWYKKy8qCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogRHVtbXkgUGxhdGZvcm0gRHJpdmVyIHRvIGV4dHJhY3QgJiBtYXAgc2hhcmVkIHJlZ2lzdGVyIHJlZ2lvbnMKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKi8KK3N0YXRpYyB2b2lkCittcHNjX3Jlc291cmNlX2VycihjaGFyICpzKQoreworCXByaW50ayhLRVJOX1dBUk5JTkcgIk1QU0M6IFBsYXRmb3JtIGRldmljZSByZXNvdXJjZSBlcnJvciBpbiAlc1xuIiwgcyk7CisJcmV0dXJuOworfQorCitzdGF0aWMgaW50CittcHNjX3NoYXJlZF9tYXBfcmVncyhzdHJ1Y3QgcGxhdGZvcm1fZGV2aWNlICpwZCkKK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mVncy5NUFNDX01SUl9tID0gMDsKKwkJbXBzY19zaGFyZWRfcmVncy5NUFNDX1JDUlJfbSA9IDA7CisJCW1wc2Nfc2hhcmVkX3JlZ3MuTVBTQ19UQ1JSX20gPSAwOworCQltcHNjX3NoYXJlZF9yZWdzLlNETUFfSU5UUl9DQVVTRV9tID0gMDsKKwkJbXBzY19zaGFyZWRfcmVncy5TRE1BX0lOVFJfTUFTS19tID0gMDsKKwkJcmMgPSAwOworCX0KKworCXJldHVybiByYzsKK30KKworc3RhdGljIHN0cnVjdCBkZXZpY2VfZHJpdmVyIG1wc2Nfc2hhcmVkX2RyaXZlciA9IHsKKwkubmFtZQk9IE1QU0NfU0hBUkVEX05BTUUsCisJLmJ1cwk9ICZwbGF0Zm9ybV9idXNfdHlwZSwKKwkucHJvYmUJPSBtcHNjX3NoYXJlZF9kcnZfcHJvYmUsCisJLnJlbW92ZQk9IG1wc2Nfc2hhcmVkX2Rydl9yZW1vdmUsCit9OworCisvKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICoKKyAqIERyaXZlciBJbnRlcmZhY2UgUm91dGluZXMKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKi8KK3N0YXRpYyBzdHJ1Y3QgdWFydF9kcml2ZXIgbXBzY19yZWcgPSB7CisJLm93bmVyICAgICAgID0gVEhJU19NT0RVTEUsCisJLmRyaXZlcl9uYW1lID0gTVBTQ19EUklWRVJfTkFNRSwKKwkuZGV2ZnNfbmFtZSAgPSBNUFNDX0RFVkZTX05BTUUsCisJLmRldl9uYW1lICAgID0gTVBTQ19ERVZfTkFNRSwKKwkubWFqb3IgICAgICAgPSBNUFNDX01BSk9SLAorCS5taW5vciAgICAgICA9IE1QU0NfTUlOT1JfU1RBUlQsCisJLm5yICAgICAgICA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CisvKioKKyAqIG11eF9kcnZfcG9sbCAtIE11eCBwb2xsIGZ1bmN0aW9uLgorICogQHVudXNlZDogVW51c2VkIHZhcmlhYmxlCisgKgorICogVGhpcyBmdW5jdGlvbiBwZXJpb2RpY2FsbHkgcG9sbHMgdGhlIFNlcmlhbCBNVVggdG8gY2hlY2sgZm9yIG5ldyBkYXRhLgorICovCitzdGF0aWMgdm9pZCBtdXhfcG9sbCh1bnNpZ25lZCBsb25nIHVudXNlZCkKK3sgIAorCWludCBpOworCisJZm9yKGkgPSAwOyBpIDwgcG9ydF9jbnQ7ICsraSkgeworCQlpZighbXV4X3BvcnRzW2ldLmluZm8pCisJCQljb250aW51ZTsKKworCQltdXhfcmVhZCgmbXV4X3BvcnRzW2ldKTsKKwkJbXV4X3dyaXRlKCZtdXhfcG9ydHNbaV0pOworCX0KKworCW1vZF90aW1lcigmbXV4X3RpbWVyLCBqaWZmaWVzICsgTVVYX1BPTExfREVMQVkpOworfQorCisKKyNpZmRlZiBDT05GSUdfU0VSSUFMX01VWF9DT05TT0xFCitzdGF0aWMgdm9pZCBtdXhfY29uc29sZV93cml0ZShzdHJ1Y3QgY29uc29sZSAqY28sIGNvbnN0IGNoYXIgKnMsIHVuc2lnbmVkIGNvdW50KQoreworICAgICAgICB3aGlsZShjb3VudC0tKQorICAgICAgICAgICAgICAgIHBkY19pb2RjX3B1dGMoKnMrKyk7Cit9CisKK3N0YXRpYyBpbnQgbXV4X2NvbnNvbGVfc2V0dXAoc3RydWN0IGNvbnNvbGUgKmNvLCBjaGFyICpvcHRpb25zKQoreworICAgICAgICByZXR1cm4gMDsKK30KKworc3RydWN0IHR0eV9kcml2ZXIgKm11eF9jb25zb2xlX2RldmljZShzdHJ1Y3QgY29uc29sZSAqY28sIGludCAqaW5kZXgpCit7CisgICAgICAgICppbmRleCA9IGNvLT5pbmRleDsKKwlyZXR1cm4gbXV4X2RyaXZlci50dHlfZHJpdmVyOworfQorCitzdGF0aWMgc3RydWN0IGNvbnNvbG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TKTsKKwkJenNzeW5jKHVhcF9hKTsJCQorICAgICAgIAkJaWYgKHIzICYgQ0hBRVhUKQorICAgICAgIAkJCXBtel9zdGF0dXNfaGFuZGxlKHVhcF9hLCByZWdzKTsKKwkJaWYgKHIzICYgQ0hBUnhJUCkKKwkJCXR0eSA9IHBtel9yZWNlaXZlX2NoYXJzKHVhcF9hLCByZWdzKTsKKyAgICAgICAJCWlmIChyMyAmIENIQVR4SVApCisgICAgICAgCQkJcG16X3RyYW5zbWl0X2NoYXJzKHVhcF9hKTsKKwkgICAgICAgIHJjID0gSVJRX0hBTkRMRUQ7CisgICAgICAgCX0KKyAgICAgICAJc3Bpbl91bmxvY2soJnVhcF9hLT5wb3J0LmxvY2spOworCWlmICh0dHkgIT0gTlVMTCkKKwkJdHR5X2ZsaXBfYnVmZmVyX3B1c2godHR5KTsKKworCWlmICh1YXBfYi0+bm9kZSA9PSBOVUxMKQorCQlnb3RvIG91dDsKKworICAgICAgIAlzcGluX2xvY2soJnVhcF9iLT5wb3J0LmxvY2spOworCXR0eSA9IE5VTEw7CisJaWYgKHIzICYgKENIQkVYVCB8IENIQlR4SVAgfCBDSEJSeElQKSkgeworCQl3cml0ZV96c3JlZyh1YXBfYiwgUjAsIFJFU19IX0lVUyk7CisJCXpzc3luYyh1YXBfYik7CisgICAgICAgCQlpZiAocjMgJiBDSEJFWFQpCisgICAgICAgCQkJcG16X3N0YXR1c19oYW5kbGUodWFwX2IsIHJlZ3MpOworICAgICAgIAkgICAgICAgCWlmIChyMyAmIENIQlJ4SVApCisgICAgICAgCQkJdHR5ID0gcG16X3JlY2VpdmVfY2hhcnModWFwX2IsIHJlZ3MpOworICAgICAgIAkJaWYgKHIzICYgQ0hCVHhJUCkKKyAgICAgICAJCQlwbXpfdHJhbnNtaXRfY2hhcnModWFwX2IpOworCSAgICAgICAJcmMgPSBJUlFfSEFORExFRDsKKyAgICAgICAJfQorICAgICAgIAlzcGluX3VubG9jaygmdWFwX2ItPnBvcnQubG9jayk7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pY291bnQuZGNkICAgICAgICAgPSBjbm93LmRjZDsKKwlpY291bnQucnggICAgICAgICAgPSBjbm93LnJ4OworCWljb3VudC50eCAgICAgICAgICA9IGNub3cudHg7CisJaWNvdW50LmZyYW1lICAgICAgID0gY25vdy5mcmFtZTsKKwlpY291bnQub3ZlcnJ1biAgICAgPSBjbm93Lm92ZXJydW47CisJaWNvdW50LnBhcml0eSAgICAgID0gY25vdy5wYXJpdHk7CisJaWNvdW50LmJyayAgICAgICAgID0gY25vdy5icms7CisJaWNvdW50LmJ1Zl9vdmVycnVuID0gY25vdy5idWZfb3ZlcnJ1bjsKKworCXJldHVybiBjb3B5X3RvX3VzZXIoaWNudCwgJmljb3VudCwgc2l6ZW9mKGljb3VudCkpID8gLUVGQVVMVCA6IDA7Cit9CisKKy8qCisgKiBDYWxsZWQgdmlhIHN5c19pb2N0bCB1bmRlciB0aGUgQktMLiAgV2UgY2FuIHVzZSBzcGluX2xvY2tfaXJxKCkgaGVyZS4KKyAqLworc3RhdGljIGludAordWFydF9pb2N0bChzdHJ1Y3QgdHR5X3N0cnVjdCAqdHR5LCBzdHJ1Y3QgZmlsZSAqZmlscCwgdW5zaWduZWQgaW50IGNtZCwKKwkgICB1bnNpZ25lZCBsb25nIGFyZykKK3sKKwlzdHJ1Y3QgdWFydF9zdGF0ZSAqc3RhdGUgPSB0dHktPmRyaXZlcl9kYXRhOworCXZvaWQgX191c2VyICp1YXJnID0gKHZvaWQgX191c2VyICopYXJnOworCWludCByZXQgPSAtRU5PSU9DVExDTUQ7CisKKwlCVUdfT04oIWtlcm5lbF9sb2NrZWQoKSk7CisKKwkvKgorCSAqIFRoZXNlIGlvY3RscyBkb24ndCByZWx5IG9uIHRoZSBoYXJkd2FyZSB0byBiZSBwcmVzZW50LgorCSAqLworCXN3aXRjaCAoY21kKSB7CisJY2FzZSBUSU9DR1NFUklBTDoKKwkJcmV0ID0gdWFydF9nZXRfaW5mbyhzdGF0ZSwgdWFyZyk7CisJCWJyZWFrOwor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IzMiwgICAgICAyIH0sCisJeyBNQU5GSURfTkFUSU5TVCwgUFJPRElEX05BVElOU1RfUVVBRF9SUzIzMiwgICAgNCB9Cit9OworI2RlZmluZSBNVUxUSV9DT1VOVCAoc2l6ZW9mKG11bHRpX2lkKS9zaXplb2Yoc3RydWN0IG11bHRpX2lkKSkKKworc3RydWN0IHNlcmlhbF9pbmZvIHsKKwlkZXZfbGlua190CQlsaW5rOworCWludAkJCW5kZXY7CisJaW50CQkJbXVsdGk7CisJaW50CQkJc2xhdmU7CisJaW50CQkJbWFuZmlkOworCWRldl9ub2RlX3QJCW5vZGVbNF07CisJaW50CQkJbGluZVs0XTsKK307CisKK3N0YXRpYyB2b2lkIHNlcmlhbF9jb25maWcoZGV2X2xpbmtfdCAqIGxpbmspOworc3RhdGljIGludCBzZXJpYWxfZXZlbnQoZXZlbnRfdCBldmVudCwgaW50IHByaW9yaXR5LAorCQkJZXZlbnRfY2FsbGJhY2tfYXJnc190ICogYXJncyk7CisKK3N0YXRpYyBkZXZfaW5mb190IGRldl9pbmZvID0gInNlcmlhbF9jcyI7CisKK3N0YXRpYyBkZXZfbGlua190ICpzZXJpYWxfYXR0YWNoKHZvaWQpOworc3RhdGljIHZvaWQgc2VyaWFsX2RldGFjaChkZXZfbGlua190ICopOworCitzdGF0aWMgZGV2X2xpbmtfdCAqZGV2X2xpc3QgPSBOVUxMOworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKworICAgIEFmdGVyIGEgY2FyZCBpcyByZW1vdmVkLCBzZXJpYWxfcmVtb3ZlKCkgd2lsbCB1bnJlZ2lzdGVyCisgICAgdGhlIHNlcmlhbCBkZXZpY2UocyksIGFuZCByZWxlYXNlIHRoZSBQQ01DSUEgY29uZmlndXJhdGlvbi4KKyAgICAKKz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT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aSA8IGluZm8tPm5kZXY7IGkrKykKKwkJCXNlcmlhbDgyNTBfc3VzcGVuZF9wb3J0KGluZm8tPmxpbmVbaV0pOworCisJCWlmICghaW5mby0+c2xhdmUpCisJCQlwY21jaWFfcmVsZWFzZV9jb25maWd1cmF0aW9uKGxpbmstPmhhbmRsZSk7CisJfQorfQorCitzdGF0aWMgdm9pZCBzZXJpYWxfcmVzdW1lKGRldl9saW5rX3QgKmxpbmspCit7CisJbGluay0+c3RhdGUgJj0gfkRFVl9TVVNQRU5EOworCisJaWYgKERFVl9PSyhsaW5rKSkgeworCQlzdHJ1Y3Qgc2VyaWFsX2luZm8gKmluZm8gPSBsaW5rLT5wcml2OworCQlpbnQgaTsKKworCQlpZiAoIWluZm8tPnNsYXZlKQorCQkJcGNtY2lhX3JlcXVlc3RfY29uZmlndXJhdGlvbihsaW5rLT5oYW5kbGUsICZsaW5rLT5jb25mKTsKKworCQlmb3IgKGkgPSAwOyBpIDwgaW5mby0+bmRldjsgaSsrKQorCQkJc2VyaWFsODI1MF9yZXN1bWVfcG9ydChpbmZvLT5saW5lW2ldKTsKKwl9Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorCisgICAgc2VyaWFsX2F0dGFjaCgpIGNyZWF0ZXMgYW4gImluc3RhbmNlIiBvZiB0aGUgZHJpdmVyLCBhbGxvY2F0aW5nCisgICAgbG9jYWwgZGF0YSBzdHJ1Y3R1cmVzIGZvciBvbmUgZGV2aWNlLiAgVGhlIGRldmljZSBpcyByZWdpc3RlcmVkCisgICAgd2l0aCBDYXJkIFNlcnZpY2VzLgorCis9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGRldl9saW5rX3QgKnNlcmlhbF9hdHRhY2godm9pZCkKK3sKKwlzdHJ1Y3Qgc2VyaWFsX2luZ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RfUkVNT1ZBTCB8CisJICAgIENTX0VWRU5UX1JFU0VUX1BIWVNJQ0FMIHwgQ1NfRVZFTlRfQ0FSRF9SRVNFVCB8CisJICAgIENTX0VWRU5UX1BNX1NVU1BFTkQgfCBDU19FVkVOVF9QTV9SRVNVTUU7CisJY2xpZW50X3JlZy5ldmVudF9oYW5kbGVyID0gJnNlcmlhbF9ldmVudDsKKwljbGllbnRfcmVnLlZlcnNpb24gPSAweDAyMTA7CisJY2xpZW50X3JlZy5ldmVudF9jYWxsYmFja19hcmdzLmNsaWVudF9kYXRhID0gbGluazsKKwlyZXQgPSBwY21jaWFfcmVnaXN0ZXJfY2xpZW50KCZsaW5rLT5oYW5kbGUsICZjbGllbnRfcmVnKTsKKwlpZiAocmV0ICE9IENTX1NVQ0NFU1MpIHsKKwkJY3NfZXJyb3IobGluay0+aGFuZGxlLCBSZWdpc3RlckNsaWVudCwgcmV0KTsKKwkJc2VyaWFsX2RldGFjaChsaW5rKTsKKwkJcmV0dXJuIE5VTEw7CisJfQorCisJcmV0dXJuIGxpbms7Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorCisgICAgVGhpcyBkZWxldGVzIGEgZHJpdmVyICJpbnN0YW5jZSIuICBUaGUgZGV2aWNlIGlzIGRlLXJlZ2lzdGVyZWQKKyAgICB3aXRoIENhcmQgU2VydmljZXMuICBJZiBpdCBoYXMgYmVlbiByZWxlYXNlZCwgYWxsIGxvY2FsIGRhdGEKKyAgICBzdHJ1Y3R1cmVzIGFyZSBmcmVlZC4gIE90aGVyd2lzZSwgdGhlIHN0cnVjdHVyZXMgd2lsbCBiZSBmcmVlZAorICAgIHdoZW4gdGhlIGRldmljZSBpcyByZWxlYXNlZC4KKworPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyB2b2lkIHNlcmlhbF9kZXRhY2goZGV2X2xpbmtfdCAqIGxpbmspCit7CisJc3RydWN0IHNlcmlhbF9pbmZvICppbmZvID0gbGluay0+cHJpdjsKKwlkZXZfbGlua190ICoqbGlua3A7CisJaW50IHJldDsKKworCURFQlVHKDAsICJzZXJpYWxfZGV0YWNoKDB4JXApXG4iLCBsaW5rKTsKKworCS8qIExvY2F0ZSBkZXZpY2Ugc3RydWN0dXJlICovCisJZm9yIChsaW5rcCA9ICZkZXZfbGlzdDsgKmxpbmtwOyBsaW5rcCA9ICYoKmxpbmtwKS0+bmV4dCkKKwkJaWYgKCpsaW5rcCA9PSBsaW5rKQorCQkJYnJlYWs7CisJaWYgKCpsaW5rcCA9PSBOVUxMKQorCQlyZXR1cm47CisKKwkvKgorCSAqIEVuc3VyZSBhbnkgb3V0c3RhbmRpbmcgc2NoZWR1bGVkIHRhc2tzIGFyZSBjb21wbGV0ZWQuCisJICovCisJZmx1c2hfc2NoZWR1bGVkX3dvcmsoKTsKKworCS8qCisJICogRW5zdXJlIHRoYXQgdGhlIHBvcnRzIGhhdmUgYmVlbiByZWxlYXNlZC4KKwkgKi8KKwlzZXJpYWxfcmVtb3ZlKGxpbmspOworCisJaWYgKGxpbmstPmhhbmRsZSkgeworCQlyZXQgPSBwY21jaWFfZGVyZWdpc3Rlcl9jbGllbnQobGluay0+aGFuZGxlKTsKKwkJaWYgKHJldCAhPSBDU19TVUNDRVNTKQorCQkJY3NfZXJyb3IobGluay0+aGFuZGxlLCBEZXJlZ2lzdGVyQ2xpZW50LCByZXQpOworCX0KKworCS8qIFVubGluayBkZXZpY2Ugc3RydWN0dXJlLCBmcmVlIGJpdHMgKi8KKwkqbGlua3AgPSBsaW5rLT5uZXh0OworCWtmcmVlKGluZm8pOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCBzZXR1cF9zZXJpYWwoY2xpZW50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T09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IHNpbXBsZV9jb25maWcoZGV2X2xpbmtfdCAqbGluaykKK3sKKwlzdGF0aWMga2lvX2FkZHJfdCBiYXNlWzVdID0geyAweDNmOCwgMHgyZjgsIDB4M2U4LCAweDJlOCwgMHgwIH07CisJc3RhdGljIGludCBzaXplX3RhYmxlWzJdID0geyA4LCAxNiB9OworCWNsaWVudF9oYW5kbGVfdCBoYW5kbGUgPSBsaW5rLT5oYW5kbGU7CisJc3RydWN0IHNlcmlhbF9pbmZvICppbmZvID0gbGluay0+cHJpdjsKKwl0dXBsZV90IHR1cGxlOworCXVfY2hhciBidWZbMjU2XTsKKwljaXNwYXJzZV90IHBhcnNlOworCWNpc3RwbF9jZnRhYmxlX2VudHJ5X3QgKmNmID0gJnBhcnNlLmNmdGFibGVfZW50cnk7CisJY29uZmlnX2luZm9fdCBjb25maWc7CisJaW50IGksIGosIHRyeTsKKwlpbnQgczsKKworCS8qIElmIHRoZSBjYXJkIGlzIGFscmVhZHkgY29uZmlndXJlZCwgbG9vayB1cCB0aGUgcG9ydCBhbmQgaXJxICovCisJaSA9IHBjbWNpYV9nZXRfY29uZmlndXJhdGlvbl9pbmZvKGhhbmRsZSwgJmNvbmZpZyk7CisJaWYgKChpID09IENTX1NVQ0NFU1MpICYmIChjb25maWcuQXR0cmlidXRlcyAmIENPTkZfVkFMSURfQ0xJRU5UKSkgeworCQlraW9fYWRkcl90IHBvcnQgPSAwOworCQlpZiAoKGNvbmZpZy5CYXNlUG9ydDIgIT0gMCkgJiYgKGNvbmZpZy5OdW1Qb3J0czIgPT0gOCkpIHsKKwkJCXBvcnQgPSBjb25maWcuQmFzZVBvcnQyOworCQkJaW5mby0+c2xhdmUgPSAxOworCQl9IGVsc2UgaWYgKChpbmZvLT5tYW5maWQgPT0gTUFORklEX09TSVRFQ0gpICYmCisJCQkgICAoY29uZmlnL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c3NpZ25lZElSUSk7CisJCQlvdXRiKDEyLCBiYXNlMiArIDEpOworCQl9CisJCXJldHVybiAwOworCX0KKworCXNldHVwX3NlcmlhbChoYW5kbGUsIGluZm8sIGxpbmstPmlvLkJhc2VQb3J0MSwgbGluay0+aXJxLkFzc2lnbmVkSVJRKTsKKwkvKiBUaGUgTm9raWEgY2FyZHMgYXJlIG5vdCByZWFsbHkgbXVsdGlwb3J0IGNhcmRzICovCisJaWYgKGluZm8tPm1hbmZpZCA9PSBNQU5GSURfTk9LSUEpCisJCXJldHVybiAwOworCWZvciAoaSA9IDA7IGkgPCBpbmZvLT5tdWx0aSAtIDE7IGkrKykKKwkJc2V0dXBfc2VyaWFsKGhhbmRsZSwgaW5mbywgYmFzZTIgKyAoOCAqIGkpLCBsaW5rLT5pcnEuQXNzaWduZWRJUlEpOworCisJcmV0dXJuIDA7Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorCisgICAgc2VyaWFsX2NvbmZpZygpIGlzIHNjaGVkdWxlZCB0byBydW4gYWZ0ZXIgYSBDQVJEX0lOU0VSVElPTiBldmVudAorICAgIGlzIHJlY2VpdmVkLCB0byBjb25maWd1cmUgdGhlIFBDTUNJQSBzb2NrZXQsIGFuZCB0byBtYWtlIHRoZQorICAgIHNlcmlhbCBkZXZpY2UgYXZhaWxhYmxlIHRvIHRoZSBzeXN0ZW0uCisKKz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCit2b2lkIHNlcmlhbF9jb25maWcoZGV2X2xpbmtfdCAqIGxpbmspCit7CisJY2xpZW50X2hhbmRsZV90IGhhbmRsZSA9IGxpbmstPmhhbmRsZTsKKwlzdHJ1Y3Qgc2VyaWFsX2luZm8gKmluZm8gPSBsaW5rLT5wcml2OworCXR1cGxlX3QgdHVwbGU7CisJdV9zaG9yd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SB7CisJCQlsYXN0X2ZuID0gQWNjZXNzQ29uZmlndXJhdGlvblJlZ2lzdGVyOworCQkJZ290byBjc19mYWlsZWQ7CisJCX0KKwl9CisKKwlsaW5rLT5kZXYgPSAmaW5mby0+bm9kZVswXTsKKwlsaW5rLT5zdGF0ZSAmPSB+REVWX0NPTkZJR19QRU5ESU5HOworCXJldHVybjsKKworIGNzX2ZhaWxlZDoKKwljc19lcnJvcihsaW5rLT5oYW5kbGUsIGxhc3RfZm4sIGxhc3RfcmV0KTsKKyBmYWlsZWQ6CisJc2VyaWFsX3JlbW92ZShsaW5rKTsKKwlsaW5rLT5zdGF0ZSAmPSB+REVWX0NPTkZJR19QRU5ESU5HOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKworICAgIFRoZSBjYXJkIHN0YXR1cyBldmVudCBoYW5kbGVyLiAgTW9zdGx5LCB0aGlzIHNjaGVkdWxlcyBvdGhlcgorICAgIHN0dWZmIHRvIHJ1biBhZnRlciBhbiBldmVudCBpcyByZWNlaXZlZC4gIEEgQ0FSRF9SRU1PVkFMIGV2ZW50CisgICAgYWxzbyBzZXRzIHNvbWUgZmxhZ3MgdG8gZGlzY291cmFnZSB0aGUgc2VyaWFsIGRyaXZlcnMgZnJvbQorICAgIHRhbGtpbmcgdG8gdGhlIHBvcnRzLgorICAgIAorPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyBpbnQKK3NlcmlhbF9ldmVudChldmVudF90IGV2ZW50LCBpbnQgcHJpb3JpdHksIGV2ZW50X2NhbGxiYWNrX2FyZ3NfdCAqIGFyZ3MpCit7CisJZGV2X2xpbmtfdCAqbGluayA9IGFyZ3MtPmNsaWVudF9kYXRhOworCXN0cnVjdCBzZXJpYWxfaW5mbyAqaW5mbyA9IGxpbmstPnByaXY7CisKK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FkeShzdHJ1Y3Qgc2NpX3BvcnQgKnBvcnQpCit7CisgICAgICAgIHVuc2lnbmVkIHNob3J0IHN0YXR1cyA9IHNjaV9pbihwb3J0LCBTQ3hTUik7CisKKyAgICAgICAgaWYgKHN0YXR1cyAmIChTQ3hTUl9FUlJPUlMocG9ydCkgfCBTQ3hTUl9CUksocG9ydCkpKQorICAgICAgICAgICAgICAgIGtnZGJfaGFuZGxlX2Vycm9yKHBvcnQpOworCisgICAgICAgIHJldHVybiAoc3RhdHVzICYgU0N4U1JfUkR4Rihwb3J0KSk7Cit9CisKKy8qIFdyaXRlIGEgY2hhciAqLworc3RhdGljIHZvaWQga2dkYl9wdXRfY2hhcihzdHJ1Y3Qgc2NpX3BvcnQgKnBvcnQsIGNoYXIgYykKK3sKKyAgICAgICAgdW5zaWduZWQgc2hvcnQgc3RhdHVzOworCisgICAgICAgIGRvCisgICAgICAgICAgICAgICAgc3RhdHVzID0gc2NpX2luKHBvcnQsIFNDeFNSKTsKKyAgICAgICAgd2hpbGUgKCEoc3RhdHVzICYgU0N4U1JfVER4RShwb3J0KSkpOworCisgICAgICAgIHNjaV9vdXQocG9ydCwgU0N4VERSLCBjKTsKKyAgICAgICAgc2NpX2luKHBvcnQsIFNDeFNSKTsgICAgLyogRHVtbXkgcmVhZCAqLworICAgICAgICBzY2lfb3V0KHBvcnQsIFNDeFNSLCBTQ3hTUl9URHhFX0NMRUFSKHBvcnQpKTsKK30KKworLyogR2V0IGEgY2hhciBpZiB0aGVyZSBpcyBvbmUsIGVsc2UgcmV0IC0xICovCitzdGF0aWMgaW50IGtnZGJfZ2V0X2NoYXIoc3RydWN0IHNjaV9wb3J0ICpwb3J0KQoreworICAgICAgICBpbnQgYzsKKworICAgICAgICBpZiAoa2dkYl9pc19jaGFyX3JlYWR5KHBvcnQpID09IDApCisgICAgICAgICAgICAgICAgYyA9IC0xOworICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICBjID0gc2NpX2luKHBvcnQsIFNDeF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gPSAoc3RydWN0IHNjaV9wb3J0ICopcG9ydDsKKyAgICAgICAgICAgICAgICAgICAgICAgaWYoIXNjaV9wb3J0LT5icmVha19mbGFnKSB7CisJICAgICAgICAgICAgICAgICAgICAgICAgc2NpX3BvcnQtPmJyZWFrX2ZsYWcgPSAxOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjaV9zY2hlZHVsZV9icmVha190aW1lcigoc3RydWN0IHNjaV9wb3J0ICopcG9ydCk7CisJCQkJLyogRG8gc3lzcnEgaGFuZGxpbmcuICovCisJCQkJaWYodWFydF9oYW5kbGVfYnJlYWsocG9ydCkpIHsKKwkJCQkJcmV0dXJuIDA7CisJCQkJfQorCQkJICAgICAgICBwcl9kZWJ1Zygic2NpOiBCUkVBSyBkZXRlY3RlZFxuIik7CisJCQkgICAgICAgIGNvcGllZCsrOworCQkJICAgICAgICAqdHR5LT5mbGlwLmZsYWdfYnVmX3B0cisrID0gVFRZX0JSRUFLOworICAgICAgICAgICAgICAgICAgICAgICB9CisJCX0KKwkJZWxzZSB7CisJCQkvKiBmcmFtZSBlcnJvciAqLworCQkJY29waWVkKys7CisJCQkqdHR5LT5mbGlwLmZsYWdfYnVmX3B0cisrID0gVFRZX0ZSQU1FOworCQkJcHJfZGVidWcoInNjaTogZnJhbWUgZXJyb3JcbiIpOworCQl9CisJfQorCisJaWYgKHN0YXR1cyZTQ3hTUl9QRVIocG9ydCkgJiYgdHR5LT5mbGlwLmNvdW50PFRUWV9GTElQQlVGX1NJWkUpIHsKKwkJLyogcGFyaXR5IGVycm9yICovCisJCWNvcGllZCsrOworCQkqdHR5LT5mbGlwLmZsYWdfYnVmX3B0cisrID0gVFRZX1BBUklUWTsKKwkJcHJfZGVidWcoInNjaTogcGFyaXR5IGVycm9yXG4iKTsKKwl9CisKKwlpZiAoY29waWVkKSB7CisJCXR0eS0+ZmxpcC5jb3VudCArPSBjb3BpZWQ7CisJCXR0eV9mbGlwX2J1ZmZlcl9wdXNoKHR0eSk7Cis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sKKwl9CisJZWxzZSB7CisJCS8qIE5vdCByZWdpc3RlcmVkIHlldCAtIGNhbid0IHBhc3MgdG8gdHR5IGxheWVyLiAgKi8KKwkJdHR5ID0gTlVMTDsKKwl9CisKKwl3aGlsZSAocG9ydC0+c2Nfb3BzLT5zYWxfaW5wdXRfcGVuZGluZygpKSB7CisJCWNoID0gcG9ydC0+c2Nfb3BzLT5zYWxfZ2V0YygpOworCQlpZiAoY2ggPCAwKSB7CisJCQlwcmludGsoS0VSTl9FUlIgInNuX2NvbnNvbGU6IEFuIGVycm9yIG9jY3VyZWQgd2hpbGUgIgorCQkJICAgICAgICJvYnRhaW5pbmcgZGF0YSBmcm9tIHRoZSBjb25zb2xlICgweCUweClcbiIsIGNoKTsKKwkJCWJyZWFrOworCQl9CisjaWZkZWYgQ09ORklHX01BR0lDX1NZU1JRCisgICAgICAgICAgICAgICAgaWYgKHN5c3JxX3JlcXVlc3RlZCkgeworICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgbG9uZyBzeXNycV90aW1lb3V0ID0gc3lzcnFfcmVxdWVzdGVkICsgSFoqNTsKKworICAgICAgICAgICAgICAgICAgICAgICAgc3lzcnFfcmVxdWVzdGVkID0gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaCAmJiB0aW1lX2JlZm9yZShqaWZmaWVzLCBzeXNycV90aW1lb3V0KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGluX3VubG9ja19pcnFyZXN0b3JlKCZwb3J0LT5zY19wb3J0LmxvY2ssIGZsYWdzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlX3N5c3JxKGNoLCByZWdzLCBOVUxMKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Bpbl9sb2NrX2lycXNhdmUoJnBvcnQtPnNjX3BvcnQubG9jaywgZmxhZ3MpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBpZ25vcmUgYWN0dWFsIHN5c3JxIGNvbW1hbmQgY2hhciAqLworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKGNoID09ICpzeXNycV9zZXJpYWxfcHRyKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoISgqKytzeXNycV9zZXJpYWxfcHRyKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzeXNycV9yZXF1ZXN0ZWQgPSBqaWZmaWVzOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzeXNycV9zZXJpYWxfcHRyID0gc3lzcnFfc2VyaWFsX3N0cjsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKwkJCS8qCisJCQkgKiBpZ25vcmUgdGhlIHdob2xlIHN5c3JxIHN0cmluZyBleGNlcHQgZm9yIHRoZQorCQkJICogbGVhZGluZyBlc2NhcGUKKwkJCSAqLworCQkJaWYgKGNoICE9ICdcZScpCisJCQkJY29udGludWU7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UKKwkJCXN5c3JxX3NlcmlhbF9wdHIgPSBzeXNycV9zZXJpYWxfc3RyOworI2VuZGlmIC8qIENPTkZJR19NQUdJQ19TWVNSUSAqLworCisJCS8qIHJlY29yZCB0aGUgY2hhcmFjdGVyIHRvIHBhc3MgdXAgdG8gdGhlIHR0eSBsYXllciAqLworCQlpZiAodHR5KSB7CisJCQkqdHR5LT5mbGlwLmNoYXJfYnVmX3B0ciA9IGNoOworCQkJKnR0eS0+ZmxpcC5mbGFnX2J1Zl9wdHIgPSBUVFlfTk9STUFMOworCQkJdHR5LT5mbGlwLmNoYXJfYnVmX3B0cisrOworCQkJdHR5LT5mbGlwLmNvdW50Kys7CisJCQlpZiAodHR5LT5mbGlwLmNvdW50ID09IFRUWV9GTElQQlVGX1NJWkUpCisJCQkJYnJ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CWVyciA9IHByb21fZ2V0cHJvcGVydHkoenNub2RlLCAiaW50ZXJydXB0cyIsCisJCQkJCSAgICAgICAoY2hhciAqKSAmc3VuNHVfaW5vLAorCQkJCQkgICAgICAgc2l6ZW9mKHN1bjR1X2lubykpOworCQkJemlsb2dfaXJxID0gc2J1c19idWlsZF9pcnEoc2J1c19yb290LCBzdW40dV9pbm8pOworCQl9CisJfQorCisJcmV0dXJuIChzdHJ1Y3Qgemlsb2dfbGF5b3V0IF9faW9tZW0gKikgbWFwcGVkX2FkZHI7Cit9CisjZWxzZSAvKiBDT05GSUdfU1BBUkM2NCAqLworCisvKgorICogWFhYIFRoZSBzdW40ZCBjYXNlIGlzIHV0dGVybHkgc2NyZXdlZDogaXQgdHJpZXMgdG8gcmUtd2FsayB0aGUgdHJlZQorICogKGZvciB0aGUgM3JkIHRpbWUpIGluIG9yZGVyIHRvIGZpbmQgYm9vdGJ1cyBhbmQgY3B1LiBTdHJlYW1saW5lIGl0LgorICovCitzdGF0aWMgc3RydWN0IHppbG9nX2xheW91dCBfX2lvbWVtICogX19pbml0IGdldF96c19zdW40Y21kKGludCBjaGlwLCBpbnQgbm9kZSkKK3sKKwlzdHJ1Y3QgbGludXhfcHJvbV9pcnFzIGlycV9pbmZvWzJdOworCXZvaWQgX19pb21lbSAqbWFwcGVkX2FkZHIgPSBOVUxMOworCWludCB6c25vZGUsIGNwdW5vZGUsIGJibm9kZTsKKwlzdHJ1Y3QgbGludXhfcHJvbV9yZWdpc3RlcnMgenNyZWdbNF07CisJc3RydWN0IHJlc291cmNlIHJlczsKKworCWlmIChzcGFyY19jcHVfbW9kZWwgPT0gc3VuNGQpIHsKKwkJaW50IHdhbGs7CisKKwkJenNub2RlID0gMDsKKwkJYmJub2RlID0gMDsKKwkJY3B1bm9kZSA9IDA7CisJCWZvciAod2FsayA9IHByb21fZ2V0Y2hpbGQocHJvbV9yb290X25vZGUpOworCQkgICAgICh3YWxrID0gcHJvbV9zZWFyY2hzaWJsaW5ncy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