Commit c45c3d0059d738c856fc730ee2e51bf5868815e1
1 parent
baca51fa
write to both IDE drives - return 0 for not present drives
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@672 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
43 additions
and
14 deletions
hw/ide.c
| ... | ... | @@ -1060,7 +1060,7 @@ static void cdrom_change_cb(void *opaque) |
| 1060 | 1060 | static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) |
| 1061 | 1061 | { |
| 1062 | 1062 | IDEState *ide_if = opaque; |
| 1063 | - IDEState *s = ide_if->cur_drive; | |
| 1063 | + IDEState *s; | |
| 1064 | 1064 | int unit, n; |
| 1065 | 1065 | |
| 1066 | 1066 | #ifdef DEBUG_IDE |
| ... | ... | @@ -1071,28 +1071,35 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) |
| 1071 | 1071 | case 0: |
| 1072 | 1072 | break; |
| 1073 | 1073 | case 1: |
| 1074 | - s->feature = val; | |
| 1074 | + /* NOTE: data is written to the two drives */ | |
| 1075 | + ide_if[0].feature = val; | |
| 1076 | + ide_if[1].feature = val; | |
| 1075 | 1077 | break; |
| 1076 | 1078 | case 2: |
| 1077 | 1079 | if (val == 0) |
| 1078 | 1080 | val = 256; |
| 1079 | - s->nsector = val; | |
| 1081 | + ide_if[0].nsector = val; | |
| 1082 | + ide_if[1].nsector = val; | |
| 1080 | 1083 | break; |
| 1081 | 1084 | case 3: |
| 1082 | - s->sector = val; | |
| 1085 | + ide_if[0].sector = val; | |
| 1086 | + ide_if[1].sector = val; | |
| 1083 | 1087 | break; |
| 1084 | 1088 | case 4: |
| 1085 | - s->lcyl = val; | |
| 1089 | + ide_if[0].lcyl = val; | |
| 1090 | + ide_if[1].lcyl = val; | |
| 1086 | 1091 | break; |
| 1087 | 1092 | case 5: |
| 1088 | - s->hcyl = val; | |
| 1093 | + ide_if[0].hcyl = val; | |
| 1094 | + ide_if[1].hcyl = val; | |
| 1089 | 1095 | break; |
| 1090 | 1096 | case 6: |
| 1097 | + ide_if[0].select = val & 0x4f; | |
| 1098 | + ide_if[1].select = val & 0x4f; | |
| 1091 | 1099 | /* select drive */ |
| 1092 | 1100 | unit = (val >> 4) & 1; |
| 1093 | 1101 | s = ide_if + unit; |
| 1094 | 1102 | ide_if->cur_drive = s; |
| 1095 | - s->select = val; | |
| 1096 | 1103 | break; |
| 1097 | 1104 | default: |
| 1098 | 1105 | case 7: |
| ... | ... | @@ -1100,6 +1107,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) |
| 1100 | 1107 | #if defined(DEBUG_IDE) |
| 1101 | 1108 | printf("ide: CMD=%02x\n", val); |
| 1102 | 1109 | #endif |
| 1110 | + s = ide_if->cur_drive; | |
| 1103 | 1111 | switch(val) { |
| 1104 | 1112 | case WIN_IDENTIFY: |
| 1105 | 1113 | if (s->bs && !s->is_cdrom) { |
| ... | ... | @@ -1228,26 +1236,47 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) |
| 1228 | 1236 | ret = 0xff; |
| 1229 | 1237 | break; |
| 1230 | 1238 | case 1: |
| 1231 | - ret = s->error; | |
| 1239 | + if (!s->bs) | |
| 1240 | + ret = 0; | |
| 1241 | + else | |
| 1242 | + ret = s->error; | |
| 1232 | 1243 | break; |
| 1233 | 1244 | case 2: |
| 1234 | - ret = s->nsector & 0xff; | |
| 1245 | + if (!s->bs) | |
| 1246 | + ret = 0; | |
| 1247 | + else | |
| 1248 | + ret = s->nsector & 0xff; | |
| 1235 | 1249 | break; |
| 1236 | 1250 | case 3: |
| 1237 | - ret = s->sector; | |
| 1251 | + if (!s->bs) | |
| 1252 | + ret = 0; | |
| 1253 | + else | |
| 1254 | + ret = s->sector; | |
| 1238 | 1255 | break; |
| 1239 | 1256 | case 4: |
| 1240 | - ret = s->lcyl; | |
| 1257 | + if (!s->bs) | |
| 1258 | + ret = 0; | |
| 1259 | + else | |
| 1260 | + ret = s->lcyl; | |
| 1241 | 1261 | break; |
| 1242 | 1262 | case 5: |
| 1243 | - ret = s->hcyl; | |
| 1263 | + if (!s->bs) | |
| 1264 | + ret = 0; | |
| 1265 | + else | |
| 1266 | + ret = s->hcyl; | |
| 1244 | 1267 | break; |
| 1245 | 1268 | case 6: |
| 1246 | - ret = s->select; | |
| 1269 | + if (!s->bs) | |
| 1270 | + ret = 0; | |
| 1271 | + else | |
| 1272 | + ret = s->select; | |
| 1247 | 1273 | break; |
| 1248 | 1274 | default: |
| 1249 | 1275 | case 7: |
| 1250 | - ret = s->status; | |
| 1276 | + if (!s->bs) | |
| 1277 | + ret = 0; | |
| 1278 | + else | |
| 1279 | + ret = s->status; | |
| 1251 | 1280 | pic_set_irq(s->irq, 0); |
| 1252 | 1281 | break; |
| 1253 | 1282 | } | ... | ... |