X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdevices%2Fdisk.c;h=9e4b9f506358296c0eb2f9b49760059e12a95282;hb=f6580e9ad405b519dbe85027691bf3c66074b0a4;hp=1a50969df20fd772c076349446dd9fcadcab9fa0;hpb=f09512e71e50d7be09249e7b87b270906ed8e499;p=pintos-anon diff --git a/src/devices/disk.c b/src/devices/disk.c index 1a50969..9e4b9f5 100644 --- a/src/devices/disk.c +++ b/src/devices/disk.c @@ -1,11 +1,11 @@ #include "disk.h" #include -#include "debug.h" -#include "io.h" -#include "interrupt.h" -#include "lib.h" -#include "synch.h" #include "timer.h" +#include "lib/debug.h" +#include "lib/lib.h" +#include "threads/io.h" +#include "threads/interrupt.h" +#include "threads/synch.h" /* ATA command block port addresses. */ #define reg_data(CHANNEL) ((CHANNEL)->reg_base + 0) /* Data. */ @@ -46,20 +46,20 @@ /* An ATA device. */ struct disk { - char name[8]; /* e.g. "hd0:1". */ + char name[8]; /* Name, e.g. "hd0:1". */ struct channel *channel; /* Channel disk is on. */ int dev_no; /* Device 0 or 1 for master or slave. */ bool is_ata; /* 1=This device is an ATA disk. */ - disk_sector_no capacity; /* Capacity in sectors (if is_ata is true). */ + disk_sector_t capacity; /* Capacity in sectors (if is_ata is true). */ }; /* An ATA channel (aka controller). Each channel can control up to two disks. */ struct channel { - char name[8]; /* e.g. "hd0" */ - uint16_t reg_base; /* 0x1f0 for hd0, 0x170 for hd1. */ + char name[8]; /* Name, e.g. "hd0". */ + uint16_t reg_base; /* Base I/O port. */ uint8_t irq; /* Interrupt in use. */ struct lock lock; /* Must acquire to access the controller. */ @@ -71,14 +71,14 @@ struct channel }; /* We support the two "legacy" ATA channels found in a standard PC. */ -#define CHANNEL_CNT (sizeof channels / sizeof *channels) -static struct channel channels[2]; +#define CHANNEL_CNT 2 +static struct channel channels[CHANNEL_CNT]; static void reset_channel (struct channel *); static bool check_device_type (struct disk *); static void identify_ata_device (struct disk *); -static void select_sector (struct disk *, disk_sector_no); +static void select_sector (struct disk *, disk_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 *); @@ -133,7 +133,7 @@ disk_init (void) } /* Register interrupt handler. */ - intr_register (c->irq, 0, IF_OFF, interrupt_handler, c->name); + intr_register (c->irq, 0, INTR_OFF, interrupt_handler, c->name); /* Reset hardware. */ reset_channel (c); @@ -167,7 +167,7 @@ disk_get (int chan_no, int dev_no) /* Returns the size of disk D, measured in DISK_SECTOR_SIZE-byte sectors. */ -disk_sector_no +disk_sector_t disk_size (struct disk *d) { ASSERT (d != NULL); @@ -178,7 +178,7 @@ disk_size (struct disk *d) /* Reads sector SEC_NO from disk D into BUFFER, which must have room for DISK_SECTOR_SIZE bytes. */ void -disk_read (struct disk *d, disk_sector_no sec_no, void *buffer) +disk_read (struct disk *d, disk_sector_t sec_no, void *buffer) { struct channel *c; @@ -200,7 +200,7 @@ disk_read (struct disk *d, disk_sector_no sec_no, void *buffer) DISK_SECTOR_SIZE bytes. Returns after the disk has acknowledged receiving the data. */ void -disk_write (struct disk *d, disk_sector_no sec_no, const void *buffer) +disk_write (struct disk *d, disk_sector_t sec_no, const void *buffer) { struct channel *c; @@ -383,7 +383,7 @@ printk_ata_string (char *string, size_t size) writes SEC_NO to the disk's sector selection registers. (We use LBA mode.) */ static void -select_sector (struct disk *d, disk_sector_no sec_no) +select_sector (struct disk *d, disk_sector_t sec_no) { struct channel *c = d->channel; @@ -406,7 +406,7 @@ issue_pio_command (struct channel *c, uint8_t command) { /* Interrupts must be enabled or our semaphore will never be up'd by the completion handler. */ - ASSERT (intr_get_level () == IF_ON); + ASSERT (intr_get_level () == INTR_ON); c->expecting_interrupt = true; outb (reg_command (c), command);