faybs wrote:
Yes, however think about the use case here: why exactly do we need dynamically generated device IDs? . . . Feel free to correct me, but I believe that the only thing we *really* gain from a dynamic device id is avoiding duplicate ids on the bus.
That is what you achieve. You also achieve the freedom from having to manually set (and remember) which device has which ID. The idea is to make the life of the human operator easy. If this is not your goal, then so be it.
Quote:
. . ., at some point in the hardware/software stack those will have to be bound to a fixed point to be usable (eg my one shift register joystick port needs to be /dev/joy0 regardless of what its bus ID is, otherwise my game will have to scan the bus to find it
No; your game does nothing except open /dev/joy0. Your operating system is responsible for loading a device driver. That device driver is responsible for providing the binding from /dev/joy0 to the bus peripheral.
Quote:
and forcing every user program to scan the bus is just inelegant.
Windows 95 and later, MacOS, Linux, BeOS, NeXTStep, and even OS/2 all scan the bus hierarchy on behalf of the user. Not
one of these OSes require the application program to manually scan the bus. In fact,
it is a forbidden operation to do so (attempting to do so, without actually
being a device driver, will cause your program to crash with a segmentation violation, page fault, or general protection fault, depending on the OS in question).
Quote:
Also, what does the game do if you have two joysticks plugged in?
Well, there are several options, all of which depend on how you write the game. I think these options are pretty self-evident.
1) Always use /dev/joy0. Period. The user has no choice. The user can screw off.
2) Scan /dev/joy*, and let the user select from inside the game.
3) Let the user pass which joystick device to use explicitly on the command-line (myGame -joy /dev/joy2). If unspecified, default to /dev/joy0.
I'm sure there are others.
Remember, games for Windows and Linux all have to face the same issues, and they get along just fine.
Quote:
Personally, I think that if SCSI and CBM IEC could get away with user settable addresses it can't be that big a deal
Both buses are not optimized for simple I/O, and none of these buses allow for peripherals to be inserted and removed via hot-swapping. Finally, if you read the earlier computer literature, the requirement for setting device addresses was viewed strictly as an annoyance by everyone who was
not a system administrator for a company. This is why autoconfiguration systems evolved to begin with!
Quote:
even that can be resolved by using the device's position in the bus as its physical ID.
The 20-pin serial interface bus does exactly this. This is called "geophysical addressing." However, the 10-pin bus lacks this feature because it lacks explicit select pins for each peripheral. The daisy-chained-RESET approach also prevents a peripheral from knowing where it sits in the bus, because it is able to see
only its predecessor in the chain. Thus, the computer must assign unique IDs to peripherals as peripherals incrementally receive their IDs.
Quote:
That could probably be derived using extra lines on the bus and some clever wiring as the signals pass from device to device.
This sentence makes me think that you haven't read this whole thread carefully; I recommend re-reading the first handful of entries on this thread. The architecture and algorithm for autoconfiguration has already been discussed. Although I may lack a lot of the specific details, I know the core algorithm works, because it's essentially how Amiga computers equipped with Zorro-II/-III slots auto-configured compatible peripherals.