|
|
在EDK source中提供了对physical 和vitural disk的operation
: X4 |% ^7 y! B" D0 L4 b参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件% Q+ l8 K! f9 f) O7 Z; p% S* }
set EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512
+ H% w; ^; b) d5 m: K, A当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:0 b+ B3 @( a6 P8 E. b. F
// set disk type,Physical or Virtual disk? and get the name
# w0 M8 ~2 C) [' y! hif (DiskType == EfiWinNtVirtualDisks) {3 t9 H" n$ Q; l: m6 S4 f0 K
WinNtIo->WinNtThunk->SPrintf (; g& M3 x( f6 } Q3 Q3 M: M1 Z! q
Buffer,: H- V8 Y' r" N" v( h' i
L"Diskfile%d",6 M( I! k3 E* U
WinNtIo->InstanceNumber
5 U) x$ ^4 O: a# u* C );) |' i- }" P2 T: O+ S# k
} else {
1 a. @( n5 g+ s; R8 D* ]8 r& V# E if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {! h, X2 b" o) p5 I+ s
WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);8 K+ p: M9 ?( M. j
} else {/ A1 _% w0 ~4 h
WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);8 H4 i5 I9 f, q9 |
}8 U0 a0 C% @6 B }$ B- t, e0 o
//create mapping
6 w$ {# v* Y8 x% n) ?7 s Status = WinNtBlockIoCreateMapping (* n: D* X8 O) }" k
WinNtIo,
+ l# d" t& i3 ^# W2 y/ H7 W8 h! | Handle,1 K( J9 O! }$ b
Buffer,: l/ u; [# J; c$ S
WriteProtected,0 N+ [9 Y" O: @5 w3 k2 x( M* ^1 ^
RemovableMedia,
: K- {, d: g, w NumberOfBlocks,
$ c) \# M. b. { BlockSize,8 B. i: |. G! d
DiskType
( |' _( g% v& m* q- O/ M );+ N) g4 C; F' D! z
//register read or write blocks function3 y& P! `0 \% Y6 T( j
BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;: H$ N0 e. d9 E1 M. l6 x0 l
BlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;
3 m; f. C8 h5 r- n( c9 C$ l, ^0 }! ~7 l8 I
//in the WinNtBlockIoReadBlocks,read file API
! ~6 v, p3 _1 u; ^- ~9 a, q5 o) |Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);5 G3 m) G& s4 j. I
] f! ?6 C5 z( v3 X
问题如下:
, r% a3 C$ S2 w2 R; _* LEDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊! x! w: N* r+ D% @" ?
% ]/ |. h/ ^! l) y* F$ m% Q/ U& _ J
[ 本帖最后由 libeili 于 2009-3-23 18:01 编辑 ] |
|