|
在EDK source中提供了对physical 和vitural disk的operation
2 R& V2 U9 s' h- h+ N ~参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件
+ L% _3 g+ j/ {' Fset EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512
2 E# c/ r1 ^5 o! s6 A0 i当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:
* Z" R8 b4 u' |, c// set disk type,Physical or Virtual disk? and get the name
. s! X5 M# p: J7 ~if (DiskType == EfiWinNtVirtualDisks) {
3 p- Z) ^8 K5 o& \& P% N4 d3 k, a h WinNtIo->WinNtThunk->SPrintf (
" c8 P D& |! E* v. n9 D* u0 x Buffer,
) r# Q2 J$ Y% d0 }' V. u3 U' p" S L"Diskfile%d",
$ F$ `1 l' u6 c; E$ o) h: w WinNtIo->InstanceNumber
* o/ T m) D- k+ k5 F% L8 }" o8 v' p );4 |0 {6 N d1 {3 L, e+ n- [% X
} else {$ h c0 b0 }% z, t; h1 A2 U$ R
if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {1 e( c I2 }7 M6 H% L! m
WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);/ U, W$ n/ V2 ~+ v
} else {# X9 x+ \ O$ l' ] P
WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);
! o0 p( i) l4 l: e" u, G" g& { }
' {9 B4 k$ L9 \6 @" Q8 Y/ n//create mapping # f% c. m9 ^# m1 s& g
Status = WinNtBlockIoCreateMapping (
" x8 w: _8 K2 S8 n# b4 x WinNtIo,' l9 T1 R$ r8 g. P7 O8 t2 p) n7 p
Handle,4 `; q* n& _3 T" f- P: p0 Q
Buffer,9 O. y" m7 w& f4 }; m
WriteProtected,3 V; x' [9 I) j# }4 V! v/ `* z
RemovableMedia,
* q2 V- I0 b% C' \ NumberOfBlocks,% A) U4 p$ s' Z
BlockSize,6 A3 C4 g0 Z% Z0 ]
DiskType0 @) P. ?) x2 G# k
);
* g6 B6 F; j) g9 U6 i( ^9 R; n//register read or write blocks function/ Z% O8 ]7 f$ n: C
BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;
6 N+ s3 X& A" W( tBlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;1 S9 F# _. V d" s
- g/ i7 H# `- o' p% ?//in the WinNtBlockIoReadBlocks,read file API( \7 n- V. z* n( w$ t3 B) S
Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);
/ K8 y0 t8 w# V8 V7 r' m' \& ?+ ~+ ^ Z+ }: L
问题如下:% d; c3 y% b1 d0 z; H& K
EDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊
, ?7 j, L) ]9 |9 R7 _3 g6 u8 |4 R. v1 G8 G
[ 本帖最后由 libeili 于 2009-3-23 18:01 编辑 ] |
|