Annotation of driverkit/notes/unixdisks, revision 1.1

1.1     ! root        1: notes on mapping Unix disk to DiskObject
        !             2: 
        !             3: OBSOLETE as of 25 Oct 91..
        !             4: 
        !             5: * block devices map to LogicalDisks. All they can do is open, close,
        !             6:   and strategy (readAsync, writeAsync). One per partition.
        !             7:   
        !             8:   sd0a <==> lsd0a etc.
        !             9:   
        !            10: * raw devices other than live partition also map onto LogicalDisks to 
        !            11:   handle DEV_BSIZE mapping. They can do open, close, read, write, ioctl.
        !            12:   One per disk.
        !            13: 
        !            14: * live partitions map onto DiskObjects (SCSIDisk, FloppyDisk). They can do 
        !            15:   read, write (maybe ioctl). One per disk.
        !            16:   
        !            17: * some kind of disk with n partitions has:
        !            18:        n LDs for block devices (lsd0a, lsd0b, lsd0c)
        !            19:        one LD for raw device (rsd0a)
        !            20:        one DiskObject subclass for live device (sd0)
        !            21:        
        !            22: * Unix level needs to be able to map a dev_t to an id.
        !            23:   DiskObject and LogicalDisk should register with Unix-level code via:
        !            24:     
        !            25:        typedef enum {
        !            26:                DISK_TYPE_RAW,
        !            27:                DISK_TYPE_BLOCK,
        !            28:                DISK_TYPE_LIVE
        !            29:        } diskType_t;
        !            30: 
        !            31:        - (void)registerUnixDisk        : (int) Unit
        !            32:                                          partition : (int) partition   
        !            33:                                          diskType : (diskType_t)diskType;
        !            34: 
        !            35:            
        !            36:     Unix level will keep a bunch of structs doing this mapping around, 
        !            37:     probably as an array, not a list, to simplify lookup:
        !            38:        
        !            39:     one per Unix unit (one for sd0, one for sd1, etc)
        !            40:     
        !            41:     typedef {
        !            42:        id raw_dev_id;          // LogicalDisk for raw device
        !            43:        id live_part_id;        // DiskObject/SCSIDisk (etc) for live partition
        !            44:        id block_id[NPART];     // for block devices
        !            45:     } struct dev_to_id_map_t;
        !            46:     
        !            47:     These are allocated statically, and a pointer to the array is kept in
        !            48:     each DiskObject's idMapArray instance variable.
        !            49:     
        !            50: * SCSIDisk init sequence (# indicates not currently implemented)
        !            51: 
        !            52:   from somewhere {
        !            53:        probe and init SCSIController object;
        !            54:        SCSIDisk probe:controllerId {
        !            55:            foreach target and lun {
        !            56:                    if it's a disk we can snag {
        !            57:                            registerDevice;             ==> IODevice
        !            58:                            registerDisk;               ==> DiskObject
        !            59:                    }
        !            60:            }
        !            61:        }
        !            62:   }
        !            63:   
        !            64:   DiskObject registerDisk {
        !            65:        log raw device info;
        !            66:        [registerUnixDisk DISK_TYPE_LIVE]; 
        !            67:        [LogicalDisk probe:self]
        !            68:        enable disk insert detection;
        !            69:   }
        !            70:   
        !            71:   
        !            72:   
        !            73: Two level config:
        !            74:   
        !            75:   go thru all dev_type registers; mark as in use those which we have
        !            76:        internal drivers for;
        !            77:   run Config, give it a chance to hand out dev_types to user-level driver 
        !            78:        (only dev_types which we don't have internal drivers for will be
        !            79:                reported; dev_numbers for devices with internal drivers
        !            80:                will be reported as DEV_TYPE_NULL).
        !            81:                
        !            82:   statically generate array of these at config time:
        !            83:   
        !            84:        typedef {
        !            85:                int (*probe_fcn)(void *regptr);
        !            86:                dev_type_t dev_type;
        !            87:        } internal_device_driver;
        !            88:        
        !            89:        note "probe_fcn" might be replaced by some objC enumeration of 
        !            90:        class names to allow something like [*classname probe]...if not 
        !            91:        possible, each driver will just have a little C fcn to do this.
        !            92:        
        !            93:    internal autoconfig {
        !            94:        for each device page {
        !            95:                get internal_device_driver * for this dev_type;
        !            96:                if non-null {
        !            97:                        dev_port_create() a dev_port;
        !            98:                        (*probe_fcn)(device_page_ptr, dev_port);
        !            99:                }
        !           100:        }
        !           101:    }
        !           102:    
        !           103: in SCSIDiskUnix:
        !           104: 
        !           105:   internal:
        !           106:        sd_probe(device_page_ptr, dev_port)
        !           107:        sd_dev_to_id(dev)
        !           108:        
        !           109:   exported via cdevsw[]:
        !           110:        sd_raw_open(dev, flag)
        !           111:        sd_raw_close(dev)
        !           112:        sd_read(dev, uiop)
        !           113:        sd_write(dev, uiop)
        !           114:        sd_ioctl(dev, cmd, data, flag)
        !           115:        
        !           116:   exported via bdevsw[]:
        !           117:        sd_block_open(dev, flag)
        !           118:        sd_block_close(dev)
        !           119:        sd_strategy(bp)
        !           120:   
        !           121: misc todo:
        !           122:   maybe SCSIController probe: should do probes of all known SCSI devices?
        !           123:   iostats needs to work!

unix.superglobalmegacorp.com

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