# TCM: Overview

TCM is an abbreviation for "Tightly Coupled Memory." It is high-speed memory attached directly to the ARM9 core. Since this memory is not connected to the ARM9 bus, it is possible for the ARM9 to perform process using TCM, even in DMA.

There are two types of TCM: Instruction TCM (ITCM) and Data TCM (DTCM). ITCM has 32 kilobytes of space, while DTCM has 16 kilobytes. ITCM can store instructions and data. DTCM can store data, but cannot store instructions.

## Enabling and Disabling

ITCM and DTCM can be enabled and disabled with the following functions:

`OS_EnableITCM` enables ITCM.
`OS_DisableITCM` disables ITCM.
`OS_EnableDTCM` enables DTCM.
`OS_DisableDTCM` disables DTCM.

## Mapping

ITCM can be mapped to an address that is a multiple of 32 KB, while DTCM can be mapped to an address that is 16 KB.

These will be placed at the following addresses.

TCM Type | Size | Usage | Address
--- | --- | --- | ---
ITCM | 32KB | Instruction Code / Data | 0x01FF8000 - 0x01FFFFFF
DTCM | 16KB | Data | 0x027E0000 - 0x027E3FFF (for NITRO ROM) (NOTE 1) 0x02FE0000 - 0x02FE3FFF (for HYBRID / LIMITED ROM) (NOTE 2)

(NOTE 1) DTCM starts at `0x027E000` for a NITRO ROM. This is regardless of whether the NITRO ROM is run on NITRO hardware or TWL hardware.

(NOTE 2) DTCM starts at `0x02FE000` for a HYBRID ROM or a LIMITED ROM. This is obvious when running in TWL mode, but also applies to a HYBRID ROM that is running in NITRO mode, regardless of the hardware.

Note that DTCM addresses thus depend upon the ROM type instead of the operating mode.

### Functions to Get ITCM Addresses

In ITCM, `OS_GetITCMAddress()` is prepared as a function to get the `HW_ITCM` constant. The `HW_ITCM` constant is defined at the default ITCM starting address: `0x01FF8000`.

### Functions to Get DTCM Addresses

For DTCM, `OS_GetDTCMAddress()` can be used to get the mapped address. `OS_SetDTCMAddress()` sets the address. The stack region and each type of hook vector are mapped for the DTCM. The program may become unstable if the mapping locations are changed while the program is running. It is therefore recommended that you avoid making frequent changes with one program.

## TCM–Related CP15 Settings

The ITCM and DTCM configurations depend on the configuration of the internal register of co-processor 15 (`CP15`). TWL-SDK provides functions that directly access this register. ITCM and DTCM both have Set and Get functions that take arguments to be provided to the register (or loaded from the register). However, in order to use them (particularly the Set functions), you must have a firm understanding of their operating principles.

`OS_SetITCMParam` sets the ITCM parameters.
`OS_GetITCMParam` gets the ITCM parameters.
`OS_SetDTCMParam` sets the DTCM parameters.
`OS_GetDTCMParam` gets the DTCM parameters.

## See Also

`An Overview of OS Functions (TCM)
`

## Revision History

2007/11/28 Added descriptions related to TWL mode.
2005/04/13 Changed the default DTCM address.
2004/12/14 Revised terminology and word endings.
2004/11/09 Initial version.

CONFIDENTIAL