some cleanup in the SD card controller

This commit is contained in:
Maik Merten committed 2014-08-12 21:34:00 +02:00
1 parent b2670aedf1
commit 792366fddb
1 file changed
+8 -11
@@ -79,22 +79,18 @@ public class SdController extends Device {
switch(address) { switch(address) {
case 0 : case 0 :
writeData(data); writeData(data);
break; return;
case 1 : case 1 :
writeCommand(data); writeCommand(data);
break; return;
case 2 : case 2 :
this.lba0 = data; this.lba0 = data;
computePosition(); return;
break;
case 3 : case 3 :
this.lba1 = data; this.lba1 = data;
computePosition(); return;
break;
case 4 : case 4 :
this.lba2 = data; this.lba2 = data;
computePosition();
break;
} }
} }
@@ -168,7 +164,8 @@ public class SdController extends Device {
if(sdImageFile != null) { if(sdImageFile != null) {
try { try {
FileOutputStream fos = new FileOutputStream(sdImageFile); FileOutputStream fos = new FileOutputStream(sdImageFile);
fos.write(writeBuffer, this.position, writeBuffer.length); fos.getChannel().position(this.position);
fos.write(writeBuffer, 0, writeBuffer.length);
fos.close(); fos.close();
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.WARNING, "could not write data back to SD image file!", ex); logger.log(Level.WARNING, "could not write data back to SD image file!", ex);
@@ -196,10 +193,10 @@ public class SdController extends Device {
switch(this.command) { switch(this.command) {
case 0 : case 0 :
prepareRead(); prepareRead();
break; return;
case 1 : case 1 :
prepareWrite(); prepareWrite();
break; return;
default: default:
this.status = Status.IDLE; this.status = Status.IDLE;
} }