This is a technique that is probably best known from its implementation with the BIOS ROMs used in a PC. The idea behind shadowing is to copy the contents of the slow ROM into faster RAM and execute the code from the RAM. As a result the time taken to execute the code is greatly reduced. The shadowing refers to the fact that the RAM contains a copy of the original ROM contents.
This mechanism can be implemented either with hardware assist or entirely in software. The basic principles behind the shadowing mechanism are as follows:
Typically the ROM contains the start up code as well as the system software. When the CPU is reset it will start execut-ing this start-up code. As part of the initialisation, the contents of the ROM is copied into the RAM area where it can be executed. This part is common to both implementa-tions.
• With a hardware assisted implementation, the address decode logic is used to switch the address decode to select the RAM instead of the ROM. As a result, any access to the ROM will be automatically switched to the RAM and will execute faster and without any change in the software as the addressing has not changed. This also provides an option to execute the code out of ROM or RAM and this can be used to isolate problems when executing out of RAM. If there are software-based timing routines in the ROM code, then this will execute faster when they are executed out of RAM and can cause problems. Virtually all IBM PCs implement their shadowing for the BIOS ROMs using this technique. It is also possible to use a MMU to perform the address transla-tion if needed.
• In the pure software-based system, the software that is copied is now in a different memory location and providing the software was compiled and linked to execute in this location, there is no need to use any memory address translation. The code can simply be executed. In this case, the ROM is simply used to contain the code and in practice, running the software from this location is not intended. It is possible with position independent code and by changing the entry points into the code to execute it from the ROM but this requires some careful software design and manage-ment to ensure that this can be done. These techniques are covered in Chapter 7.