Annotation of driverkit/notes/IOStats, revision 1.1.1.1

1.1       root        1: general I/O stats/config mechanism
                      2: 
                      3: * new kern_dev rpcs
                      4: 
                      5:   to find out what lives:
                      6:   
                      7:   dev_return_t dev_inquire(
                      8:        port_t device_master,   // same as Config uses? 
                      9:        int unit,               // global device "unit num space"
                     10:        devname_t *devname,     // IODevice's devname (sd0, etc)
                     11:   );
                     12:   
                     13:   to get general parameter for unit n:
                     14:   
                     15:   dev_return_t dev_param(
                     16:        port_t device_master,
                     17:        int unit,
                     18:        char paramName[PARAM_NAME_SIZE],
                     19:        int *parameter,         // returned
                     20:   );
                     21:   
                     22:   to set general parameter in unit n:
                     23:   
                     24:   dev_return_t dev_set_param(
                     25:        port_t device_master,
                     26:        int unit,
                     27:        char paramName[PARAM_NAME_SIZE],
                     28:        int parameter           // returned
                     29:   );
                     30:   
                     31:   -- devname should be sufficient key to allow appropriate App to decide
                     32:      whether or not to do dev_params() on that unit.
                     33:   -- DiskObject should override deviceRegister:, only pass up calls for
                     34:      physical devices. (Maybe not...want to register rsd0a...
                     35:      
                     36: * IODevice instance variables
                     37:   char deviceType[]
                     38:        e.g. "LogicalDisk", "SCSIDisk" (or maybe just "Disk"), "EtherNet"
                     39:   char deviceName[]
                     40:        e.g. "SCSIDisk0", "BlockSCSIDisk0a", etc.
                     41:   
                     42: * IODevice methods
                     43:   - (dev_return_t)getParam:(const char *)paramName param:(int *)parameter;
                     44:   - (dev_return_t)setParam:(const char *)paramName param:(int)parameter;
                     45:   
                     46:   * Any subclass can override these to handle new parameters; any not
                     47:     known are passed up to [super getParam:]. 
                     48:     
                     49:     e.g. in NetDriver:
                     50:     
                     51:     - (int)getParam:(const char *)paramName
                     52:     {
                     53:        if(strcmp(paramName, "inPackets"))
                     54:                return (if_ipackets([self getNetif]);
                     55:        else if (...)
                     56:                return whatever;
                     57:        else
                     58:                return [super getParam:paramName];
                     59:     }
                     60:     
                     61: * Dispatching from kern_dev to instance:
                     62:   -- need to map unit to id.
                     63:   -- needs to work the same in user space! shlib version of IODevice needs
                     64:      to provide a "user_device_master" port, advertised in nmserver, 
                     65:      providing these same functions...
                     66:   
                     67:   IODevice's registerDevice:
                     68:   
                     69:   typedef struct {
                     70:        id              instance;
                     71:        int             unit;
                     72:        queue_chain_t   link;
                     73:   } unitToIdMap_t;
                     74:   
                     75:   /*
                     76:    * Both of these should be locked with a spin lock 
                     77:    */
                     78:   static int globalUnitCounter;
                     79:   static queue_head_t unitToIdList;    // queue of unitToIdMap_t's
                     80:   
                     81:   - (int)registerDevice
                     82:   {
                     83:        globalUnit = globalUnitCounter++;
                     84:        create a unitToIdMap_t for this instance;
                     85:        enqueue it on unitToIdList;
                     86:        return;
                     87:   }
                     88:   
                     89: kernel:
                     90:   dev_return_t dev_param(
                     91:        port_t device_master,
                     92:        int unit,
                     93:        char paramName[PARAM_NAME_SIZE],
                     94:        int *parameter)                 // returned
                     95:   {
                     96:        return IODeviceParameter(unit, paramName, parameter);
                     97:   }
                     98:   
                     99:   dev_return_t dev_set_param(
                    100:        port_t device_master;
                    101:        int unit;
                    102:        char paramName[PARAM_NAME_SIZE];
                    103:        int parameter) 
                    104:   {
                    105:        return IODeviceSetParameter(unit, paramName, parameter);
                    106:   }
                    107:   
                    108:   IODevice.m:
                    109:   
                    110:   dev_return_t IODeviceParameter(unit, paramName, *parameter)
                    111:   {
                    112:        get unitToIdMap_t for this unit;
                    113:        if NULL
                    114:                return error;
                    115:        else
                    116:                return [unitToIdMap->instance getParam:paramName];
                    117:   }
                    118:   dev_return_t IODeviceSetParameter(unit, paramName, *parameter)
                    119:   {
                    120:        get unitToIdMap_t for this unit;
                    121:        if NULL
                    122:                return error;
                    123:        else
                    124:                return [unitToIdMap->instance setParam:paramName];
                    125:   }
                    126: 
                    127: * Eventually this should work with RO? What's the name space? Maybe make 
                    128:   user-level wrapper around the three Kernel RPCs, do it all with RO with
                    129:   one "master device object". Ideally this should just provide the id of
                    130:   the desired unit, but won't wotk in the kernel...styick with RPCs to 
                    131:   device_master for now.
                    132:   
                    133: ....................................
                    134: 
                    135: returning arrays
                    136: 
                    137: /*
                    138:  * Get one unsigned int
                    139:  */
                    140: dev_return_t dev_param(
                    141:        port_t device_master,
                    142:        int unit,
                    143:        char paramName[PARAM_NAME_SIZE],
                    144:        unsigned int *parameter,                // returned
                    145: );
                    146:   
                    147: /*
                    148:  * Get an array of unsigned ints.
                    149:  */
                    150: dev_return_t  dev_get_param_int(
                    151:        port_t device_master,
                    152:        int unit,
                    153:        char paramName[PARAM_NAME_SIZE],
                    154:        int maxCount,
                    155:        unsigned *paramArray,                   // array RETURNED here
                    156:        unsigned *returnedCount);               // size of returned array
                    157:        
                    158: /*
                    159:  * Get an array of unsigned chars.
                    160:  */
                    161: dev_return_t  dev_get_param_char(
                    162:        port_t device_master,
                    163:        int unit,
                    164:        char paramName[PARAM_NAME_SIZE],
                    165:        int maxCount,
                    166:        unsigned char *paramArray,              // array RETURNED here
                    167:        unsigned *returnedCount);               // size of returned array
                    168: 
                    169: /*
                    170:  * Set an array of unsigned ints.
                    171:  */
                    172: dev_return_t  dev_set_param_int(
                    173:        port_t device_master,
                    174:        int unit,
                    175:        char paramName[PARAM_NAME_SIZE],
                    176:        int count,
                    177:        unsigned int *paramArray);
                    178:        
                    179: /*
                    180:  * Set an array of unsigned chars.
                    181:  */
                    182: dev_return_t  dev_set_param_char(
                    183:        port_t device_master,
                    184:        int unit,
                    185:        char paramName[PARAM_NAME_SIZE],
                    186:        int count,
                    187:        unsigned char *paramArray);

unix.superglobalmegacorp.com

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