Page 3 of 3

Re:floppy in pmode

Posted: Fri Jun 10, 2005 4:04 pm
by GLneo
i found that my start motor also fails, and bochs doesn't care if it is on or off

p.s. does any one know a place to put code online free (not sourcefourge ???

Re:floppy in pmode

Posted: Fri Jun 10, 2005 6:50 pm
by bubach
Any free host, like mine at www.asmhackers.net

Re:floppy in pmode

Posted: Sat Jun 11, 2005 7:08 am
by Dex4u
GLneo wrote: i found that my start motor also fails, and bochs doesn't care if it is on or off
If code like that fails, then ever your floppy is fault or your using a usb floppy drive or it does not get call in your code??.

Or you could try ;

Code: Select all

void start_motor()
{
    outport(0x372, 0x1C);
    delay(1);
}    
To see if its configured as a secondary controller.

Re:floppy in pmode

Posted: Mon Jun 13, 2005 8:57 am
by GLneo
ok, i've got time in betwing all statments and it worked!, but after a few minetes of delays what doesn't and what does need time sensitivity ???, thx :)

Re:floppy in pmode

Posted: Mon Jun 13, 2005 9:26 am
by Dex4u
Look at the code fdd.asm, look for this bit of code:

Code: Select all

mov   [Timer],5         ; 5 = 250us or 20 = 1 second.
It may now always be"5" it could be "1" or "20" etc.
You should know what your timer is compared to a second (eg: 18.2) = a second etc, now put the same delay in as is in my code at the same place in your code.
Note: One of the most critical timing things is that from starting the floppy motor, it need to get up to speed, so set this to 1 second for now, from starting to moving on to the rest of the code.

Re:floppy in pmode

Posted: Mon Jun 13, 2005 1:58 pm
by GLneo
i was working on a read_sector based on Dex4u driver, here is all code:

Code: Select all

void floppy_read_sector(unsigned char *buf, int pos)
{
    int sec, cyl, head;
    sec = (pos % 18) + 1;
    cyl = (pos / 18) / 2;
    head = pos % 2;
    if(motor_on == 0)
    {
        start_motor();
        motor_on = 1;
    }
    outport((base_used + 0x7), 0);
    set_dma(buf, 512);
    send_byte(0xE6);
    send_byte(0x00);
    send_byte((unsigned char)cyl);
    send_byte((unsigned char)head);
    send_byte((unsigned char)sec);
    send_byte(0x02);
    send_byte(0x12);
    send_byte(0x1B);
    send_byte(0xFF);
    wait_irq6();
    (void)get_byte();
    (void)get_byte();
    (void)get_byte();
    (void)get_byte();
    (void)get_byte();
    (void)get_byte();
    (void)get_byte();
}

Code: Select all

void set_dma(char *buff, short size)
{
    char page; 
    short offset;
    page = (char)((int)buff >> 16);
???offset = (short)((int)buff & 0xFFFF);
    outport(0x0A, 6);
    outport(0x0B, 70);
    outport(0x0C, 1);
    outport(0x04, offset | 0xFF);
    outport(0x04, offset >> 4);
    outport(0x81, page);
    outport(0x0C, 1);
    outport(0x05, size | 0xFF);
    outport(0x05, size >> 4);
    outport(0x0A, 2);
}
bochs says:

Code: Select all

00350430685e[FDD  ] head number in command[1] doesn't match head field

Re:floppy in pmode

Posted: Tue Jun 14, 2005 4:09 pm
by GLneo
the motor wasn't on, but now the dma has problems:

Code: Select all

00980630292e[DMA  ] write to command register: value(10h) not 0x00
00985368858e[FDD  ] head number in command[1] doesn't match head field

Re:floppy in pmode

Posted: Wed Jun 15, 2005 5:11 pm
by GLneo
ok, i've fixed the previous problem, but a new one:

Code: Select all

00391632969p[CPU  ] >>PANIC<< bound: op2 must be memory reference
00391665829e[DEV  ] write to port 0x03d5 with len 4 ignored
00391665950p[CPU  ] >>PANIC<< prefetch: running in bogus memory
the old code is the same exept:

Code: Select all

sec = (pos % 18) + 1;
    cyl = (pos / 18) / 2;
    head = cyl % 2;
over the old converter

Re:floppy in pmode

Posted: Wed Jun 15, 2005 10:46 pm
by GLneo
does any one know of a very little fdc, plz :'(

Re:floppy in pmode

Posted: Wed Jun 15, 2005 11:10 pm
by AR
I don't know whether or not this will help, my code for LBA to CHS Conversion looks like:

Code: Select all

Sector = (static_cast<UINT32>(Offset) % volume->Parent->Sectors) + 1;
Cylinder = (static_cast<UINT32>(Offset) / volume->Parent->Sectors) / volume->Parent->Heads;
Head = (static_cast<UINT32>(Offset) / volume->Parent->Sectors) % volume->Parent->Heads;
(The casts are there because Offset is 64bit, just disregard them) - This code is used by my bootloader for calculating the parameters for the BIOS INT 13h service but it looks like it should work the same, I'm not an expert on the FDC though.

Re:floppy in pmode

Posted: Tue Aug 01, 2006 1:18 am
by EinM
Hi!
GLneo: can you tell me, how do you fix the "head number in command[1] doesn't match head field" Problem?

Thank you!