D
dfwforce
Unregistered / Unconfirmed
GUEST, unregistred user!
bool ReadHddParams(unsigned short *params, int pn, int dn)
{
int i,IdePort[2] = {0x1f0, 0x170}
//primary & secondary IDE Controller
unsigned char HD_Selection[2]={0xa0,0xb0}
// Master Disk: 1010 0000, Slave Disk: 1011 0000
unsigned short BasePort = IdePort[pn];
for(i=0;i<500;i++) //Get HDC Status, wait until HDC not busy
{
if((inportb(BasePort+7)&0x80)==0)
break
//hdc is ready
Sleep(1);
}
if(i>=300)return false
//HDC no response
outportb(BasePort+6, HD_Selection[dn])
//master or slave hard disk
outportb(BasePort+7, 0x10)
//HDD status
for(i=0;i<300;i++) //Get HDD Status, wait until HDD not busy
{
if((inportb(BasePort+7)&0x80)==0)
break;
Sleep(1);
}
if(i>=300)return false
//HDC no response
if(inportb(BasePort+7)!=0x50)return false
//HDD ready: 0101 0000
outportb(BasePort+6, HD_Selection[dn])
//master or slave hard disk
outportb(BasePort+7, 0xec)
//HDD parameters
for(i=0;i<300;i++) //wait for parameters retrieved
{
if(inportb(BasePort+7)==0x58) //retrieved OK
break;
Sleep(1);
}
if(i>=300)return false
//parameters retrieved error
for(i=0;i<256;i++)
params=inportw(BasePort);
return true;
}
由于对BCB不太熟悉,好多数据类型不知道怎么转换,请求各位大大帮忙一下把上面的函数翻译成delphi的,分数不够可以另加,先谢谢了~~~
{
int i,IdePort[2] = {0x1f0, 0x170}
//primary & secondary IDE Controller
unsigned char HD_Selection[2]={0xa0,0xb0}
// Master Disk: 1010 0000, Slave Disk: 1011 0000
unsigned short BasePort = IdePort[pn];
for(i=0;i<500;i++) //Get HDC Status, wait until HDC not busy
{
if((inportb(BasePort+7)&0x80)==0)
break
//hdc is ready
Sleep(1);
}
if(i>=300)return false
//HDC no response
outportb(BasePort+6, HD_Selection[dn])
//master or slave hard disk
outportb(BasePort+7, 0x10)
//HDD status
for(i=0;i<300;i++) //Get HDD Status, wait until HDD not busy
{
if((inportb(BasePort+7)&0x80)==0)
break;
Sleep(1);
}
if(i>=300)return false
//HDC no response
if(inportb(BasePort+7)!=0x50)return false
//HDD ready: 0101 0000
outportb(BasePort+6, HD_Selection[dn])
//master or slave hard disk
outportb(BasePort+7, 0xec)
//HDD parameters
for(i=0;i<300;i++) //wait for parameters retrieved
{
if(inportb(BasePort+7)==0x58) //retrieved OK
break;
Sleep(1);
}
if(i>=300)return false
//parameters retrieved error
for(i=0;i<256;i++)
params=inportw(BasePort);
return true;
}
由于对BCB不太熟悉,好多数据类型不知道怎么转换,请求各位大大帮忙一下把上面的函数翻译成delphi的,分数不够可以另加,先谢谢了~~~