Floppy driver without DMA?
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Floppy driver without DMA?
Hello all, I'm wanting to write a floppy driver but I don't want to use DMA (all the tutorials I've looked at have been so vague that I just give up on it).
Now the real question is, how can I read/write bytes to the floppy via IRQ 6?
Now the real question is, how can I read/write bytes to the floppy via IRQ 6?
IRQ 6 is INT 0Eh by BIOS.
You can access the primary floppy controller by ports 3F0-3F7 hexa, and if the PC is AT compatible, you can access the secondary FDC by ports 370-377 hexadecimal.
If you want these functions, ask me, i will try to translate these complicated functions to English language , but BIOS and INT 13 makes things a lot easier in real mode (you can access memory up to 4GB by unreal mode)
inflater
You can access the primary floppy controller by ports 3F0-3F7 hexa, and if the PC is AT compatible, you can access the secondary FDC by ports 370-377 hexadecimal.
If you want these functions, ask me, i will try to translate these complicated functions to English language , but BIOS and INT 13 makes things a lot easier in real mode (you can access memory up to 4GB by unreal mode)
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
FDC should (if used right) process the commands, no? I don't see any problem... *if* you are using that FDC ports and not BIOS.
inflater
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Translation:
//EDIT: Eww, the tables are corrupted...
3F2H Write: digital register input
┌7┬6┬5┬4┬3┬2┬1┬0┐
│D C B A│ │ │ │
└┬┴─┴─┴┬┴┬┴┬┴┬┴┬┘ bit
└──┬──┘ │ │ └─┴─ 0-1: disk (0-3, AT: 0-1)
│ │ └───── 2: 0 = FDC reset
│ └─────── 3: 1 = enable DMA and interrupts
└──────────── 4-7: spin up motor (AT: bits 6-7 not used)
3F4H Reading: main status register
┌7┬6┬5┬4┬3┬2┬1┬0┐
│ │ │ │ │D C B A│
└┬┴┬┴┬┴┬┴┬┴─┴─┴┬┘ bit
│ │ │ │ └─────┴─ 0: drive is busy (AT: bits 2-3 not used)
│ │ │ └───────── 4: 1 = FDC is busy (reading or writing in progr.)
│ │ └─────────── 5: 1 = non-DMA mode; 0 = DMA mode activated
│ └───────────── 6: direction of data transfer:
│ 1 = FDC ──► CPU
│ 0 = CPU ──► FDC
└─────────────── 7: status register:
1 = OK for data transfer
3F5H Reading/Writing: register of commands and data
0E6 h - Read data (sector) from diskette
──────────────────────────────────────────────────────
Command order:
0E6h
xxxx xHdd H - head ,d - drive
tttt tttt t - track
hhhh hhhh h - head
ssss ssss s - sector
xxxx xxll l - sector size ( 00 - 128B, 01 - 256B, 10 512B, 11 - 1KB )
eeee eeee e - Last sector on track
gggg gggg g - GAP size
vvvv vvvv v - transfer length ( 0ffh )
Returns:
1.Sb 0 Status byte 0
Bits :
7 6 5 4 3 2 1 0
┌──┬──┬──┬──┬──┬──┬──┬──┐
│Term │Se│Er│Nr│Hd│Drive│
└──┴──┴──┴──┴──┴──┴──┴──┘
Term - status of operation end 11 HW error ( unconnected )
10 bad command
01 cant finish
00 OK
Se - The "head standing up" is in progress
Er - Drive error
Nr - Not ready
Hd - Current selected head
Drive- Current drive
2.Sb 1 Status byte 1
Bity :
7 6 5 4 3 2 1 0
┌──┬──┬──┬──┬──┬──┬──┬──┐
│ET│0 │Tr│Or│0 │Se│Wp│Am│
└──┴──┴──┴──┴──┴──┴──┴──┘
ET - sector is above last sector ( EOT error)
Tr - data transfer error
Or - Too high transfer speed
Se - Error reading sector
Wp - Write-protected drive
Am - Address mark not found
3.Sb 2 Status byte 2
Bity :
7 6 5 4 3 2 1 0
┌──┬──┬──┬──┬──┬──┬──┬──┐
│0 │DD│CR│Tr│??│??│Bt│Am│
└──┴──┴──┴──┴──┴──┴──┴──┘
DD - DDAM found
CR - CRC error
Tr - Bad track identification
Bt - Bad track
Am - Address mark not found
4.Track
5.Head
6.Sector
7.Len
//EDIT: Eww, the tables are corrupted...
3F2H Write: digital register input
┌7┬6┬5┬4┬3┬2┬1┬0┐
│D C B A│ │ │ │
└┬┴─┴─┴┬┴┬┴┬┴┬┴┬┘ bit
└──┬──┘ │ │ └─┴─ 0-1: disk (0-3, AT: 0-1)
│ │ └───── 2: 0 = FDC reset
│ └─────── 3: 1 = enable DMA and interrupts
└──────────── 4-7: spin up motor (AT: bits 6-7 not used)
3F4H Reading: main status register
┌7┬6┬5┬4┬3┬2┬1┬0┐
│ │ │ │ │D C B A│
└┬┴┬┴┬┴┬┴┬┴─┴─┴┬┘ bit
│ │ │ │ └─────┴─ 0: drive is busy (AT: bits 2-3 not used)
│ │ │ └───────── 4: 1 = FDC is busy (reading or writing in progr.)
│ │ └─────────── 5: 1 = non-DMA mode; 0 = DMA mode activated
│ └───────────── 6: direction of data transfer:
│ 1 = FDC ──► CPU
│ 0 = CPU ──► FDC
└─────────────── 7: status register:
1 = OK for data transfer
3F5H Reading/Writing: register of commands and data
0E6 h - Read data (sector) from diskette
──────────────────────────────────────────────────────
Command order:
0E6h
xxxx xHdd H - head ,d - drive
tttt tttt t - track
hhhh hhhh h - head
ssss ssss s - sector
xxxx xxll l - sector size ( 00 - 128B, 01 - 256B, 10 512B, 11 - 1KB )
eeee eeee e - Last sector on track
gggg gggg g - GAP size
vvvv vvvv v - transfer length ( 0ffh )
Returns:
1.Sb 0 Status byte 0
Bits :
7 6 5 4 3 2 1 0
┌──┬──┬──┬──┬──┬──┬──┬──┐
│Term │Se│Er│Nr│Hd│Drive│
└──┴──┴──┴──┴──┴──┴──┴──┘
Term - status of operation end 11 HW error ( unconnected )
10 bad command
01 cant finish
00 OK
Se - The "head standing up" is in progress
Er - Drive error
Nr - Not ready
Hd - Current selected head
Drive- Current drive
2.Sb 1 Status byte 1
Bity :
7 6 5 4 3 2 1 0
┌──┬──┬──┬──┬──┬──┬──┬──┐
│ET│0 │Tr│Or│0 │Se│Wp│Am│
└──┴──┴──┴──┴──┴──┴──┴──┘
ET - sector is above last sector ( EOT error)
Tr - data transfer error
Or - Too high transfer speed
Se - Error reading sector
Wp - Write-protected drive
Am - Address mark not found
3.Sb 2 Status byte 2
Bity :
7 6 5 4 3 2 1 0
┌──┬──┬──┬──┬──┬──┬──┬──┐
│0 │DD│CR│Tr│??│??│Bt│Am│
└──┴──┴──┴──┴──┴──┴──┴──┘
DD - DDAM found
CR - CRC error
Tr - Bad track identification
Bt - Bad track
Am - Address mark not found
4.Track
5.Head
6.Sector
7.Len
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
AThelp, a little program I use in OS dev
But it is in czech language... If you want that program, just whistle and i will attach the program to this post. (phpBB atachments)
inflater
But it is in czech language... If you want that program, just whistle and i will attach the program to this post. (phpBB atachments)
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Hmmm... do you know of any pmode open-source floppy drivers that I could "borrow" code from.... I just really need to see how other people do it in pmode so that I can figure it out myself. So far my floppy driver code is:
But I really need to be able to read sectors in the least to be able to continue development.
Code: Select all
#include "mattise.h"
/**** revision 2 ****/
int floppy_flag = 1;
char* drive_types[6] = { "No floppy drive.",
"360KB 5.25in floppy",
"1.2MB 5.25in floppy",
"720KB 3.5in floppy",
"1.44MB 3.5in floppy",
"2.88MB 3.5in floppy"
};
void DetectFloppyDrives()
{
unsigned char c;
outportb( 0x70, 0x10 );
c = inportb( 0x71 );
unsigned char drive1;
unsigned char drive2;
drive1 = c >> 4;
drive2 = c & 0xF;
kputs( "Floppy 1: " ); kputs( drive_types[ drive1 ] );
kputs( "\n" );
kputs( "Floppy 2: " ); kputs( drive_types[ drive2 ] );
kputs( "\n" );
}
// floppy IRQ handler
void FloppyHandler( struct regs* r )
{
// reset the flag, say that we
// have handled the interrupt
// lets the initialization return
floppy_flag = 0;
}
// reset the floppy disk
void ResetFloppy()
{
// reset the drive
outportb( 0x3F2, 0x00 );
outportb( 0x3F7, 0x00 );
outportb( 0x3F2, 0x0C );
// set the flag
floppy_flag = 1;
// wait for the interrupt...
while( floppy_flag == 1 );
}
// initializes the floppy
void InitFloppy()
{
// install the handler
irq_install_handler( 6, FloppyHandler );
}
Sorry, I dunno C++...
Maybe others will help you.
Anyway, I've posted AThelp. If you need help with it, just ask.
http://inflater.ic.cz/athelp.zip
inflater
Maybe others will help you.
Anyway, I've posted AThelp. If you need help with it, just ask.
http://inflater.ic.cz/athelp.zip
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Well, 50 percent 16-bit ASM (BIOS), my file system, boot sector and bootlader (sets up INT 30h, kernel functions), and 50 percent Borland Pascal 7.0 (16-bit too), the main kernel. My OS isnt pure unreal mode, it has just a special memory manager.
inflater
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
"dud zip" ? You mean dead zip? Well, try download again, it should be 902 kB long.
//EDIT: The zip works for me...
inflater
//EDIT: The zip works for me...
inflater
Last edited by inflater on Sat Feb 24, 2007 6:20 am, edited 1 time in total.
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )