Revision b93af93d

b/hw/ide/core.c
34 34

  
35 35
#include <hw/ide/internal.h>
36 36

  
37
static const int smart_attributes[][5] = {
38
    /* id,  flags, val, wrst, thrsh */
39
    { 0x01, 0x03, 0x64, 0x64, 0x06}, /* raw read */
40
    { 0x03, 0x03, 0x64, 0x64, 0x46}, /* spin up */
41
    { 0x04, 0x02, 0x64, 0x64, 0x14}, /* start stop count */
42
    { 0x05, 0x03, 0x64, 0x64, 0x36}, /* remapped sectors */
43
    { 0x00, 0x00, 0x00, 0x00, 0x00}
37
/* These values were based on a Seagate ST3500418AS but have been modified
38
   to make more sense in QEMU */
39
static const int smart_attributes[][12] = {
40
    /* id,  flags, hflags, val, wrst, raw (6 bytes), threshold */
41
    /* raw read error rate*/
42
    { 0x01, 0x03, 0x00, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06},
43
    /* spin up */
44
    { 0x03, 0x03, 0x00, 0x64, 0x64, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
45
    /* start stop count */
46
    { 0x04, 0x02, 0x00, 0x64, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14},
47
    /* remapped sectors */
48
    { 0x05, 0x03, 0x00, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24},
49
    /* power on hours */
50
    { 0x09, 0x03, 0x00, 0x64, 0x64, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
51
    /* power cycle count */
52
    { 0x0c, 0x03, 0x00, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
53
    /* airflow-temperature-celsius */
54
    { 190,  0x03, 0x00, 0x45, 0x45, 0x1f, 0x00, 0x1f, 0x1f, 0x00, 0x00, 0x32},
55
    /* end of list */
56
    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
44 57
};
45 58

  
46 59
/* XXX: DVDs that could fit on a CD will be reported as a CD */
......
1843 1856
        break;
1844 1857
    case WIN_CHECKPOWERMODE1:
1845 1858
    case WIN_CHECKPOWERMODE2:
1859
        s->error = 0;
1846 1860
        s->nsector = 0xff; /* device active or idle */
1847 1861
        s->status = READY_STAT | SEEK_STAT;
1848 1862
        ide_set_irq(s->bus);
......
2097 2111
		if (smart_attributes[n][0] == 0)
2098 2112
			break;
2099 2113
		s->io_buffer[2+0+(n*12)] = smart_attributes[n][0];
2100
		s->io_buffer[2+1+(n*12)] = smart_attributes[n][4];
2114
		s->io_buffer[2+1+(n*12)] = smart_attributes[n][11];
2101 2115
		}
2102 2116
		for (n=0; n<511; n++) /* checksum */
2103 2117
		s->io_buffer[511] += s->io_buffer[n];
......
2110 2124
		memset(s->io_buffer, 0, 0x200);
2111 2125
		s->io_buffer[0] = 0x01; /* smart struct version */
2112 2126
		for (n=0; n<30; n++) {
2113
		if (smart_attributes[n][0] == 0)
2127
		    if (smart_attributes[n][0] == 0) {
2114 2128
			break;
2115
		s->io_buffer[2+0+(n*12)] = smart_attributes[n][0];
2116
		s->io_buffer[2+1+(n*12)] = smart_attributes[n][1];
2117
		s->io_buffer[2+3+(n*12)] = smart_attributes[n][2];
2118
		s->io_buffer[2+4+(n*12)] = smart_attributes[n][3];
2129
		    }
2130
		    int i;
2131
		    for(i = 0; i < 11; i++) {
2132
			s->io_buffer[2+i+(n*12)] = smart_attributes[n][i];
2133
		    }
2119 2134
		}
2120 2135
		s->io_buffer[362] = 0x02 | (s->smart_autosave?0x80:0x00);
2121 2136
		if (s->smart_selftest_count == 0) {

Also available in: Unified diff