How to use multiple disks?
-
- Posts: 24
- Joined: Thu Jul 14, 2022 10:46 am
- Libera.chat IRC: json
- Location: Canada
- Contact:
Re: How to use multiple disks?
OK so i did some reading and there is a register at port 0x1f6 is a disk ID. BIOS sets that to the ID of the disks booted to. How can I find more IDs? Sorry if this is a dumb question lol
-
- Member
- Posts: 5560
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to use multiple disks?
Er, I don't know what you've been reading, but port 0x1F6 isn't an ID. If your IDE controller is mapped at the legacy addresses, that port contains the drive select bit, but that only tells you which drive is selected on that IDE channel.
What kind of ID are you looking for? Why do you need an ID? There are different IDs available, and the one that works best for you will depend on what you want to do with it.
What kind of ID are you looking for? Why do you need an ID? There are different IDs available, and the one that works best for you will depend on what you want to do with it.
-
- Posts: 24
- Joined: Thu Jul 14, 2022 10:46 am
- Libera.chat IRC: json
- Location: Canada
- Contact:
Re: How to use multiple disks?
I must have read something wrong. I think I'm not clicking somewhere.
Attatched is a snippet of som code I wrote. Let me know if I have the correct understanding of what to do
Attatched is a snippet of som code I wrote. Let me know if I have the correct understanding of what to do
Code: Select all
bool ata_identify(uint16_t base_port)
{
outb(base_port + 6, 0xA0); //master
outb(base_port + 2, 0);
outb(base_port + 3, 0);
outb(base_port + 4, 0);
outb(base_port + 5, 0);
outb(base_port + 7, 0xEC);
uint8_t buf[512];
unsigned short* ptr = (unsigned short*) buf;
// Wait for the buffer to be ready
uint8_t c = insb(base_port + 7);
if(!c)
return false;
while(c & 0x80)
c = insb(base_port + 7);
uint8_t lba_mid = insb(base_port + 4), lba_hi = insb(base_port + 5);
if(lba_hi || lba_mid)
return false;
do
c = insb(base_port + 7);
while(!(c & 0x08) || !(c & 0x01));
for (int i = 0; i < 256; i++)
{
*ptr = insw(base_port);
ptr++;
}
return true;
}
int ata_count_connected_disks()
{
int res = 0;
for(uint16_t i = 0x400; i < 0xFFFF; i += 8)
if(ata_identify(i))
res++;
return res;
}
-
- Member
- Posts: 5560
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to use multiple disks?
Code: Select all
outb(base_port + 6, 0xA0); //master
Code: Select all
uint8_t c = insb(base_port + 7);
Code: Select all
while(!(c & 0x08) || !(c & 0x01));
Code: Select all
*ptr = insw(base_port);
Code: Select all
for(uint16_t i = 0x400; i < 0xFFFF; i += 8)
if(ata_identify(i))
-
- Posts: 24
- Joined: Thu Jul 14, 2022 10:46 am
- Libera.chat IRC: json
- Location: Canada
- Contact:
Re: How to use multiple disks?
OK so PCI will tell me the port num of IDE controller. Does one IDE controller control every disks connected? or will each disk have its own controller? If each disk has its own controller, then will PCI tell me address of each controller?
-
- Member
- Posts: 5560
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to use multiple disks?
There may be any number of IDE controllers. Each IDE controller may have up to two channels. Each channel may have up to two disks.jaihsonk wrote:Does one IDE controller control every disks connected? or will each disk have its own controller?
Yes.jaihsonk wrote:will PCI tell me address of each controller?
-
- Posts: 24
- Joined: Thu Jul 14, 2022 10:46 am
- Libera.chat IRC: json
- Location: Canada
- Contact:
Re: How to use multiple disks?
OK thank you so much. This s a lot clearer now. Humans are a lot better the articles lol
-
- Posts: 24
- Joined: Thu Jul 14, 2022 10:46 am
- Libera.chat IRC: json
- Location: Canada
- Contact:
Re: How to use multiple disks?
For anyone else, I also found this video to explain a fw things: https://www.youtube.com/watch?v=CF_copQaORQ