Re: ide_initialize problem
Posted: Tue Jul 20, 2010 4:27 am
No it's not. Do you understand pointer arithmetic ? It's not enough to get rid of warnings. The code must be correct.ide_buf is unsigned char
The Place to Start for Operating System Developers
http://f.osdev.org/
No it's not. Do you understand pointer arithmetic ? It's not enough to get rid of warnings. The code must be correct.ide_buf is unsigned char
gerryg400 wrote:No it's not. Do you understand pointer arithmetic ? It's not enough to get rid of warnings. The code must be correct.ide_buf is unsigned char
Code: Select all
unsigned char ide_buf[2048] = {0};
Code: Select all
ide_devices[count].Signature = (unsigned int)ide_buf + ATA_IDENT_DEVICETYPE;
Code: Select all
ide_devices[count].Size = ((unsigned int *)(ide_buf + ATA_IDENT_MAX_LBA_EXT));
Code: Select all
void ide_initialize(unsigned int BAR0, unsigned int BAR1, unsigned int BAR2, unsigned int BAR3,
unsigned int BAR4) {
int j, k, count = 0;
// 1- Detect I/O Ports which interface IDE Controller:
channels[ATA_PRIMARY ].base = (BAR0 & 0xFFFFFFFC) + 0x1F0 * (!BAR0);
channels[ATA_PRIMARY ].ctrl = (BAR1 & 0xFFFFFFFC) + 0x3F4 * (!BAR1);
channels[ATA_SECONDARY].base = (BAR2 & 0xFFFFFFFC) + 0x170 * (!BAR2);
channels[ATA_SECONDARY].ctrl = (BAR3 & 0xFFFFFFFC) + 0x374 * (!BAR3);
channels[ATA_PRIMARY ].bmide = (BAR4 & 0xFFFFFFFC) + 0; // Bus Master IDE
channels[ATA_SECONDARY].bmide = (BAR4 & 0xFFFFFFFC) + 8; // Bus Master IDE
It sets up the struct to be used by ide_write and ide_read...gerryg400 wrote:Found on wikiWhat on earth does this code do ? Well I can sort of see what it does, but why ?Code: Select all
void ide_initialize(unsigned int BAR0, unsigned int BAR1, unsigned int BAR2, unsigned int BAR3, unsigned int BAR4) { int j, k, count = 0; // 1- Detect I/O Ports which interface IDE Controller: channels[ATA_PRIMARY ].base = (BAR0 & 0xFFFFFFFC) + 0x1F0 * (!BAR0); channels[ATA_PRIMARY ].ctrl = (BAR1 & 0xFFFFFFFC) + 0x3F4 * (!BAR1); channels[ATA_SECONDARY].base = (BAR2 & 0xFFFFFFFC) + 0x170 * (!BAR2); channels[ATA_SECONDARY].ctrl = (BAR3 & 0xFFFFFFFC) + 0x374 * (!BAR3); channels[ATA_PRIMARY ].bmide = (BAR4 & 0xFFFFFFFC) + 0; // Bus Master IDE channels[ATA_SECONDARY].bmide = (BAR4 & 0xFFFFFFFC) + 8; // Bus Master IDE
Idk why, no explanation on the wiki...
To confuse people. It's what most people know as "optimized code"; code written for a processor instead of humans. We write code for humans and compilers though, so there's no need confusing it like that.
Code: Select all
channels[ATA_PRIMARY ].base = BAR0 ? (BAR0 & 0xFFFFFFFC) : 0x1F0;