|
|
在EDK source中提供了对physical 和vitural disk的operation8 K7 T9 \' w4 G9 G" p/ ]% f: C5 _) h
参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件0 s& M0 p4 J5 H( ~+ ]$ u
set EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=5128 \' w; q; w7 d+ A
当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:
% g) i# t2 R: _7 [& \$ `3 I' u4 d; y// set disk type,Physical or Virtual disk? and get the name' O$ ~- N% F4 T j( q0 r
if (DiskType == EfiWinNtVirtualDisks) {9 e# d* S8 n4 k
WinNtIo->WinNtThunk->SPrintf (
# s' U2 _% }( ]) H% B Buffer,% z2 d. J8 u3 u3 t, d8 y6 M/ Z2 h# {
L"Diskfile%d",4 L5 z0 J. W' j' H
WinNtIo->InstanceNumber6 l! B; T" q" O+ w: J
);
0 T, h* c: P3 X) j: d+ @/ x } else {
, J2 X. n( c+ x* Z$ p+ q. K if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {. ~8 `* b6 q& c( L
WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);
2 t1 `, N* V% r5 B7 V } else {5 x! w6 \ T1 U
WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);* |" U0 K! b- q! g$ P S+ C, t! ~
}) O$ ?' t/ z' B% Q+ d* ?4 t
//create mapping
- j7 l9 ^8 n$ x2 [0 F2 \ Status = WinNtBlockIoCreateMapping (
4 V) y1 ?9 J7 x: w2 O1 j+ k, C WinNtIo," y4 E7 F7 O* G" N! n- R0 u1 ?9 V5 h& N6 b
Handle, m& Z. }/ Y Q* D
Buffer,6 e" `9 F( J% {% Z) p& ]/ ~. L4 y
WriteProtected,2 U. F: \$ v8 B Z9 N; |% r/ r( s
RemovableMedia,
7 o! G$ Q; x2 g/ j- b+ a NumberOfBlocks,
' \' q: b0 B. d! _5 k* c, R BlockSize,5 p0 R2 D0 [1 p8 \2 }* b! y8 T
DiskType t" C/ A; w6 d3 `+ e
);0 P' ^) y9 S4 g: w5 R' e; ]
//register read or write blocks function: t. ` @1 p# x" z
BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;
; v" O, ?9 p2 E5 H; h) EBlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;# p5 Y& N, @( q4 G+ A ^
7 L3 x5 ~4 `/ J8 ?; P' T
//in the WinNtBlockIoReadBlocks,read file API' k' G; v+ b. Z& B
Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);4 s% Y: Q# }1 V# ^2 g( d# Q2 G! S7 z
5 u* d- Q7 u1 t0 E问题如下:' q( L: p' Q7 B* E2 M. J/ D
EDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊2 ^8 ^* a5 x6 K# j
( E' \( P) b, I9 Q* d( n0 q" }; I[ 本帖最后由 libeili 于 2009-3-23 18:01 编辑 ] |
|