Annotation of lucent/sys/src/libmach/setmach.c, revision 1.1

1.1     ! root        1: #include       <u.h>
        !             2: #include       <libc.h>
        !             3: #include       <bio.h>
        !             4: #include       <mach.h>
        !             5:                /* table for selecting machine-dependent parameters */
        !             6: 
        !             7: typedef        struct machtab Machtab;
        !             8: 
        !             9: struct machtab
        !            10: {
        !            11:        char            *name;                  /* machine name */
        !            12:        short           type;                   /* executable type */
        !            13:        short           boottype;               /* bootable type */
        !            14:        int             asstype;                /* disassembler code */
        !            15:        Mach            *mach;                  /* machine description */
        !            16:        Machdata        *machdata;              /* machine functions */
        !            17: };
        !            18: 
        !            19: extern Mach            mmips, msparc, m68020, mi386, mi960;
        !            20: extern Machdata        mipsmach, sparcmach, m68020mach, i386mach, i960mach;
        !            21: 
        !            22: /*
        !            23:  *     machine selection table.  machines with native disassemblers should
        !            24:  *     follow the plan 9 variant in the table; native modes are selectable
        !            25:  *     only by name.
        !            26:  */
        !            27: Machtab        machines[] =
        !            28: {
        !            29:        {       "68020",                        /*68020*/
        !            30:                F68020,
        !            31:                F68020B,
        !            32:                A68020,
        !            33:                &m68020,
        !            34:                &m68020mach,    },
        !            35:        {       "68020",                        /*Next 68040 bootable*/
        !            36:                F68020,
        !            37:                FNEXTB,
        !            38:                A68020,
        !            39:                &m68020,
        !            40:                &m68020mach,    },
        !            41:        {       "mips",                         /*plan 9 mips*/
        !            42:                FMIPS,
        !            43:                FMIPSB,
        !            44:                AMIPS,
        !            45:                &mmips,
        !            46:                &mipsmach,      },
        !            47:        {       "mipsco",                       /*native mips - must follow plan 9*/
        !            48:                FMIPS,
        !            49:                FMIPSB,
        !            50:                AMIPSCO,
        !            51:                &mmips,
        !            52:                &mipsmach,      },
        !            53:        {       "sparc",                        /*plan 9 sparc */
        !            54:                FSPARC,
        !            55:                FSPARCB,
        !            56:                ASPARC,
        !            57:                &msparc,
        !            58:                &sparcmach,     },
        !            59:        {       "sunsparc",                     /*native sparc - must follow plan 9*/
        !            60:                FSPARC,
        !            61:                FSPARCB,
        !            62:                ASUNSPARC,
        !            63:                &msparc,
        !            64:                &sparcmach,     },
        !            65:        {       "386",                          /*plan 9 386*/
        !            66:                FI386,
        !            67:                FI386B,
        !            68:                AI386,
        !            69:                &mi386,
        !            70:                &i386mach,      },
        !            71:        {       "86",                           /*8086 - a peach of a machine*/
        !            72:                FI386,
        !            73:                FI386B,
        !            74:                AI8086,
        !            75:                &mi386,
        !            76:                &i386mach,      },
        !            77:        {       "960",                          /*i960*/
        !            78:                FI960,
        !            79:                FI960B,
        !            80:                AI960,
        !            81:                &mi960,
        !            82:                &i960mach,      },
        !            83:        {       0               },              /*the terminator*/
        !            84: };
        !            85: 
        !            86: /*
        !            87:  *     select a machine by executable file type
        !            88:  */
        !            89: void
        !            90: machbytype(int type)
        !            91: {
        !            92:        Machtab *mp;
        !            93: 
        !            94:        for (mp = machines; mp->name; mp++){
        !            95:                if (mp->type == type || mp->boottype == type) {
        !            96:                        asstype = mp->asstype;
        !            97:                        machdata = mp->machdata;
        !            98:                        break;
        !            99:                }
        !           100:        }
        !           101: }
        !           102: /*
        !           103:  *     select a machine by name
        !           104:  */
        !           105: int
        !           106: machbyname(char *name)
        !           107: {
        !           108:        Machtab *mp;
        !           109: 
        !           110:        if (!name) {
        !           111:                asstype = AMIPS;
        !           112:                machdata = &mipsmach;
        !           113:                mach = &mmips;
        !           114:                return 1;
        !           115:        }
        !           116:        for (mp = machines; mp->name; mp++){
        !           117:                if (strcmp(mp->name, name) == 0) {
        !           118:                        asstype = mp->asstype;
        !           119:                        machdata = mp->machdata;
        !           120:                        mach = mp->mach;
        !           121:                        return 1;
        !           122:                }
        !           123:        }
        !           124:        return 0;
        !           125: }

unix.superglobalmegacorp.com

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