找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 8708|回复: 1

physical disk operation in EDK NT32 platform

[复制链接]
发表于 2009-3-23 18:00:26 | 显示全部楼层 |阅读模式
在EDK source中提供了对physical 和vitural disk的operation
' d3 @/ g# h' n1 C参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件
2 b. ^+ N1 T! Z3 Z" Y( ~7 R1 |5 Wset EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512! q+ {/ x* `3 G% a- u& w
当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:: y1 t9 A; f: w6 n! p
// set disk type,Physical or Virtual disk? and get the name
3 s6 O8 k) t& J$ c2 |, Cif (DiskType == EfiWinNtVirtualDisks) {
+ p6 [; [; h  H8 k    WinNtIo->WinNtThunk->SPrintf (* I$ f5 f7 v, ~) N- s1 L. t
                          Buffer,- J* d1 W; \9 X1 R& Q, j
                          L"Diskfile%d",! k  Y3 x) n) [. K
                          WinNtIo->InstanceNumber
" w$ R5 u% n$ J4 m1 S" N* F                          );
8 }* L1 G& y! t# k+ Z* ~  } else {
0 m" a3 m- m: n  g% c    if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {
6 }  }+ F5 i& X, A7 m      WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);
1 c; t* S$ b% l7 O3 V    } else {
+ u# O4 h  [, _+ `2 u      WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);
2 u3 J! Z5 [$ V' E) Q    }
9 b3 z/ ]5 J2 e" Q- Z0 }5 `/ f//create mapping . B) q. W* c1 |8 \/ a
Status = WinNtBlockIoCreateMapping (( y# P- q9 o' D
                    WinNtIo,
  y- n" _7 q) h/ ~" q; Y8 q: Z                    Handle,
& s. U7 R1 o9 h/ N. X                    Buffer,
/ ]1 Q& J+ y8 J- ~) S: v                    WriteProtected,  g$ a9 i% e. t, a0 ?* N
                    RemovableMedia,
7 T' ~: m0 `( p! Y                    NumberOfBlocks,7 j! _+ p. `! p
                    BlockSize,
* t! Z) n! n6 M: m. q                    DiskType. i0 p' T# H9 S) `, j. g& G
                    );
2 j5 {) |3 `" j' j//register read or write blocks function0 w0 |0 e4 a* N( u3 A
BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;' W. L* e1 ^# d0 L; u
BlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;
0 k2 }4 w' {% S  m6 _: u# A( i" C% v0 K
//in the WinNtBlockIoReadBlocks,read file API
$ F2 T+ _$ _" Z% ]Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);
" }" {% W/ y) X& S$ U
0 ?, `: u# ]9 ~$ |1 `问题如下:# N* T, s+ {1 j! v( N$ x& z
EDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊
; |; b5 u. \; J9 R2 Y& j% M5 ^/ J9 J
, ^# A7 u5 {8 k[ 本帖最后由 libeili 于 2009-3-23 18:01 编辑 ]
发表于 2009-3-24 16:52:44 | 显示全部楼层
没有物理disk controller handle,Win NT bus driver为所有virtual NT thunk device创建device handle.' j1 l% ]% W( U: Q- f! T$ p: ]. ~. s* n
" e/ @5 M1 s5 L8 D
参见 WinNtBusDriverBindingStart()
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入计匠网

本版积分规则

Archiver|手机版|小黑屋|计匠网

GMT+8, 2026-8-11 17:03 , Processed in 0.047537 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表