Page 1 of 1
i don't know this IDE hard return code
Posted: Thu Jul 24, 2014 12:39 am
by Kuroneko
testing vmware 10 for linux
outb(0xE0|(slave_bit<<4), DRV_HEAD_NUM_REG);
outb(sector_count_high, SECT_COUNT_HIGH_REG);
outb(lba4, LBA4_REG);
outb(lba5, LBA5_REG);
outb(lba6, LBA6_REG);
outb(sector_count_low, SECT_COUNT_LOW_REG);
outb(lba1, LBA1_REG);
outb(lba2, LBA2_REG);
outb(lba3, LBA3_REG);
/* READ_SECTORS_EXT COMMAND(0x24) */
outb(0x24, CMD_REG);
pata_delay(delay_pata_vlong);
for(i=0;i<512;i++){
while(inb(STATUS_REG)&STATUS_BSY);
buffer
=inb(DATA_REG);
}
this is code.
i was dump buffer. but in buffer is 0x7f7f7f7f7f7f7f7f.................... fully.
i don't know this code is what...
in pci class list, Class 1, Subclass 0, Prog IF 0 device is detected...
it is not IDE... it is SCSI...
how i doing?
help me... T.T
Re: i don't know this IDE hard return code
Posted: Thu Jul 24, 2014 1:27 am
by Combuster
Good luck reading data when your I/O register sizes are off.
Re: i don't know this IDE hard return code
Posted: Thu Jul 24, 2014 1:47 am
by Kuroneko
Combuster wrote:Good luck reading data when your I/O register sizes are off.
please teach me how to I/O register on... T.T OR link please...
Re: i don't know this IDE hard return code
Posted: Thu Jul 24, 2014 2:07 am
by Nable
Kuroneko wrote:please teach me how to I/O register on... T.T OR link please...
One of the suitable links:
http://wiki.osdev.org/ATA_PIO_Mode#x86_Directions
tl;dr: although most I/O ports are 8-bit, some of them are 16-bit and even 32-bit. ATA data port is 16-bit, not 8.
Letter `b' in out
b()/in
b() means `byte'. There are also `w' for word (16-bit) and `l' for long (32-bit).
Be attentive, please.
Re: i don't know this IDE hard return code
Posted: Thu Jul 24, 2014 2:23 am
by Kuroneko
Nable wrote:Kuroneko wrote:please teach me how to I/O register on... T.T OR link please...
One of the suitable links:
http://wiki.osdev.org/ATA_PIO_Mode#x86_Directions
tl;dr: although most I/O ports are 8-bit, some of them are 16-bit and even 32-bit. ATA data port is 16-bit, not 8.
Letter `b' in out
b()/in
b() means `byte'. There are also `w' for word (16-bit) and `l' for long (32-bit).
Be attentive, please.
this is all of code
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code: Select all
#include <asm.h>
#include <pata.h>
#include <printk.h>
#include <pci.h>
void pata_delay(unsigned int num){
unsigned int i=0;
while(i<num)
i++;
}
#define delay_pata_zero 0x00
#define delay_pata_short 0x8F
#define delay_pata_normal 0xFFF
#define delay_pata_long 0x1FFF
#define delay_pata_vlong 0x2FFF
#define SB 0
#define _LBA48_
#ifndef _LBA48_
#else
void test_write(unsigned short * buffer){
/*outb(val,port)*/
char slave_bit=SB;
char lba1=1;
char lba2=0;
char lba3=0;
char lba4=0;
char lba5=0;
char lba6=0;
char sector_count_high=0;
char sector_count_low=1;
int i;
outb(0xE0|(slave_bit<<4), DRV_HEAD_NUM_REG);
outb(sector_count_high, SECT_COUNT_HIGH_REG);
outb(lba4, LBA4_REG);
outb(lba5, LBA5_REG);
outb(lba6, LBA6_REG);
outb(sector_count_low, SECT_COUNT_LOW_REG);
outb(lba1, LBA1_REG);
outb(lba2, LBA2_REG);
outb(lba3, LBA3_REG);
/* WRITE_SECTORS_EXT COMMAND(0x34) */
outb(0x34, CMD_REG);
pata_delay(delay_pata_vlong);
for(i=0;i<256;i++){
while(inb(STATUS_REG)&STATUS_BSY);
outw(buffer[i], DATA_REG);
}
/* flush command(0xE7) */
outb(0xE7, CMD_REG);
}
void test_read(unsigned short * buffer){
/*outb(val,port)*/
char slave_bit=SB;
char lba1=1;
char lba2=0;
char lba3=0;
char lba4=0;
char lba5=0;
char lba6=0;
char sector_count_high=0;
char sector_count_low=1;
int i;
outb(0xE0|(slave_bit<<4), DRV_HEAD_NUM_REG);
outb(sector_count_high, SECT_COUNT_HIGH_REG);
outb(lba4, LBA4_REG);
outb(lba5, LBA5_REG);
outb(lba6, LBA6_REG);
outb(sector_count_low, SECT_COUNT_LOW_REG);
outb(lba1, LBA1_REG);
outb(lba2, LBA2_REG);
outb(lba3, LBA3_REG);
/* READ_SECTORS_EXT COMMAND(0x24) */
outb(0x24, CMD_REG);
pata_delay(delay_pata_vlong);
for(i=0;i<256;i++){
while(inb(STATUS_REG)&STATUS_BSY);
buffer[i]=inw(DATA_REG);
}
/* flush command(0xE7) */
outb(0xE7, CMD_REG);
}
#endif
void pata_test(void){
int i;
unsigned char buffer[512]={0, };
unsigned char f[512]={0, };
int fcount=0;
pci_normal_device_info(0, 16, 0);
for(i=0;i<511;i++)
f[i]='F';
f[i]=0;
printk("buffer element : %s\n", buffer);
test_write((unsigned short *)f);
test_read((unsigned short *)buffer);
printk("buffer hex : %x\n",((unsigned int *)buffer)[0]);
printk("buffer element : %s\n", buffer);
for(i=0;i<512;i++){
if(buffer[i]=='F')
fcount++;
}
printk("fcount : %d\n", fcount);
}
---------------------------------------------------------------------------------------------------------------------------------------------
what is problem...?
this is result...
Re: i don't know this IDE hard return code
Posted: Thu Jul 24, 2014 2:58 am
by Combuster
Forum rules wrote:You need to be precise and informative. This end is not served by simply dumping huge volumes of code or data into a help request.
Forum rules wrote: Use
tags when posting code. Use indentation and source comments.
Re: i don't know this IDE hard return code
Posted: Thu Jul 24, 2014 3:19 am
by Kuroneko
Combuster wrote:Forum rules wrote:You need to be precise and informative. This end is not served by simply dumping huge volumes of code or data into a help request.
Forum rules wrote: Use
tags when posting code. Use indentation and source comments.
IDE Hard disk in VMware is operate like this link(
http://wiki.osdev.org/ATA_PIO_Mode)?
i dumped PCI Device list, there is not exist IDE Device...
and result is 0xff7fff7fff7f..................
i don't have english skill...
I don't know how to say this.
Re: i don't know this IDE hard return code
Posted: Thu Jul 24, 2014 7:57 am
by Schol-R-LEA
That is one of the ways to access the hard disk, yes. It is the simplest of the methods that don't use the BIOS, but it is also poorly suited to a multitasking environment, so it is usually only used in the beginning of the boot-up.
Kuroneko wrote:i dumped PCI Device list, there is not exist IDE Device... and result is 0xff7fff7fff7f..................
How are you getting the dump of the PCI devices? Some PCI dump programs will show IDE/ATA drives as SCSI drives, especially under Linux.
Kuroneko wrote:i don't have english skill... I don't know how to say this.
That's quite alright, just do the best you can. While we are willing to be patient with non-English speakers, up to a point, it has to be a two-way street; you need to make an effort to be a clear as possible, and work on improving your English while posting here. Also, regardless of your ability to write and read English, you should read the other posters responses as carefully as you can, and take their advice to heart.
In this case, the main issue is that you are using the wrong output instruction; as Combuster and Nable pointed out, for PIO output to the ATA controller, you should be using
outw(), which takes a 16-bit value, rather than the byte valued
outb().