aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@trantor.hos.anvin.org>2008-12-30 11:02:45 -0800
committerH. Peter Anvin <hpa@trantor.hos.anvin.org>2008-12-30 11:02:45 -0800
commit3be3dea5ec7bf0d7ff4c1109c8f4e09500d4d387 (patch)
treee315cef121e8f32c93329a2f074d7783aa9f3732
parent1ff0514691cac201f918c72562d9cd7f9154997e (diff)
downloadabc80-3be3dea5ec7bf0d7ff4c1109c8f4e09500d4d387.tar.gz
abc80-3be3dea5ec7bf0d7ff4c1109c8f4e09500d4d387.tar.xz
abc80-3be3dea5ec7bf0d7ff4c1109c8f4e09500d4d387.zip
sddrom: be more careful about DEHL during sd_init
In the sd_init sequence, be really careful about the argument registers (DEHL). If there is ever any doubt, call RST 16 to clear them - it is only a one-byte instruction, and this is not time-critical code in any way.
-rw-r--r--data/sddrom.asm13
1 files changed, 7 insertions, 6 deletions
diff --git a/data/sddrom.asm b/data/sddrom.asm
index 8d97d26..da85a02 100644
--- a/data/sddrom.asm
+++ b/data/sddrom.asm
@@ -541,7 +541,8 @@ sd_init_wait:
ld a,59 ; CMD59 - CDC_ON_OFF
rst 8
; If this command fails, ignore it.
- dec l ; Restore DEHL <- 1
+ ; DEHL = 1 here, but we're about to clobber HL...
+
;
; Probe for extended features
;
@@ -563,12 +564,13 @@ sd_init_wait:
or h
ld c,LED_3
jr nz,sd_carderr
- ld l,a ; Restore DEHL = 0
;
; Initialize card
;
- ld d,40h ; SDHC supported
old_card:
+ rst 16 ; DEHL <- 0
+ ld d,40h ; SDHC supported
+
sd_init_acmd41:
ld a,41
call sd_acmd
@@ -606,11 +608,9 @@ sd_probe_ocr:
and a
ld c,LED_5
jr nz,sd_carderr
- push hl
ld hl,card_ocr+3
ld bc,0x0430 ; 4 bytes from port 30h
otdr
- pop hl
no_sdhc:
;
@@ -619,7 +619,8 @@ no_sdhc:
; that violates the spec.)
;
sd_set_blklen:
- ld h,2 ; Argument <- 512
+ rst 16 ; DEHL <- 0, A <- 0
+ ld h,2 ; DEHL <- 512
ld a,16 ; CMD16 - SET_BLOCKLEN
rst 8
and a