From owner-freebsd-hackers Fri Feb 17 06:14:37 1995 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id GAA10929 for hackers-outgoing; Fri, 17 Feb 1995 06:14:37 -0800 Received: from hda.com (hda.com [199.232.40.182]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id GAA10923 for ; Fri, 17 Feb 1995 06:14:32 -0800 Received: (dufault@localhost) by hda.com (8.6.9/8.3) id HAA21778; Fri, 17 Feb 1995 07:57:45 -0500 From: Peter Dufault Message-Id: <199502171257.HAA21778@hda.com> Subject: SCSI and config(8): Done. To: freebsd-hackers@freefall.cdrom.com Date: Fri, 17 Feb 1995 07:57:44 -0500 (EST) X-Mailer: ELM [version 2.4 PL24] Content-Type: text Content-Length: 2582 Sender: hackers-owner@FreeBSD.org Precedence: bulk I've added support to configure the SCSI system using config(8). I'm going to wait for the "slice" code to settle before committing. Here is what I did. This config file entry: > controller scbus0 at aha0 > > disk sd0 at scbus0 target 0 unit 0 > disk sd1 at scbus0 target 1 > disk sd2 at scbus0 target 3 > device cd? at scbus? > tape st0 at scbus0 target 6 Generates this in ioconf.c: > #include "scsi/scsiconf.h" > > struct scsi_ctlr_config scsi_cinit[] = { > /* driver unit */ > { "aha", 0 }, > { 0, 0 } > }; > > struct scsi_device_config scsi_dinit[] = { > /* type unit cunit target LUN flags */ > { T_DIRECT, 0, 0, 0, 0, 0x0 }, > { T_DIRECT, 1, 0, 1, -1, 0x0 }, > { T_DIRECT, 2, 0, 3, -1, 0x0 }, > { T_READONLY, '?', '?', -1, -1, 0x0 }, > { T_SEQUENTIAL, 0, 0, 6, -1, 0x0 }, > { -1, 0, 0, 0, 0, 0 } > }; (cunit in scsi_dinit is the controller unit and is the index into the scsi_cinit table for that device) The SCSI bus (scsi_cinit) table is passing in names instead of "isa_dev's", but I wanted to use the adapter name since I'm not sure how the PCI stuff wires in. When you configure a SCSI controller it looks up its bus number by driver name and unit number. When there is no match it uses the lowest unused bus number greater than the highest configured bus number. (I have to look at how the multiple SCSI bus adapters work - I suppose both busses have the same driver and adapter unit number, so this current scheme may not work: I may need driver, unit and bus in the scsi_cinit table.) When you configure a device it looks through the dinit table for the unit to use. Each type (T_DIRECT == "sd", etc) is handled independently and the same approach is used as for the busses: If there is an exact match then that is used, if there is no match you use the lowest unused unit number greater than the highest configured unit number. Unknown LUNS (LUN == -1) are treated as LUN 0 for matching. All information from the config file is stored in the structures so you can go backwards from the structures to the config if you want. For current config files this approach degenerates into the current autocounting scheme. For new config files this becomes "use assignments when provided, then autocount beginning after the highest assigned number". Peter -- Peter Dufault Real Time Machine Control and Simulation HD Associates, Inc. Voice: 508 433 6936 dufault@hda.com Fax: 508 433 5267