Japanese
INDEXBack (STN-28)
STN-28 Attachments

SEGASATURN

How to use dual CPU

Ver1.1

February 10, 1995


table of contents

  1. Introduction
  2. Overview of dual CPU in Sega Saturn
  3. About setting up dual CPU development equipment
  4. About programming using slave CPU
  5. Regarding communication between master CPU/slave CPU
  6. About data transfer between master and slave
  7. Program using slave CPU
  8. Debugging method using one IBM-PC (including compatible machines)

■1. Introduction

This manual describes how to use two CPUs (SH2) installed in the Sega Saturn. When the Sega Saturn starts up, it runs only on the main CPU. To start a slave CPU, you must follow the steps described in this manual.
This manual assumes that you have a general knowledge of Sega Saturn hardware and software. Please have the following manual ready before reading.


■2. Overview of dual CPU in Sega Saturn

I will explain the outline of the dual CPU in Sega Saturn.

●2.1 Fully shared mode (memory sharing)

The Sega Saturn slave CPU shares all external devices with the master CPU. The programs executed by the slave CPU and the reset vector acquired at reset are completely the same as those of the master CPU.
However, since it is necessary to determine the master CPU and slave CPU within the BOOTROM and initialize each CPU separately, the master/slave determination is performed within the BOOTROM.
When external access conflicts between the master CPU and slave CPU, one of the CPUs is forced to wait for access, resulting in a decrease in execution speed.

●2.2 Communication using free running timer (FRT)

In the Sega Saturn, it is now possible to use the Free Running Timer (FRT) input capture signal of the built-in SH2 module as a means of communication between the master CPU and slave CPU.
Specifically, if you write any 16-bit data to address 21000000H, you can input the FRT input capture signal to the slave CPU, and if you write any 16-bit data to address 21800000H, you can input the FRT input capture signal to the master CPU. Masu.

●2.3 About slave CPU interrupts

Unlike the master CPU, interrupts from the SCU are not set for the slave CPU. Therefore, interrupts are connected from the peripheral module (DCC) that controls this dual CPU.

(1) Interrupts used by slave CPU

(2) About H blank IN interrupt and V blank IN interrupt
In the slave CPU, both the H blank IN interrupt and the V blank IN interrupt are level signal interrupts that accept interrupts during the blank period.
For example, even if V blank IN interrupt processing is started and completed, if the V blank period is still in progress, the interrupt will be started again.
□In order to call the interrupt function only once for each interrupt, measures must be taken on the application side. There are two possible concrete methods:

1. How to wait for end of blank inside interrupt function
Two ways to wait for the blank period to end are to monitor the blank flag in the screen status register of VDP2 and return from the interrupt function when the blank period ends, and to set a timer to the same length as the blank period at the beginning of the interrupt process. One possible method is to confirm that the set time has elapsed and then return from the interrupt function. The former accesses the external address (VDP2), so performance on the master side may deteriorate.

2. How to operate the interrupt mask when returning
One possible method is to manipulate the interrupt mask saved on the stack so that it is not returned during the blank period even after returning from the interrupt function, so that the same interrupt is not accepted.
One possible way to achieve this method is to use timer interrupts, but please note that other interrupts (internal interrupts) should be at a higher level than the H blank IN, V blank IN, and timer interrupts. is needed.


■3. About setting up dual CPU development equipment

This section explains how to set up and debug development equipment with dual CPUs.

●3.1 Dual CPU development method

When developing dual CPUs, connect an E7000 emulator or EVA board to the master and slave sides respectively.

●3.2 How to set up the E7000 emulator

When using E7000 as a slave CPU, you need to set the slave mode using the emulator's MODE command.

    ★Slave side setting method :mode;c (RET)
	    E7000 MODE(MD5-0)=xx? 2E(RET)
	    MODE SET (C:CONFIGURATION/U:USER/M:MASTER-SALVE)=X? C(RET)
	    CONFIGURATION WRITE OK?(Y/N)? Y(RET)
    ★Master side setting E7000 MODE(MD5-0)=xx? 0E(RET)
  

●3.3 How to set up the EVA board

□When using an EVA board for the slave CPU, the following settings are required. 1. Cancellation of reset □Cancel the reset of the slave CPU using the emulator on the master CPU side. ★How to release:m 2010001f;b(RET) 2010001f xx ? 02(RET) 20100020 xx ? _(RET) The EVA board on the slave CPU side will start up with the above settings. 2. Things to check □Check that the EVA board on the slave CPU side is em ct=d. 3. Notes □When using an EVA board on the slave CPU side, the EVA board cannot be operated until the slave CPU is reset.

●3.4 About debugging environment

Depending on the environment used, the following configurations are possible.

1.Developing on a workstation
When developing on a workstation (Sun SPARC series, HP9000/700 series), use an E7000 emulator on both the master and slave sides. (Note: EVA board cannot be used) The software used can operate on any combination of GUISH and LAN host system.

2.Development on IBM-PC compatible machine
When developing on an IBM-PC (including compatible machines), there are two ways to use one: two PC-compatible machines and one PC-compatible machine. When using two units, it is possible to operate the master side and slave side at the same time. Any combination of GUISH and IPI software can be used.
However, in the case of one unit, operations on the master side and slave side are performed by switching windows. ( Chapter 8 explains the development method and limitations on one IBM-PC)


■4. About programming using slave CPU

●4.1 Program coexistence

Since the master CPU and slave CPU share all external devices, both can freely execute a single executable file anywhere.
(If the cache is used as internal RAM, programs placed in internal RAM will not be shared.)

●4.2 Stack variables and stack, global variables

The master CPU and slave CPU have separate stack areas (BOOT ROM settings), so they can execute reentrant functions at the same time. However, when both CPUs execute a program that rewrites static variables or global variables, you need to be careful about the execution order and simultaneous execution on each CPU.

●4.3 Initialization of slave CPU

When the master CPU starts the slave CPU, the master CPU rewrites the execution entry after initialization read by the BOOT ROM (SYS_SETSINT(0x94, EntryFunc);), and resets the slave using the SMPC I/F library. It is released by the slave SH2 ON function (PER_SMPC_SSH_ON).

*EntryFunc is the slave entry function

●4.4 Initialization using BOOT ROM (vector, stack)

(1) BOOT ROM initializes the slave CPU as follows
・Vector base register (VBR) = address 6000400H
・Stack pointer (SP) = address 6001000H
・Interrupt initialization = FRT input capture interrupt enabled (64H, level 15)

(2) The vector table for the slave CPU on the work RAM will not be changed by turning ON/OFF the slave SH2.

●4.5 About clock change

When performing a clock change, the slave CPU is moved to the reset state by SMPC, so after performing the clock change, the slave CPU must be activated using the SMPC command (SSH_ON = 02H) or the slave SH2_ON function (PER_SMPC_SSH_ON) of the SMPC I/F library. , you need to restart it.

●4.6 Precautions when using slave CPU

The following contents cannot be executed on the slave CPU side.
・Multiplayer call function cannot be used
・Programs that assume SCU interrupts cannot be used.
・Processing related to acquiring peripherals of the SMPC I/F library is not possible.


■5. Regarding communication between master CPU/slave CPU

This section explains how to communicate between the master CPU and slave CPU.
Reference: “SH7095 Hardware Manual”/11. 16-bit free running timer

●5.1 Communication from master CPU to slave CPU

In order for the master CPU and slave CPU to work together, a means of bidirectional communication is required.

(1) FRT input capture interrupt
The FRT input capture interrupt is set for the slave CPU during initialization in the BOOT ROM. By registering an interrupt routine in interrupt vector 64H of the slave CPU in the application's initialization routine, the processing to be performed when an interrupt occurs can be set from the master CPU.

→The interrupt vector when registering from the master CPU is 164H.

Also, if you want to generate this interrupt from the master CPU, write any 16-bit length data to address 21000000H. This causes the slave CPU to start processing the interrupt registered in advance.

(2) Polling of FRT input capture flag
When the SH2CPU receives an FRT input capture flag, it sets a flag in a register inside the FRT unit, so there is also a way to monitor changes in this flag while in the processing wait state (or synchronization wait state). This method takes less time to accept than when processing interrupts, so it is particularly effective when there is a lot of synchronization or waiting for processing.
□When using this method, the FRT input capture interrupt must be re-disabled in the application's initialization routine.

→TIMER: Set 01H in byte to address FFFFFE10H

●5.2 Communication from slave CPU to master CPU

(1) FRT input capture interrupt
The FRT input capture interrupt is set for the master CPU during initialization in the BOOT ROM. By registering an interrupt routine in interrupt vector 64H of the master CPU in the application's initialization routine, the processing to be performed when an interrupt occurs can be set from the master CPU.
Also, if you want to generate this interrupt from the slave CPU, write any 16-bit length data to address 21800000H. This causes the master CPU to start the pre-registered interrupt processing.

(2) Polling of FRT input capture flag
When the SH2CPU receives an FRT input capture flag, it sets a flag in a register inside the FRT unit, so there is also a way to monitor changes in this flag while in the processing wait state (or synchronization wait state). This method takes less time to accept than when processing interrupts, so it is particularly effective when there is a lot of synchronization or waiting for processing.
□When using this method, the FRT input capture interrupt must be re-disabled in the application's initialization routine.


■6. About data transfer between master and slave

The SH2 cache unit does not have a snoop function. When passing data between a master CPU and a slave CPU, the CPU on the side reading the data must read it using cache-through or after purging the cache of the target area.

Reference: "SH7095 Hardware Manual"/8. Cache

●6.1 Loading cache-through

Cache-through reading is performed by reading from the address that is the target address plus 20000000H (logical OR).

Details: "SCU User's Manual"/ SCU Mapping

●6.2 Cache initialization (purge)

There are two methods to purge cache memory:

(1) Cache purge (full initialization)
Initialization is performed by writing "1" to the CP bit (4th bit) of SH2's CCR (write 10H in bytes to address FFFFFE92H).
After performing this complete initialization, it is necessary to write a value to CCR again to enable the cache.

value to write
:For 4KB cache mode=01H
: For 2KB cache + 2KB RAM = 09H

(2) Purging specific lines
This is done by writing "0" with 16-bit access to the address where 40000000H is added to the target purge. This operation purges the 16-byte area including the target address.


■7. Program using slave CPU

This shows a program that uses a slave CPU. I will explain how to poll the FRT input capture flag.

●7.1 Function to initialize/start slave CPU

Executes the function that initializes and starts the slave CPU on the master CPU.

	volatile Uint8 *SMPC_SF =(Uint8 *)0x20100063; /* SMPC status flag */
	volatile Uint8 *SMPC_COM =(Uint8 *)0x2010001F; /* SMPC command register */
	const Uint8 SMPC_SSHON =0x02; /* SMPC slave SH on command */
	const Uint8 SMPC_SSHOFF =0x03; /* SMPC slave SH off command */
	void InitSlaveCPU(void)
	{
		volatile Uint16 i;
		/* Set SlaveSH reset state */

●7.2 Entry function from main CPU to slave CPU

How to poll the FRT input capture flag

●7.3 Requesting function execution from master CPU to slave CPU


■8. Debugging method using one IBM-PC (including compatible machines)

When debugging a dual CPU by connecting an E7000 PC and an EVA board to one IBM-PC (including compatible machines), there are two methods as follows.

●8.1 Settings and operation method when using only IPI

Open two MS-Windows DOS prompts and run IPI on each window. When explaining the setting procedure, we will assume that the E7000 is connected to the master side and the EVA board is connected to the slave side.

Connection example
Tools used soft IBM interface board
Master side E7000PC IPI.EXE D000:0000H IRQ11
slave side EVA board IPI.EXE D400:0000H IRQ12
★It is assumed that the above settings do not conflict with the settings of other expansion boards.

 (1) PC I/F board mounting address
Mounting address of master side PC I/F board (hereinafter referred to as master side board) and slave side PCI/F board (hereinafter referred to as slave side board) implementation address must be set to a different address.

In the connection example, the master side = D000:0000H and the slave side = D400:0000H.

(2) CONFIG.SYS settings
If you have installed a virtual EMS memory driver in CONFIG.SYS, you will need to change its settings. For the setting method, refer to "IBM-PC Interface User's Manual/p6-p7".
In the connection example, if you want to set the master side board and slave side board memory address range (D0000H to D3FFFH and D4000H to D7FFFH) under the management of the virtual EMS driver, and set the base address of the EMS page frame to E0000H,

DEVICE=C:\WINDOWS\EMM386.EXE RAM /X=D000-D7FF FRAME=E000

 (3) SYSTEM.INI settings
Master side board and slave side board memory address range (D0000H to D3FFFH and D4000H to D7FFFH) Modify SYSTEM.INI to set it under MS-Windows memory management.

In the connection example,
[386Enh]
EMMExclude=D000-D7FF
      

(4) Setting environment variables
Set the environment variables used by the master board and slave board. It is convenient to define this environment variable in AUTOEXEC.BAT in advance. Please be sure to set the mounting addresses of the master side board and slave side board in the environment variables. If not set, two IPIs will use the master board at the same time.

In the connection example,
	   SET SYS1=C:\SYS1,1B,D0 Master side IPI environment variable → E7000PC system needs to be installed in \SYS1               				   
	   SET SYS2=C:\SYS2,1B,D4 Slave side IPI environment variable

Note: If you also use E7000 on the slave side, you need to install the E7000PC system program to \SYS2.

 (5) Starting the master side and slave side boards using IPI
Starting the master side board
 After starting the DOS prompt of the main group of MS-Windows, start IPI as shown below and connect to the E7000PC.

C:\>IPI SYS1(RET)

 Enter "S" or "R" in the E7000 monitor menu to load the E7000PC system program. When the E7000PC prompt ":" is displayed, start the slave side board.

Starting the slave board
 After starting the DOS prompt of the main group of MS-Windows, start the IPI as shown below and connect it to the EVA board.

C:\>IPI SYS2(RET)

 When the EVA board prompt ":" is displayed, start the EVA board by following the steps in "●3.3 How to set up the EVA board".

 ●8.2 Settings and operation method when using GUISH

Two GUISH (graphical user interface software) cannot be started at the same time. It is possible to operate if one side is IPI.
Below are the settings to run IPI and GUISH simultaneously. In explaining the setting procedure, we will use an E7000PC on both the master and slave sides. I will explain it assuming that it is connected.

 ■Connection example
Tools usedSoftware usedIBM interface board (DSW)< /TH>
Address (1~5)Interrupt level (6~7)
Master side E7000PC GUISH.EXE D000:0000H IRQ11
Slave side E7000PC IPI.EXE D400:0000H IRQ12
(The above settings assume that there will be no conflict with other expansion boards.)

(1) Setting the PC I/F board mounting address
The mounting address of the PC I/F connected with GUISH must be set higher than the mounting address of the PC I/F board connected with IPI.
In the connection example, since GUISH is used on the master side, the implementation address D000:0000H is set higher than the implementation address D400:0000H on the slave side.

(2) CONFIG.SYS settings
If you have installed a virtual EMS memory driver in CONFIG.SYS, you will need to change its settings. For the setting method, refer to "IBM-PC Interface User's Manual/p6-p7".
In the connection example, if you want to set the master side board and slave side board memory address range (D0000H to D3FFFH and D4000H to D7FFFH) under the management of the virtual EMS driver, and set the base address of the EMS page frame to E0000H,

DEVICE=C:\WINDOWS\EMM386.EXE RAM /X=D000-D7FF FRAME=E000

 (3) SYSTEM.INI settings
Master side board and slave side board memory address range (D0000H to D3FFFH and D4000H to D7FFFH) Modify SYSTEM.INI to set it under MS-Windows memory management.

In the connection example,
---------------------------------------------	   

[386Enh]
    EMMExclude=D000-D7FF

---------------------------------------------

(4) Setting environment variables
Set the environment variables used by GUISH (master side) and IPI (slave side). It is convenient to define this environment variable in AUTOEXEC.BAT in advance. Please be sure to set the implementation address of the slave board in the environment variables used by IPI.
If not set, GUISH and IPI will use the master board at the same time.

In the connection example, the settings are as follows.

---------------------------------------------

SET GUISHPATH=C:\GUISH GUISH environment variables SET E7000SYS=C:\SYS2,IB,D4 IPI environment variables-------------------------------------- --------------------

(5) About the startup method

  1. Starting the master side (GUISH)

  2. Click the E7000PC icon in the GUISH group of MS-Windows.
    GUISH will start and connect to the E7000PC.
    The E7000 monitor menu will be displayed in the command area of GUISH, so enter "S" or "R" to load the E7000PC system program. When the E7000PC prompt: appears, start the slave side.

  3. Slave side (IPI) startup

  4. After starting the DOS prompt of the main group of MS-Windows, start IPI and connect to the E7000PC as shown below.

    ---------------------------------------------
    
    C:\> IPI(RET)
    
    ---------------------------------------------
    

    In the E7000 monitor menu, enter "S" or "R" to load the E7000PC system program.

that's all
INDEXBack (STN-28)
Copyright SEGA ENTERPRISES, LTD., 1997