floppy in pmode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
GLneo

Re:floppy in pmode

Post 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 ???
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:floppy in pmode

Post by bubach »

Any free host, like mine at www.asmhackers.net
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
Dex4u

Re:floppy in pmode

Post 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.
GLneo

Re:floppy in pmode

Post 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 :)
Dex4u

Re:floppy in pmode

Post 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.
GLneo

Re:floppy in pmode

Post 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
GLneo

Re:floppy in pmode

Post 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
GLneo

Re:floppy in pmode

Post 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
GLneo

Re:floppy in pmode

Post by GLneo »

does any one know of a very little fdc, plz :'(
AR

Re:floppy in pmode

Post 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.
EinM

Re:floppy in pmode

Post 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!
Post Reply