|
|
在EDK source中提供了对physical 和vitural disk的operation- C+ F; r- o6 `) {- H1 b
参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件
: _6 d9 m* J+ f& \4 Kset EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512 N C7 O2 o, m- B; q
当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:. l+ X) n/ x/ u) ]/ T
// set disk type,Physical or Virtual disk? and get the name
! Y# y+ P6 ?( W: G6 M0 w! Cif (DiskType == EfiWinNtVirtualDisks) {
2 I- ?# v5 b8 D, _* G5 } WinNtIo->WinNtThunk->SPrintf (
. Q! B3 v% t. S$ c$ }! }7 V9 R Buffer,
3 Q8 a* x9 q# I: S L"Diskfile%d",
2 o2 ?0 U7 h# h* g" L, b6 l' t7 s WinNtIo->InstanceNumber G& a$ e; p- Y, P$ Q: d0 K
);
8 Q! a; l H4 e2 a6 i } else {
6 l6 i0 O4 A P( s9 ` if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {
, m9 J$ q# h2 z WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);2 R5 h2 l% c& N- R. x1 O
} else {
7 A# g6 J7 e) { WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);
" O% W, G$ @3 p( ~9 @- L }' g7 C5 o) V/ X& x
//create mapping
, E6 Y" c4 P2 H4 P) \2 E A2 s! y Status = WinNtBlockIoCreateMapping (* c4 L# {6 @" M, g* C3 e# r3 n
WinNtIo,
# r: w9 B( a* _# d- y Handle,# ^# ^& R0 t7 C# x
Buffer,0 q$ v9 G/ j5 T! |
WriteProtected,4 i0 O% m7 V1 t) F: N3 k4 ~0 b
RemovableMedia, |; b$ O& S3 |7 r
NumberOfBlocks,$ P: ^: {3 i# T0 i8 Q, ^
BlockSize,
' m% S# [; \0 O2 O! D) q( |4 \ DiskType+ G- W; V+ U! T
);; j# A" x: P( V6 [; c
//register read or write blocks function. @3 k# m* @/ T0 x& I3 Z9 n5 T
BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;5 U8 Q) I; e0 h
BlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;
7 ]$ N* E) D7 p( ~9 Q# E/ B0 Y$ _7 j/ X' F- N S7 H N
//in the WinNtBlockIoReadBlocks,read file API
( z- D5 [. O) U, y/ KFlag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);% `& q+ l) y1 \3 M1 b0 ] Z
- ]% ~# O- ^2 V+ p. o3 ^
问题如下:7 E+ D' E% |% b* L6 w
EDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊4 h5 k8 e7 j7 I
5 m8 }% ~+ Z) q. x; {5 d[ 本帖最后由 libeili 于 2009-3-23 18:01 编辑 ] |
|