"Maxim S. Shatskih" wrote:
> > 1. For bus master DMA with scatter/gather supported, is there a way to
> > make the start address of each physical segment aligned to 4KB? I find in
> > http://support.microsoft.com/kb/153264/en-us/ that only a maximun of Double
> > Dword alignment is supoorted, but I think that may not be the limitation..
> > 2. Following the 1st question, can each data segment be a multiple of
> > 512bytes? I find in WDK docs that the related parameters are
> > MaximunTransferLength and NumberOfPhysicalBreaks in
> > PORT_CONFIGURATION_INFORMATION, which can not help to solve my problem.
>
> No. Windows DMA API cannot provide these guarantees. So, the hardware must be smart enough to never require them.
So the DMA scatter/gather can not guarantee the alignment of data buffer to
exceed double DWORD, and the size of each segment can not be preassigned.
Obviously the hardware have to be smart..
>
> > 3. In Windows XP, how many SCSI commands are mandatory for OS to use
> > the ram disk?
>
> Just look at what commands arrive to your code and fail.
>
> I think that at least some mode pages (MODE SENSE) are mandatory.
>
> FORMAT UNIT is not used by Windows "format" command. VERIFY is used.
I replied MODE SENSE(page code = 0x3F) with one mode parameter block
descriptor(Number of blocks set to 0, Block length set to 0x200). And I
replied VERIFY with SRB_STATUS_SUCCESS always.
And I define a BYTE array with a depth of 16*1024*1024 to present a 16MB
disk. For READ and WRITE operation, I read from/write to the BYTE array.
I passed the initialization, but the "format" command can't be correctly
processed.
During the debugging process, OS firstly write 1 bolck of data(512byte) to
the block address of 3F, then repeatly send commands READ CAPACITY, MODE
SENSE(mode page = 0x3F), TEST UNIT READY(I replied with success always), and
READ 8 blocks of data at block address 3F, READ 4 blocks of data at block
address 0x7F.
After sending the above commands for certain times, OS begins to send VERIFY
from block address of 0x3F with a length of 512 blocks, and increase the
address by 0x200 until the last VERIFY command of address 0x7C3F and length
of 0x143 block.
After that, OS WRITE 1 block data to address 0x3F and begin to repeat READ
CAPACITY, MODE SENSE, and READ 8 blocks at address 0x3F , 4 blocks at address
0x7F.
In the end, the "format" finished with failure.
I'm wondering what exactly is the OS expecting to get from the 8 blocks
data at address 0x3F and the 4 blocks at address 0x7F, OS just write 1 block
data to 0x3F, what more does it want?
There are 3 commands I did not reply:
The function of SRB is SRB_FUNCTION_IO_CONTROL, I am not quite sure this
function, and I replied with SRB_STATUS_INVALID_REQUEST.
INQUIRY with EVPD set to 1, I don't think vital data is madatory, so I
replied with SRB_STATUS_ERROR.
MODE SENSE with page code set to 0x1C, I set in INQUIRY that the driver
support SCSI-2, so the page code is reserved and I also replied with
SRB_STATUS ERROR.
What is the problem with my dirver? Is there any other things I did not
handle?
Thanks a lot!