i don't know this IDE hard return code
i don't know this IDE hard return code
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
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: i don't know this IDE hard return code
Good luck reading data when your I/O register sizes are off.
Re: i don't know this IDE hard return code
please teach me how to I/O register on... T.T OR link please...Combuster wrote:Good luck reading data when your I/O register sizes are off.
Re: i don't know this IDE hard return code
One of the suitable links: http://wiki.osdev.org/ATA_PIO_Mode#x86_DirectionsKuroneko wrote:please teach me how to I/O register on... T.T OR link please...
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 outb()/inb() 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
Nable wrote:One of the suitable links: http://wiki.osdev.org/ATA_PIO_Mode#x86_DirectionsKuroneko wrote:please teach me how to I/O register on... T.T OR link please...
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 outb()/inb() 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...
Last edited by Kuroneko on Thu Jul 24, 2014 3:28 am, edited 2 times in total.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: i don't know this IDE hard return code
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: Usetags when posting code. Use indentation and source comments.Code: Select all
Re: i don't know this IDE hard return code
IDE Hard disk in VMware is operate like this link(http://wiki.osdev.org/ATA_PIO_Mode)?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: Usetags when posting code. Use indentation and source comments.Code: Select all
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.
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: i don't know this IDE hard return code
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:IDE Hard disk in VMware is operate like this link(http://wiki.osdev.org/ATA_PIO_Mode)?
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 dumped PCI Device list, there is not exist IDE Device... and result is 0xff7fff7fff7f..................
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.Kuroneko wrote:i don't have english skill... I don't know how to say this.
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().
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.