When using this document, keep the following in mind:ntialGeneral Notice

1. This document is confidential. By accepting this document you acknowledge that you are boundby the terms set forth in the non-disclosure and confidentiality agreement signed separately and /inthe possession of SEGA. If you have not signed such a non-disclosure agreement, please contact
SEGA immediately and return this document to SEGA.

de2. This document may include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new versions of the
document. SEGA may make improvements and/or changes in the product(s) and/or the
program(s) described in this document at any time.

nfi

3. No one is permitted to reproduce or duplicate, in any form, the whole or part of this document
without SEGA’S written permission. Request for copies of this document and for technicalinformation about SEGA products must be made to your authorized SEGA Technical Services
representative.

Co

4. No license is granted by implication or otherwise under any patents, copyrights, trademarks, orother intellectual property rights of SEGA Enterprises, Ltd., SEGA of America, Inc., or any third
party.
5. Software, circuitry, and other examples described herein are meant merely to indicate the characteristics and performance of SEGA’s products. SEGA assumes no responsibility for any intellectual
property claims or other problems that may result from applications based on the examples
describe herein.

GA

6. It is possible that this document may contain reference to, or information about, SEGA products(development hardware/software) or services that are not provided in countries other than Japan.
Such references/information must not be construed to mean that SEGA intends to provide such
SEGA products or services in countries other than Japan. Any reference of a SEGA licensed product/program in this document is not intended to state or simply that you can use only SEGA’slicensed products/programs. Any functionally equivalent hardware/software can be used instead.
7. SEGA will not be held responsible for any damage to the user that may result from accidents or any
other reasons during operation of the user’s equipment, or programs according to this document.

SE

NOTE: A reader's comment/correction form is provided with thisdocument. Please address comments to :(6/27/95- 002)

SEGA of America, Inc., Developer Technical Support (att. Evelyn Merritt)
150 Shoreline Drive, Redwood City, CA 94065
SEGA may use or distribute whatever information you supply in any way
it believes appropriate without incurring any obligation to you.

SE

GA

Co

nfi

de

nti
al

TM

SEGA Saturn
Dual CPU
User's Guide
Doc. # ST-202-R1-120994© 1994 SEGA. All Rights Reserved.

nti
al

READER CORRECTION/COMMENT SHEETKeep us updated!
If you should come across any incorrect or outdated information while reading through the attacheddocument, or come up with any questions or comments, please let us know so that we can make therequired changes in subsequent revisions. Simply fill out all information below and return this form to
the Developer Technical Support Manager at the address below. Please make more copies of this form if
more space is needed. Thank you.
General Information:

Phone

Document number
Document namedeYour Name

Date

ST-202-R1-120994

SEGA Saturn Dual CPU User's Guide

Corrections:
Correction

nfi

pg. #

GA

Co

Chpt.

SE

Questions/comments:

Fax:

Where to send your corrections:(415) 802-3963
Attn: Manager,
Developer Technical Support

Mail:

SEGA OF AMERICA
Attn: Manager,
Developer Technical Support
275 Shoreline Dr. Ste 500
Redwood City, CA 94065

Version
1.0
1.1

December 9, 1994

1.2

Update History

Correction of typographical errors in address values for 2.2 EVA
board settings
Corrected translated error on page 5. Address 28000000H under
section 6.1 was changed to 21800000H.

SE

GA

Co

nfi

de

Date
August 5, 1994
September 28, 1994nti
alUpdate History1.0 Dual CPU Configuration in Sega Saturn ......................... 1
1.1 Complete Shared Mode (Memory Sharing ............ 1
1.2 Communication by FRT Input Capture Signal ....... 1
2.0 Settings for Debugging Environment ............................. 2
2.1 E7000 ICE Settings ............................................... 2
2.2 EVA Board Settings ............................................... 2de

3.0 Clock Changes .................................................................. 2ntialContentsnfi

4.0 Programming ..................................................................... 3
4.1 Program Sharing ................................................... 3
4.2 Stack Variables and Static and Global Variables ... 3
4.3 Slave CPU Initialization ......................................... 3
4.4 Initialization (Vector, Stack) by the Boot ROM ....... 3
5.0 Communication from Master CPU to Slave CPU ........... 4
5.1 FRT Input Capture Interrupt ................................... 4
5.2 Polling of the FRT Input Capture Flag ................... 4Co

6.0 Communication from Slave CPU to Master CPU ........... 5
6.1 FRT Input Capture Interrupt ................................... 5
6.2 Polling of the FRT Input Capture Flag ................... 5
7.0 Data Transfer Between Master and Slave CPUs ............ 5
7.1 Cache-through Read ............................................. 5
7.2 Cache Invalidate .................................................... 5
8.0 Programming Examples Using the Slave CPU .............. 6
8.2 Function Execution Request from Master CPU
to Slave CPU ......................................................... 6

SE

GA

Virtual CD Tool ........................................................................... 7

Dual CPU Configuration in Sega Saturn

1.1

Complete Shared Mode (Memory Sharing)

nti
al

1.0

In the Sega Saturn, the slave CPU shares all external devices with the master CPU.
The programs executed by the slave CPU and the reset vector obtained during resetare exactly the same as those of the master CPU. However, identification of themaster and slave CPUs is performed in the boot ROM because each CPU must be
initialized separately.

1.2

de

When the slave and master CPUs compete for external access, one of the CPUs isforced to wait for access and execution speed decreases.
Communication by FRT Input Capture Signal

SE

GA

Co

nfi

The Sega Saturn is designed so that the FRT Input Capture signal of the SH2 built-in
module can be used to implement communication between the master and slave
CPUs. Specifically, to input the FRT Input Capture signal to the slave CPU, write
16-bit data to address 21000000H; to input the FRT Input Capture signal to the master CPU, write 16-bit data to address 21800000H.

SEGA Saturn Dual CPU User's Guide

1

Settings for Debugging Environment

2.1

E7000 ICE Settings

nti
al

2.0

To use the E7000 ICE in the slave CPU, slave mode must be specified with the ICE
MODE command.
Setting Procedure

2.2

de

:mode;c [Return]E7000 MODE(MD5-0)=xx? 2E [Return]
MODE SET (C:CONFIGURATION/U:USER/M:MASTER-SLAVE)=X? C [Return]
CONFIGURATION WRITE OK?(Y/N)? Y [Return]
EVA Board Settings

To use the EVA board in the slave CPU, the following settings are required:

Release Procedure:m 2010001f:b [Return]2010001f xx? 02 [Return]20100020 xx? . [Return]nfi

1. Release the slave CPU reset in the master CPU emulator.

Co

2. The EVA board in the slave CPU is started.

3. Execute em ct=d on the EVA board in the slave CPU.
When using the EVA board in the slave CPU, note that the EVA board cannot be
operated until the slave CPU reset is released.

Clock Change

GA

3.0

SE

When the clock is changed, the SMPC switches the slave CPU to reset state. The
slave CPU must therefore be restarted by the SMPC command (SSH_ON = 02H) after
the clock is changed.

2

Programming

4.1

Program Sharing

nti
al

4.0

Because the slave and master CPUs share all external devices, either CPU can execute an execution file from any location. (If the cache is used as internal RAM,
programs placed in internal RAM are not shared.)
4.2

Stack Variables and Static and Global Variables

4.3

Slave CPU InitializationdeRe-entrant functions can be executed concurrently for the slave and master CPUs
because a stack area is allocated separately for each CPU (boot ROM setting). However, if both CPUs execute programs that rewrite static or global variables, special
attention must be paid to the execution sequence and to concurrent execution ineach CPU.

4.4

nfi

In slave CPU activation by the master CPU, the boot ROM rewrites the execution
entry (SYS_SETSINT(164H, EntryFunc);) after read initialization. The master CPU
then uses the SMPC command (SSH_ON = 02H) to release the slave reset.
(EntryFunc is the slave entry function).
Initialization (Vector, Stack) by the Boot ROM

Co

The boot ROM initializes the slave CPU as follows:SE

GA

1. Vector VBR is set to address 6000400H.
2. Stack SP is set to address 6001000H.
3. Of the interrupts, only the FRT Input Capture interrupt is enabled (64H, level 1).

SEGA Saturn Dual CPU User's Guide

3

5.0

Communication from Master CPU to Slave CPU

5.1

nti
al

Bidirectional communication is necessary for coordinating operation between themaster and slave CPUs. For communication from the master CPU to the slave CPU,the Sega Saturn provides the methods described in the following sections.
FRT Input Capture Interrupt

deDuring boot ROM initialization, the FRT Input Capture interrupt is set for the slaveCPU. To set interrupt processing from the master CPU, use the application initialization routine to register the interrupt processing routine to interrupt vector 64H ofthe slave CPU. (When the interrupt processing routine is registered from the master
PCU, the interrupt vector is 164H.)
To issue this interrupt from the master CPU, write 16-bit data to address 21000000H.
The slave CPU then starts the interrupt processing that was previously registered.
5.2

Polling of the FRT Input Capture Flag

SE

GA

Co

nfi

When the SH CPU accepts the FRT Input Capture signal, it sets a flag to an internalregister in the FRT unit. The SH CPU then monitors change in the flag during processing wait state (or synchronous wait state). This method is especially effective
when there are many synchronous or processing waits because it has a shorter
reception time than the interrupt processing method. When using this method, besure to disable the FRT Input Capture interrupt in the application initialization
routine. (Set 01H to TIER.)

4

6.0

Communication from Slave CPU to Master CPU

6.1

nti
al

In addition to providing communication methods from the master CPU to the slave
CPU, the Sega Saturn also provides all of the same communication methods forcommunication from the slave CPU to the master CPU.
FRT Input Capture Interrupt

During boot ROM initialization, the FRT Input Capture interrupt is set for the master CPU. To set interrupt processing from the slave CPU, set up the application
initialization routine to register the interrupt processing routine to interrupt vector
64H of the master CPU.

de

To issue this interrupt from the slave CPU, write 16-bit data to address 21800000H.
The slave CPU then starts the interrupt processing that was previously registered.
6.2

Polling of the FRT Input Capture Flag

7.0

Co

nfi

When the SH CPU accepts the FRT Input Capture signal, it sets a flag to an internalregister in the FRT unit. The SH CPU then monitors change in the flag during processing wait state (or synchronous wait state). This method is especially effective
when there are many synchronous or processing waits because it has a shorter
reception time than the interrupt processing method. When using this method, besure to disable the FRT Input Capture interrupt in the application initialization
routine.

Data Transfer Between Master and Slave CPUs

7.1

GA

The cache unit of the SH CPU does not support a bus snoop function. Therefore
when data is transferred between the master and slave CPUs, the CPU reading thedata must either perform a cache-through read or read the data after the cache of thetarget area is invalidated.
Cache-through Read

In cache-through read, the CPU reads data starting from the address obtained when
20000000H is added to the target address.
7.2

Cache InValidate

SE

To invalidate the cache, the CPU writes 0 by 16-bit access to the address obtained
when 40000000H is added to the target address. This operation invalidates a 16-byte
area that includes the target address.

SEGA Saturn Dual CPU User's Guide

5

8.0

Programming Examples Using the Slave CPU

8.1

nti
al

The following sections shows program examples that use the slave CPU(when the FRT Input Capture Flag is polled.)
Slave CPU Initialization

The following examples show a program that initializes the slave CPU and an execution entry function of the slave CPU.

devoid /* Initialize/start slave CPU (from master CPU) */InitSlaveCPU(void){
volatile Uint 16 i;

nfi/* Set Slave SH reset status in Slave SH */while((*SMPC_SF & 0x01) == 0x01);*SMPC_SF = 1;/* — SMPC StatusFlag SET */*SMPC_COM = SMPC_SSHOFF;/* — Slave SH OFF SET */while((*SMPC_SF & 0x01 == 0x01);
for(i = 0; i < 10; i++);/* slave RESET assert length */SETSINT(0x94,(void *)&SlaveCPUmain);/* Set Entry Function *//* Release reset status of Slave SH */*SMPC_SF = 1;/* — SMPC Status Flag SET */*SMPC_COM = SMPC_SSHON;/* — Slave SH ON SET */while((*SMPC_SF & 0x01) == 0x01);

Co

}

SE

GA

void /* Slave CPU entry function (FRT Input Capture Polling) */SlaveCPUmain(void){/* Wait until SlaveCommand is set *//* then call function for SlaveCommand */set_imask(0xf);*IPRA = 0x0000;/* Disable IPRA interrupt */*IPRB = 0x0000;/* Disable IPRB interrupt */*TIER = 0x01;/* Disable TIER FRT Input Capture interrupt */while(1){/* Use “FRT InputCaptureFlag” Polling for wait command from Master */if((*FTCSR & 0x80) == 0x80){*FTCSR = 0x00;/* FTCSR clear *//* Execute function requested from master CPU */(*(void(*)(void))*(void**)((Uint32)&SlaveCommand+0x20000000))();
SlaveCommand = (void*)0;/* RESET request code */
}
}
}

8.2

Function Execution Request from Master CPU to Slave CPU

extern void SlaveFunction(void);
SlaveCommand = SlaveFunction;*(Uint16 *)0x21000000 = 0xffff;

6/* FRT Input Capture for Slave */

nti
al

Virtual CD Tool (September 27, 1994 Version)
This document provides details about the virtual CD tool 9/27/94.

Note that to use the virtual CD, virtual internal CD Board ROM version 3.1 must be
replaced with version 3.2. Also note that the script syntax changed when the
VCDPRE.EXE was upgraded from version 1.xx to version 2.xx.

de1. Virtual CD interface board EPROM (version 3.2)
This version corrects a fault that prevented CD-DA data on the virtual CD frombeing played in multi-player mode.
2. VCDEMU.EXE (version 1.70)
This version implements multi-index and scan play. Scan play is valid only inreal-time emulation mode.

Note:

nfi

The current version does not support file interleaving during direct DOS fileaccess.
To operate VCDEMU.EXE version 1.70, you must upgrade the ROM on the virtual CD
board to version 3.2.

Co

3. VCDPRE.EXE, VCDBUILD.EXE (version 2.13)
Modifications from version 2.11
• The directory record is always located at the beginning of a sector when thenumber of files is large and the directory file extends over multiple sectors.
• Processing is interrupted if the same file name exists.
[Restriction]
The total number of files that are currently operating is only a little more than 500. Although thespecification allows up to 1300 files to be executed as options when XMS is used, this specification has not been announced due to a bug that was found.

GA

Furthermore, an urgent request to support 2000 or more files has been made.
Note:

In version 2.xx, the syntax of the script file is different from the syntax used in version
1.xx. Users of version 1.xx must change the script file. For details, refer to the syntax initem 7, EXSAMPLE.SCR.

SE

4. VCDUTL.EXE (version 1.00)
5. VCDMKTOC.EXE (version 1.20)
6. SWAP.EXE (version 1.00)
SWAP.EXE is an endian conversion program for CD-DA data.
7. EXSAMPLE.SCR
EXSAMPLE.SCR is an example of new script file for VCDPRE version 2.xx. Referto this example during script modification.

SEGA Saturn Dual CPU User's Guide

7