|
|
在EDK source中提供了对physical 和vitural disk的operation
- Y# x& Y' B; t4 ~" Q( o7 |参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件
) I8 p9 s; T* X+ l" i3 Yset EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512
9 A" _( A f6 \% a当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:
2 k9 G3 p5 k# t6 Z2 X" e6 }// set disk type,Physical or Virtual disk? and get the name. b9 ~, s; d+ Q5 L/ g7 E
if (DiskType == EfiWinNtVirtualDisks) {
0 W+ I& L. Z9 e2 A! `& `- B7 c( h WinNtIo->WinNtThunk->SPrintf (
) @, {8 V4 h1 _ Buffer,
6 B$ U: _0 K; A! g& P L"Diskfile%d",
" x( D2 t; f; ]; d" t8 v2 ? WinNtIo->InstanceNumber; x! m. ^8 ]/ m6 f
); ]" s' X- o) l% U
} else {
1 V8 m- F% _2 u! g, ]/ _7 [0 ] if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {( V! [4 R# n4 D; c/ ]
WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);
% m( Z3 [# P M h7 o } else {
6 U }, l$ \! u! g WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);+ X; Y2 T' t; M* q# z! {
}5 D( k, f- ^) G1 g9 b4 `' n: |+ X, g
//create mapping
: ?$ \3 B( K: ]8 V2 g Status = WinNtBlockIoCreateMapping (
. \1 l# t) b( T" u J3 f- K WinNtIo,7 v0 O7 D) b- O+ l* T) m6 @+ v/ G
Handle,
( P/ S. j: O8 q7 h' |4 V Buffer,
: Z" r; {' n/ r0 D! Y$ k& t WriteProtected,) V# C! S& c" {5 }% n7 {
RemovableMedia,; }4 D" e4 c5 C9 J
NumberOfBlocks,7 Y! P6 k: u H- i+ {
BlockSize,
7 V7 k0 ~! H3 \ DiskType3 p! s* W7 q! Y7 l9 h. G8 h5 {
);1 [7 z9 J- ^8 B0 F4 G
//register read or write blocks function
* r: N1 j9 h' f5 H5 _BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;
/ T5 f( G6 j! H8 \BlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;3 V* a" J+ ^9 D( B- f4 V
2 o9 U' Q6 d& _, }//in the WinNtBlockIoReadBlocks,read file API6 `3 P- s$ C/ b9 ]) [2 @1 b5 _1 \
Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);% D" [7 v# L* O/ V
3 `% v \9 L0 X: c6 t) w8 H1 c4 u2 ~问题如下:. ^; V- w8 x8 H+ k, d+ Y" `5 W P
EDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊$ `7 h1 q; u4 ?6 e* [% M
* y/ D8 l. S/ q# g* c# [' ^
[ 本帖最后由 libeili 于 2009-3-23 18:01 编辑 ] |
|