pintos/src/devices/ide.c File Reference

#include "devices/ide.h"
#include <ctype.h>
#include <debug.h>
#include <stdbool.h>
#include <stdio.h>
#include "devices/block.h"
#include "devices/partition.h"
#include "devices/timer.h"
#include "threads/io.h"
#include "threads/interrupt.h"
#include "threads/synch.h"

Go to the source code of this file.

Data Structures

struct  ata_disk
struct  channel

Defines

#define reg_data(CHANNEL)   ((CHANNEL)->reg_base + 0)
#define reg_error(CHANNEL)   ((CHANNEL)->reg_base + 1)
#define reg_nsect(CHANNEL)   ((CHANNEL)->reg_base + 2)
#define reg_lbal(CHANNEL)   ((CHANNEL)->reg_base + 3)
#define reg_lbam(CHANNEL)   ((CHANNEL)->reg_base + 4)
#define reg_lbah(CHANNEL)   ((CHANNEL)->reg_base + 5)
#define reg_device(CHANNEL)   ((CHANNEL)->reg_base + 6)
#define reg_status(CHANNEL)   ((CHANNEL)->reg_base + 7)
#define reg_command(CHANNEL)   reg_status (CHANNEL)
#define reg_ctl(CHANNEL)   ((CHANNEL)->reg_base + 0x206)
#define reg_alt_status(CHANNEL)   reg_ctl (CHANNEL)
#define STA_BSY   0x80
#define STA_DRDY   0x40
#define STA_DRQ   0x08
#define CTL_SRST   0x04
#define DEV_MBS   0xa0
#define DEV_LBA   0x40
#define DEV_DEV   0x10
#define CMD_IDENTIFY_DEVICE   0xec
#define CMD_READ_SECTOR_RETRY   0x20
#define CMD_WRITE_SECTOR_RETRY   0x30
#define CHANNEL_CNT   2

Functions

static void reset_channel (struct channel *)
static bool check_device_type (struct ata_disk *)
static void identify_ata_device (struct ata_disk *)
static void select_sector (struct ata_disk *, block_sector_t)
static void issue_pio_command (struct channel *, uint8_t command)
static void input_sector (struct channel *, void *)
static void output_sector (struct channel *, const void *)
static void wait_until_idle (const struct ata_disk *)
static bool wait_while_busy (const struct ata_disk *)
static void select_device (const struct ata_disk *)
static void select_device_wait (const struct ata_disk *)
static void interrupt_handler (struct intr_frame *)
void ide_init (void)
static char * descramble_ata_string (char *, int size)
static void ide_read (void *d_, block_sector_t sec_no, void *buffer)
static void ide_write (void *d_, block_sector_t sec_no, const void *buffer)

Variables

static struct channel channels [CHANNEL_CNT]
static struct block_operations ide_operations


Define Documentation

#define CHANNEL_CNT   2

Definition at line 80 of file ide.c.

Referenced by ide_init(), and interrupt_handler().

#define CMD_IDENTIFY_DEVICE   0xec

Definition at line 50 of file ide.c.

Referenced by identify_ata_device().

#define CMD_READ_SECTOR_RETRY   0x20

Definition at line 51 of file ide.c.

Referenced by ide_read().

#define CMD_WRITE_SECTOR_RETRY   0x30

Definition at line 52 of file ide.c.

Referenced by ide_write().

#define CTL_SRST   0x04

Definition at line 40 of file ide.c.

Referenced by reset_channel().

#define DEV_DEV   0x10

Definition at line 45 of file ide.c.

Referenced by select_device(), and select_sector().

#define DEV_LBA   0x40

Definition at line 44 of file ide.c.

Referenced by select_sector().

#define DEV_MBS   0xa0

Definition at line 43 of file ide.c.

Referenced by select_device(), and select_sector().

#define reg_alt_status ( CHANNEL   )     reg_ctl (CHANNEL)

Definition at line 32 of file ide.c.

Referenced by select_device(), and wait_while_busy().

#define reg_command ( CHANNEL   )     reg_status (CHANNEL)

Definition at line 26 of file ide.c.

Referenced by issue_pio_command().

#define reg_ctl ( CHANNEL   )     ((CHANNEL)->reg_base + 0x206)

Definition at line 31 of file ide.c.

Referenced by reset_channel().

#define reg_data ( CHANNEL   )     ((CHANNEL)->reg_base + 0)

Definition at line 18 of file ide.c.

Referenced by input_sector(), and output_sector().

#define reg_device ( CHANNEL   )     ((CHANNEL)->reg_base + 6)

Definition at line 24 of file ide.c.

Referenced by select_device(), and select_sector().

#define reg_error ( CHANNEL   )     ((CHANNEL)->reg_base + 1)

Definition at line 19 of file ide.c.

Referenced by check_device_type().

#define reg_lbah ( CHANNEL   )     ((CHANNEL)->reg_base + 5)

Definition at line 23 of file ide.c.

Referenced by check_device_type(), and select_sector().

#define reg_lbal ( CHANNEL   )     ((CHANNEL)->reg_base + 3)

Definition at line 21 of file ide.c.

Referenced by reset_channel(), and select_sector().

#define reg_lbam ( CHANNEL   )     ((CHANNEL)->reg_base + 4)

Definition at line 22 of file ide.c.

Referenced by check_device_type(), and select_sector().

#define reg_nsect ( CHANNEL   )     ((CHANNEL)->reg_base + 2)

Definition at line 20 of file ide.c.

Referenced by reset_channel(), and select_sector().

#define reg_status ( CHANNEL   )     ((CHANNEL)->reg_base + 7)

Definition at line 25 of file ide.c.

Referenced by check_device_type(), interrupt_handler(), and wait_until_idle().

#define STA_BSY   0x80

Definition at line 35 of file ide.c.

Referenced by check_device_type(), wait_until_idle(), and wait_while_busy().

#define STA_DRDY   0x40

Definition at line 36 of file ide.c.

Referenced by check_device_type().

#define STA_DRQ   0x08

Definition at line 37 of file ide.c.

Referenced by wait_until_idle(), and wait_while_busy().


Function Documentation

static bool check_device_type ( struct ata_disk d  )  [static]

static char * descramble_ata_string ( char *  string,
int  size 
) [static]

Definition at line 317 of file ide.c.

References isspace().

Referenced by identify_ata_device().

void ide_init ( void   ) 

static void ide_read ( void *  d_,
block_sector_t  sec_no,
void *  buffer 
) [static]

static void ide_write ( void *  d_,
block_sector_t  sec_no,
const void *  buffer 
) [static]

static void identify_ata_device ( struct ata_disk d  )  [static]

static void input_sector ( struct channel c,
void *  sector 
) [static]

Definition at line 421 of file ide.c.

References BLOCK_SECTOR_SIZE, insw(), and reg_data.

Referenced by ide_read(), and identify_ata_device().

static void interrupt_handler ( struct intr_frame f  )  [static]

static void issue_pio_command ( struct channel c,
uint8_t  command 
) [static]

static void output_sector ( struct channel c,
const void *  sector 
) [static]

Definition at line 429 of file ide.c.

References BLOCK_SECTOR_SIZE, outsw(), and reg_data.

Referenced by ide_write().

static void reset_channel ( struct channel c  )  [static]

static void select_device ( const struct ata_disk d  )  [static]

static void select_device_wait ( const struct ata_disk d  )  [static]

Definition at line 499 of file ide.c.

References select_device(), and wait_until_idle().

Referenced by identify_ata_device(), and select_sector().

static void select_sector ( struct ata_disk d,
block_sector_t  sec_no 
) [static]

static void wait_until_idle ( const struct ata_disk d  )  [static]

Definition at line 442 of file ide.c.

References ata_disk::channel, inb(), ata_disk::name, printf(), reg_status, STA_BSY, STA_DRQ, and timer_usleep().

Referenced by select_device_wait().

static bool wait_while_busy ( const struct ata_disk d  )  [static]


Variable Documentation

struct channel channels[CHANNEL_CNT] [static]

Definition at line 81 of file ide.c.

Referenced by ide_init(), and interrupt_handler().

static struct block_operations ide_operations [static, read]

Initial value:

Definition at line 83 of file ide.c.

Referenced by identify_ata_device().


Generated on Mon Jan 10 16:43:58 2011 for Pintos by  doxygen 1.5.6