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

physical disk operation in EDK NT32 platform

[复制链接]
发表于 2009-3-23 18:00:26 | 显示全部楼层 |阅读模式
在EDK source中提供了对physical 和vitural disk的operation
, o" o: d/ K. |1 K# _3 c/ ~参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件
2 k# v" F* b* p7 ~$ T% d1 wset EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512
! e# b& S( }* K7 R当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:
- R0 R' c' S+ g) R// set disk type,Physical or Virtual disk? and get the name3 _4 G% I) }* |8 P; g: s. Q6 a
if (DiskType == EfiWinNtVirtualDisks) {+ o$ P1 J: S, |) T4 x1 t) d& e
    WinNtIo->WinNtThunk->SPrintf (
+ a+ P5 ~/ A7 S7 h% O& |                          Buffer,' h' w* P1 `6 H- @) C9 |
                          L"Diskfile%d",, S! L; g3 k- A7 G1 P5 I. |3 I
                          WinNtIo->InstanceNumber5 e( x$ i/ C: _5 {
                          );
. z  }7 t& \' H4 ?" C- R! o  } else {
& V0 Z2 C) u% S    if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {
& c2 k8 W: G% b) n2 c7 c      WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);
7 O# O* r4 F0 \; ^7 f    } else {% X8 X3 D- n2 u- }3 T
      WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);+ y( e( s* j, K6 ~8 G3 i! y& f
    }
) _' Q! h8 F) K( w. E, O//create mapping 3 U% z4 a3 ]% t/ ^, C! N
Status = WinNtBlockIoCreateMapping (
2 p, {; {; Y- r( C' q2 l! T                    WinNtIo,
* S+ F5 b" o/ U% g8 q                    Handle,# q7 Q! R+ h4 R# V% D; t
                    Buffer,+ p! h# |* C; `) e7 i
                    WriteProtected,6 T" ^7 Q+ [( b5 o
                    RemovableMedia,
9 o* Y8 N1 w  o9 h' M. O$ {* C% [                    NumberOfBlocks,9 x; L3 A/ \9 i5 P* N+ P
                    BlockSize,- n/ n6 W# b% S4 H
                    DiskType3 k  H2 y: ~; a+ a
                    );4 y# x2 Z3 ]7 G& A
//register read or write blocks function' |  i1 X  p. I; _2 V1 S- b
BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;
$ [  X, s6 M/ ^( rBlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;+ S+ r6 ^. B! b) O, p
( w# f8 T3 z9 I  G: H
//in the WinNtBlockIoReadBlocks,read file API
) T  G" i7 `& ~Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);, V  a# W) [6 u8 O
$ u0 l  A$ H9 y  [
问题如下:
& t$ q9 I1 T8 W6 P5 l- C# XEDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊
* t9 i+ e/ t. X* N5 Q2 N8 `$ j5 N
[ 本帖最后由 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.$ G9 k: S& t: N) k+ K2 K1 |- \
/ X5 s" V% _0 w
参见 WinNtBusDriverBindingStart()
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-18 22:42 , Processed in 0.055259 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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