Annotation of embedaddon/smartmontools/os_solaris_ata.s, revision 1.1
1.1 ! misho 1: !
! 2: ! os_solaris_ata.s
! 3: !
! 4: ! Home page of code is: http://smartmontools.sourceforge.net
! 5: !
! 6: ! Copyright (C) 2003-8 SAWADA Keiji <smartmontools-support@lists.sourceforge.net>
! 7: !
! 8: ! This program is free software; you can redistribute it and/or modify
! 9: ! it under the terms of the GNU General Public License as published by
! 10: ! the Free Software Foundation; either version 2 of the License, or
! 11: ! (at your option) any later version.
! 12: !
! 13: ! This program is distributed in the hope that it will be useful, but
! 14: ! WITHOUT ANY WARRANTY; without even the implied warranty of
! 15: ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! 16: ! General Public License for more details.
! 17: !
! 18: ! You should have received a copy of the GNU General Public License
! 19: ! along with this program; if not, write to the Free Software
! 20: ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
! 21: !
! 22: !
! 23: ! --------------------------------------------------------
! 24: ! direct access routines to ATA device under Solaris/SPARC
! 25: ! --------------------------------------------------------
! 26: !
! 27: ! Information
! 28: ! -----------
! 29: !
! 30: ! In Solaris, programmer can pass SCSI command to target device directly
! 31: ! by using USCSI ioctl or using "scg" generic SCSI driver. But, such
! 32: ! method does not exist for ATA devices.
! 33: !
! 34: ! However, I can access Solaris kernel source because I am subscriber of
! 35: ! Source Foundation Program of Solaris. So, I can find method of
! 36: ! accessing ATA device directly. The method is to pack command in
! 37: ! undocumented structure and issue ioctl that appears only in kernel
! 38: ! source. Yes, that is the same way in using USCSI interface.
! 39: !
! 40: ! But, I met difficulty in disclosing this technique. I have signed NDA
! 41: ! with Sun that inhibits me not to violate their intellectual property.
! 42: !
! 43: ! Fortunately, Sun allows licensees to publish "Interfaces" if:
! 44: !
! 45: ! (1) he/she treats Solaris code as confidential
! 46: !
! 47: ! (2) and he/she doesn't incorporate Sun's code into his/her code
! 48: !
! 49: ! (3) and disclose enough information to use "Interface" to everyone.
! 50: !
! 51: ! So, I publish that technique in assembly code or object code because:
! 52: !
! 53: ! (1) I believe Sun's intellectural property is not invaded because I
! 54: ! didn't reveal any struct member and ioctl to non-licensee.
! 55: !
! 56: ! (2) no piece of kernel source is included in this code.
! 57: !
! 58: ! (3) And finally, I publish enough information below in order to use
! 59: ! this code.
! 60: !
! 61: ! For last reason, please don't remove "Calling Interface" section from
! 62: ! distribution.
! 63: !
! 64: !
! 65: ! Calling Interface
! 66: ! -----------------
! 67: !
! 68: ! Name of function/macro presents corresponding S.M.A.R.T. command.
! 69: !
! 70: ! Parameters are described below.
! 71: !
! 72: ! int fd
! 73: !
! 74: ! File descriptor of ATA device. Device would be
! 75: ! /dev/rdsk/cXtXdXsX.
! 76: !
! 77: ! Device should be raw device serviced by "dada" driver. ATAPI
! 78: ! CD-ROM/R/RW, DVD-ROM, and so on are not allowed because they are
! 79: ! serviced by "sd" driver. On x86 Solaris, "cmdk" driver services
! 80: ! them, this routines doesn't work.
! 81: !
! 82: ! int s
! 83: ! Select sector for service. For example, this indicates log sector
! 84: ! number for smart_read_log() function. Probably you need to read
! 85: ! ATA specification for this parameter.
! 86: !
! 87: ! void *data
! 88: ! Data going to be read/written. It don't have to be word aligned,
! 89: ! But data shall points valid user memory space.
! 90: !
! 91: ! This is very tiny routines, but if you feel this insufficient, please
! 92: ! let me know.
! 93: !
! 94: ! ksw / SAWADA Keiji
! 95: ! <card_captor@users.sourceforge.net>
! 96: .file "solaris-ata-in.c"
! 97: .section ".rodata"
! 98: .align 8
! 99: .LLC0:
! 100: .asciz "$Id: os_solaris_ata.s,v 1.6 2008/03/04 22:09:47 ballen4705 Exp $"
! 101: .global os_solaris_ata_s_cvsid
! 102: .section ".data"
! 103: .align 4
! 104: .type os_solaris_ata_s_cvsid, #object
! 105: .size os_solaris_ata_s_cvsid, 4
! 106: os_solaris_ata_s_cvsid:
! 107: .long .LLC0
! 108: .section ".text"
! 109: .align 4
! 110: .type ata_cmd, #function
! 111: .proc 04
! 112: ata_cmd:
! 113: !#PROLOGUE# 0
! 114: save %sp, -184, %sp
! 115: !#PROLOGUE# 1
! 116: st %i0, [%fp+68]
! 117: st %i1, [%fp+72]
! 118: st %i2, [%fp+76]
! 119: st %i3, [%fp+80]
! 120: st %i4, [%fp+84]
! 121: st %i5, [%fp+88]
! 122: ld [%fp+92], %g1
! 123: st %g1, [%fp-76]
! 124: ld [%fp-76], %g1
! 125: and %g1, 3, %g1
! 126: cmp %g1, 0
! 127: be .LL2
! 128: nop
! 129: mov -2, %g1
! 130: st %g1, [%fp-80]
! 131: b .LL1
! 132: nop
! 133: .LL2:
! 134: add %fp, -56, %g1
! 135: mov %g1, %o0
! 136: mov 0, %o1
! 137: mov 36, %o2
! 138: call memset, 0
! 139: nop
! 140: add %fp, -72, %g1
! 141: mov %g1, %o0
! 142: mov 0, %o1
! 143: mov 16, %o2
! 144: call memset, 0
! 145: nop
! 146: ld [%fp+72], %g1
! 147: stb %g1, [%fp-72]
! 148: mov 1, %g1
! 149: stb %g1, [%fp-71]
! 150: mov 1, %g1
! 151: stb %g1, [%fp-70]
! 152: ld [%fp+76], %g1
! 153: stb %g1, [%fp-69]
! 154: ld [%fp+84], %g1
! 155: sll %g1, 9, %g1
! 156: st %g1, [%fp-68]
! 157: ld [%fp+80], %g1
! 158: st %g1, [%fp-60]
! 159: mov 10, %g1
! 160: sth %g1, [%fp-52]
! 161: ld [%fp+88], %g1
! 162: cmp %g1, 0
! 163: be .LL3
! 164: nop
! 165: mov 14, %g1
! 166: st %g1, [%fp-84]
! 167: b .LL4
! 168: nop
! 169: .LL3:
! 170: mov 6, %g1
! 171: st %g1, [%fp-84]
! 172: .LL4:
! 173: ld [%fp-84], %g1
! 174: st %g1, [%fp-48]
! 175: ld [%fp+88], %g1
! 176: sll %g1, 9, %g1
! 177: st %g1, [%fp-44]
! 178: ld [%fp+88], %g1
! 179: sll %g1, 9, %g1
! 180: st %g1, [%fp-40]
! 181: ld [%fp+88], %g1
! 182: cmp %g1, 0
! 183: be .LL5
! 184: nop
! 185: ld [%fp+92], %g1
! 186: st %g1, [%fp-88]
! 187: b .LL6
! 188: nop
! 189: .LL5:
! 190: st %g0, [%fp-88]
! 191: .LL6:
! 192: ld [%fp-88], %g1
! 193: st %g1, [%fp-36]
! 194: add %fp, -72, %g1
! 195: st %g1, [%fp-32]
! 196: add %fp, -56, %g1
! 197: ld [%fp+68], %o0
! 198: mov 1481, %o1
! 199: mov %g1, %o2
! 200: call ioctl, 0
! 201: nop
! 202: mov %o0, %g1
! 203: st %g1, [%fp-80]
! 204: .LL1:
! 205: ld [%fp-80], %i0
! 206: ret
! 207: restore
! 208: .size ata_cmd, .-ata_cmd
! 209: .align 4
! 210: .global ata_identify
! 211: .type ata_identify, #function
! 212: .proc 04
! 213: ata_identify:
! 214: !#PROLOGUE# 0
! 215: save %sp, -648, %sp
! 216: !#PROLOGUE# 1
! 217: st %i0, [%fp+68]
! 218: st %i1, [%fp+72]
! 219: add %fp, -536, %g1
! 220: st %g1, [%sp+92]
! 221: ld [%fp+68], %o0
! 222: mov 236, %o1
! 223: mov 0, %o2
! 224: mov 0, %o3
! 225: mov 1, %o4
! 226: mov 1, %o5
! 227: call ata_cmd, 0
! 228: nop
! 229: mov %o0, %g1
! 230: st %g1, [%fp-20]
! 231: add %fp, -536, %g1
! 232: ld [%fp+72], %o0
! 233: mov %g1, %o1
! 234: mov 512, %o2
! 235: call memcpy, 0
! 236: nop
! 237: ld [%fp-20], %g1
! 238: cmp %g1, 0
! 239: be .LL8
! 240: nop
! 241: mov -1, %g1
! 242: st %g1, [%fp-540]
! 243: b .LL9
! 244: nop
! 245: .LL8:
! 246: st %g0, [%fp-540]
! 247: .LL9:
! 248: ld [%fp-540], %g1
! 249: mov %g1, %i0
! 250: ret
! 251: restore
! 252: .size ata_identify, .-ata_identify
! 253: .align 4
! 254: .global ata_pidentify
! 255: .type ata_pidentify, #function
! 256: .proc 04
! 257: ata_pidentify:
! 258: !#PROLOGUE# 0
! 259: save %sp, -648, %sp
! 260: !#PROLOGUE# 1
! 261: st %i0, [%fp+68]
! 262: st %i1, [%fp+72]
! 263: add %fp, -536, %g1
! 264: st %g1, [%sp+92]
! 265: ld [%fp+68], %o0
! 266: mov 161, %o1
! 267: mov 0, %o2
! 268: mov 0, %o3
! 269: mov 1, %o4
! 270: mov 1, %o5
! 271: call ata_cmd, 0
! 272: nop
! 273: mov %o0, %g1
! 274: st %g1, [%fp-20]
! 275: add %fp, -536, %g1
! 276: ld [%fp+72], %o0
! 277: mov %g1, %o1
! 278: mov 512, %o2
! 279: call memcpy, 0
! 280: nop
! 281: ld [%fp-20], %g1
! 282: cmp %g1, 0
! 283: be .LL11
! 284: nop
! 285: mov -1, %g1
! 286: st %g1, [%fp-540]
! 287: b .LL12
! 288: nop
! 289: .LL11:
! 290: st %g0, [%fp-540]
! 291: .LL12:
! 292: ld [%fp-540], %g1
! 293: mov %g1, %i0
! 294: ret
! 295: restore
! 296: .size ata_pidentify, .-ata_pidentify
! 297: .align 4
! 298: .global smart_read_data
! 299: .type smart_read_data, #function
! 300: .proc 04
! 301: smart_read_data:
! 302: !#PROLOGUE# 0
! 303: save %sp, -648, %sp
! 304: !#PROLOGUE# 1
! 305: st %i0, [%fp+68]
! 306: st %i1, [%fp+72]
! 307: add %fp, -536, %g1
! 308: st %g1, [%sp+92]
! 309: ld [%fp+68], %o0
! 310: mov 176, %o1
! 311: mov 208, %o2
! 312: sethi %hi(12733440), %g1
! 313: or %g1, 768, %o3
! 314: mov 0, %o4
! 315: mov 1, %o5
! 316: call ata_cmd, 0
! 317: nop
! 318: mov %o0, %g1
! 319: st %g1, [%fp-20]
! 320: add %fp, -536, %g1
! 321: ld [%fp+72], %o0
! 322: mov %g1, %o1
! 323: mov 512, %o2
! 324: call memcpy, 0
! 325: nop
! 326: ld [%fp-20], %g1
! 327: cmp %g1, 0
! 328: be .LL14
! 329: nop
! 330: mov -1, %g1
! 331: st %g1, [%fp-540]
! 332: b .LL15
! 333: nop
! 334: .LL14:
! 335: st %g0, [%fp-540]
! 336: .LL15:
! 337: ld [%fp-540], %g1
! 338: mov %g1, %i0
! 339: ret
! 340: restore
! 341: .size smart_read_data, .-smart_read_data
! 342: .align 4
! 343: .global smart_read_thresholds
! 344: .type smart_read_thresholds, #function
! 345: .proc 04
! 346: smart_read_thresholds:
! 347: !#PROLOGUE# 0
! 348: save %sp, -648, %sp
! 349: !#PROLOGUE# 1
! 350: st %i0, [%fp+68]
! 351: st %i1, [%fp+72]
! 352: add %fp, -536, %g1
! 353: st %g1, [%sp+92]
! 354: ld [%fp+68], %o0
! 355: mov 176, %o1
! 356: mov 209, %o2
! 357: sethi %hi(12733440), %g1
! 358: or %g1, 769, %o3
! 359: mov 1, %o4
! 360: mov 1, %o5
! 361: call ata_cmd, 0
! 362: nop
! 363: mov %o0, %g1
! 364: st %g1, [%fp-20]
! 365: add %fp, -536, %g1
! 366: ld [%fp+72], %o0
! 367: mov %g1, %o1
! 368: mov 512, %o2
! 369: call memcpy, 0
! 370: nop
! 371: ld [%fp-20], %g1
! 372: cmp %g1, 0
! 373: be .LL17
! 374: nop
! 375: mov -1, %g1
! 376: st %g1, [%fp-540]
! 377: b .LL18
! 378: nop
! 379: .LL17:
! 380: st %g0, [%fp-540]
! 381: .LL18:
! 382: ld [%fp-540], %g1
! 383: mov %g1, %i0
! 384: ret
! 385: restore
! 386: .size smart_read_thresholds, .-smart_read_thresholds
! 387: .align 4
! 388: .global smart_auto_save
! 389: .type smart_auto_save, #function
! 390: .proc 04
! 391: smart_auto_save:
! 392: !#PROLOGUE# 0
! 393: save %sp, -128, %sp
! 394: !#PROLOGUE# 1
! 395: st %i0, [%fp+68]
! 396: st %i1, [%fp+72]
! 397: st %g0, [%sp+92]
! 398: ld [%fp+68], %o0
! 399: mov 176, %o1
! 400: mov 210, %o2
! 401: sethi %hi(12733440), %g1
! 402: or %g1, 768, %o3
! 403: ld [%fp+72], %o4
! 404: mov 0, %o5
! 405: call ata_cmd, 0
! 406: nop
! 407: mov %o0, %g1
! 408: st %g1, [%fp-20]
! 409: ld [%fp-20], %g1
! 410: cmp %g1, 0
! 411: be .LL20
! 412: nop
! 413: mov -1, %g1
! 414: st %g1, [%fp-24]
! 415: b .LL21
! 416: nop
! 417: .LL20:
! 418: st %g0, [%fp-24]
! 419: .LL21:
! 420: ld [%fp-24], %g1
! 421: mov %g1, %i0
! 422: ret
! 423: restore
! 424: .size smart_auto_save, .-smart_auto_save
! 425: .align 4
! 426: .global smart_immediate_offline
! 427: .type smart_immediate_offline, #function
! 428: .proc 04
! 429: smart_immediate_offline:
! 430: !#PROLOGUE# 0
! 431: save %sp, -128, %sp
! 432: !#PROLOGUE# 1
! 433: st %i0, [%fp+68]
! 434: st %i1, [%fp+72]
! 435: ld [%fp+72], %g1
! 436: and %g1, 255, %o5
! 437: sethi %hi(12733440), %g1
! 438: or %g1, 768, %g1
! 439: or %o5, %g1, %g1
! 440: st %g0, [%sp+92]
! 441: ld [%fp+68], %o0
! 442: mov 176, %o1
! 443: mov 212, %o2
! 444: mov %g1, %o3
! 445: mov 0, %o4
! 446: mov 0, %o5
! 447: call ata_cmd, 0
! 448: nop
! 449: mov %o0, %g1
! 450: st %g1, [%fp-20]
! 451: ld [%fp-20], %g1
! 452: cmp %g1, 0
! 453: be .LL23
! 454: nop
! 455: mov -1, %g1
! 456: st %g1, [%fp-24]
! 457: b .LL24
! 458: nop
! 459: .LL23:
! 460: st %g0, [%fp-24]
! 461: .LL24:
! 462: ld [%fp-24], %g1
! 463: mov %g1, %i0
! 464: ret
! 465: restore
! 466: .size smart_immediate_offline, .-smart_immediate_offline
! 467: .align 4
! 468: .global smart_read_log
! 469: .type smart_read_log, #function
! 470: .proc 04
! 471: smart_read_log:
! 472: !#PROLOGUE# 0
! 473: save %sp, -128, %sp
! 474: !#PROLOGUE# 1
! 475: st %i0, [%fp+68]
! 476: st %i1, [%fp+72]
! 477: st %i2, [%fp+76]
! 478: st %i3, [%fp+80]
! 479: ld [%fp+72], %g1
! 480: and %g1, 255, %o5
! 481: sethi %hi(12733440), %g1
! 482: or %g1, 768, %g1
! 483: or %o5, %g1, %o5
! 484: ld [%fp+80], %g1
! 485: st %g1, [%sp+92]
! 486: ld [%fp+68], %o0
! 487: mov 176, %o1
! 488: mov 213, %o2
! 489: mov %o5, %o3
! 490: ld [%fp+76], %o4
! 491: ld [%fp+76], %o5
! 492: call ata_cmd, 0
! 493: nop
! 494: mov %o0, %g1
! 495: st %g1, [%fp-20]
! 496: ld [%fp-20], %g1
! 497: cmp %g1, 0
! 498: be .LL26
! 499: nop
! 500: mov -1, %g1
! 501: st %g1, [%fp-24]
! 502: b .LL27
! 503: nop
! 504: .LL26:
! 505: st %g0, [%fp-24]
! 506: .LL27:
! 507: ld [%fp-24], %g1
! 508: mov %g1, %i0
! 509: ret
! 510: restore
! 511: .size smart_read_log, .-smart_read_log
! 512: .align 4
! 513: .global smart_enable
! 514: .type smart_enable, #function
! 515: .proc 04
! 516: smart_enable:
! 517: !#PROLOGUE# 0
! 518: save %sp, -128, %sp
! 519: !#PROLOGUE# 1
! 520: st %i0, [%fp+68]
! 521: st %g0, [%sp+92]
! 522: ld [%fp+68], %o0
! 523: mov 176, %o1
! 524: mov 216, %o2
! 525: sethi %hi(12733440), %g1
! 526: or %g1, 768, %o3
! 527: mov 0, %o4
! 528: mov 0, %o5
! 529: call ata_cmd, 0
! 530: nop
! 531: mov %o0, %g1
! 532: st %g1, [%fp-20]
! 533: ld [%fp-20], %g1
! 534: cmp %g1, 0
! 535: be .LL29
! 536: nop
! 537: mov -1, %g1
! 538: st %g1, [%fp-24]
! 539: b .LL30
! 540: nop
! 541: .LL29:
! 542: st %g0, [%fp-24]
! 543: .LL30:
! 544: ld [%fp-24], %g1
! 545: mov %g1, %i0
! 546: ret
! 547: restore
! 548: .size smart_enable, .-smart_enable
! 549: .align 4
! 550: .global smart_disable
! 551: .type smart_disable, #function
! 552: .proc 04
! 553: smart_disable:
! 554: !#PROLOGUE# 0
! 555: save %sp, -128, %sp
! 556: !#PROLOGUE# 1
! 557: st %i0, [%fp+68]
! 558: st %g0, [%sp+92]
! 559: ld [%fp+68], %o0
! 560: mov 176, %o1
! 561: mov 217, %o2
! 562: sethi %hi(12733440), %g1
! 563: or %g1, 768, %o3
! 564: mov 0, %o4
! 565: mov 0, %o5
! 566: call ata_cmd, 0
! 567: nop
! 568: mov %o0, %g1
! 569: st %g1, [%fp-20]
! 570: ld [%fp-20], %g1
! 571: cmp %g1, 0
! 572: be .LL32
! 573: nop
! 574: mov -1, %g1
! 575: st %g1, [%fp-24]
! 576: b .LL33
! 577: nop
! 578: .LL32:
! 579: st %g0, [%fp-24]
! 580: .LL33:
! 581: ld [%fp-24], %g1
! 582: mov %g1, %i0
! 583: ret
! 584: restore
! 585: .size smart_disable, .-smart_disable
! 586: .align 4
! 587: .global smart_status
! 588: .type smart_status, #function
! 589: .proc 04
! 590: smart_status:
! 591: !#PROLOGUE# 0
! 592: save %sp, -128, %sp
! 593: !#PROLOGUE# 1
! 594: st %i0, [%fp+68]
! 595: st %g0, [%sp+92]
! 596: ld [%fp+68], %o0
! 597: mov 176, %o1
! 598: mov 218, %o2
! 599: sethi %hi(12733440), %g1
! 600: or %g1, 768, %o3
! 601: mov 0, %o4
! 602: mov 0, %o5
! 603: call ata_cmd, 0
! 604: nop
! 605: mov %o0, %g1
! 606: st %g1, [%fp-20]
! 607: ld [%fp-20], %g1
! 608: cmp %g1, 0
! 609: be .LL35
! 610: nop
! 611: mov -1, %g1
! 612: st %g1, [%fp-24]
! 613: b .LL36
! 614: nop
! 615: .LL35:
! 616: st %g0, [%fp-24]
! 617: .LL36:
! 618: ld [%fp-24], %g1
! 619: mov %g1, %i0
! 620: ret
! 621: restore
! 622: .size smart_status, .-smart_status
! 623: .align 4
! 624: .global smart_status_check
! 625: .type smart_status_check, #function
! 626: .proc 04
! 627: smart_status_check:
! 628: !#PROLOGUE# 0
! 629: save %sp, -128, %sp
! 630: !#PROLOGUE# 1
! 631: st %i0, [%fp+68]
! 632: st %g0, [%sp+92]
! 633: ld [%fp+68], %o0
! 634: mov 176, %o1
! 635: mov 218, %o2
! 636: sethi %hi(12733440), %g1
! 637: or %g1, 768, %o3
! 638: mov 0, %o4
! 639: mov 0, %o5
! 640: call ata_cmd, 0
! 641: nop
! 642: mov %o0, %g1
! 643: st %g1, [%fp-20]
! 644: ld [%fp-20], %g1
! 645: cmp %g1, 0
! 646: be .LL38
! 647: nop
! 648: mov -1, %g1
! 649: st %g1, [%fp-24]
! 650: b .LL37
! 651: nop
! 652: .LL38:
! 653: st %g0, [%fp-24]
! 654: .LL37:
! 655: ld [%fp-24], %i0
! 656: ret
! 657: restore
! 658: .size smart_status_check, .-smart_status_check
! 659: .align 4
! 660: .global smart_auto_offline
! 661: .type smart_auto_offline, #function
! 662: .proc 04
! 663: smart_auto_offline:
! 664: !#PROLOGUE# 0
! 665: save %sp, -128, %sp
! 666: !#PROLOGUE# 1
! 667: st %i0, [%fp+68]
! 668: st %i1, [%fp+72]
! 669: st %g0, [%sp+92]
! 670: ld [%fp+68], %o0
! 671: mov 176, %o1
! 672: mov 219, %o2
! 673: sethi %hi(12733440), %g1
! 674: or %g1, 768, %o3
! 675: ld [%fp+72], %o4
! 676: mov 0, %o5
! 677: call ata_cmd, 0
! 678: nop
! 679: mov %o0, %g1
! 680: st %g1, [%fp-20]
! 681: ld [%fp-20], %g1
! 682: cmp %g1, 0
! 683: be .LL40
! 684: nop
! 685: mov -1, %g1
! 686: st %g1, [%fp-24]
! 687: b .LL41
! 688: nop
! 689: .LL40:
! 690: st %g0, [%fp-24]
! 691: .LL41:
! 692: ld [%fp-24], %g1
! 693: mov %g1, %i0
! 694: ret
! 695: restore
! 696: .size smart_auto_offline, .-smart_auto_offline
! 697: .ident "GCC: (GNU) 3.4.2"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>