|
在EDK source中提供了对physical 和vitural disk的operation
, Z1 Y) E _, i# Q. y# Y3 G& c3 Y4 d参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件7 n9 I. z L6 w% ?% t6 `7 r# S
set EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512
/ r- x0 v9 p N- P5 Z当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:
4 F/ R0 t! r3 H0 \& v// set disk type,Physical or Virtual disk? and get the name
x, X( \6 d Z, r! d' z" l5 Sif (DiskType == EfiWinNtVirtualDisks) {
# k- X# c$ Y0 @ WinNtIo->WinNtThunk->SPrintf (
7 M, Y* M7 s: n& } Buffer,
0 M; X! I0 m5 O8 O; g6 Y" h L"Diskfile%d",
1 E$ h$ L+ S+ R WinNtIo->InstanceNumber: ^! o* U) u* R( H
);
, `& F, [% g7 |" O, f! X } else {
* l; e& N" t4 B- j8 o' G7 | if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {
: K) ]. o& p. N8 M: w( N WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);9 W* |: l% C& ^+ k4 e0 f3 m2 i; e5 @
} else {
0 o$ u: e# c, m6 W# e WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);
" Y( F0 t& q- O. e' P$ i1 V }
( z7 u0 o& a! P% a//create mapping ) t6 P. m3 |3 E# H4 ~
Status = WinNtBlockIoCreateMapping (
: w- X1 `4 H" Q$ ] WinNtIo,+ T0 |2 x( C7 } G, W
Handle,
3 N) u( N4 w% U9 p0 r Buffer,3 |4 x" r6 m+ p7 ~! V
WriteProtected,
, ~$ l, b0 e2 m4 L# `$ |% u0 O RemovableMedia,1 J# i5 _! q# V" t5 H
NumberOfBlocks,) e1 ^. Q1 n3 U& e& o) R: j
BlockSize,4 r6 C$ l! o7 v# W
DiskType
( _- _- @& S8 l- q7 S# M) [# i; c );
! Q; V' `' {# m4 ?* Y//register read or write blocks function: B: ^0 x! @! g1 m( o4 ?& i
BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;
^: w' W- N) e, RBlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;
1 N' w; S A# @* ~% F7 c5 z
( |( k" i8 c2 F) ~//in the WinNtBlockIoReadBlocks,read file API
+ e, M; K$ c: q% BFlag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);% Y' u# w3 g' b9 U, c, A: g" H
% w! a: j1 g1 _
问题如下:% k1 ~: ]# z2 b7 L, y3 Q6 F1 X1 f
EDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊
8 ^9 b" h6 x$ x; v% f
( m2 j( f8 s1 g. m i+ f[ 本帖最后由 libeili 于 2009-3-23 18:01 编辑 ] |
|