Annotation of 43BSDTahoe/sys/tahoestand/vdformat/vdfmt.h, revision 1.1

1.1     ! root        1: /*     vdfmt.h 1.7     88/06/07        */
        !             2: 
        !             3: /*
        !             4:  * VERSAbus disk controller (vd) disk formatter.
        !             5:  */
        !             6: #include <setjmp.h>
        !             7: #include "tahoe/mtpr.h"
        !             8: #include "param.h"
        !             9: #include "buf.h"
        !            10: #include "disklabel.h" 
        !            11: #include "inode.h" 
        !            12: #include "fs.h"
        !            13: #include "tahoevba/vbaparam.h"
        !            14: #include "tahoevba/vdreg.h"
        !            15: 
        !            16: #include "tahoe/cp.h"
        !            17: extern struct cpdcb_i cpin;            /* found in cons.c */
        !            18: 
        !            19: /*
        !            20:  * Poll console and return 1 if input is present.
        !            21:  */
        !            22: #define        input() \
        !            23:     (uncache(&cpin.cp_hdr.cp_unit), (cpin.cp_hdr.cp_unit&CPDONE))
        !            24: 
        !            25: /*
        !            26:  * Configuration parameters
        !            27:  */
        !            28: #define        MAXCTLR         8               /* Maximum # of controllers */
        !            29: #define        MAXDRIVE        16              /* Max drives per controller */
        !            30: 
        !            31: #define NUMMAP         1               /* # Cyls in bad sector map */
        !            32: #define        NUMMNT          1               /* # cyls for diagnostics */
        !            33: #define        NUMREL          3               /* # Cyls in relocation area */
        !            34: #define        NUMSYS  (NUMREL+NUMMNT+NUMMAP)  /* Total cyls used by system */
        !            35: 
        !            36: #define        MAXTRKS         24
        !            37: #define        MAXSECS_PER_TRK 72              /* at 512 bytes/sector */
        !            38: #define        MAXERR          1000
        !            39: #define        MAXTRKSIZ       ((512/sizeof(long)) * MAXSECS_PER_TRK)
        !            40: #define bytes_trk      (lab->d_nsectors * lab->d_secsize)
        !            41: 
        !            42: #define        HARD_ERROR \
        !            43:     (DCBS_NRDY|DCBS_IVA|DCBS_NEM|DCBS_DPE|DCBS_OAB|DCBS_WPT|DCBS_SKI|DCBS_OCYL)
        !            44: #define DATA_ERROR \
        !            45:     (DCBS_UDE|DCBS_DCE|DCBS_DSE|DCBS_DSL|DCBS_TOP|DCBS_TOM|DCBS_CCD|\
        !            46:      DCBS_HARD|DCBS_SOFT)
        !            47: #define HEADER_ERROR   (DCBS_HCRC|DCBS_HCE)
        !            48: #define        NRM             (short)0
        !            49: #define        BAD             (short)VDUF
        !            50: #define WPT            (short)(NRM | VDWPT)
        !            51: #define RELOC_SECTOR   (short)(VDALT)
        !            52: #define        ALT_SECTOR      (short)(VDALT)
        !            53: 
        !            54: typedef enum { false, true } boolean;
        !            55: typedef enum { u_false, u_true, u_unknown } uncertain;
        !            56: 
        !            57: /*
        !            58:  * Free bad block allocation bit map
        !            59:  */
        !            60: typedef struct {
        !            61:        enum { ALLOCATED, NOTALLOCATED } free_status;
        !            62: } fmt_free;
        !            63: 
        !            64: typedef enum { SINGLE_SECTOR, FULL_TRACK } rel_type;   /* relocation type */
        !            65: 
        !            66: /*
        !            67:  * Error table format
        !            68:  */
        !            69: typedef struct {
        !            70:        dskadr  err_adr;
        !            71:        long    err_stat;
        !            72: } fmt_err;
        !            73: 
        !            74: /* utilities */
        !            75: int    to_sector();
        !            76: int    to_track();
        !            77: int    data_ok();
        !            78: boolean        get_yes_no();
        !            79: boolean        is_in_map();
        !            80: boolean        is_formatted();
        !            81: boolean        read_bad_sector_map();
        !            82: dskadr *from_sector();
        !            83: dskadr *from_track();
        !            84: dskadr *from_unix();
        !            85: dskadr is_relocated();
        !            86: dskadr *new_location();
        !            87: 
        !            88: /*
        !            89:  * Operation table
        !            90:  */
        !            91: typedef struct {
        !            92:        int     (*routine)();
        !            93:        char    *op_name;
        !            94:        char    *op_action;
        !            95: } op_tbl;
        !            96: 
        !            97: #define        NUMOPS  7
        !            98: op_tbl operations[NUMOPS];
        !            99: 
        !           100: /*
        !           101:  * Operation bit mask values (must match order in operations table)
        !           102:  */
        !           103: #define        FORMAT_OP       0x01    /* Format operation bit */
        !           104: #define        VERIFY_OP       0x02    /* Verify operation bit */
        !           105: #define        RELOCATE_OP     0x04    /* Relocate operation bit */
        !           106: #define        INFO_OP         0x08    /* Info operation bit */
        !           107: #define        CORRECT_OP      0x10    /* Correct operation bit */
        !           108: #define        PROFILE_OP      0x20    /* Profile operation bit */
        !           109: #define        EXERCISE_OP     0x40    /* Exercise operation bit */
        !           110: 
        !           111: extern int format(), verify(), relocate(), info();
        !           112: extern int correct(), profile(), exercise();
        !           113: 
        !           114: 
        !           115: /*
        !           116:  * Operation table type and definitions
        !           117:  */
        !           118: typedef struct {
        !           119:        int     op;
        !           120:        int     numpat;
        !           121: } op_spec;
        !           122: op_spec        ops_to_do[MAXCTLR][MAXDRIVE];
        !           123: 
        !           124: /*
        !           125:  * Contains all the current parameters
        !           126:  */
        !           127: typedef enum {
        !           128:        formatted,
        !           129:        half_formatted,
        !           130:        unformatted,
        !           131:        unknown
        !           132: } drv_stat;
        !           133: typedef enum {
        !           134:        fmt,
        !           135:        vfy,
        !           136:        rel,
        !           137:        cor,
        !           138:        inf,
        !           139:        cmd,
        !           140:        exec,
        !           141:        prof,
        !           142:        setup
        !           143: } state;
        !           144: typedef enum {
        !           145:        sub_chk,
        !           146:        sub_rcvr,
        !           147:        sub_stat,
        !           148:        sub_rel,
        !           149:        sub_vfy,
        !           150:        sub_fmt,
        !           151:        sub_sk,
        !           152:        sub_wmap
        !           153: } substate;
        !           154: 
        !           155: /*
        !           156:  * Different environments for setjumps
        !           157:  */
        !           158: jmp_buf        reset_environ;  /* Use when reset is issued */
        !           159: jmp_buf        quit_environ;   /* Use when you want to quit what your doing */
        !           160: jmp_buf        abort_environ;  /* Use when nothing can be done to recover */
        !           161: 
        !           162: /*
        !           163:  * Flaw map definitions and storage
        !           164:  */
        !           165: typedef struct {
        !           166:        short   bs_cyl;                 /* Cylinder position of flaw */
        !           167:        short   bs_trk;                 /* Track position of flaw */
        !           168:        long    bs_offset;              /* (byte) Position of flaw on track */
        !           169:        long    bs_length;              /* Length (in bits) of flaw */
        !           170:        dskadr  bs_alt;                 /* Addr of alt sector (all 0 if none) */
        !           171:        enum { flaw_map, scanning, operator } bs_how; /* How it was found */
        !           172: } bs_entry ;
        !           173: 
        !           174: struct {
        !           175:        int             controller;
        !           176:        int             drive;
        !           177:        state           state;
        !           178:        substate        substate;
        !           179:        int             error;
        !           180:        dskadr          daddr;
        !           181: } cur;
        !           182: 
        !           183: /*
        !           184:  * Controller specific information
        !           185:  */
        !           186: typedef struct {
        !           187:        uncertain       alive;
        !           188:        struct  vddevice *addr;
        !           189:        char            *name;
        !           190:        int             type;
        !           191:        fmt_err         *(*decode_pos)();
        !           192:        bs_entry        *(*code_pos)();
        !           193: } ctlr_info;
        !           194: 
        !           195: ctlr_info      c_info[MAXCTLR];
        !           196: ctlr_info      *C_INFO;
        !           197: 
        !           198: /*
        !           199:  * Drive specific information
        !           200:  */
        !           201: typedef struct {
        !           202:        uncertain       alive;
        !           203:        int             id;
        !           204:        struct          disklabel label;
        !           205:        drv_stat        condition;
        !           206: } drive_info;
        !           207: #define        d_traksize      d_drivedata[1]
        !           208: #define        d_pat           d_drivedata[2]
        !           209: 
        !           210: drive_info     d_info[MAXCTLR][MAXDRIVE];
        !           211: drive_info     *D_INFO;
        !           212: struct disklabel *lab;
        !           213: 
        !           214: struct disklabel vdproto[];
        !           215: int    ndrives;
        !           216: int    smddrives;
        !           217: 
        !           218: typedef struct {
        !           219:        unsigned int    bs_id;          /* Pack id */
        !           220:        unsigned int    bs_count;       /* number of known bad sectors */
        !           221:        unsigned int    bs_max;         /* Maximum allowable bad sectors */
        !           222:        bs_entry        list[1];
        !           223: } bs_map;
        !           224: 
        !           225: #define MAX_FLAWS (((MAXTRKSIZ*sizeof(long))-sizeof(bs_map))/sizeof(bs_entry))
        !           226: 
        !           227: long   bs_map_space[MAXTRKSIZ];
        !           228: bs_map *bad_map;
        !           229: 
        !           230: boolean        kill_processes;
        !           231: int    num_controllers;
        !           232: extern int vdtimeout;
        !           233: 
        !           234: /*
        !           235:  * Pattern buffers and the sort
        !           236:  */
        !           237: fmt_free       free_tbl[NUMREL*MAXTRKS][MAXSECS_PER_TRK];
        !           238: struct mdcb    mdcb;           /* Master device control block */
        !           239: struct dcb     dcb;            /* Device control blocks */
        !           240: 
        !           241: long   pattern_0[MAXTRKSIZ],  pattern_1[MAXTRKSIZ];
        !           242: long   pattern_2[MAXTRKSIZ],  pattern_3[MAXTRKSIZ];
        !           243: long   pattern_4[MAXTRKSIZ],  pattern_5[MAXTRKSIZ];
        !           244: long   pattern_6[MAXTRKSIZ],  pattern_7[MAXTRKSIZ];
        !           245: long   pattern_8[MAXTRKSIZ],  pattern_9[MAXTRKSIZ];
        !           246: long   pattern_10[MAXTRKSIZ], pattern_11[MAXTRKSIZ];
        !           247: long   pattern_12[MAXTRKSIZ], pattern_13[MAXTRKSIZ];
        !           248: long   pattern_14[MAXTRKSIZ], pattern_15[MAXTRKSIZ];
        !           249: 
        !           250: long   *pattern_address[16];   /* pointers to pattern_* */
        !           251: 
        !           252: /*
        !           253:  * Double buffer for scanning existing
        !           254:  * file systems and general scratch
        !           255:  */
        !           256: long   scratch[MAXTRKSIZ];
        !           257: long   save[MAXTRKSIZ];
        !           258: 
        !           259: /* XXX */
        !           260: /*
        !           261:  * Flaw map stuff 
        !           262:  */
        !           263: typedef struct {
        !           264:        long    flaw_sync;
        !           265:        short   flaw_cyl;
        !           266:        char    flaw_trk;
        !           267:        char    flaw_sec;
        !           268:        struct {
        !           269:                short   flaw_offset;
        !           270:                short   flaw_length;
        !           271:        } flaw_pos[4];
        !           272:        char    flaw_status;
        !           273:        char    flaw_junk[1024]; /* Fill up 518 byte block */
        !           274: } flaw;
        !           275: 
        !           276: typedef struct {
        !           277:        long            smde_sync;
        !           278:        unsigned        adr_cyl  : 12;
        !           279:        unsigned        adr_trk  : 8;
        !           280:        unsigned        adr_sec  : 8;
        !           281:        unsigned        sec_flgs : 4;
        !           282:        unsigned        alt_cyl  : 12;
        !           283:        unsigned        alt_trk  : 8;
        !           284:        unsigned        alt_sec  : 8;
        !           285:        char            smde_junk[1024];
        !           286: } smde_hdr;
        !           287: 
        !           288: /* for MAXTOR */
        !           289: 
        !           290: typedef struct {
        !           291:        unsigned long   esdi_flaw_sync;
        !           292:        unsigned short  esdi_flaw_cyl;
        !           293:        unsigned char   esdi_flaw_trk;
        !           294:        unsigned char   esdi_flaw_sec;
        !           295:        unsigned char   esdi_flags;
        !           296:        unsigned char   esdi_ecc_1[2];
        !           297:        unsigned char   esdi_pad_1[2];
        !           298:        unsigned char   esdi_plo_sync[26];
        !           299: } esdi_flaw_header;
        !           300: 
        !           301: typedef struct {
        !           302:        unsigned long   esdi_data_sync;
        !           303:        unsigned char   esdi_month;
        !           304:        unsigned char   esdi_day;
        !           305:        unsigned char   esdi_year;
        !           306:        unsigned char   esdi_head;
        !           307:        unsigned char   esdi_pad_2[2];
        !           308:        unsigned char   esdi_flaws[50][5];  /* see esdi_flaw_entry */
        !           309:        unsigned char   esdi_ecc_2[2];
        !           310:        unsigned char   esdi_pad_3[2];
        !           311:        char            esdi_flaw_junk[1024]; /* Fill up block */
        !           312: } esdi_flaw_data;
        !           313: 
        !           314: 
        !           315: 
        !           316: typedef struct {
        !           317:        esdi_flaw_header        esdi_header;
        !           318:        esdi_flaw_data          esdi_data;
        !           319: } esdi_flaw;
        !           320: 
        !           321: 
        !           322: 
        !           323: /*
        !           324: **  since each flaw entry is 5 bytes and this forces alignment problems we
        !           325: ** define a structure here so that the entries can be BCOPYed into a
        !           326: ** reasonable work area before access.
        !           327: */
        !           328: 
        !           329: typedef struct {
        !           330:        unsigned short  esdi_flaw_cyl;
        !           331:        unsigned short  esdi_flaw_offset;
        !           332:        unsigned char   esdi_flaw_length;
        !           333: } esdi_flaw_entry;
        !           334: 
        !           335: #define        CDCSYNC         0x1919
        !           336: #define        SMDSYNC         0x0019
        !           337: #define        SMDESYNC        0x0009
        !           338: #define        SMDE1SYNC       0x000d
        !           339: #define        ESDISYNC        0x00fe
        !           340: #define        ESDI1SYNC       0x00fe /* 0x00f8 */
        !           341: 
        !           342: /* XXX */
        !           343: 
        !           344: /*
        !           345:  * Flaw testing patterns.
        !           346:  */
        !           347: struct flawpat {
        !           348:        u_int   fp_pat[16];
        !           349: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.