General Notice When using this document, keep the following in mind: ntial 1. This document is confidential. By accepting this document you acknowledge that you are bound by the terms set forth in the non-disclosure and confidentiality agreement signed separately and /in the possession of SEGA. If you have not signed such a non-disclosure agreement, please contact SEGA immediately and return this document to SEGA. 2. This document may include technical inaccuracies or typographical errors. Changes are periodi- cally made to the information herein; these changes will be incorporated in new versions of the program(s) described in this document at any time. de document. SEGA may make improvements and/or changes in the product(s) and/or the 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 technical information about SEGA products must be made to your authorized SEGA Technical Services representative. nfi 4. No license is granted by implication or otherwise under any patents, copyrights, trademarks, or other intellectual property rights of SEGA Enterprises, Ltd., SEGA of America, Inc., or any third party. describe herein. Co 5. Software, circuitry, and other examples described herein are meant merely to indicate the character- istics 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 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 prod- GA uct/program in this document is not intended to state or simply that you can use only SEGA’s licensed 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. NOTE: A reader's comment/correction form is provided with this document. Please address comments to : SE 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. (6/27/95- 002) TM ntial de nfi Co GA SEGA Saturn Dual CPU User's Guide SE Doc. # ST-202-R1-120994 © 1994 SEGA. All Rights Reserved. READER CORRECTION/COMMENT SHEET Keep us updated! nti If you should come across any incorrect or outdated information while reading through the attached document, or come up with any questions or comments, please let us know so that we can make the al required 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: Your Name Phone Document number Document name Corrections: Chpt. pg. # ST-202-R1-120994 SEGA Saturn Dual CPU User's Guide Correction de Date nfi Co GA Questions/comments: SE 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 Update History Date August 5, 1994 September 28, 1994 December 9, 1994 Version 1.0 1.1 1.2 nti Update History Correction of typographical errors in address values for 2.2 EVA board settings al Corrected translated error on page 5. Address 28000000H under section 6.1 was changed to 21800000H. de nfi Co GA SE Contents 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 ntial 2.1 E7000 ICE Settings ............................................... 2 2.2 EVA Board Settings ............................................... 2 3.0 Clock Changes .................................................................. 2 4.1 Program Sharing ................................................... 3 de 4.0 Programming ..................................................................... 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 nfi 5.1 FRT Input Capture Interrupt ................................... 4 5.2 Polling of the FRT Input Capture Flag ................... 4 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 Co 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 Virtual CD Tool ........................................................................... 7 GA SE 1.0 Dual CPU Configuration in Sega Saturn 1.1 Complete Shared Mode (Memory Sharing) nti 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 reset al are exactly the same as those of the master CPU. However, identification of the master and slave CPUs is performed in the boot ROM because each CPU must be initialized separately. When the slave and master CPUs compete for external access, one of the CPUs is forced to wait for access and execution speed decreases. 1.2 de Communication by FRT Input Capture Signal 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 mas- nfi ter CPU, write 16-bit data to address 21800000H. Co GA SE SEGA Saturn Dual CPU User's Guide 1 2.0 Settings for Debugging Environment 2.1 E7000 ICE Settings MODE command. nti To use the E7000 ICE in the slave CPU, slave mode must be specified with the ICE Setting Procedure :mode;c [Return] E7000 MODE(MD5-0)=xx? 2E [Return] al MODE SET (C:CONFIGURATION/U:USER/M:MASTER-SLAVE)=X? C [Return] CONFIGURATION WRITE OK?(Y/N)? Y [Return] 2.2 EVA Board Settings de To use the EVA board in the slave CPU, the following settings are required: 1. Release the slave CPU reset in the master CPU emulator. Release Procedure :m 2010001f:b [Return] 2010001f xx 20100020 xx ? 02 [Return] ? . [Return] nfi 2. The EVA board in the slave CPU is started. Co 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. 3.0 Clock Change GA 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. SE 2 4.0 Programming 4.1 Program Sharing programs placed in internal RAM are not shared.) nti Because the slave and master CPUs share all external devices, either CPU can ex- ecute an execution file from any location. (If the cache is used as internal RAM, 4.2 Stack Variables and Static and Global Variables al Re-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). How- ever, if both CPUs execute programs that rewrite static or global variables, special attention must be paid to the execution sequence and to concurrent execution in each CPU. 4.3 Slave CPU Initialization de 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 4.4 nfi 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 The boot ROM initializes the slave CPU as follows: Co 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). GA SE SEGA Saturn Dual CPU User's Guide 3 5.0 Communication from Master CPU to Slave CPU Bidirectional communication is necessary for coordinating operation between the 5.1 nti master 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 al During boot ROM initialization, the FRT Input Capture interrupt is set for the slave CPU. To set interrupt processing from the master CPU, use the application initial- ization routine to register the interrupt processing routine to interrupt vector 64H of the slave CPU. (When the interrupt processing routine is registered from the master PCU, the interrupt vector is 164H.) 5.2 de 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. Polling of the FRT Input Capture Flag When the SH CPU accepts the FRT Input Capture signal, it sets a flag to an internal nfi register in the FRT unit. The SH CPU then monitors change in the flag during pro- cessing 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, be sure to disable the FRT Input Capture interrupt in the application initialization routine. (Set 01H to TIER.) Co GA SE 4 6.0 Communication from Slave CPU to Master CPU In addition to providing communication methods from the master CPU to the slave communication from the slave CPU to the master CPU. nti CPU, the Sega Saturn also provides all of the same communication methods for 6.1 FRT Input Capture Interrupt al During boot ROM initialization, the FRT Input Capture interrupt is set for the mas- ter 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. To issue this interrupt from the slave CPU, write 16-bit data to address 21800000H. 6.2 de The slave CPU then starts the interrupt processing that was previously registered. Polling of the FRT Input Capture Flag When the SH CPU accepts the FRT Input Capture signal, it sets a flag to an internal register in the FRT unit. The SH CPU then monitors change in the flag during pro- routine. nfi cessing 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, be sure to disable the FRT Input Capture interrupt in the application initialization 7.0 Co Data Transfer Between Master and Slave CPUs 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 the data must either perform a cache-through read or read the data after the cache of the target area is invalidated. 7.1 GA 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 To invalidate the cache, the CPU writes 0 by 16-bit access to the address obtained SE 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 The following sections shows program examples that use the slave CPU (when the FRT Input Capture Flag is polled.) 8.1 Slave CPU Initialization ntial The following examples show a program that initializes the slave CPU and an execu- tion entry function of the slave CPU. void /* Initialize/start slave CPU (from master CPU) */ InitSlaveCPU(void) { volatile Uint 16 i; while((*SMPC_SF & 0x01) == 0x01); de /* Set Slave SH reset status in Slave SH */ *SMPC_SF = 1; *SMPC_COM = SMPC_SSHOFF; /* — SMPC StatusFlag SET */ /* — Slave SH OFF SET */ while((*SMPC_SF & 0x01 == 0x01); for(i = 0; i < 10; i++); /* slave RESET assert length */ } *SMPC_SF = 1; nfi SETSINT(0x94,(void *)&SlaveCPUmain); /* Release reset status of Slave SH */ *SMPC_COM = SMPC_SSHON; /* Set Entry Function */ /* — SMPC Status Flag SET */ /* — Slave SH ON SET */ while((*SMPC_SF & 0x01) == 0x01); { SlaveCPUmain(void) Co void /* Slave CPU entry function (FRT Input Capture Polling) */ /* 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 */ GA 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 */ } } SE } 8.2 Function Execution Request from Master CPU to Slave CPU extern void SlaveFunction(void); SlaveCommand = SlaveFunction; *(Uint16 *)0x21000000 = 0xffff; /* FRT Input Capture for Slave */ 6 Virtual CD Tool (September 27, 1994 Version) VCDPRE.EXE was upgraded from version 1.xx to version 2.xx. nti 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 al replaced with version 3.2. Also note that the script syntax changed when the 1. Virtual CD interface board EPROM (version 3.2) This version corrects a fault that prevented CD-DA data on the virtual CD from being played in multi-player mode. 2. VCDEMU.EXE (version 1.70) de This version implements multi-index and scan play. Scan play is valid only in real-time emulation mode. The current version does not support file interleaving during direct DOS file access. Note: nfi To operate VCDEMU.EXE version 1.70, you must upgrade the ROM on the virtual CD board to version 3.2. 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 the [Restriction] Co number of files is large and the directory file extends over multiple sectors. • Processing is interrupted if the same file name exists. The total number of files that are currently operating is only a little more than 500. Although the specification allows up to 1300 files to be executed as options when XMS is used, this specifica- tion has not been announced due to a bug that was found. Furthermore, an urgent request to support 2000 or more files has been made. GA 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 in item 7, EXSAMPLE.SCR. 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. SE 7. EXSAMPLE.SCR EXSAMPLE.SCR is an example of new script file for VCDPRE version 2.xx. Refer to this example during script modification. SEGA Saturn Dual CPU User's Guide 7