dm.h

来自「disksim是一个非常优秀的磁盘仿真工具」· C头文件 代码 · 共 512 行 · 第 1/2 页

H
512
字号
/* diskmodel (version 1.0) * Authors: John Bucy, Greg Ganger * Contributors: John Griffin, Jiri Schindler, Steve Schlosser * * Copyright (c) of Carnegie Mellon University, 2001-2008. * * This software is being provided by the copyright holders under the * following license. By obtaining, using and/or copying this * software, you agree that you have read, understood, and will comply * with the following terms and conditions: * * Permission to reproduce, use, and prepare derivative works of this * software is granted provided the copyright and "No Warranty" * statements are included with all reproductions and derivative works * and associated documentation. This software may also be * redistributed without charge provided that the copyright and "No * Warranty" statements are included in all redistributions. * * NO WARRANTY. THIS SOFTWARE IS FURNISHED ON AN "AS IS" BASIS. * CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER * EXPRESSED OR IMPLIED AS TO THE MATTER INCLUDING, BUT NOT LIMITED * TO: WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY * OF RESULTS OR RESULTS OBTAINED FROM USE OF THIS SOFTWARE. CARNEGIE * MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH * RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT * INFRINGEMENT.  COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE * OF THIS SOFTWARE OR DOCUMENTATION.   */#ifndef _DM_DM_H#define _DM_DM_H#ifdef __cplusplusextern "C" {#endif#ifdef _DM_SOURCE#include "dm_config.h"#else#include <diskmodel/dm_types.h>#endif // mostly opaque; interface through function pointers;// avoid type fields and switch statementsstruct dm_disk_if;// map lbns to pbns and vice versastruct dm_layout_if;// stuff related to disk mechanics, i.e. head positioningstruct dm_mech_if;/*  struct dm_disk_if *dm_load_diskspec(char *filename); *//*  int dm_write_diskspec(struct dm_disk_if *, char *filename); */// convert fixed-point nsecs to double secs and vice versadm_time_t dm_time_dtoi(double);double    dm_time_itod(dm_time_t);// a physical block addressstruct dm_pbn {  int cyl;  int head;  int sector;};// convert the internal format to a struct dm_pbnint dm_to_pbn(dm_pbn_t, struct dm_pbn *);// convert a struct dm_pbn to the internal format int dm_from_pbn(struct dm_pbn *, dm_pbn_t *);// the state of the mechanical elementsstruct dm_mech_state {  int cyl;  int head;  // divide the circle into 2^32 angles; increments of  \pi / 2^31 radians  dm_angle_t theta;};// convert angles between doubles and fixed-point representationdouble      dm_angle_itod(dm_angle_t);dm_angle_t  dm_angle_dtoi(double);// this tries to be compatible with disksimtypedef enum {  DM_SLIPPED = -1,   // may also include unused spares XXX is this right?  DM_REMAPPED = -2,  DM_OK = -3,  DM_NX = -4         // doesn't exist -- there are holes in the cyl space                     // on e.g. atlas10k} dm_ptol_result_t;typedef enum {  DM_SU_SECTORS = 0,  DM_SU_REVOLUTIONS} dm_skew_unit_t;typedef enum {  MAP_NONE                = 0,  MAP_IGNORESPARING       = 1,  MAP_ZONEONLY            = 2,  MAP_ADDSLIPS            = 3,  MAP_FULL                = 4,  MAP_FROMTRACE           = 5,  MAP_AVGCYLMAP           = 6} dm_layout_maptype;#define DM_MAXMAPTYPE MAP_AVGCYLMAP// What is the angle relative to?// There are three reasonable "zeroes" to speak of.  The first which// we'll call "literal" or "absolute" zero or just 0 is a fixed point// that is the same on every track on the disk.  The second is the// offset of the leading edge of the first sector lying entirely past// 0 on the track.  This will typically be the same for all of the// tracks on a given surface within a zone.  We refer to this as 0t// for "track."  (in the current implementation, 0t is probably the// same as 0).  The third zero is the offset of the leading edge of// the block whose lbn is numerically lowest of all of the blocks on// the track.  This will also probably be the same for all tracks per// surface,zone.  We refer to this as 0l for lbn or logical.// 0t is not affected by skews but is affected by // slipping in some defect-management schemes.// 0l is affected by: track and cylinder switch skew as well as// slipping in some defect-management schemes.// We try to be precise about which 0 we mean in describing the// interface below.// Further complicating this is how to number the sectors on a given// track in pbns.  It would be reasonable to call either the one at 0t// sector zero or the one at 0l sector zero.// This is crummy because with derated heads, both SPT and TPI can// vary.  The g4 code has to fake these.struct dm_layout_zone {  int spt;  // number of sectors per track  int lbn_low;  int lbn_high;  int cyl_low;  int cyl_high;};// 'if' because its an interface, not the real struct which has// other data members ...struct dm_layout_if {  // if the lbn was remapped, *remapsector will be set to a nonzero  // value if remapsector is non-NULL.  This emulates the behavior  // of disksim's global of the same name.  dm_ptol_result_t  (*dm_translate_ltop)(struct dm_disk_if *, 		       int lbn, 		       dm_layout_maptype,		       struct dm_pbn *result,		       int *remapsector);  dm_ptol_result_t  (*dm_translate_ltop_0t)(struct dm_disk_if *, 			  int lbn, 			  dm_layout_maptype,			  struct dm_pbn *result,			  int *remapsector);    // if the pbn is defective and remapped,  // *remapsector will be set to a nonzero value if remapsector is non-NULL  dm_ptol_result_t  (*dm_translate_ptol)(struct dm_disk_if *, 		       struct dm_pbn *p,		       int *remapsector);  dm_ptol_result_t  (*dm_translate_ptol_0t)(struct dm_disk_if *, 			  struct dm_pbn *p,			  int *remapsector);  // the number of physical sectors on the track containing the given lbn  int  (*dm_get_sectors_lbn)(struct dm_disk_if *d,			int lbn);    // as above for pbns  int  (*dm_get_sectors_pbn)(struct dm_disk_if *d,			struct dm_pbn *);  // compute lbn boundaries for track  // This is different from disksim's idosyncratic semantic (second  // value is first sector of next track).  Our semantic is that   // last_lbn is that of the last sector on the given track.  // We set remapsector if nonzero to a nonzero value if   // the first or last block on the track are remapped.  // Returns DM_NX if the whole track is unmapped, DM_OK otherwise.  dm_ptol_result_t  (*dm_get_track_boundaries)(struct dm_disk_if *d,			     struct dm_pbn *,			     int *first_lbn,			     int *last_lbn,			     int *remapsector);  // Compute the seek distance in cylinders that would be incurred for  // given request.  Returns a dm_ptol_result_t since one or both of  // the LBNs may be slipped or remapped.  dm_ptol_result_t  (*dm_seek_distance)(struct dm_disk_if *,		      int start_lbn,		      int dest_lbn);  // Compute the starting offset of a pbn relative to 0.  This  // accounts for all skews, slips, etc.  dm_angle_t  (*dm_pbn_skew)(struct dm_disk_if *,		 struct dm_pbn *);  // same as pbn_skew(d, {cyl, head, 0})  dm_angle_t  (*dm_get_track_zerol)(struct dm_disk_if *,   			struct dm_mech_state *);  // convert from a pbn to an angle.  // first result angle is the distance from 0.  // This accounts for slips and defects but *not* skew --  // so this is in 0l.  // The second result parameter is for the width of the sector --  // currently unimplemented.  void  (*dm_convert_ptoa)(struct dm_disk_if *,		     struct dm_pbn *,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?