Welcome back. The first installment might have given you the idea that knowing machine code was necessary for understanding bank switching. Would I do that to you? On occasion, machine code will be presented to support “fixes”, but if you don’t actually make the fixes you can skip it without any loss.
We previously discussed how to fix a statement like: CLOSE #3 when new devices had been added. “C” for a CENTRONIX printer is a typical example. The OPEN statement pulls an error which can be trapped with ON ERR. Fixing this type of problem is quite simple. The error number and location are available in the system variables.
OPEN #3,”C” is sufficient syntax if patches have been made to the CHANS table, or a new channel has been inserted.
The complete syntax for OPEN goes beyond this. The statement for an EXBU floppy disc drive, bearing a BEU chip is:
OPEN #7#”D”,[parameter list]
The parameter list includes such information as drive number, disc label, filename, extension, disc format standard, and file attributes. This syntax is common to all bus expansion units. Different devices require different parameters, of course.
Does this give you the idea that you can read, say, an IBM formatted disc? Yup, but it won’t be easy until the interface routines become available.
What an OPEN statement does is to verify the presence of the device, then post the offset to STRMS pointing to either CHANS or SYSCON as appropriate. In the process, a device dependent OPEN routine is generally required–just as for CLOSE.
The key here is “the presence of the device”. That is where bank switching begins.
When you turn your computer on, it goes through a lengthy initialization process to make it possible to do all those wonderous things. Just before the copyright message appears, the bank switching system is invoked to search out and identify what is connected; and to prepare a sorted list of them. That list is the system configuration table (SYSCON).
Ah! There is more to this bank switching than you thought! Cartridges which plug into the dock have reserved places at the bottom of SYSCON; one for AROS and one for LROS types.
Does it make more sense now, that this article began with I/O? It was necessary to put in perspective what bank switching does, before showing how it works.
It is still too early to explore how it works, but in the interest of fairness, a short description is in order.
The bank switching controller (BSC) resides in the SCLD. It can be reached directly through the I/O system and indirectly by issuing orders to MACROs in the SCLD. The indirect route uses memory mapped I/O and “doubletalk” which is almost magical. The SCLD MACROs issue lots of instructions to the BSC for each order received, so it pays to use them. They also perform other tasks involving the CPU.
The bank switching system has a separate data bus all its own. This consists of four lines from the joystick port (which transfer “nibbles”) for data, and one line which steers the data to a LSn or MSn register. Data is transferred a byte at a time, taking two cycles per transfer. While doing this, the SCLD turns off the CPU clock, leaving the CPU frozen in time with all its signals maintained, active or passive.
This solves the problem of being interrupted. The SCLD takes over most of the computer. When the MACRO task is complete, the clock starts running again without the CPU being aware that the lapse has occurred.
Bank switching control lines include DZOUT, DZIN, and BUSISO. Though CPU lines are “frozen”, the address lines A13 to A15 can be borrowed and used as function selectors. Anyone interested in learning more about peripheral control systems can find the IEEE 488 standard in their libraries or in the INTEL manual.
None of the control lines are connected in the TS2068. We’ll cross that bridge when we come to it. For now, we’ll assume all signals are available.
Every BEU has an Identification Number (ID) which it recognizes when it appears on the bank switching data bus. It responds by sending DZIN. No two devices can have the same ID and zero is not allowed. The BSC polls from 1 to 255, stopping when DZIN is sensed. In this way it finds all attached devices, one at a time. It returns control to the CPU each time.
The CPU tests the bank for being RAM or ROM and creates an entry for it in the SYSCON table. All RAM is treated alike, but ROM is prepared for sorting. Before going on, the BEU is told to recognize its position in the SYSCON table instead of its ID.
The XFER_BYTES routine in chunk 3 lets the CPU get data from chunk 0 of the bank into the SYSCON table, using bank switching of course. Only one byte is needed to test if it is RAM. For ROM, the first 22 bytes are copied into SYSCON. If the device is not an EXBU, these bytes (and others perhaps) belong to the BEU chip. The data is used for initialization, but the device is never bank switched. This is the case with most printers and the better implementations of DOS systems.
Those first 22 bytes of ROM carry all the information needed to identify and operate the device. Some devices are not ROM, requiring additional testing to identify them.
Once the table is complete, and all BEU’s are recognizing the new assigned bank numbers (ABN), it is sorted according to the priority read in byte 22, lower numbers mean higher priority to be placed near the bottom of the SYSCON table. RAM is given a priority of 255 so it is always above any ROM entries. Devices which have handling routines in the HOME ROM are at the bottom. NonEXBU devices come next, then EXBUs. It was planned to accommodate thirteen different devices, but which has not been said. RAM banks are loaded with the interrupt handler from the EXROM.
The last phase of initialization is the posting of nonEXBUs to CHANS and posting that fact back to SYSCON.
THEN–the copyright notice appears.
Next we will look a lot more closely at that SCLD, examining its power and limitations, but not now. Yes, the system will be summarized, but not until the final article in the series.
Complicated isn’t it? Like life, it’s “verrrry interesting.”
© 1985 William J. Pedersen
