2 Copyright 2006-2008, Romz
4 Licenced under Academic Free License version 3.0
5 Review OpenUsbLd README & LICENSE files for further details.
10 int mc_configure(MemoryCard
*mcds
)
14 DPRINTF("vmcSpec[0].active = %d\n", vmcSpec
[0].active
);
15 DPRINTF("vmcSpec[1].active = %d\n", vmcSpec
[1].active
);
17 if(vmcSpec
[0].active
== 0 && vmcSpec
[1].active
== 0)
20 for (i
= 0; i
< MCEMU_PORTS
; i
++, mcds
++)
22 DPRINTF("vmcSpec[%d].flags = 0x%X\n", i
, vmcSpec
[i
].flags
);
23 DPRINTF("vmcSpec[%d].cspec.PageSize = 0x%X\n", i
, vmcSpec
[i
].cspec
.PageSize
);
24 DPRINTF("vmcSpec[%d].cspec.BlockSize = 0x%X\n", i
, vmcSpec
[i
].cspec
.BlockSize
);
25 DPRINTF("vmcSpec[%d].cspec.CardSize = 0x%X\n", i
, (unsigned int)vmcSpec
[i
].cspec
.CardSize
);
27 if(vmcSpec
[i
].active
== 1)
29 // Set virtual memorycard informations
31 mcds
->tcode
= 0x5A; /* 'Z' */
32 mcds
->cbufp
= &mceccbuf
[i
][0];
33 mcds
->dbufp
= &mcdatabuf
[0];
34 mcds
->flags
= vmcSpec
[i
].flags
;
35 mcds
->cspec
.PageSize
= vmcSpec
[i
].cspec
.PageSize
;
36 mcds
->cspec
.BlockSize
= vmcSpec
[i
].cspec
.BlockSize
;
37 mcds
->cspec
.CardSize
= vmcSpec
[i
].cspec
.CardSize
;
46 //---------------------------------------------------------------------------
47 int mc_read(int mc_num
, void *buf
, u32 page_num
)
52 lba
= Mcpage_to_Apasector(mc_num
, page_num
);
56 lba
= vmcSpec
[mc_num
].stsec
+ page_num
;
60 lba
= page_num
* vmcSpec
[mc_num
].cspec
.PageSize
;
63 DPRINTF("reading page 0x%X at lba 0x%X\n", (unsigned int)page_num
, (unsigned int)lba
);
66 ata_device_dma_transfer(0, buf
, lba
, 1, ATA_DIR_READ
);
70 mass_stor_readSector(lba
, 1, buf
);
74 if(vmcSpec
[mc_num
].fid
== 0xFFFF)
76 if(!smb_OpenAndX(vmcSpec
[mc_num
].fname
, &vmcSpec
[mc_num
].fid
, 1))
80 smb_ReadFile(vmcSpec
[mc_num
].fid
, lba
, 0, buf
, vmcSpec
[mc_num
].cspec
.PageSize
);
86 //---------------------------------------------------------------------------
87 int mc_write(int mc_num
, void *buf
, u32 page_num
)
92 lba
= Mcpage_to_Apasector(mc_num
, page_num
);
96 lba
= vmcSpec
[mc_num
].stsec
+ page_num
;
100 lba
= page_num
* vmcSpec
[mc_num
].cspec
.PageSize
;
103 DPRINTF("writing page 0x%X at lba 0x%X\n", (unsigned int)page_num
, (unsigned int)lba
);
106 ata_device_dma_transfer(0, buf
, lba
, 1, ATA_DIR_WRITE
);
110 mass_stor_writeSector(lba
, 1, buf
);
114 smb_WriteFile(vmcSpec
[mc_num
].fid
, lba
, 0, buf
, vmcSpec
[mc_num
].cspec
.PageSize
);