Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Floppy Class Reference

This is the floppy disk driver. More...

#include <floppy.h>

Collaboration diagram for Floppy:

Collaboration graph
[legend]
List of all members.

Public Methods

void init ()
void update_timers ()
void deinit ()
void reset ()
void send_byte (unsigned short int byte)
short int get_byte ()
bool wait_for_op (bool sense_interrupt_status)
bool seek (unsigned char track)
void recalibrate ()
void turn_motor_on ()
void turn_motor_off ()
bool read_block (unsigned int block, void *data)
bool write_block (unsigned int block, void *data)
bool read_write (unsigned int block, void *data, bool read)
void implement (Block_device &disk)

Public Attributes

volatile bool operation_done

Protected Attributes

DMA_buffer buffer
volatile unsigned int timeout_counter
bool motor_on
int motor_counter
bool disk_change
unsigned char status [7]
unsigned char status_size
unsigned char sr0
unsigned char current_track

Static Protected Attributes

const unsigned int BLOCK_SIZE = 512

Detailed Description

This is the floppy disk driver.

Much of it is based on code by Fabian Nunez.


Member Function Documentation

void Floppy::deinit  
 

Deinitialize the floppy driver.

short int Floppy::get_byte  
 

Receive a byte from the floppy disk controller. Return -1 on timeout.

void Floppy::implement Block_device   disk
 

Serve as the implementation driver for the given abstract block device.

void Floppy::init  
 

Initialize the floppy driver and reset the drive.

bool Floppy::read_block unsigned int    block,
void *    data
 

Read a block of data from disk into the provided 512-byte buffer.

bool Floppy::read_write unsigned int    block,
void *    data,
bool    read
 

Since reads and writes differ only by a few lines, this function handles both. It is called by read_block() and write_block().

void Floppy::recalibrate  
 

Recalibrate the drive.

void Floppy::reset  
 

Reset the floppy drive to a known state.

bool Floppy::seek unsigned char    track
 

Seek to the given track.

void Floppy::send_byte unsigned short int    byte
 

Send a byte to the floppy disk controller.

void Floppy::turn_motor_off  
 

Start drive motor kill countdown.

void Floppy::turn_motor_on  
 

Turn drive motor on.

void Floppy::update_timers  
 

Increment one tick of the timers.

bool Floppy::wait_for_op bool    sense_interrupt_status
 

Wait for a floppy controller operation to complete. Return false on timeout, true if operation completed.

bool Floppy::write_block unsigned int    block,
void *    data
 

Write a block of data to disk from the provided 512-byte buffer.


Member Data Documentation

const unsigned int Floppy::BLOCK_SIZE = 512 [static, protected]
 

DMA_buffer Floppy::buffer [protected]
 

floppy read/write data buffer.

unsigned char Floppy::current_track [protected]
 

current track position.

bool Floppy::disk_change [protected]
 

int Floppy::motor_counter [protected]
 

motor kill countdown.

bool Floppy::motor_on [protected]
 

whether the motor is on.

volatile bool Floppy::operation_done
 

whether last operation is complete.

unsigned char Floppy::sr0 [protected]
 

unsigned char Floppy::status[7] [protected]
 

unsigned char Floppy::status_size [protected]
 

volatile unsigned int Floppy::timeout_counter [protected]
 

timeout countdown.


The documentation for this class was generated from the following files:

Torsion Operating System, Copyright (C) 2000-2002 Dan Helfman