From: Alan Cox Date: Mon, 26 Nov 2018 11:53:36 +0000 (+0000) Subject: divmmc: add swap device, second port support and stripy I/O X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=de4ab1c26b07242bf08f51f78be7237afe33a6b7;p=FUZIX.git divmmc: add swap device, second port support and stripy I/O --- diff --git a/Kernel/platform-zxdiv/divmmc.c b/Kernel/platform-zxdiv/divmmc.c index 5fa9fa52..5d4b5442 100644 --- a/Kernel/platform-zxdiv/divmmc.c +++ b/Kernel/platform-zxdiv/divmmc.c @@ -1,6 +1,7 @@ #include #include #include +#include __sfr __at 0xE7 divmmc_cs; __sfr __at 0xEB divmmc_data; @@ -22,7 +23,10 @@ uint8_t sd_spi_receive_byte(void) void sd_spi_lower_cs(void) { - divmmc_data = 0x02; /* FIXME we can have a slave */ + if (sd_drive == 0) + divmmc_data = 0x02; /* Lower bit 0 (active low) */ + else + divmmc_data = 0x01; /* Lower bit 1 (active low) */ } void sd_spi_clock(bool go_fast) @@ -42,14 +46,30 @@ bool sd_spi_receive_sector(void) __naked __asm ld a, (_blk_op+BLKPARAM_IS_USER_OFFSET) ld hl, (_blk_op+BLKPARAM_ADDR_OFFSET) - or a ; Set the Z flag up and save it, dont do it twice push af +#ifdef SWAPDEV + cp #2 + jr nz, not_swapin + ld a,(_blk_op+BLKPARAM_SWAP_PAGE) + call map_for_swap + jr doread +not_swapin: +#endif + or a call nz,map_process_always +doread: ld bc, #0xEB ; b = 0, c = port + ld a,#0x05 + out (0xfe),a inir + ld a,#0x02 + out (0xfe),a inir + ld a,(_vtborder) + out (0xfe),a pop af - call nz,map_kernel + or a + jp nz,map_kernel ret __endasm; } @@ -59,14 +79,30 @@ bool sd_spi_transmit_sector(void) __naked __asm ld a, (_blk_op+BLKPARAM_IS_USER_OFFSET) ld hl, (_blk_op+BLKPARAM_ADDR_OFFSET) - or a ; Set the Z flag up and save it, dont do it twice push af +#ifdef SWAPDEV + cp #2 + jr nz, not_swapout + ld a, (_blk_op+BLKPARAM_SWAP_PAGE) + call map_for_swap + jr dowrite +not_swapout: +#endif + or a call nz,map_process_always +dowrite: ld bc, #0xEB + ld a,#0x05 + out (0xfe),a otir + ld a,#0x02 + out (0xfe),a otir + ld a,(_vtborder) + out (0xfe),a pop af - call nz,map_kernel + or a + jp nz,map_kernel ret __endasm; }