1/* 2 * Some or all of this work - Copyright (c) 2006 - 2016, Intel Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * Neither the name of Intel Corporation nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 * Data type conversion and manipulation 31 * 32 * Concatenate two strings, integers or buffers 33 */ 34 35/* 36// !!!!!!!!!!!!!!!!!!!!!!!!!! ??????????????????? 37// SEE: (Compare two buffers) 38// Remove (?) this method and replace it with the 39// LNotEqual, LEqual............ ????? !!!!!!!!!! 40// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 41*/ 42 43Name(z036, 36) 44 45 46// Compare two buffers 47// 48// Arg0 - name 49// Arg1 - buffer1 50// Arg2 - buffer2 51// Arg3 - length 52Method(m310, 4) 53{ 54 Store(0, Local0) 55 While (LLess(Local0, arg3)) { 56 Store(Derefof(Index(arg1, Local0)), Local1) 57 Store(Derefof(Index(arg2, Local0)), Local2) 58 if (LNotEqual(Local1, Local2)) { 59 return (Ones) 60 } 61 Increment(Local0) 62 } 63 64 return (Zero) 65} 66 67// Compare two buffers 68// 69// Arg0 - name 70// Arg1 - buffer1 71// Arg2 - buffer2 72Method(m311, 3) 73{ 74 if (LNotequal(ObjectType(arg1), 3)) { 75 err("m311: unexpected type of Arg1", z036, 0, 0, 0, 0, 0) 76 return (Ones) 77 } 78 79 if (LNotequal(ObjectType(arg2), 3)) { 80 err("m311: unexpected type of Arg2", z036, 1, 0, 0, 0, 0) 81 return (Ones) 82 } 83 84 Store(Sizeof(arg1), Local0) 85 86 if (LNotEqual(Local0, Sizeof(arg2))) { 87 return (Ones) 88 } 89 90 if (m310(Arg0, Arg1, Arg2, Local0)) { 91 return (Ones) 92 } 93 94 return (Zero) 95} 96 97// Verifying 2-parameters, 1-result operator 98Method(m312, 6, Serialized) 99{ 100 Store(0, Local5) 101 Store(arg1, Local3) 102 103 While(Local3) { 104 105 // Operands 106 107 Multiply(Local5, 2, Local6) 108 Store(DeRefOf(Index(arg3, Local6)), Local0) 109 Increment(Local6) 110 Store(DeRefOf(Index(arg3, Local6)), Local1) 111 112 // Expected result 113 114 Store(DeRefOf(Index(arg4, Local5)), Local2) 115 116 switch (ToInteger (arg5)) { 117 case (0) { 118 // Results in buffer 119 Concatenate(Local0, Local1, Local7) 120 121 if (m311(Arg0, Local7, Local2)) { 122 err(arg0, z036, 2, 0, 0, Local5, arg2) 123 } 124 } 125 case (1) { 126 // Results in string 127 128 Concatenate(Local0, Local1, Local7) 129 130 if (LNotequal(ObjectType(Local7), 2)) { 131 err(arg0, z036, 3, 0, 0, Local7, arg2) 132 } elseif (LNotequal(ObjectType(Local2), 2)) { 133 err(arg0, z036, 4, 0, 0, Local2, arg2) 134 } elseif (LNotEqual(Local7, Local2)) { 135 err(arg0, z036, 5, 0, 0, Local7, arg2) 136 } 137 } 138 } 139 140 Increment(Local5) 141 Decrement(Local3) 142 } 143} 144 145// Integers 146Method(m313,, Serialized) 147{ 148 Name(ts, "m313") 149 150 Name(p000, Package() 151 { 152 0, 0, 153 0xffffffff, 0xffffffff, 154 0, 0xffffffff, 155 0, 0x81, 156 0, 0x9ac6, 157 0, 0xab012345, 158 0x92, 0x81, 159 0x93, 0x8476, 160 0xab, 0xdc816778, 161 0xac93, 0x8476, 162 0xf63b, 0x8c8fc2da, 163 0x8790f6a4, 0x98de45ba, 164 }) 165 166 Name(p001, Package() 167 { 168 Buffer() { 0, 0, 0, 0, 0, 0, 0, 0 }, 169 Buffer() { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, 170 Buffer() { 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff }, 171 Buffer() { 0, 0, 0, 0, 0x81, 0, 0, 0 }, 172 Buffer() { 0, 0, 0, 0, 0xc6, 0x9a, 0, 0 }, 173 Buffer() { 0, 0, 0, 0, 0x45, 0x23, 0x01, 0xab }, 174 Buffer() { 0x92, 0, 0, 0, 0x81, 0, 0, 0 }, 175 Buffer() { 0x93, 0, 0, 0, 0x76, 0x84, 0, 0 }, 176 Buffer() { 0xab, 0, 0, 0, 0x78, 0x67, 0x81, 0xdc }, 177 Buffer() { 0x93, 0xac, 0, 0, 0x76, 0x84, 0, 0 }, 178 Buffer() { 0x3b, 0xf6, 0, 0, 0xda, 0xc2, 0x8f, 0x8c }, 179 Buffer() { 0xa4, 0xf6, 0x90, 0x87, 0xba, 0x45, 0xde, 0x98 }, 180 }) 181 182 Name(p002, Package() 183 { 184 Buffer() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 185 Buffer() { 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0 }, 186 Buffer() { 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0 }, 187 Buffer() { 0, 0, 0, 0, 0, 0, 0, 0, 0x81, 0, 0, 0, 0, 0, 0, 0 }, 188 Buffer() { 0, 0, 0, 0, 0, 0, 0, 0, 0xc6, 0x9a, 0, 0, 0, 0, 0, 0 }, 189 Buffer() { 0, 0, 0, 0, 0, 0, 0, 0, 0x45, 0x23, 0x01, 0xab, 0, 0, 0, 0 }, 190 Buffer() { 0x92, 0, 0, 0, 0, 0, 0, 0, 0x81, 0, 0, 0, 0, 0, 0, 0 }, 191 Buffer() { 0x93, 0, 0, 0, 0, 0, 0, 0, 0x76, 0x84, 0, 0, 0, 0, 0, 0 }, 192 Buffer() { 0xab, 0, 0, 0, 0, 0, 0, 0, 0x78, 0x67, 0x81, 0xdc, 0, 0, 0, 0 }, 193 Buffer() { 0x93, 0xac, 0, 0, 0, 0, 0, 0, 0x76, 0x84, 0, 0, 0, 0, 0, 0 }, 194 Buffer() { 0x3b, 0xf6, 0, 0, 0, 0, 0, 0, 0xda, 0xc2, 0x8f, 0x8c, 0, 0, 0, 0 }, 195 Buffer() { 0xa4, 0xf6, 0x90, 0x87, 0, 0, 0, 0, 0xba, 0x45, 0xde, 0x98, 0, 0, 0, 0 }, 196 }) 197 198 Name(p003, Package() 199 { 200 0xffffffffffffffff, 0xffffffffffffffff, 201 0x1234567890abcdef, 0x1122334455667788, 202 }) 203 204 Name(p004, Package() 205 { 206 Buffer() { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 207 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, 208 Buffer() { 0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12, 209 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11 }, 210 }) 211 212 213 if (LEqual(F64, 1)) { 214 m312(ts, 12, "p000", p000, p002, 0) 215 m312(ts, 2, "p003", p003, p004, 0) 216 } else { 217 m312(ts, 12, "p000", p000, p001, 0) 218 } 219} 220 221// Strings 222Method(m314,, Serialized) 223{ 224 Name(ts, "m314") 225 226 Name(p000, Package() 227 { 228 "qwertyuiop", "qwertyuiop", 229 "qwertyuiop", "qwertyuiop0", 230 "qwertyuiop", "qwertyuio", 231 232 "", "", 233 " ", "", 234 "", " ", 235 " ", " ", 236 " ", " ", 237 " ", " ", 238 239 "a", "", 240 "", "a", 241 " a", "a", 242 "a", " a", 243 "a ", "a", 244 "a", "a ", 245 "a b", "ab", 246 "ab", "a b", 247 "a b", "a b", 248 "a b", "a b", 249 "abcDef", "abcdef", 250 251 // 100 + 100 252 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", 253 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", 254 255 "0", "", 256 }) 257 258 Name(p001, Package() 259 { 260 "qwertyuiopqwertyuiop", 261 "qwertyuiopqwertyuiop0", 262 "qwertyuiopqwertyuio", 263 264 "", 265 " ", 266 " ", 267 " ", 268 " ", 269 " ", 270 271 "a", 272 "a", 273 " aa", 274 "a a", 275 "a a", 276 "aa ", 277 "a bab", 278 "aba b", 279 "a ba b", 280 "a ba b", 281 "abcDefabcdef", 282 "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", 283 }) 284 285 m312(ts, 21, "p000", p000, p001, 1) 286} 287 288// Buffers 289Method(m315,, Serialized) 290{ 291 Name(ts, "m314") 292 293 Name(p000, Package() 294 { 295 Buffer(100){}, 296 Buffer(101){}, 297 }) 298 299 Name(p001, Package() 300 { 301 Buffer(201){}, 302 }) 303 304 Name(p002, Package() 305 { 306 Buffer() {1, 1, 2, 3, 4}, 307 Buffer() {1, 2, 3, 4, 5, 6, 7, 8, 308 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 309 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 310 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 311 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 312 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 313 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 314 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,112, 315 113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128}, 316 Buffer() { 317 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 318 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 319 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 320 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 321 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 322 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 323 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,112, 324 113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128, 325 129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144, 326 145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160, 327 161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176, 328 177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192, 329 193,194,195,196,197,198,199,200, 330 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 331 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 332 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 333 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 334 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 335 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 336 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,112, 337 113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128, 338 129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144, 339 145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160, 340 161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176, 341 177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192, 342 193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208, 343 209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224, 344 225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240, 345 241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, 0, 1}, 346 }) 347 348 m312(ts, 1, "p000", p000, p001, 0) 349 m312(ts, 3, "p325", p325, p002, 0) 350} 351 352// Run-method 353Method(CCT0) 354{ 355 Store("TEST: CCT0, Concatenate two strings, integers or buffers", Debug) 356 357 m313() 358 m314() 359 m315() 360} 361 362 363