1 / 14

Project: Disk Driver

Project: Disk Driver ICS 145B L. Bic file system disk driver disk controller disk 1 2 emulation software Assignment implement a driver for a simulated disk fs requests reading/writing of logical disk blocks (0:L-1)

bernad
Download Presentation

Project: Disk Driver

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project: Disk Driver ICS 145B L. Bic

  2. file system disk driver disk controller disk 1 2 emulation software Assignment • implement a driver for a simulated disk • fs requests reading/writing of logical disk blocks (0:L-1) • disk driver interacts with HW controller via register interface to read/write blocks

  3. Organization of the Disk (pg 369) • each surface consist of tracks • each track consist of sectors (blocks) • each sector consist of bytes • tracks with same diameter is a cylinder • thus a cylinder also consist of tracks • sector is the smallest unit of transfer

  4. FS/Driver Interface (1) • read_block(int i, char *p) • write_block(int i, char *p) copy block i to/from main memory (ptr) • init_disk(…) • save_disk(…) file system disk driver disk controller disk 1 2 emulation software

  5. Disk Driver • principles of operation (see Section 11.4.3, page 379) driver SW

  6. Disk Driver • valid opcodes • SEEK • READ • WRITE • REPORT • writing opcode (OP reg) starts operation • controller becomes busy (BUSY reg) • driver must await completion • await_intrpt() for SEEK/READ/WRITE • busy-wait for REPORT (test BUSY reg)

  7. Disk Driver • SEEK/READ/WRITE operation may fail • permanent failure (e.g., invalid parameter) • transient failure (generated at random) • driver must check status after every operation • write REPORT opcode • busy-wait until report operation completes • test STAT register • repeat operation if error is transient; report is permanent

  8. Controller Registers (2) • writable registers • OP: SEEK, READ, WRITE, REPORT • CYL: 0..CYL_NO-1 (used by SEEK) • SURF: 0..NO_SURF-1 (used by READ/WRITE) • SECT: 0..NO_SECT-1 (used by READ/WRITE) • MEM: pointer (used by READ/WRITE) • read-only registers • BUSY: TRUE/FALSE • STAT: OK, ILL_OP, ILL_CYL, ILL_SURF, ILL_SECT, ERROR (transient error) file system disk driver disk controller disk 1 2 emulation software

  9. Controller Interface Functions • int read_reg(int reg_no) • read value of BUSY or STAT • int write_int_reg(int reg_no, int v) • write v into OP, CYL, SURF, SECT register • writing OP also starts operation (if not busy) • int write_mem_reg(char* v) • write starting location in memory (v) into MEM • int await_intrpt() • block process until completion interrupt

  10. Controller Interface Functions • int init_disk(int no_cyl, int no_surf, int no_sect, int sect_len, char disk_cont[]) • create/initialized disk • disk_cont[] is the initialization file; if nonexistent, disk is filled with blanks • int save_disk(char disk_cont[]) • save the current disk contents in the file disk_cont[]

  11. Driver Protocol • translate logical block number into a disk address (cylinder #, surface #, sector #) • if read/write head is already at desired cylinder, skip to step 3; else perform seek: • write cylinder # into the CYL register • write opcode SEEK into OP register • wait for interrupt (by calling await_intrpt() ) • write opcode REPORT into OP register • busy-wait until BUSY register becomes FALSE • read STAT register • if operation ok, go to step 3; else retry SEEK

  12. Driver Protocol -- cont 3. Perform READ or WRITE operation: • write parameters into controller registers (SURF, SECT, MEM) • write opcode READ or WRITE into OP register • wait for interrupt (by calling await_intrpt() ) • write opcode REPORT into OP register • busy-wait until BUSY register becomes FALSE • read STAT register • if operation ok, go to step 1; else retry READ/WRITE

  13. Using Simulation Software • the following files are on the web page • controller.c • internal.h • interface.h • DO NOT MODIFY THESE IN ANY WAY • compile these into controller.o • compile/link your program with controller.o • your program must include interface.h, i.e.: • #include ”interface.h” • your program uses the disk by invoking the controller interface functions (see protocol)

  14. Summary of tasks • design/implement driver • test driver (handling transient errors) • develop presentation/test shell (optional) • turn in design documentation • hard copy of high-level documentation to Distribution Center • commented code to Masterhit • code will be tested as part of FS project

More Related