From e71bc9a4f2a092b3c397570d9ed37f5f6fffd9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Wed, 24 Oct 2012 13:49:22 +0000 Subject: [PATCH] finished incorporating sd_card routines --- BaS_GNU/BaS_GNU/Makefile | 1 + BaS_GNU/BaS_GNU/bas.lk.in | 1 + BaS_GNU/BaS_GNU/sources/BaS.c | 2 +- BaS_GNU/BaS_GNU/sources/sd_card.c | 13 +++++++++- BaS_GNU/BaS_GNU/sources/sd_card_asm.S | 37 ++++++++++++++++++++++----- 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/BaS_GNU/BaS_GNU/Makefile b/BaS_GNU/BaS_GNU/Makefile index 59b61b6..cf10d34 100644 --- a/BaS_GNU/BaS_GNU/Makefile +++ b/BaS_GNU/BaS_GNU/Makefile @@ -45,6 +45,7 @@ CSRCS= \ ASRCS= \ $(SRCDIR)/mmu.S \ + $(SRCDIR)/sd_card_asm.S \ $(SRCDIR)/exceptions.S \ $(SRCDIR)/supervisor.S \ $(SRCDIR)/ewf.S \ diff --git a/BaS_GNU/BaS_GNU/bas.lk.in b/BaS_GNU/BaS_GNU/bas.lk.in index 6fa0e29..52a25de 100644 --- a/BaS_GNU/BaS_GNU/bas.lk.in +++ b/BaS_GNU/BaS_GNU/bas.lk.in @@ -75,6 +75,7 @@ SECTIONS { { objs/BaS.o(.text) /* put other routines into the same segment (RAM) as BaS.o */ + objs/sd_card_asm.o(.text) objs/sd_card.o(.text) objs/mmu.o(.text) objs/exceptions.o(.text) diff --git a/BaS_GNU/BaS_GNU/sources/BaS.c b/BaS_GNU/BaS_GNU/sources/BaS.c index d6117d7..86dd0df 100644 --- a/BaS_GNU/BaS_GNU/sources/BaS.c +++ b/BaS_GNU/BaS_GNU/sources/BaS.c @@ -40,7 +40,7 @@ void BaS(void) az_sectors = sd_card_init(); - if(az_sectors>0) + if (az_sectors > 0) { sd_card_idle(); } diff --git a/BaS_GNU/BaS_GNU/sources/sd_card.c b/BaS_GNU/BaS_GNU/sources/sd_card.c index af22cb6..13b1f2d 100644 --- a/BaS_GNU/BaS_GNU/sources/sd_card.c +++ b/BaS_GNU/BaS_GNU/sources/sd_card.c @@ -10,8 +10,8 @@ void sd_card_idle(void) __asm__ __volatile__ ( ".extern sd_idle\n\t" "bsr sd_idle\n\t" - /* input */ : /* output */: + /* input */ : /* clobber */: "a0","a1","a2","a3","a4","a5","a6", "d0","d1","d2","d3","d4","d5","d6","d7","memory" ); @@ -21,6 +21,17 @@ void sd_card_idle(void) int sd_card_init(void) { + register int ret __asm__("d0"); + __asm__ __volatile__ ( + ".extern sd_init\n\t" + "bsr.l sd_init\n\t" + /* output */: "=r" (ret) + /* input */ : + /* clobber */: "a0","a1","a2","a3","a4","a5","a6", + "d1","d2","d3","d4","d5","d6","d7","memory" + ); + + return ret; } diff --git a/BaS_GNU/BaS_GNU/sources/sd_card_asm.S b/BaS_GNU/BaS_GNU/sources/sd_card_asm.S index 5d8453d..431f52a 100644 --- a/BaS_GNU/BaS_GNU/sources/sd_card_asm.S +++ b/BaS_GNU/BaS_GNU/sources/sd_card_asm.S @@ -11,16 +11,38 @@ #define MCF_PAD_PAR_DSPI (__MBAR+0xA50) #define MCF_PSC0_PSCTB_8BIT (__MBAR+0x860C) #define MCF_DSPI_DMCR (__MBAR+0x8A00) -.text +#define MCF_SLT0_SCNT (__MBAR + 0x908) + +warte_10ms: + move.l d0,-(sp) + move.l MCF_SLT0_SCNT,d0 + sub.l #1320000,d0 +warte_d6: + cmp.l MCF_SLT0_SCNT,d0 + bcs warte_d6 + move.l (sp)+,d0 + rts + +warte_1ms: + move.l d0,-(sp) + move.l MCF_SLT0_SCNT,d0 + sub.l #132000,d0 +warte_d5: + cmp.l MCF_SLT0_SCNT,d0 + bcs warte_d5 + move.l (sp)+,d0 + rts + .text .global sd_idle + .global sd_init -sd_test: +sd_init: lea MCF_PSC0_PSCTB_8BIT,a6 move.l #LONGASC('S', 'D', '-', 'A'),(a6) move.l #LONGASC('a', 'r', 'd', ' '),(a6) - move.l #_Bas_base,a5 // basis addresse (diesen bereich brauchen wir nicht mehr!) + move.l buffer,a5 // basis addresse (diesen bereich brauchen wir nicht mehr!) move.l #0x1fffffff,d0 // normal dspi move.l d0,MCF_PAD_PAR_DSPI lea MCF_DSPI_DMCR,a0 @@ -30,9 +52,9 @@ sd_test: move.l #0x082000ff,d4 // tx vorbesetzen mov3q.l #-1,dspi_dsr(a0) - bsr.l _wait_1ms + bsr.l warte_1ms move.l #0xc00d3c00,(a0) // 8 bit 4MHz clocken cs off - bsr.l _wait_10ms + bsr.l warte_10ms move.l #0x800d3c00,(a0) // 8 bit 4MHz normal cs on bsr sd_com bsr sd_com @@ -53,7 +75,7 @@ sd_test: bsr sd_com bsr sd_com move.l #0x802d3c00,(a0) // 8 bit 4MHz normal cs off - bsr.l _wait_10ms + bsr.l warte_10ms // sd idle move.l #100,d6 // 100 versuche @@ -411,3 +433,6 @@ sd_rcv_rd_rb: bne sd_rcv_rd_rb rts /******************************************/ + + .data +buffer: dc.l 0, 0, 0, 0, 0, 0, 0, 0