- Main Page
- Data Structures
- Files
- Directories

- Search for |

- File List
- Globals

# fdc.c File Reference

`#include <isa/fdc.h>`
`#include <isa/8259.h>`
`#include <sys/video.h>`
`#include <sys/gdt.h>`
`#include <sys/idt.h>`
`#include <ubixos/types.h>`
`#include <ubixos/spinlock.h>`
`#include <sys/io.h>`
`#include <sys/dma.h>`
`#include <sys/device.h>`
`#include <lib/kprintf.h>`
`#include <lib/kmalloc.h>`
`#include <devfs/devfs.h>`

Include dependency graph for fdc.c:

Go to the source code of this file.

## Functions
| asm (".globl floppyIsr \n""floppyIsr: \n"" pusha \n"" push %ss \n"" push %ds \n"" push %es \n"" push %fs \n"" push %gs \n"" call floppyIsrhndlr \n"" pop %gs \n"" pop %fs \n"" pop %es \n"" pop %ds \n"" pop %ss \n"" popa \n"" iret \n")
void | block2Hts (int block, int *head, int *track, int *sector)
int | fdc_init ()
int | fdcInit2 (struct device_node *dev)
void | fdcRead (void *info, void *baseAddr, uInt32 startSector, uInt32 sectorCount)
bool | fdcRw (int block, Int8 *blockBuffer, bool read, unsigned long numSectors)
void | fdcWrite (void *info, void *baseAddr, uInt32 startSector, uInt32 sectorCount)
void | floppyIsrhndlr ()
int | getByte ()
void | motorOff (void)
void | motorOn (void)
bool | readBlock (int block, Int8 *blockBuffer, unsigned long numSectors)
void | recalibrate (void)
void | reset (void)
bool | seek (int track)
void | sendByte (int Int8)
bool | waitFdc (bool sensei)
bool | writeBlock (int block, Int8 *blockBuffer, unsigned long numSectors)
## Variables
static bool | diskChange = FALSE
static volatile bool | done = FALSE
static spinLock_t | fdcSpinLock = SPIN_LOCK_INITIALIZER
static volatile Int8 | fdcTrack = 0xff
static drvGeom | geometry = { dg144Heads,dg144Tracks,dg144Spt }
static bool | motor = FALSE
static Int8 | sr0 = 0
static Int8 | statSize = 0
static Int8 | status [7] = { 0 }
unsigned long | tbaddr = 0x80000L
static volatile int | timeOut = 0

## Function Documentation

asm | ( | ".globl floppyIsr \n""floppyIsr: \n"" pusha \n"" push %ss \n"" push %ds \n"" push %es \n"" push %fs \n"" push %gs \n"" call floppyIsrhndlr \n"" pop %gs \n"" pop %fs \n"" pop %es \n"" pop %ds \n"" pop %ss \n"" popa \n"" iret \n" |  | ) |

void block2Hts | ( | int | block,
|  | int * | head,
|  | int * | track,
|  | int * | sector |
| ) |  |  |

Definition at line 201 of file fdc.c.

References geometry, DrvGeom::heads, and DrvGeom::spt.

Referenced by fdcRw().

int fdc_init | ( |  | ) |

Definition at line 63 of file fdc.c.

References devfs_makeNode(), device_add(), dInt, dPresent, fdcInit2(), fdcRead(), fdcWrite(), floppyIsr(), device_interface::init, irqEnable(), kmalloc(), device_interface::major, mVec, device_interface::read, device_interface::reset, reset(), setVector(), and device_interface::write.

Here is the call graph for this function:

int fdcInit2 | ( | struct device_node * | dev | ) |

Definition at line 58 of file fdc.c.

References device_node::devInfo, and device_interface::size.

Referenced by fdc_init().

void fdcRead | ( | void * | info,
|  | void * | baseAddr,
|  | uInt32 | startSector,
|  | uInt32 | sectorCount |
| ) |  |  |

Definition at line 303 of file fdc.c.

References fdcSpinLock, readBlock(), spinLock(), and spinUnlock().

Referenced by fdc_init().

Here is the call graph for this function:

bool fdcRw | ( | int | block,
|  | Int8 * | blockBuffer,
|  | bool | read,
|  | unsigned long | numSectors |
| ) |  |  |

Definition at line 129 of file fdc.c.

References block2Hts(), cmdRead, cmdWrite, dg144Gap3rw, dg144Spt, dg168Gap3rw, diskChange, dmaXfer(), FALSE, fdcCcr, fdcDir, fdcRw(), geometry, inportByte(), kprint(), kprintf(), motorOff(), motorOn(), outportByte(), recalibrate(), reset(), seek(), sendByte(), DrvGeom::spt, status, tbaddr, TRUE, and waitFdc().

Referenced by fdcRw(), readBlock(), and writeBlock().

Here is the call graph for this function:

void fdcWrite | ( | void * | info,
|  | void * | baseAddr,
|  | uInt32 | startSector,
|  | uInt32 | sectorCount |
| ) |  |  |

Definition at line 309 of file fdc.c.

References writeBlock().

Referenced by fdc_init().

Here is the call graph for this function:

void floppyIsrhndlr | ( |  | ) |

Definition at line 98 of file fdc.c.

References done, outportByte(), TRUE, and x20.

Here is the call graph for this function:

int getByte | ( |  | ) |

Definition at line 116 of file fdc.c.

References fdcData, fdcMsr, and inportByte().

Referenced by waitFdc().

Here is the call graph for this function:

void motorOff | ( | void |  | ) |

Definition at line 214 of file fdc.c.

References FALSE, motor, and TRUE.

Referenced by fdcRw(), and recalibrate().

void motorOn | ( | void |  | ) |

Definition at line 207 of file fdc.c.

References FALSE, fdcDor, motor, outportByte(), and TRUE.

Referenced by fdcRw(), and recalibrate().

Here is the call graph for this function:

bool readBlock | ( | int | block,
|  | Int8 * | blockBuffer,
|  | unsigned long | numSectors |
| ) |  |  |

Definition at line 241 of file fdc.c.

References fdcRw(), and TRUE.

Referenced by fdcRead().

Here is the call graph for this function:

void recalibrate | ( | void |  | ) |

Definition at line 280 of file fdc.c.

References cmdRecal, motorOff(), motorOn(), sendByte(), TRUE, and waitFdc().

Referenced by fdcRw(), and reset().

Here is the call graph for this function:

void reset | ( | void |  | ) |

Definition at line 288 of file fdc.c.

References cmdSpecify, diskChange, done, FALSE, fdcDor, motor, outportByte(), recalibrate(), seek(), sendByte(), TRUE, and waitFdc().

Referenced by fdc_init(), and fdcRw().

Here is the call graph for this function:

bool seek | ( | int | track | ) |

Definition at line 222 of file fdc.c.

References cmdSeek, FALSE, fdcTrack, kprintf(), sendByte(), sr0, TRUE, waitFdc(), and x20.

Referenced by fdcRw(), and reset().

Here is the call graph for this function:

void sendByte | ( | int | Int8 | ) |

Definition at line 103 of file fdc.c.

References fdcData, fdcMsr, inportByte(), and outportByte().

Referenced by fdcRw(), recalibrate(), reset(), seek(), and waitFdc().

Here is the call graph for this function:

bool waitFdc | ( | bool | sensei | ) |

Definition at line 256 of file fdc.c.

References cmdSensei, diskChange, done, FALSE, fdcDir, fdcMsr, fdcTrack, getByte(), inportByte(), sendByte(), sr0, statSize, status, timeOut, and TRUE.

Referenced by fdcRw(), recalibrate(), reset(), and seek().

Here is the call graph for this function:

bool writeBlock | ( | int | block,
|  | Int8 * | blockBuffer,
|  | unsigned long | numSectors |
| ) |  |  |

Definition at line 252 of file fdc.c.

References FALSE, and fdcRw().

Referenced by fdcWrite().

Here is the call graph for this function:

## Variable Documentation

bool diskChange = FALSE`[static]`

Definition at line 48 of file fdc.c.

Referenced by fdcRw(), reset(), and waitFdc().

volatile bool done = FALSE`[static]`

Definition at line 46 of file fdc.c.

Referenced by bcopy(), floppyIsrhndlr(), reset(), and waitFdc().

spinLock_t fdcSpinLock = SPIN_LOCK_INITIALIZER`[static]`

Definition at line 44 of file fdc.c.

Referenced by fdcRead().

volatile Int8 fdcTrack = 0xff`[static]`

Definition at line 50 of file fdc.c.

Referenced by seek(), and waitFdc().

drvGeom geometry = { dg144Heads,dg144Tracks,dg144Spt }`[static]`

Definition at line 47 of file fdc.c.

Referenced by block2Hts(), and fdcRw().

bool motor = FALSE`[static]`

Definition at line 49 of file fdc.c.

Referenced by motorOff(), motorOn(), and reset().

Int8 sr0 = 0`[static]`

Definition at line 51 of file fdc.c.

Referenced by seek(), and waitFdc().

Int8 statSize = 0`[static]`

Definition at line 53 of file fdc.c.

Referenced by waitFdc().

Int8 status[7] = { 0 }`[static]`

Definition at line 54 of file fdc.c.

Referenced by fdcRw(), ne2kHandler(), vmmFindFreePage(), vmmFreeProcessPages(), vmmMemMapInit(), and waitFdc().

unsigned long tbaddr = 0x80000L

Definition at line 56 of file fdc.c.

Referenced by fdcRw().

volatile int timeOut = 0`[static]`

Definition at line 52 of file fdc.c.

Referenced by waitFdc().