dm.h
来自「disksim是一个非常优秀的磁盘仿真工具」· C头文件 代码 · 共 512 行 · 第 1/2 页
H
512 行
dm_angle_t *start, dm_angle_t *width); // convert from an angle to a pbn // returns a ptol_result since provided angle could be in slipped // space, etc. Rounds angle down to a sector starting offset // Takes the angle in 0l. dm_ptol_result_t (*dm_convert_atop)(struct dm_disk_if *, struct dm_mech_state *, struct dm_pbn *); // how wide is a chunk of num sectors on the given track // returns 0 if num > s/t dm_angle_t (*dm_get_sector_width)(struct dm_disk_if *, struct dm_pbn *track, int num); // Compute the angular distance/offset between two logical blocks. dm_angle_t (*dm_lbn_offset)(struct dm_disk_if *, int lbn1, int lbn2); // how big will this layout struct be when marshaled int(*dm_marshaled_len)(struct dm_disk_if *); // unmarshal this layout struct into the provided buffer void *(*dm_marshal)(struct dm_disk_if *, char *); // returns the number of zones for the layout int (*dm_get_numzones)(struct dm_disk_if *); // Fetch the info about the nth zone and store it in the result // parameter z. Returns 0 on success, -1 on error (bad n) // n should be within 0 and (dm_get_numzones() - 1) int (*dm_get_zone)(struct dm_disk_if *, int n, struct dm_layout_zone *z); // return the number of defects on the given track // result stored at *result // returns DM_OK or DM_NX for bad parameters dm_ptol_result_t (*dm_defect_count)(struct dm_disk_if *d, struct dm_pbn *track, int *result);};// Anatomy of a mech-model access and related terminology// (bucy 5/2002)// +-------------------------+------------+----------+---------+----------+// | seek | initial | | add. | |// | headswitch | rotational | xfertime | rot. | xfertime |// | extra settle | latency | | latency | |// +-------------------------+------------+----------+---------+----------+// |---------seektime--------|// |-----------positioning-time-----------|// |------------------------------access-time-----------------------------|// ^// |// bus transfer to host// begins now// What disksim calls "SERVTIME" is really access time minus xfertime;// we've agreed to call this NOXFERTIME in the future to reduce confusion.// For zero-latency accesses, disksim's disklatency() function returns// the initial rotational latency in this nomenclature; disksim's // "addtolatency" is our additional rotational latency.struct dm_mech_acctimes { dm_time_t seektime; dm_time_t initial_latency; dm_time_t initial_xfer; dm_time_t addl_latency; dm_time_t addl_xfer;};struct dm_mech_if { // how long to seek from the first to the second track, possibly // including a head switch and additional write settling time. This // is only track-to-track so the angles in the parameters are // ignored. dm_time_t(*dm_seek_time)(struct dm_disk_if *, struct dm_mech_state *start_track, struct dm_mech_state *end_track, int rw); // this function subsumes the functionality of the "trackstart" // global in disksim. From the given inital condition and access, // it will return the first block on the track to be read. int(*dm_access_block)(struct dm_disk_if *, struct dm_mech_state *initial, int start, int len, int immed); // There are two rotational latency functions. Read carefully to // make sure you're using the one you want. // This function implements the "disksim semantic: read *up to* // <len> blocks from the track starting from angle <initial> and // sector <start>. This will access to the end of the track *but // not wrap around* e.g. for a sequential access that starts on the // given track and switches to another, after reaching the end of // the first. The return value is the amount of time before the // media transfer begins. Any additional rotational latency (as // defined above) will be filled into addtolatency if nonzero. // Initial angle is relative to 0! dm_time_t(*dm_latency)(struct dm_disk_if *, struct dm_mech_state *initial, // initial state int start, // start sector int len, // number of sectors int immed, // zero-latency? dm_time_t *addtolatency); // UNIMPLEMENTED // Compute the rotational latency incurred for the given (possibly // "zero-latency") access. The access is of the form: starting from // the initial angle <initial>, read len blocks from the track // starting with start, wrapping around zero if the access is that // long. The return value is only rotational latency before the // data transfer begins. In the case of zero-latency accesses, // there may be an additional rotational latency. This additional // amount is filled into the last parameter if nonzero. dm_time_t(*dm_latency_seq)(struct dm_disk_if *, struct dm_mech_state *initial, // initial state int start, // start sector int len, // number of sectors int immed, // zero-latency? dm_time_t *addtolatency); // Seek, any extra settling for write, initial rotational latency. // i.e. the amount of time before media transfer starts. // len must be >= 1 dm_time_t(*dm_pos_time)(struct dm_disk_if *, struct dm_mech_state *initial, struct dm_pbn *start, int len, int rw, int immed, struct dm_mech_acctimes *breakdown); // access time is postime, xfertime and any additional rotational // latency not included in postime, e.g. in the middle of a // zero-latency access xfer. // if the last parameter is nonzero, it will be filled // in with the state of the disk as of the reported result time; // i.e. where the disk will be when the access completes. // Consider changing this to an lbn since most occurances in // disksim seem to do ltop and pass the result here. // Simplifies g1 "multi-track" wrapper. // len must be >= 1 dm_time_t(*dm_acctime)(struct dm_disk_if *, struct dm_mech_state *initial_state, struct dm_pbn *start, int len, int rw, int immed, struct dm_mech_state *result_state, struct dm_mech_acctimes *breakdown); // compute how long it will take the disk to rotate from the angle // in the first position to that in the second position dm_time_t(*dm_rottime)(struct dm_disk_if *, dm_angle_t begin, dm_angle_t end); // Amount of time to read len sectors from the track designated by // the 2nd argument. This is a convience wrapper for // rottime. dm_time_t(*dm_xfertime)(struct dm_disk_if *d, struct dm_mech_state *, int len); // This is probably constant for now but might not be in the future. dm_time_t(*dm_headswitch_time)(struct dm_disk_if *, int h1, int h2); // how far will the media rotate in the given amount of time // only the angle in the result is set dm_angle_t(*dm_rotate)(struct dm_disk_if *, dm_time_t *time); // how long does one revolution take dm_time_t(*dm_period)(struct dm_disk_if *); // interface to disksim for rpm randomization // 2nd argument is the amount of time one rotation takes void(*dm_randomize_rpm)(struct dm_disk_if *); // how big will this layout struct be when marshaled int(*dm_marshaled_len)(struct dm_disk_if *); // unmarshal this layout struct into the provided buffer // returns a pointer to the first byte in the buffer it didn't write to void *(*dm_marshal)(struct dm_disk_if *, char *);};// all the methods below return zero on success, nonzero on errorstruct dm_disk_if { // some general parameters int dm_cyls; // int dm_tracks; // what needs this? int dm_surfaces; int dm_sectors; struct dm_layout_if *layout; struct dm_mech_if *mech;};//// libparam related stuff (probably should live somewhere else)//struct lp_block;// these are the libparam loader functions for mech and layout modelstypedef struct dm_mech_if *(*dm_mech_loader_t)(struct lp_block *, struct dm_disk_if *);typedef struct dm_layout_if *(*dm_layout_loader_t)(struct lp_block *, struct dm_disk_if *);#ifdef __cplusplus}#endif#endif /* _DM_DM_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?