libnds
Data Structures | Macros
tlf.h File Reference

TLF (Teak Loadable Format) description and helpers. More...

#include <stdint.h>

Data Structures

struct  tlf_header
 TLF file header. More...
 
struct  tlf_section_header
 TLF section header description. More...
 

Macros

#define TLF_MAGIC   0x30464C54
 Magic value of the TLF header file. Same as 'TLF0'.
 
#define TLF_SEGMENT_CODE   0
 The section contains code.
 
#define TLF_SEGMENT_DATA   1
 The section contains data.
 

Detailed Description

TLF (Teak Loadable Format) description and helpers.

TLF is a format designed to hold executable files for the Teak DSP of the DSi. It is a simplified version of the CDC/DSP1 format.

General structure of the file:

+======================+
| TLF header           | It specifies the number of sections in the file.
+======================+
| TLF section header 0 | As many section headers as sections.
+----------------------+
| TLF section header 1 |
+----------------------+
| TLF section header 2 |
+======================+
| Section data 0       | Data of each section, one after the other.
+----------------------+
| Section data 1       |
+----------------------+
| Section data 2       |
+======================+

TLF header: General information about the file.

+--------------------+-------------+--------------------------------+
| Field              | Type        | Notes                          |
+====================+=============+================================+
| Magic              | uint32_t    | 0x30464C54 == 'TLF0'           |
+--------------------+-------------+--------------------------------+
| Version            | uint8_t     | Current version: 0             |
+--------------------+-------------+--------------------------------+
| Number of sections | uint8_t     |                                |
+--------------------+-------------+--------------------------------+
| Padding            | uint8_t * 2 | Unused, set to zero.           |
+====================+=============+================================+

TLF section header: Saved right after the TLF header. This is repeated for all sections stored in the file.

+====================+=============+================================+
| Address            | uint16_t    | As seen by the DSP (in words). |
+--------------------+-------------+--------------------------------+
| Size (in bytes)    | uint16_t    |                                |
+--------------------+-------------+--------------------------------+
| Section type       | uint8_t     | 0 = code, 1 = data.            |
+--------------------+-------------+--------------------------------+
| Padding            | uint8_t * 3 | Unused, set to zero.           |
+--------------------+-------------+--------------------------------+
| Data offset        | uint32_t    | Offset to the section data     |
|                    |             | from the start of the file.    |
+====================+=============+================================+

Section data: The data of the sections is stored right after the array of TLF section headers.