1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 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 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721
|
!
! os_solaris_ata.s
!
! Home page of code is: http://smartmontools.sourceforge.net
!
! Copyright (C) 2003-4 SAWADA Keiji <smartmontools-support@lists.sourceforge.net>
!
! 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., 675 Mass Ave, Cambridge, MA 02139, USA.
!
!
! --------------------------------------------------------
! direct access routines to ATA device under Solaris/SPARC
! --------------------------------------------------------
!
! Information
! -----------
!
! In Solaris, programmer can pass SCSI command to target device directly
! by using USCSI ioctl or using "scg" generic SCSI driver. But, such
! method does not exist for ATA devices.
!
! However, I can access Solaris kernel source because I am subscriber of
! Source Foundation Program of Solaris. So, I can find method of
! accessing ATA device directly. The method is to pack command in
! undocumented structure and issue ioctl that appears only in kernel
! source. Yes, that is the same way in using USCSI interface.
!
! But, I met difficulty in disclosing this technique. I have signed NDA
! with Sun that inhibits me not to violate their intellectual property.
!
! Fortunately, Sun allows licensees to publish "Interfaces" if:
!
! (1) he/she treats Solaris code as confidential
!
! (2) and he/she doesn't incorporate Sun's code into his/her code
!
! (3) and disclose enough information to use "Interface" to everyone.
!
! So, I publish that technique in assembly code or object code because:
!
! (1) I believe Sun's intellectural property is not invaded because I
! didn't reveal any struct member and ioctl to non-licensee.
!
! (2) no piece of kernel source is included in this code.
!
! (3) And finally, I publish enough information below in order to use
! this code.
!
! For last reason, please don't remove "Calling Interface" section from
! distribution.
!
!
! Calling Interface
! -----------------
!
! Name of function/macro presents corresponding S.M.A.R.T. command.
!
! Parameters are described below.
!
! int fd
!
! File descriptor of ATA device. Device would be
! /dev/rdsk/cXtXdXsX.
!
! Device should be raw device serviced by "dada" driver. ATAPI
! CD-ROM/R/RW, DVD-ROM, and so on are not allowed because they are
! serviced by "sd" driver. On x86 Solaris, "cmdk" driver services
! them, this routines doesn't work.
!
! int s
! Select sector for service. For example, this indicates log sector
! number for smart_read_log() function. Probably you need to read
! ATA specification for this parameter.
!
! void *data
! Data going to be read/written. It don't have to be word aligned,
! But data shall points valid user memory space.
!
! This is very tiny routines, but if you feel this insufficient, please
! let me know.
!
! ksw / SAWADA Keiji
! <card_captor@users.sourceforge.net>
.file "os_solaris_ata.s"
.global os_solaris_ata_s_cvsid
.section ".rodata"
.align 8
.LLC0:
.asciz "$Id: os_solaris_ata.s,v 1.2 2004/02/13 17:29:09 ballen4705 Exp $"
.section ".data"
.align 4
.type os_solaris_ata_s_cvsid,#object
.size os_solaris_ata_s_cvsid,4
os_solaris_ata_s_cvsid:
.uaword .LLC0
.section ".text"
.align 4
.type ata_cmd, #function
.proc 04
ata_cmd:
!#PROLOGUE# 0
save %sp, -184, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
st %i2, [%fp+76]
st %i3, [%fp+80]
st %i4, [%fp+84]
st %i5, [%fp+88]
ld [%fp+88], %g1
st %g1, [%fp-76]
ld [%fp-76], %g1
and %g1, 3, %g1
cmp %g1, 0
be .LL2
nop
mov -2, %g1
st %g1, [%fp-80]
b .LL1
nop
.LL2:
add %fp, -56, %g1
mov %g1, %o0
mov 0, %o1
mov 36, %o2
call memset, 0
nop
add %fp, -72, %g1
mov %g1, %o0
mov 0, %o1
mov 16, %o2
call memset, 0
nop
ldub [%fp+75], %g1
stb %g1, [%fp-72]
mov 1, %g1
stb %g1, [%fp-71]
mov 1, %g1
stb %g1, [%fp-70]
ldub [%fp+79], %g1
stb %g1, [%fp-69]
ld [%fp+84], %g1
sll %g1, 9, %g1
st %g1, [%fp-68]
ld [%fp+80], %g1
st %g1, [%fp-60]
mov 10, %g1
sth %g1, [%fp-52]
ld [%fp+84], %g1
cmp %g1, 0
be .LL3
nop
mov 14, %g1
st %g1, [%fp-84]
b .LL4
nop
.LL3:
mov 6, %g1
st %g1, [%fp-84]
.LL4:
ld [%fp-84], %g1
st %g1, [%fp-48]
ld [%fp+84], %g1
sll %g1, 9, %g1
st %g1, [%fp-44]
ld [%fp+84], %g1
sll %g1, 9, %g1
st %g1, [%fp-40]
ld [%fp+84], %g1
cmp %g1, 0
be .LL5
nop
ld [%fp+88], %g1
st %g1, [%fp-88]
b .LL6
nop
.LL5:
st %g0, [%fp-88]
.LL6:
ld [%fp-88], %g1
st %g1, [%fp-36]
add %fp, -72, %g1
st %g1, [%fp-32]
add %fp, -56, %g1
ld [%fp+68], %o0
mov 1481, %o1
mov %g1, %o2
call ioctl, 0
nop
mov %o0, %g1
st %g1, [%fp-80]
.LL1:
ld [%fp-80], %i0
ret
restore
.size ata_cmd, .-ata_cmd
.align 4
.global ata_identify
.type ata_identify, #function
.proc 04
ata_identify:
!#PROLOGUE# 0
save %sp, -640, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
add %fp, -536, %g1
ld [%fp+68], %o0
mov 236, %o1
mov 0, %o2
mov 0, %o3
mov 1, %o4
mov %g1, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
add %fp, -536, %g1
ld [%fp+72], %o0
mov %g1, %o1
mov 512, %o2
call memcpy, 0
nop
ld [%fp-20], %g1
cmp %g1, 0
be .LL8
nop
mov -1, %g1
st %g1, [%fp-540]
b .LL9
nop
.LL8:
st %g0, [%fp-540]
.LL9:
ld [%fp-540], %g1
mov %g1, %i0
ret
restore
.size ata_identify, .-ata_identify
.align 4
.global ata_pidentify
.type ata_pidentify, #function
.proc 04
ata_pidentify:
!#PROLOGUE# 0
save %sp, -640, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
add %fp, -536, %g1
ld [%fp+68], %o0
mov 161, %o1
mov 0, %o2
mov 0, %o3
mov 1, %o4
mov %g1, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
add %fp, -536, %g1
ld [%fp+72], %o0
mov %g1, %o1
mov 512, %o2
call memcpy, 0
nop
ld [%fp-20], %g1
cmp %g1, 0
be .LL11
nop
mov -1, %g1
st %g1, [%fp-540]
b .LL12
nop
.LL11:
st %g0, [%fp-540]
.LL12:
ld [%fp-540], %g1
mov %g1, %i0
ret
restore
.size ata_pidentify, .-ata_pidentify
.align 4
.global smart_read_data
.type smart_read_data, #function
.proc 04
smart_read_data:
!#PROLOGUE# 0
save %sp, -640, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
add %fp, -536, %o5
ld [%fp+68], %o0
mov 176, %o1
mov 208, %o2
sethi %hi(12733440), %g1
or %g1, 769, %o3
mov 1, %o4
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
add %fp, -536, %g1
ld [%fp+72], %o0
mov %g1, %o1
mov 512, %o2
call memcpy, 0
nop
ld [%fp-20], %g1
cmp %g1, 0
be .LL14
nop
mov -1, %g1
st %g1, [%fp-540]
b .LL15
nop
.LL14:
st %g0, [%fp-540]
.LL15:
ld [%fp-540], %g1
mov %g1, %i0
ret
restore
.size smart_read_data, .-smart_read_data
.align 4
.global smart_read_thresholds
.type smart_read_thresholds, #function
.proc 04
smart_read_thresholds:
!#PROLOGUE# 0
save %sp, -640, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
add %fp, -536, %o5
ld [%fp+68], %o0
mov 176, %o1
mov 209, %o2
sethi %hi(12733440), %g1
or %g1, 769, %o3
mov 1, %o4
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
add %fp, -536, %g1
ld [%fp+72], %o0
mov %g1, %o1
mov 512, %o2
call memcpy, 0
nop
ld [%fp-20], %g1
cmp %g1, 0
be .LL17
nop
mov -1, %g1
st %g1, [%fp-540]
b .LL18
nop
.LL17:
st %g0, [%fp-540]
.LL18:
ld [%fp-540], %g1
mov %g1, %i0
ret
restore
.size smart_read_thresholds, .-smart_read_thresholds
.align 4
.global smart_auto_save
.type smart_auto_save, #function
.proc 04
smart_auto_save:
!#PROLOGUE# 0
save %sp, -120, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
ld [%fp+72], %g1
and %g1, 255, %o5
sethi %hi(12733440), %g1
or %g1, 768, %g1
or %o5, %g1, %g1
ld [%fp+68], %o0
mov 176, %o1
mov 210, %o2
mov %g1, %o3
mov 0, %o4
mov 0, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
ld [%fp-20], %g1
cmp %g1, 0
be .LL20
nop
mov -1, %g1
st %g1, [%fp-24]
b .LL21
nop
.LL20:
st %g0, [%fp-24]
.LL21:
ld [%fp-24], %g1
mov %g1, %i0
ret
restore
.size smart_auto_save, .-smart_auto_save
.align 4
.global smart_immediate_offline
.type smart_immediate_offline, #function
.proc 04
smart_immediate_offline:
!#PROLOGUE# 0
save %sp, -120, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
ld [%fp+72], %g1
and %g1, 255, %o5
sethi %hi(12733440), %g1
or %g1, 768, %g1
or %o5, %g1, %g1
ld [%fp+68], %o0
mov 176, %o1
mov 212, %o2
mov %g1, %o3
mov 0, %o4
mov 0, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
ld [%fp-20], %g1
cmp %g1, 0
be .LL23
nop
mov -1, %g1
st %g1, [%fp-24]
b .LL24
nop
.LL23:
st %g0, [%fp-24]
.LL24:
ld [%fp-24], %g1
mov %g1, %i0
ret
restore
.size smart_immediate_offline, .-smart_immediate_offline
.align 4
.global smart_read_log
.type smart_read_log, #function
.proc 04
smart_read_log:
!#PROLOGUE# 0
save %sp, -128, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
st %i2, [%fp+76]
st %i3, [%fp+80]
ld [%fp+76], %g1
sll %g1, 9, %g1
mov %g1, %o0
call malloc, 0
nop
mov %o0, %g1
st %g1, [%fp-24]
ld [%fp-24], %g1
cmp %g1, 0
bne .LL26
nop
mov -1, %g1
st %g1, [%fp-28]
b .LL25
nop
.LL26:
ld [%fp+72], %g1
and %g1, 255, %o5
sethi %hi(12733440), %g1
or %g1, 768, %g1
or %o5, %g1, %g1
ld [%fp+68], %o0
mov 176, %o1
mov 213, %o2
mov %g1, %o3
ld [%fp+76], %o4
ld [%fp-24], %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
ld [%fp+76], %g1
sll %g1, 9, %g1
ld [%fp+80], %o0
ld [%fp-24], %o1
mov %g1, %o2
call memcpy, 0
nop
ld [%fp-24], %o0
call free, 0
nop
ld [%fp-20], %g1
cmp %g1, 0
be .LL27
nop
mov -1, %g1
st %g1, [%fp-32]
b .LL28
nop
.LL27:
st %g0, [%fp-32]
.LL28:
ld [%fp-32], %g1
st %g1, [%fp-28]
.LL25:
ld [%fp-28], %i0
ret
restore
.size smart_read_log, .-smart_read_log
.align 4
.global smart_enable
.type smart_enable, #function
.proc 04
smart_enable:
!#PROLOGUE# 0
save %sp, -120, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
ld [%fp+68], %o0
mov 176, %o1
mov 216, %o2
sethi %hi(12733440), %g1
or %g1, 769, %o3
mov 0, %o4
mov 0, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
ld [%fp-20], %g1
cmp %g1, 0
be .LL30
nop
mov -1, %g1
st %g1, [%fp-24]
b .LL31
nop
.LL30:
st %g0, [%fp-24]
.LL31:
ld [%fp-24], %g1
mov %g1, %i0
ret
restore
.size smart_enable, .-smart_enable
.align 4
.global smart_disable
.type smart_disable, #function
.proc 04
smart_disable:
!#PROLOGUE# 0
save %sp, -120, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
ld [%fp+68], %o0
mov 176, %o1
mov 217, %o2
sethi %hi(12733440), %g1
or %g1, 769, %o3
mov 0, %o4
mov 0, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
ld [%fp-20], %g1
cmp %g1, 0
be .LL33
nop
mov -1, %g1
st %g1, [%fp-24]
b .LL34
nop
.LL33:
st %g0, [%fp-24]
.LL34:
ld [%fp-24], %g1
mov %g1, %i0
ret
restore
.size smart_disable, .-smart_disable
.align 4
.global smart_status
.type smart_status, #function
.proc 04
smart_status:
!#PROLOGUE# 0
save %sp, -120, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
ld [%fp+68], %o0
mov 176, %o1
mov 218, %o2
sethi %hi(12733440), %g1
or %g1, 769, %o3
mov 0, %o4
mov 0, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
ld [%fp-20], %g1
cmp %g1, 0
be .LL36
nop
mov -1, %g1
st %g1, [%fp-24]
b .LL37
nop
.LL36:
st %g0, [%fp-24]
.LL37:
ld [%fp-24], %g1
mov %g1, %i0
ret
restore
.size smart_status, .-smart_status
.align 4
.global smart_status_check
.type smart_status_check, #function
.proc 04
smart_status_check:
!#PROLOGUE# 0
save %sp, -120, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
ld [%fp+68], %o0
mov 176, %o1
mov 218, %o2
sethi %hi(12733440), %g1
or %g1, 769, %o3
mov 0, %o4
mov 0, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
ld [%fp-20], %g1
cmp %g1, 0
be .LL39
nop
mov -1, %g1
st %g1, [%fp-24]
b .LL38
nop
.LL39:
st %g0, [%fp-24]
.LL38:
ld [%fp-24], %i0
ret
restore
.size smart_status_check, .-smart_status_check
.align 4
.global smart_auto_offline
.type smart_auto_offline, #function
.proc 04
smart_auto_offline:
!#PROLOGUE# 0
save %sp, -120, %sp
!#PROLOGUE# 1
st %i0, [%fp+68]
st %i1, [%fp+72]
ld [%fp+72], %g1
and %g1, 255, %o5
sethi %hi(12733440), %g1
or %g1, 768, %g1
or %o5, %g1, %g1
ld [%fp+68], %o0
mov 176, %o1
mov 219, %o2
mov %g1, %o3
mov 0, %o4
mov 0, %o5
call ata_cmd, 0
nop
mov %o0, %g1
st %g1, [%fp-20]
ld [%fp-20], %g1
cmp %g1, 0
be .LL41
nop
mov -1, %g1
st %g1, [%fp-24]
b .LL42
nop
.LL41:
st %g0, [%fp-24]
.LL42:
ld [%fp-24], %g1
mov %g1, %i0
ret
restore
.size smart_auto_offline, .-smart_auto_offline
.ident "GCC: (GNU) 3.3.2"
|