CODINGDDI-1 Firmware: The Complete CPC 464 DISC Operating System ROM Specification

DDI-1 Firmware: Chapter 2 - CP/M 2.2 and the BIOS (1/3)
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Chapter 2 - CP/M 2.2 and the BIOS

This chapter describes the CP/M 2.2 implementation on the CPC464, with particular reference on how to use the extensive facilities available in the firmware jumpblock and in the BIOS extended jumpblock. This is not a tutorial, the reader should have some knowledge of CP/M and its structure (see ‘A Guide to CP/M' SOFT 159).

2.1 Structure of CP/M

CP/M consists of three software modules: Console Command Processor (CCP), Basic Disc Operating System (BDOS) and the Basic Input Output System (BIOS). (Note the term ‘Basic' in this context has nothing to do with the BASIC language.) The CCP and BDOS are the machine independent parts of CP/M as supplied by Digital Reserach. The BIOS is the machine dependent part which deals with all the low-level device driving, in particular the disc driving. The BIOS resides in the expansion ROM in the DDI-1 interface. The CCP and BDOS reside on the first two tracks of a system format disc and are loaded into RAM by the BIOS when a ‘Warm boot' is performed.

The BIOS ROM starts at #C000 and ends at #FFFF, that is it overlays the screen RAM. The ROM also contains AMSDOS and some parts of DR LOGO.

The RAM from #AD33 to #BFFF is always reserved. It contains the firmware jumpblock and the firmware and BIOS data areas.

The rest of store is for use by CP/M and Resident System extensions (RSXs). In the system as supplied there is no room for any RSXs, however, the utility MOVCPM.COM can be used to create a smaller CP/M system with space for RSXs as required.

The BDOS communicates with the BIOS via the BIOS jumpblock. This is positioned immediately after the BDOS.

The 16 bytes from #0040 to #004F are reserved for use by DR LOGO, they are not used by the BIOS.

2.2 Store Map

This store map has CP/M positioned as high as possible.

#FFFF#C000...#FFFF
BIOS ROM:UPPER ROM/SCREEN RAM
#C000
BIOS STACK
#BEC0

BIOS EXTENDED
JUMPBLOCK

#BE80

FIRMWARE AND BIOS
VARIABLES

#AD33RSXs go in here, move CCP and BDOS down
BIOS JUMPBLOCK
#AD00
BDOS
#9F06
CCPCCP may be overwritten by TPA
#9700
TPA#0000.. #3FFF: LOWER ROM
#0100
PAGE0
#0000

2.3 Cold Boot

The term ‘cold boot' means invoking CP/M for the first time after the machine has been switched on or reset.

CP/M is invoked in one of two ways: either automatically when the machine is switched on, or by issuing the |CPM external command.

The method used is determined by an option link on the disc interface board. This sets the address of the BIOS ROM to either 0 or 7. If the ROM address is set to 0 then the BIOS cold boot will be invoked automatically when the machine is switched on. If the ROM address is set to 7 then CP/M may be invoked by issuing the external command |CPM. The DDI-1 is supplied with the ROM number set to 7. See chapter 5.1 for details on how to change the ROM number.

Once the BIOS cold boot is invoked the firmware is reset by calling MC START PROGRAM, thus any RAM allocated to background ROMs and RSXs will be lost and all ticker chains reset.

The BIOS cold boot routine first initializes the BIOS into a ‘minimum' working state, loads a boot program from the single boot-sector on the disc into store, starting at #0100, and enters it. If all the bytes in the boot sector have the same value an error message is displayed. Otherwise it is assumed that the sector contains a valid boot program.

The ‘minimum' working state in which the boot program runs is sufficient to run CP/M but does not do any of the following: display a sign-on message, initialize the serial interface, set any keyboard translations.

The standard boot program loads the configuration sector from the disc and performs some further initialization. This ‘two stage' initialization is done so that, if required, the boot program could bring up a totally different operating system. See chapter 2.12.

Once the BIOS is initialized a warm boot is performed to load the CCP and BDOS.

2.4 Warm Boot

The term ‘warm boot' means reloading CP/M after a transient program has run or after the user has typed Control-C in order to change a disc.

A warm boot is invoked immediately after initialization and thereafter by a jump to location zero, or by calling the BDOS System Reset function. The primary function of the warm boot is to load the BDOS and CCP into memory and then to enter the CCP. The memory location used to start the load is calculated from the jump instruction at the start of the CCP. #035C is subtracted from the JMPs destination address giving the origin of the CCP. Since the position of the CCP is recalculated at every warm boot differing sized CP/Ms can be warm booted from each other.

If all the bytes in the first sector of the CCP have the same value an error message is displayed. Otherwise it is assumed that the system tracks contain a valid CCP and BDOS.

The warm boot routine initializes the jumps at #0000 and #0005 and also copies the BIOS jumpblock into RAM immediately after the BDOS (see chapter 2.2).

2.5 Resident System extensions

Resident System extensions (RSXs) allow the user to keep programs, such as special character I/O drivers, permanently in memory. They must be loaded into memory below the BIOS variable area (which starts at location #AD33) but, above the end of the RAM copy of the BIOS's jumpblock. In the CP/M system as supplied there is no space for RSXs. If RSXs are required the user must reduce the size of the TPA by the amount of space required for all RSXs. Note that the M0VCPM. COM transient utility only allows the user to relocate CP/M onto 256 byte (page) boundaries.

Let Srsx be the size of RSX required in pages (1 page = 256 bytes) then the RSX area will start at address # AD33 - (256 * Srsx) and end at # AD32.

The BIOS does not initialize any background ROMs. AMSDOS must not be initialized under CP/M.

Under version 1 of the firmware ROM the following restrictions apply:

Any background ROMs required must be explicitly initialized by calling KL INIT BAK. Using KL ROM WALK would cause the disc expansion ROM to be re-initialized which would lock up the system. The memory pool for the ROM's dynamic variables must lie in the RSX area, that is between the end of the BIOS jumpblock and below the BIOS's variables.

If the ROM address is set to 0 and BASIC is invoked AMSDOS will not be available.

2.6 Using MOVCPM.COM

In order to insert an RSX into store it is necessary to move the CP/M system down store. The CP/M utility MOVCPM.COM will create an in-store image of a CP/M system of the required size. The utility SYSGEN.COM is then used to write this image onto disc, see section 4.11.

The MOVCPM utility requires the size of CP/M system to be specified. Historically this size meant the total amount of RAM available to the original CP/M system with BIOS size of 1.5K. Nowadays it is merely a magic number to feed MOVCPM with! The MOV CPM utility supplied requires this size to be expressed in pages (1 page = 256 bytes). It is calculated as follows:

Let Scpm be the ‘size of CP/M' in pages as required by the MOVCPM utility
Let Srsx be the size in pages of RSX required.

Then Scpm = 179 - Srsx.

The BDOS will start at address Bstart = (Scpm - 20) * 256

The BDOS entry point will be at address Bentry = Bstart + 6

The TPA size = Bentry - #0100

To run MOVCPM type:

MOVCPM nnn *

where nnn is the size required and must be in the range 64.. 179.
The asterix must be present and separated from the size by a space.

The CP/M system supplied has been created from:

MOVCPM 179 *

2.7 IOBYTE

CP/M supports four logical character I/O devices called CONSOLE, READER, PUNCH and LIST. These four logical devices are mapped onto different physical devices. At any one time the current mapping of logical to physical devices is defined in a location called the IOBYTE. The STAT transient utility program can be used to change the IOBYTE.

CONSOLE may be assigned to:

  • TTY: (special I/O device 0)
  • CRT: (keyboard and screen)
  • BAT: (input from READER and output to LIST)
  • UC1: (special I/O device 1)

READER may be assigned to:

  • TTY: (special I/O device 0)
  • PTR: (end of file input)
  • UR1: (special I/O device 1)
  • UR2: (keyboard)

PUNCH may be assigned to:

  • TTY: (special I/O device 0)
  • PTP: (null output)
  • UP1: (special I/O device 1)
  • UP2: (screen)

LIST may be assigned to:

  • TTY: (special I/O device 0)
  • CRT: (screen)
  • LPT: (Centronics port)
  • UL1: (special I/O device 1)

The Keyboard input device uses the firmware routine KM WAIT CHAR to read characters from the keyboard.

The screen output device uses the firmware routine TXT OUTPUT to display text and process control characters. Refer to the firmware documentation for details of the control characters supported.

The end of file input device always returns the end of file character #1A. The null output device discards all characters sent to it.

The two special I/O devices are initially setup to drive channels A and B of a Z80 SIO. Each device has four driver routines which are all indirected via the extended jumpblock (see chapter 2.14). The user may patch these jumps in order to use an RSX device driver.

2.8 BIOS User Interaction

In general the user may freely type-ahead on the keyboard, provided the BIOS is not accessing the discs. While accessing the discs interrupts are disabled and characters can be lost.

Some characters are treated specially by the BIOS (see also chapter 2.14 on retries). When performing character I/O with the Centronics or serial interface ports the BIOS polls the keyboard for the following control characters (any other characters are lost).

CONTROL-C

To stop the system from locking-up the user may press Control-C to perform a warm boot under the following conditions:-

a) Whilst waiting to output a character to the serial interface.

b) Whilst waiting to input a character from the serial interface.

c) Whilst waiting to send a character to the Centronics printer port.

CONTROL-S

To suspend CP/M when sending or receiving characters from the serial interface the user may press Control-S. Once suspended the user must press any key to continue operation of the BIOS. The control-S and the character typed are both lost.

CONTROL-Z

Whilst waiting to input a character from the serial interface, the user may press Control-Z. This will result in a Control-Z (eof) being passed back to the calling program.

2.9 Initial Command Buffer

When CP/M is invoked, the keyboard input device reads characters from a special buffer called the Initial Command Buffer. The SETUP utility program allows the user to initialize the initial command buffer, specifying a number of commands to be automatically executed when CP/M is cold booted.

The BIOS routine CONST does not reflect the status of the initial command buffer. Thus programs which poll for Control-C will not drain the initial command buffer. In particular the BIOS user interaction, chapter 2.8, will not fetch characters from the initial command buffer.

2.10 BIOS messages

All BIOS messages are sent to the screen via TXT OUTPUT. They are not indirected via the IOBYTE.

BIOS messages are followed by the question Retry, Ignore or Cancel?. The system then discards any outstanding characters, turns on the cursor and waits for the user to type R, I or C, anything else will cause a bleep.

Typing R for retry causes the BIOS to repeat the operation.

Typing I for ignore causes the BIOS to continue as if the problem had not occured.

Typing C for cancel causes the BIOS to abandon the operation. This will often result in a BDOS error message.

After the user has typed R, I or C the cursor is turned off.

The AMSTRAD BIOS messages are as follows:-Drive:disc missing

Where < n > is the drive identifier, either A or B. This message is produced when the BIOS attempts to access a drive that does not have a disc inserted or a non-existent drive.

Failed to Load boot sector

This message is produced during a cold boot when the boot sector is not read correctly or if all the bytes in the boot sector have the same value.

Failed to Load CP/M

This message is produced during a warm boot when a sector of the CCP or BDOS is not read correctly or if all the bytes in the first CCP sector have the same value.

Drive < n >: disc is write protected

Where < n > is the drive identifier, either A or B. This message is produced when the BIOS attempts to write to a disc that is write-protected. If the user wishes to write on this disc then the user should remove the disc, write enable it, re-insert it into the drive and then type R for retry.

Drive < n >: read faiL

Where < n > is the drive identifier, either A or B. This message is produced when a hardware error has been reported whilst reading from the disc. It may also be caused by trying to read from a disc with the wrong format, for example: trying to warm boot from a DATA ONLY format disc.

Drive < n >: write faiL

Where < n > is the drive identifier, either A or B. This message is produced when a hardware error has been reported whilst writing to the disc.

In the event of a read or write fail the user is recommended to remove and re-insert the disc then type ‘R'. This may help in case the disc was badly positioned or may shift any fluff or what-not adhering to the head. If this does not clear the problem then the data will have to be recovered in some other way. It is strongly recommended that the user takes regular back-up copies of discs.

2.11 Disc Organization

The BIOS supports three different disc formats: SYSTEM format, DATA ONLY format and IBM format. The BIOS automatically detects the format of a disc. Under CP/M this occurs for drive A at a warm boot and for drive B the first time it is accessed. Under AMSDOS this occurs each time a disc with no open files is accessed. To permit this automatic detection each format has unique sector numbers.

3 inch discs are double sided, but only one side may be accessed at a time depending on which way round the user inserts the disc. There may be different formats on the two sides.

Common To All Formats

  • Single sided (the two sides of a 3 inch disc are treated separately).
  • 512 byte physical sector size.
  • 40 tracks numbered 0 to 39.
  • 1024 byte CP/M block size.
  • 64 directory entries.

System Format

  • 9 sectors per track numbered #41 to #49.
  • 2 reserved tracks. ,
  • 2 to 1 sector interleave.

The system format is the main format supported, since CP/M can only be loaded (cold and warm boot) from a system format disc. The reserved tracks are used as follows:

  • Track 0 sector #41: boot sector.
  • Track 0 sector #42: configuration sector.
  • Track 0 sectors # 43.. # 47: unused.
  • Track 0 sectors #48.. #49 and track 1 sectors #41.. #49: CCP and BDOS.

Note: ‘VENDOR' format is a special version of system format which does not contain any software on the two reserved tracks. It is intended for use in software distribution.

Data Only Format

  • 9 sectors per track numbered # C1.. # C9.
  • 0 reserved tracks.
  • 2 to 1 sector interleave.

This format is intended for future enhancement, it is not recommended for use with CP/M since it is not possible to ‘warm boot' from it. However, if only AMSDOS is to be used then there is a little more disc space available.

IBM Format

  • 8 sectors per track numbered 1.. 8.
  • 1 reserved track, no sector interleave.

This format is logically the same as the single-sided format used by CP/M on the IBM PC. It is intended for specialist use and is not otherwise recommended as it is not possible to ‘warm boot' from it.

2.12 Boot Sector

In order that non-CP/M systems may be implemented at a later date the BIOS initialization is performed, in part, by a boot program which is read from the disc before attempting to load CP/M. In the non-CP/M case the boot program would not jump to the warm boot routine but go its own way, using the BIOS and firmware routines as desired.

The boot sector is sector #41 on track 0.

During a cold boot the BIOS is initialized into a minimum state, i.e:

  • All the routines in the ROM copy of the BIOS jumpblock and all routines in the extended jumpblock are available.
  • Alternate and IY register saving is enabled.
  • Interrupts are indirected via the BIOS and run on the BIOS's stack.
  • Disc messages are enabled.
  • The initial command buffer is empty.
  • The IOBYTE at #0003 is initialized to #81 (LST: = LPT:, PUN:=TTYRDR:=TTY:,C0N:=CRT:).
  • The current drive at #0004 is initialized to #00.
  • The serial interface is not initialized.
  • The CCP and BDOS are not in store.
  • The BIOS RAM jumpblock is not in store.

The CP/M jumps at #0000 and #0005 are not initialized.

The boot sector is read and loaded into store at #0100; the stack pointer is initialized to # AD33, a value immediately below the BIOS's data area and the boot program is enteredat #0100. The boot program mayuse store from #0100 to #AD32 inclusive.

To run CP/M the boot program must, at least, jump to the warm boot entry in the ROM jumpblock.

The boot program has the following interface:

Entry:

  • SP = highest address available + 1 (a good place for the stack)
  • BC = address of ROM copy of BIOS jumpblock (BOOT).

Exit:

  • program should jump to the WBOOT entry in the above jumpblock

The ROM copy of the BIOS jumpblock should not be used at any other time (indeed, only the boot program knows where it is).

2.13 Configuration Sector.

The Boot program supplied loads the configuration sector from disc. This contains various system parameters which are used to initialize the BIOS. These parameters may be changed by using the utility SETUP.COM (see chapter 4.10).

The configuration sector is sector #42 on track 0.

Format:

byte 0 = #35, byte 1 = #12 Disc signature.

  • This signature allows the boot program to check that the configuration sector has been S ETUP.

bytes 2..3 Drive motor on delay

  • Time to wait between turning the drive motor on and starting a read/write operation. In units of 1/50 sec. A value of zero will lock up the system.

bytes 4..5 Drive motor off delay

  • Time to wait after a read/write operation before turning the drive motor off. In units of 1/50 sec. A value of zero will keep the motor on permanently.

byte 6 Step rate.

  • Step rate for moving tracks. Must be an even number in the range 2..32 milliseconds.

byte 7 IOBYTE.

  • Initial value of the CP/M IOBYTE.

byte 8 BIOS disc message enable/disable.

  • #00 ⇒ enable BIOS disc messages.
  • #FF ⇒ disable BIOS disc messages.

byte 9 Saving alternate and IY register enable/disable.

  • #00 ⇒ enable saving alternate and IY registers (slow mode).
  • #FF ⇒ disable saving alternate and IY registers (fast mode).

Bytes 10..21 are used to initialize the serial interface, if fitted.

  • byte 10: SIO channel A write register 4 (mode register),
  • byte 11: SIO channel A write register 5 (Tx register),
  • byte 12: SIO channel A write register 3 (Rx register),
  • byte 13: SIO channel B write register 4 (mode register),
  • byte 14: SIO channel B write register 5 (Tx register),
  • byte 15: SIO channel B write register 3 (Rx register),
  • bytes 16.. 17:8253 timer 0 (SIO channel A Tx baud rate),
  • bytes 18.. 19:8253 timer 1 (SIO channel A Rx baud rate),
  • bytes 20. .21:8253 timer 2 (SIO channel B Tx and Rx baud rate).

byte 22 Keep command buffer.

  • #00 ⇒ the initial command buffer will be flushed when a key is pressed.
  • #FF ⇒ the initial command buffer will not be flushed when a key is pressed.

bytes 23..99 reserved.

  • These bytes are currently unused. All set to #00.

The following fields are all of variable length and live in bytes 100....

Sign-on string.

  • String of characters that is output to the screen. The string is terminated by a dollar ($).

Printer power-up string.

  • This string of bytes is sent to the CP/M list device, that is it is indirected via the IOBYTE as set from byte 7.
    • byte 0 length of string, 0..255. byte 1... string.

Keyboard NORMAL translations.

  • This table redefines the codes produced by keys with neither SHIFT nor CONTROL pressed. Each entry in the table is two bytes long. The first byte is the key code, the second the key number that will produce that code. See Appendix I for the key numbering.

Table format:

byte0 number ofentries, 0..255.
bytes 1... entries.

Entry format:

byte 0 key code,
byte 1 key number.

Keyboard SHIFT translations.

This table redefines the codes produced by keys with SHIFT pressed. Each entry in the table is two bytes long. The first byte is the key code, the second the key number that will produce that code. See Appendix I for the key numbering.

Table format:

byte0 number ofentries, 0..255.
bytes 1... entries.

Entry format:

byte 0 key code,
byte 1 key number.

Keyboard CONTROL translations.

This table redefines the codes produced by keys with CONTROL pressed. Each entry in the table is two bytes long. The first byte is the key code, the second the key number that will produce that code. See Appendix I for the key numbering.

Table format:

byte0 number of entries, 0..255.
bytes 1... entries.

Entry format:

byte 0 key code,
byte 1 key number.

Keyboard expansions.

This table defines the keyboard expansion strings (see section 3.7).

Table format:

byte0 number ofentries, 0..255.
bytes 1... entries.

Entry format:

byte 0 expansion token,
byte 1 length of expansion string,
byte 2... expansion string.

The remainder of the configuration sector is set to #00.

2.14 BIOS Jumpblocks

The AMSTRAD BIOS has two jumpblocks: the standard CP/M jumpblock and an extended jumpblock. The extended jumpblock starts at #BE80 and contains jumps for additional facilities such as physical sector reading and writing. When CP/M is warm-booted the standard BIOS jumpblock is copied into RAM immediately after the BDOS. The address of the warm boot entry in the RAM jumpblock is held in the word at #0001.

The entry and exit conditions of the standard BIOS jumpblock are a superset of those defined in the CP/M alteration guide as listed below. All routines in the standard BIOS jumpblock optionally preserve the Z80 alternate and IY registers as specified by the SET REG SAVE routine.

READ WRITE

These two routines return some hardware error status in the accumulator when a read or write has failed. The definitions of the status bits are listed below.

  • bit 7 end of cylinder - this bit should always be set
  • bit 6 not used - always 1
  • bit 5 data error - CRC error on data or ID field
  • bit 4 overrun error
  • bit 3 drive not ready - no disc in drive
  • bit 2 no data -can't find the sector
  • bit 1 not writable - drive write protected
  • bit 0 address mark missing

In addition to the above status byte, the HL register pair contains the address of a buffer of all the bytes received during the results phase of the /J.PD765A disc controller, the first byte is a count of the number of bytes that follow. (See manufacturer's documentation.)

SELDSK

If bit 0 of E = 0, indicating that this is the first time that the disc is being accessed, then the BIOS will attempt to determine the format of the disc by reading an ID header from the current track. If successful then the relevant extended DPB is altered to correspond to the detected format.

The extended jumpblock starts at #BE80 and has the following format:

  • #BE80 JMP SET MESSAGE ;enable/disable disc error messages
  • #BE83 JMP SETUP DISC ;initialize drive parameters
  • #BE86 JMP SELECT FORMAT ;select one of the standard formats
  • #BE89 JMP READ SECTOR ;read a sector from disc
  • #BE8C JMP WRITE SECTOR ;write a sector to disc
  • #BE8F JMP FORMAT TRACK ;format an entire track
  • #BE92 JMP MOVE TRACK ;move to specified track
  • #BE95 JMP GET DR STATUS ;get drive status (µPD765A reg 3)
  • #BE98 JMP SET RETRY COUNT ;set number of error retries
  • #BE9B JMP ENTER FIRMWARE ;invoke a firmware routine
  • #BE9E JMP SET REG SAVE ;set/clear alternate register saving
  • #BEA1 JMP SET SIO initialize the serial interface
  • #BEA4 JMP SET CMND BUFFER initialize the command buffer

The following 8 routines are the indirection jumps for the special character I/O devices. The BIOS uses these jumps to access the devices. Thus the user may patch these jumps to an RSX driver if required. They all default to the serial interface driver. Device 0 is channel A of the serial interface, device 1 is channel B.

  • #BEA7 JMP D0 IN ;STATUS ;input status of device 0
  • #BEAA JMP D0 IN ;input from device 0
  • #BEAD JMP D0 OUT ;STATUS ;output status of device 0
  • #BEB0 JMP D0 OUT ;output to device 0
  • #BEB3 JMP D1 IN ;STATUS ;input status of device 1
  • #BEB6 JMP D1 IN ;input from device 1
  • #BEB9 JMP D1 OUT ;STATUS ;output status of device 1
  • #BEBC JMP D1 OUT ;output to device 1

The action performed by each entry in the extended jumpblock is detailed below, along with the entry and exit conditions of each.

These routines will, in turn, call firmware routines so they must themselves be treated like firmware routines, see chapter 2.17.

★ AUTHOR: Paul OVERELL
★ NOTE: RÉF SOFT158A

Page précédente : DDI-1 Firmware: Chapter 1-Overview
Je participe au site:

» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 157 millisecondes et consultée 384 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.