Commit 7ae9862745abb67789a34d4354cc738ab172b377
1 parent
41b9be47
ide select logic fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@717 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
19 additions
and
13 deletions
hw/ide.c
... | ... | @@ -1078,8 +1078,8 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) |
1078 | 1078 | ide_if[1].hcyl = val; |
1079 | 1079 | break; |
1080 | 1080 | case 6: |
1081 | - ide_if[0].select = val & 0x4f; | |
1082 | - ide_if[1].select = val & 0x4f; | |
1081 | + ide_if[0].select = (val & ~0x10) | 0xa0; | |
1082 | + ide_if[1].select = (val | 0x10) | 0xa0; | |
1083 | 1083 | /* select drive */ |
1084 | 1084 | unit = (val >> 4) & 1; |
1085 | 1085 | s = ide_if + unit; |
... | ... | @@ -1210,7 +1210,8 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) |
1210 | 1210 | |
1211 | 1211 | static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) |
1212 | 1212 | { |
1213 | - IDEState *s = ((IDEState *)opaque)->cur_drive; | |
1213 | + IDEState *ide_if = opaque; | |
1214 | + IDEState *s = ide_if->cur_drive; | |
1214 | 1215 | uint32_t addr; |
1215 | 1216 | int ret; |
1216 | 1217 | |
... | ... | @@ -1220,44 +1221,44 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) |
1220 | 1221 | ret = 0xff; |
1221 | 1222 | break; |
1222 | 1223 | case 1: |
1223 | - if (!s->bs) | |
1224 | + if (!ide_if[0].bs && !ide_if[1].bs) | |
1224 | 1225 | ret = 0; |
1225 | 1226 | else |
1226 | 1227 | ret = s->error; |
1227 | 1228 | break; |
1228 | 1229 | case 2: |
1229 | - if (!s->bs) | |
1230 | + if (!ide_if[0].bs && !ide_if[1].bs) | |
1230 | 1231 | ret = 0; |
1231 | 1232 | else |
1232 | 1233 | ret = s->nsector & 0xff; |
1233 | 1234 | break; |
1234 | 1235 | case 3: |
1235 | - if (!s->bs) | |
1236 | + if (!ide_if[0].bs && !ide_if[1].bs) | |
1236 | 1237 | ret = 0; |
1237 | 1238 | else |
1238 | 1239 | ret = s->sector; |
1239 | 1240 | break; |
1240 | 1241 | case 4: |
1241 | - if (!s->bs) | |
1242 | + if (!ide_if[0].bs && !ide_if[1].bs) | |
1242 | 1243 | ret = 0; |
1243 | 1244 | else |
1244 | 1245 | ret = s->lcyl; |
1245 | 1246 | break; |
1246 | 1247 | case 5: |
1247 | - if (!s->bs) | |
1248 | + if (!ide_if[0].bs && !ide_if[1].bs) | |
1248 | 1249 | ret = 0; |
1249 | 1250 | else |
1250 | 1251 | ret = s->hcyl; |
1251 | 1252 | break; |
1252 | 1253 | case 6: |
1253 | - if (!s->bs) | |
1254 | + if (!ide_if[0].bs && !ide_if[1].bs) | |
1254 | 1255 | ret = 0; |
1255 | 1256 | else |
1256 | - ret = s->select | 0xa0; | |
1257 | + ret = s->select; | |
1257 | 1258 | break; |
1258 | 1259 | default: |
1259 | 1260 | case 7: |
1260 | - if (!s->bs) | |
1261 | + if (!ide_if[0].bs && !ide_if[1].bs) | |
1261 | 1262 | ret = 0; |
1262 | 1263 | else |
1263 | 1264 | ret = s->status; |
... | ... | @@ -1272,9 +1273,14 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) |
1272 | 1273 | |
1273 | 1274 | static uint32_t ide_status_read(void *opaque, uint32_t addr) |
1274 | 1275 | { |
1275 | - IDEState *s = ((IDEState *)opaque)->cur_drive; | |
1276 | + IDEState *ide_if = opaque; | |
1277 | + IDEState *s = ide_if->cur_drive; | |
1276 | 1278 | int ret; |
1277 | - ret = s->status; | |
1279 | + | |
1280 | + if (!ide_if[0].bs && !ide_if[1].bs) | |
1281 | + ret = 0; | |
1282 | + else | |
1283 | + ret = s->status; | |
1278 | 1284 | #ifdef DEBUG_IDE |
1279 | 1285 | printf("ide: read status addr=0x%x val=%02x\n", addr, ret); |
1280 | 1286 | #endif | ... | ... |