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

physical disk operation in EDK NT32 platform

[复制链接]
发表于 2009-3-23 18:00:26 | 显示全部楼层 |阅读模式
在EDK source中提供了对physical 和vitural disk的operation
. X7 H. @$ S: \; F参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件( u# s# k. x/ P* N
set EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512
) S) D3 O# `& j- m当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:8 _" ]4 Z. P* h' i# z$ }5 J5 d% X, c
// set disk type,Physical or Virtual disk? and get the name4 R; Y6 N" x6 h) i
if (DiskType == EfiWinNtVirtualDisks) {
5 y/ b, y! E4 Z" l9 L3 W1 K, \    WinNtIo->WinNtThunk->SPrintf (
6 y. i7 P) `4 M/ X; M* U                          Buffer,/ B* T2 {/ o+ a, A
                          L"Diskfile%d",
4 O5 l( G# A7 F# f, z0 R# M9 t* m                          WinNtIo->InstanceNumber
. f/ X* }6 ~  n5 S0 T                          );# |3 t' R' z; e( e, _6 s% o" Y
  } else {
+ t1 U; E, y4 S    if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {7 R/ a) {8 A+ B
      WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);4 r1 |' B8 b9 y1 r. @
    } else {) E9 z4 s/ E9 z) E: F
      WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);
  d. L  Z. H2 E    }
) u- B& u1 O9 Y& a5 D. A9 X' o//create mapping
3 Q( H0 H0 C" Z. \0 L0 j$ o! m Status = WinNtBlockIoCreateMapping (
+ B8 l* ~( k, Y                    WinNtIo,
+ m- [! c1 T3 \4 C, [& a; @+ b                    Handle,5 N( J" S" W# L/ {* n3 {# n; Q; r3 W
                    Buffer,+ W! _; ]3 ]: o' E
                    WriteProtected,0 o: `) C0 E7 k! |0 J
                    RemovableMedia,! |7 T3 C( \3 h% i6 n. V! d/ [
                    NumberOfBlocks,
" Q+ a+ d, {* R$ z& X5 O7 w1 E5 V                    BlockSize," H; Y! j+ s0 |* {$ |
                    DiskType
" _+ ^; i- n& ~" B                    );: d' N: V3 Z! k; @# l
//register read or write blocks function
$ l5 T+ _. ~* v/ c( f9 \# iBlockIo->ReadBlocks = WinNtBlockIoReadBlocks;7 A. o* m; m0 g2 |1 R: s9 a
BlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;
2 i% L* ^% O6 U$ N7 g+ o( j) B- v2 `; W$ e3 W
//in the WinNtBlockIoReadBlocks,read file API% o8 L8 M0 i5 ~. |5 c5 G1 Y
Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);1 d% K" h5 A" P
& \( U2 r/ ?! \6 X+ |
问题如下:
- R# R) V7 ^" u0 v+ m' g1 v7 @EDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊
, Z% v8 |6 C4 F2 Z8 }8 i4 ?  x# L0 n9 X
[ 本帖最后由 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.
. ^; q" Q9 o/ d. `$ F: f5 `: s: P2 D: U3 G9 @. t, C0 h) i4 s
参见 WinNtBusDriverBindingStart()
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-19 10:41 , Processed in 0.026950 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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