1/ This Source Code Form is subject to the terms of the Mozilla Public 2/ License, v. 2.0. If a copy of the MPL was not distributed with this 3/ file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 .file "mpcpucache.c" 6/ .section .rodata.str1.1,"aMS",@progbits,1 7 .section .rodata 8.LC0: 9 .string "GenuineIntel" 10.LC1: 11 .string "AuthenticAMD" 12.LC2: 13 .string "CyrixInstead" 14.LC3: 15 .string "CentaurHauls" 16.LC4: 17 .string "NexGenDriven" 18.LC5: 19 .string "GenuineTMx86" 20.LC6: 21 .string "RiseRiseRise" 22.LC7: 23 .string "UMC UMC UMC " 24.LC8: 25 .string "Sis Sis Sis " 26.LC9: 27 .string "Geode by NSC" 28 .section .data.rel.ro.local,"aw",@progbits 29 .align 32 30 .type manMap, @object 31 .size manMap, 40 32manMap: 33 .long .LC0 34 .long .LC1 35 .long .LC2 36 .long .LC3 37 .long .LC4 38 .long .LC5 39 .long .LC6 40 .long .LC7 41 .long .LC8 42 .long .LC9 43 .section .rodata 44 .align 32 45 .type CacheMap, @object 46 .size CacheMap, 512 47CacheMap: 48 .byte 0 49 .byte 0 50 .byte 3 51 .byte 0 52 .byte 3 53 .byte 0 54 .byte 4 55 .byte 0 56 .byte 4 57 .zero 1 58 .byte 1 59 .byte 0 60 .byte 7 61 .byte 32 62 .byte 1 63 .byte 0 64 .byte 7 65 .byte 32 66 .byte 1 67 .byte 0 68 .byte 8 69 .byte 32 70 .byte 1 71 .byte 0 72 .byte 8 73 .byte 32 74 .byte 1 75 .byte 0 76 .byte 1 77 .byte 0 78 .byte 1 79 .byte 0 80 .byte 1 81 .byte 0 82 .byte 1 83 .byte 0 84 .byte 1 85 .byte 0 86 .byte 1 87 .byte 0 88 .byte 1 89 .byte 0 90 .byte 1 91 .byte 0 92 .byte 1 93 .byte 0 94 .byte 1 95 .byte 0 96 .byte 1 97 .byte 0 98 .byte 1 99 .byte 0 100 .byte 1 101 .byte 0 102 .byte 1 103 .byte 0 104 .byte 1 105 .byte 0 106 .byte 1 107 .byte 0 108 .byte 1 109 .byte 0 110 .byte 1 111 .byte 0 112 .byte 1 113 .byte 0 114 .byte 1 115 .byte 0 116 .byte 12 117 .byte 64 118 .byte 12 119 .byte 64 120 .byte 1 121 .byte 0 122 .byte 12 123 .byte 64 124 .byte 1 125 .byte 0 126 .byte 1 127 .byte 0 128 .byte 1 129 .byte 0 130 .byte 12 131 .byte 64 132 .byte 1 133 .byte 0 134 .byte 1 135 .byte 0 136 .byte 8 137 .byte 64 138 .byte 1 139 .byte 0 140 .byte 1 141 .byte 0 142 .byte 1 143 .byte 0 144 .byte 7 145 .byte 64 146 .byte 1 147 .byte 0 148 .byte 1 149 .byte 0 150 .byte 1 151 .byte 0 152 .byte 1 153 .byte 0 154 .byte 1 155 .byte 0 156 .byte 1 157 .byte 0 158 .byte 1 159 .byte 0 160 .byte 1 161 .byte 0 162 .byte 9 163 .byte 64 164 .byte 1 165 .byte 0 166 .byte 9 167 .byte 64 168 .byte 9 169 .byte 64 170 .byte 1 171 .byte 0 172 .byte 1 173 .byte 0 174 .byte 1 175 .byte 0 176 .byte 9 177 .byte 0 178 .byte 9 179 .byte 32 180 .byte 9 181 .byte 32 182 .byte 9 183 .byte 32 184 .byte 9 185 .byte 32 186 .byte 9 187 .byte 32 188 .byte 1 189 .byte 0 190 .byte 1 191 .byte 0 192 .byte 1 193 .byte 0 194 .byte 1 195 .byte 0 196 .byte 1 197 .byte 0 198 .byte 1 199 .byte 0 200 .byte 1 201 .byte 0 202 .byte 1 203 .byte 0 204 .byte 1 205 .byte 0 206 .byte 1 207 .byte 0 208 .byte 3 209 .byte 0 210 .byte 3 211 .byte 0 212 .byte 3 213 .byte 0 214 .byte 1 215 .byte 0 216 .byte 1 217 .byte 0 218 .byte 1 219 .byte 0 220 .byte 1 221 .byte 0 222 .byte 1 223 .byte 0 224 .byte 1 225 .byte 0 226 .byte 1 227 .byte 0 228 .byte 1 229 .byte 0 230 .byte 4 231 .byte 0 232 .byte 4 233 .byte 0 234 .byte 4 235 .byte 0 236 .byte 1 237 .byte 0 238 .byte 1 239 .byte 0 240 .byte 1 241 .byte 0 242 .byte 1 243 .byte 0 244 .byte 1 245 .byte 0 246 .byte 1 247 .byte 0 248 .byte 1 249 .byte 0 250 .byte 1 251 .byte 0 252 .byte 8 253 .byte 64 254 .byte 8 255 .byte 64 256 .byte 8 257 .byte 64 258 .byte 1 259 .byte 0 260 .byte 1 261 .byte 0 262 .byte 1 263 .byte 0 264 .byte 1 265 .byte 0 266 .byte 1 267 .byte 0 268 .byte 1 269 .byte 0 270 .byte 1 271 .byte 0 272 .byte 5 273 .byte 1 274 .byte 5 275 .byte 1 276 .byte 5 277 .byte 1 278 .byte 1 279 .byte 0 280 .byte 1 281 .byte 0 282 .byte 1 283 .byte 0 284 .byte 1 285 .byte 0 286 .byte 1 287 .byte 0 288 .byte 1 289 .byte 0 290 .byte 9 291 .byte 64 292 .byte 9 293 .byte 64 294 .byte 9 295 .byte 64 296 .byte 9 297 .byte 64 298 .byte 1 299 .byte 0 300 .byte 1 301 .byte 0 302 .byte 1 303 .byte 0 304 .byte 1 305 .byte 0 306 .byte 1 307 .byte 0 308 .byte 9 309 .byte 32 310 .byte 9 311 .byte 32 312 .byte 9 313 .byte 32 314 .byte 9 315 .byte 32 316 .byte 9 317 .byte 64 318 .byte 9 319 .byte 64 320 .byte 1 321 .byte 0 322 .byte 1 323 .byte 0 324 .byte 1 325 .byte 0 326 .byte 1 327 .byte 0 328 .byte 1 329 .byte 0 330 .byte 1 331 .byte 0 332 .byte 1 333 .byte 0 334 .byte 1 335 .byte 0 336 .byte 1 337 .byte 0 338 .byte 1 339 .byte 0 340 .byte 1 341 .byte 0 342 .byte 1 343 .byte 0 344 .byte 1 345 .byte 0 346 .byte 1 347 .byte 0 348 .byte 1 349 .byte 0 350 .byte 1 351 .byte 0 352 .byte 1 353 .byte 0 354 .byte 1 355 .byte 0 356 .byte 1 357 .byte 0 358 .byte 1 359 .byte 0 360 .byte 1 361 .byte 0 362 .byte 1 363 .byte 0 364 .byte 1 365 .byte 0 366 .byte 1 367 .byte 0 368 .byte 1 369 .byte 0 370 .byte 1 371 .byte 0 372 .byte 1 373 .byte 0 374 .byte 1 375 .byte 0 376 .byte 1 377 .byte 0 378 .byte 1 379 .byte 0 380 .byte 1 381 .byte 0 382 .byte 1 383 .byte 0 384 .byte 1 385 .byte 0 386 .byte 1 387 .byte 0 388 .byte 1 389 .byte 0 390 .byte 1 391 .byte 0 392 .byte 1 393 .byte 0 394 .byte 1 395 .byte 0 396 .byte 1 397 .byte 0 398 .byte 1 399 .byte 0 400 .byte 3 401 .byte 0 402 .byte 1 403 .byte 0 404 .byte 1 405 .byte 0 406 .byte 4 407 .byte 0 408 .byte 1 409 .byte 0 410 .byte 1 411 .byte 0 412 .byte 1 413 .byte 0 414 .byte 1 415 .byte 0 416 .byte 1 417 .byte 0 418 .byte 1 419 .byte 0 420 .byte 1 421 .byte 0 422 .byte 1 423 .byte 0 424 .byte 1 425 .byte 0 426 .byte 1 427 .byte 0 428 .byte 1 429 .byte 0 430 .byte 1 431 .byte 0 432 .byte 1 433 .byte 0 434 .byte 1 435 .byte 0 436 .byte 1 437 .byte 0 438 .byte 1 439 .byte 0 440 .byte 1 441 .byte 0 442 .byte 1 443 .byte 0 444 .byte 1 445 .byte 0 446 .byte 1 447 .byte 0 448 .byte 1 449 .byte 0 450 .byte 1 451 .byte 0 452 .byte 1 453 .byte 0 454 .byte 1 455 .byte 0 456 .byte 1 457 .byte 0 458 .byte 1 459 .byte 0 460 .byte 1 461 .byte 0 462 .byte 1 463 .byte 0 464 .byte 1 465 .byte 0 466 .byte 1 467 .byte 0 468 .byte 1 469 .byte 0 470 .byte 1 471 .byte 0 472 .byte 1 473 .byte 0 474 .byte 1 475 .byte 0 476 .byte 1 477 .byte 0 478 .byte 1 479 .byte 0 480 .byte 1 481 .byte 0 482 .byte 1 483 .byte 0 484 .byte 1 485 .byte 0 486 .byte 1 487 .byte 0 488 .byte 1 489 .byte 0 490 .byte 1 491 .byte 0 492 .byte 1 493 .byte 0 494 .byte 1 495 .byte 0 496 .byte 1 497 .byte 0 498 .byte 1 499 .byte 0 500 .byte 1 501 .byte 0 502 .byte 1 503 .byte 0 504 .byte 1 505 .byte 0 506 .byte 1 507 .byte 0 508 .byte 1 509 .byte 0 510 .byte 1 511 .byte 0 512 .byte 1 513 .byte 0 514 .byte 1 515 .byte 0 516 .byte 1 517 .byte 0 518 .byte 1 519 .byte 0 520 .byte 1 521 .byte 0 522 .byte 1 523 .byte 0 524 .byte 1 525 .byte 0 526 .byte 1 527 .byte 0 528 .byte 1 529 .byte 0 530 .byte 1 531 .byte 0 532 .byte 1 533 .byte 0 534 .byte 1 535 .byte 0 536 .byte 1 537 .byte 0 538 .byte 1 539 .byte 0 540 .byte 1 541 .byte 0 542 .byte 1 543 .byte 0 544 .byte 1 545 .byte 0 546 .byte 1 547 .byte 0 548 .byte 1 549 .byte 0 550 .byte 1 551 .byte 0 552 .byte 1 553 .byte 0 554 .byte 1 555 .byte 0 556 .byte 1 557 .byte 0 558 .byte 1 559 .byte 0 560 .text 561 .align 4 562.globl freebl_cpuid 563 .type freebl_cpuid, @function 564freebl_cpuid: 565 pushl %ebp 566 pushl %edi 567 pushl %esi 568 subl $8, %esp 569 movl %edx, %ebp 570/APP 571 pushl %ebx 572 xorl %ecx, %ecx 573 cpuid 574 mov %ebx,%esi 575 popl %ebx 576 577/NO_APP 578 movl %eax, (%ebp) 579 movl 24(%esp), %eax 580 movl %esi, (%eax) 581 movl 28(%esp), %eax 582 movl %ecx, (%eax) 583 movl 32(%esp), %eax 584 movl %edx, (%eax) 585 addl $8, %esp 586 popl %esi 587 popl %edi 588 popl %ebp 589 ret 590 .size freebl_cpuid, .-freebl_cpuid 591 .align 4 592 .type changeFlag, @function 593changeFlag: 594/APP 595 pushfl 596 popl %edx 597 movl %edx,%ecx 598 xorl %eax,%edx 599 pushl %edx 600 popfl 601 pushfl 602 popl %edx 603 pushl %ecx 604 popfl 605 606/NO_APP 607 xorl %ecx, %edx 608 movl %edx, %eax 609 ret 610 .size changeFlag, .-changeFlag 611 .align 4 612 .type getIntelCacheEntryLineSize, @function 613getIntelCacheEntryLineSize: 614 pushl %edi 615 pushl %esi 616 pushl %ebx 617 call .L17 618.L17: 619 popl %ebx 620 addl $_GLOBAL_OFFSET_TABLE_+[.-.L17], %ebx 621 movzbl CacheMap@GOTOFF(%ebx,%eax,2), %ecx 622 movb 1+CacheMap@GOTOFF(%ebx,%eax,2), %al 623 testb %al, %al 624 movl 16(%esp), %edi 625 je .L3 626 cmpl $6, %ecx 627 je .L6 628 cmpl $8, %ecx 629 je .L6 630 movl (%edx), %esi 631 cmpl $1, %esi 632 jg .L15 633.L8: 634 cmpl $2, %esi 635 jle .L3 636 cmpl $12, %ecx 637 je .L12 638 cmpl $14, %ecx 639 je .L12 640 .align 4 641.L3: 642 popl %ebx 643 popl %esi 644 popl %edi 645 ret 646 .align 4 647.L6: 648 movzbl %al, %eax 649 movl $1, (%edx) 650 movl %eax, (%edi) 651.L16: 652 popl %ebx 653 popl %esi 654 popl %edi 655 ret 656 .align 4 657.L15: 658 cmpl $9, %ecx 659 je .L9 660 cmpl $11, %ecx 661 jne .L8 662.L9: 663 movzbl %al, %eax 664 movl $2, (%edx) 665 movl %eax, (%edi) 666 jmp .L16 667.L12: 668 movzbl %al, %eax 669 movl $3, (%edx) 670 movl %eax, (%edi) 671 jmp .L16 672 .size getIntelCacheEntryLineSize, .-getIntelCacheEntryLineSize 673 .align 4 674 .type getIntelRegisterCacheLineSize, @function 675getIntelRegisterCacheLineSize: 676 pushl %ebp 677 movl %esp, %ebp 678 pushl %edi 679 pushl %esi 680 pushl %ecx 681 movl 8(%ebp), %edi 682 movl %eax, %esi 683 movl %edx, -12(%ebp) 684 shrl $24, %eax 685 pushl %edi 686 call getIntelCacheEntryLineSize 687 movl %esi, %eax 688 pushl %edi 689 shrl $16, %eax 690 movl -12(%ebp), %edx 691 andl $255, %eax 692 call getIntelCacheEntryLineSize 693 pushl %edi 694 movl %esi, %edx 695 movzbl %dh, %eax 696 movl -12(%ebp), %edx 697 call getIntelCacheEntryLineSize 698 andl $255, %esi 699 movl %edi, 8(%ebp) 700 movl -12(%ebp), %edx 701 addl $12, %esp 702 leal -8(%ebp), %esp 703 movl %esi, %eax 704 popl %esi 705 popl %edi 706 leave 707 jmp getIntelCacheEntryLineSize 708 .size getIntelRegisterCacheLineSize, .-getIntelRegisterCacheLineSize 709 .align 4 710.globl s_mpi_getProcessorLineSize 711 .type s_mpi_getProcessorLineSize, @function 712s_mpi_getProcessorLineSize: 713 pushl %ebp 714 movl %esp, %ebp 715 pushl %edi 716 pushl %esi 717 pushl %ebx 718 subl $188, %esp 719 call .L52 720.L52: 721 popl %ebx 722 addl $_GLOBAL_OFFSET_TABLE_+[.-.L52], %ebx 723 movl $9, -168(%ebp) 724 movl $262144, %eax 725 call changeFlag 726 xorl %edx, %edx 727 testl %eax, %eax 728 jne .L50 729.L19: 730 leal -12(%ebp), %esp 731 popl %ebx 732 popl %esi 733 movl %edx, %eax 734 popl %edi 735 leave 736 ret 737 .align 4 738.L50: 739 movl $2097152, %eax 740 call changeFlag 741 testl %eax, %eax 742 movl $32, %edx 743 je .L19 744 leal -108(%ebp), %eax 745 pushl %eax 746 leal -112(%ebp), %eax 747 pushl %eax 748 leal -116(%ebp), %eax 749 pushl %eax 750 leal -120(%ebp), %edx 751 xorl %eax, %eax 752 call freebl_cpuid 753 movl -120(%ebp), %eax 754 movl %eax, -164(%ebp) 755 movl -116(%ebp), %eax 756 movl %eax, -104(%ebp) 757 movl -108(%ebp), %eax 758 movl %eax, -100(%ebp) 759 movl -112(%ebp), %eax 760 movl %eax, -96(%ebp) 761 movb $0, -92(%ebp) 762 xorl %esi, %esi 763 addl $12, %esp 764 leal -104(%ebp), %edi 765 .align 4 766.L28: 767 subl $8, %esp 768 pushl %edi 769 pushl manMap@GOTOFF(%ebx,%esi,4) 770 call strcmp@PLT 771 addl $16, %esp 772 testl %eax, %eax 773 jne .L26 774 movl %esi, -168(%ebp) 775.L26: 776 incl %esi 777 cmpl $9, %esi 778 jle .L28 779 movl -168(%ebp), %eax 780 testl %eax, %eax 781 jne .L29 782 xorl %eax, %eax 783 cmpl $1, -164(%ebp) 784 movl $4, -144(%ebp) 785 movl $0, -140(%ebp) 786 jle .L41 787 leal -124(%ebp), %edx 788 movl %edx, -188(%ebp) 789 leal -128(%ebp), %eax 790 pushl %edx 791 movl %eax, -184(%ebp) 792 leal -132(%ebp), %edx 793 pushl %eax 794 movl %edx, -180(%ebp) 795 movl $2, %eax 796 pushl %edx 797 leal -136(%ebp), %edx 798 call freebl_cpuid 799 movl -136(%ebp), %eax 800 movl %eax, %edi 801 andl $15, %edi 802 xorl %esi, %esi 803 addl $12, %esp 804 leal -140(%ebp), %edx 805 cmpl %edi, %esi 806 movl %edx, -176(%ebp) 807 jl .L40 808 jmp .L48 809 .align 4 810.L49: 811 movl -136(%ebp), %eax 812.L40: 813 testl %eax, %eax 814 js .L35 815 xorb %al, %al 816 pushl -176(%ebp) 817 leal -144(%ebp), %edx 818 call getIntelRegisterCacheLineSize 819 popl %eax 820.L35: 821 movl -132(%ebp), %eax 822 testl %eax, %eax 823 js .L36 824 pushl -176(%ebp) 825 leal -144(%ebp), %edx 826 call getIntelRegisterCacheLineSize 827 popl %eax 828.L36: 829 movl -128(%ebp), %eax 830 testl %eax, %eax 831 js .L37 832 pushl -176(%ebp) 833 leal -144(%ebp), %edx 834 call getIntelRegisterCacheLineSize 835 popl %eax 836.L37: 837 movl -124(%ebp), %eax 838 testl %eax, %eax 839 js .L38 840 pushl -176(%ebp) 841 leal -144(%ebp), %edx 842 call getIntelRegisterCacheLineSize 843 popl %eax 844.L38: 845 incl %esi 846 cmpl %edi, %esi 847 je .L34 848 pushl -188(%ebp) 849 pushl -184(%ebp) 850 pushl -180(%ebp) 851 leal -136(%ebp), %edx 852 movl $2, %eax 853 call freebl_cpuid 854 addl $12, %esp 855.L34: 856 cmpl %edi, %esi 857 jl .L49 858.L48: 859 movl -140(%ebp), %eax 860.L41: 861 testl %eax, %eax 862 jne .L44 863 movb $32, %al 864.L44: 865 leal -12(%ebp), %esp 866 popl %ebx 867 popl %esi 868 movl %eax, %edx 869 movl %edx, %eax 870 popl %edi 871 leave 872 ret 873.L29: 874 leal -148(%ebp), %eax 875 movl %eax, -192(%ebp) 876 movl $0, -172(%ebp) 877 leal -152(%ebp), %edi 878 pushl %eax 879 pushl %edi 880 leal -156(%ebp), %esi 881 pushl %esi 882 leal -160(%ebp), %edx 883 movl $-2147483648, %eax 884 call freebl_cpuid 885 addl $12, %esp 886 cmpl $-2147483644, -160(%ebp) 887 ja .L51 888.L42: 889 movl -172(%ebp), %eax 890 jmp .L41 891.L51: 892 pushl -192(%ebp) 893 pushl %edi 894 pushl %esi 895 leal -160(%ebp), %edx 896 movl $-2147483643, %eax 897 call freebl_cpuid 898 movzbl -152(%ebp), %edx 899 addl $12, %esp 900 movl %edx, -172(%ebp) 901 jmp .L42 902 .size s_mpi_getProcessorLineSize, .-s_mpi_getProcessorLineSize 903