|
在EDK source中提供了对physical 和vitural disk的operation
& }! T5 ^8 x) C( u5 O' w3 C参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件! A' ?8 L" z+ H) V) g4 p. t
set EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512
) Y5 n7 `" P2 D当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:
% g7 H$ u& E0 u1 @6 f, j// set disk type,Physical or Virtual disk? and get the name
3 q+ @& Z" l5 K& p% A& b; P4 d8 W$ rif (DiskType == EfiWinNtVirtualDisks) {5 W+ N* F2 {' f7 L* e4 r
WinNtIo->WinNtThunk->SPrintf (/ J+ m) j/ x( U: P0 @ L
Buffer,$ v( ^) ]) ^1 @ e* I
L"Diskfile%d",5 f# {% ~8 F9 B, Q! v2 M
WinNtIo->InstanceNumber0 h& c5 Q6 S: g4 S, F: J
);
( r" m5 L- x E } else {6 x' _+ _9 b6 a2 C7 l( c- O
if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {
- r4 j1 ]1 E1 Q1 u WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);
/ S2 h# R" K( d! d3 f! d( v } else {
6 c; _0 g1 Y$ | M; M0 V WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);" {" [- H! ~8 o& q
}
: K8 u( ^% ^" `2 n: K2 m7 m//create mapping / \% Q1 M/ _+ b
Status = WinNtBlockIoCreateMapping (
$ D ?* m, K | _6 c1 q# Y2 | WinNtIo,& e* j% H; p/ i8 G3 f; `
Handle,$ c! x' P; B1 `9 H* G- q- I# m; u
Buffer," ?, u: ]5 C4 Z4 K, }
WriteProtected,& ] k! a: y" d- |; K
RemovableMedia,
$ h" y! L; q G8 \$ F4 x NumberOfBlocks,* I! e. z4 ]1 K6 k
BlockSize,: x; `8 }/ p; T8 z k6 [
DiskType
) L" i/ x' U, A" o" i );
3 S; a& l4 w+ i. }: j7 Z% _! Z//register read or write blocks function( }# h% [* N& W( Q
BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;
+ C' y( w' `" L! F, SBlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;
' L0 d U" S- B- P0 ~" W/ W( q) q' p' h. L7 O
//in the WinNtBlockIoReadBlocks,read file API
* K0 U* ~& t2 zFlag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);& O9 D! ~0 C C3 j7 `# G% h
- S! @1 U" W8 G/ ]* {问题如下:
" ~% j l% Z0 C+ h: ]+ r) {, V7 lEDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊6 Z" `& z3 J" f6 {6 A, a
g) ^" R+ a6 [4 }# k& i! ?( g
[ 本帖最后由 libeili 于 2009-3-23 18:01 编辑 ] |
|