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

physical disk operation in EDK NT32 platform

[复制链接]
发表于 2009-3-23 18:00:26 | 显示全部楼层 |阅读模式
在EDK source中提供了对physical 和vitural disk的operation2 I  w$ i7 a, D3 }0 q) E
参数设置:EDK_SOURCE\sample\platform\NT32\build中的system.cmd文件/ a8 D: {# o' A) O
set EFI_WIN_NT_PHYSICAL_DISKS=a:RW;2880;512!//设置一个软盘,大小为1.44M,block size=512
2 R  S% C' X$ V. v6 L当我们在跑EDK的时候,可以去访问该软盘。其实在EDK中去追踪该代码的时候,会发现,其实质上是在WinNtBlockIoDriver中调用WIN api进行读写,源代码如下:3 x) z+ P# S/ z( J. \
// set disk type,Physical or Virtual disk? and get the name
; F4 f, e: C  K/ ?if (DiskType == EfiWinNtVirtualDisks) {5 K! ^& ~/ {: t) x$ }2 f
    WinNtIo->WinNtThunk->SPrintf (
8 C, o* L) |  q+ U- Q                          Buffer,7 R2 D: o/ p* H  s' U& K- {
                          L"Diskfile%d",
! `1 ]$ X. B! N6 Y                          WinNtIo->InstanceNumber/ k  ~* Z2 M6 C; {$ B( t
                          );
" R0 J5 B" U2 G' e' B  F  } else {
' C: ~3 d/ c. D( Q( I; \$ A    if (*Str >= 'A' && *Str <= 'Z' || *Str >= 'a' && *Str <= 'z') {; N; b  R& p& J  e
      WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\%c:", *Str);
/ I+ t4 g8 t! X4 _& S    } else {
9 Y1 v# S6 n5 Q      WinNtIo->WinNtThunk->SPrintf (Buffer, L"\\\\.\\PHYSICALDRIVE%c", *Str);
4 J( b( U( m0 p  [    }
; _1 X1 \% k1 p5 z//create mapping
, N2 o+ C# z( Q% q9 N" G Status = WinNtBlockIoCreateMapping (
+ A3 G/ j2 }  S# q6 P                    WinNtIo,4 h* s1 o- j  G2 s
                    Handle,+ t3 z5 A+ f( X$ T
                    Buffer,& u. h4 i8 {0 m  e- g
                    WriteProtected,  \& }9 `. F* V$ G
                    RemovableMedia,0 N. ~: F/ n& i' R2 m$ D
                    NumberOfBlocks,
7 _1 W% k: Z( m6 C- Y& j                    BlockSize,
* t  W7 Q  j+ d                    DiskType
7 E- @2 Z: x+ ^1 ~                    );
4 P" h7 S5 y, s- D//register read or write blocks function
- a7 {' x; h8 H! i" ]BlockIo->ReadBlocks = WinNtBlockIoReadBlocks;1 j1 K" z" Y, Y6 k, _2 Q, q
BlockIo->WriteBlocks = WinNtBlockIoWriteBlocks;5 i) P& e  |" Y  f
' i; R8 U* P; B$ U5 A
//in the WinNtBlockIoReadBlocks,read file API
$ ^3 s3 Q, p5 v$ M$ G$ T2 @/ VFlag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);
/ V' N: L- n  H+ h" s# C& s* }; b, o7 i4 \& Q  ^0 k* Y& E
问题如下:7 m1 v4 c/ P, K% R" P
EDK 的NT32下应该是不能对物理设备进行访问的,但是现在却可以访问一个物理disk,试问当connect controller to driver的时候,物理disk controller handle是怎么得到?希望高手解释一下啊
; w* W5 r) ]* @& [8 w- x9 Q% u, b5 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.
2 D6 [' m& o& ?' l: W( R& N5 B. K6 O# I% B! E' X
参见 WinNtBusDriverBindingStart()
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-20 03:41 , Processed in 0.042154 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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