SEGMENT

Supported by Ginmake 1.61

[SEGMENT,<mem_type>,<name>,<symbol_name>{,<checksum_name>,<checksum_type>}]

Defines segments that should be used by the page table and address assignment.

Segment definitions must precede the page table (PAGTBL or PAGETBLv2). Additionally, the definitions must precede the checksum locations.

Parameter Description

<mem_type> Describes the type of memory. One of: nvm: Non volatile memory (i.e. Calibration memory – options/maps). ram: Parameter memory (e.g. parameters, parameter tables). rom: Readonly memory (e.g. ECU header at DF00).
Name of the segment. There should be a #define that equates to its address that is used during page table processing. e.g. EEROM, RAMBS etc.
<symbol_name> Name of the symbol used for the storage attribute to in the C source code. For ASM compilations, this field is for segment lookups e.g. EEROM. The symbol name is case insensitive for historical reasons. e.g. idata, near (legacy names from X25 code). uint16_t near option_variable; // [Option X, …] This may use a #define that is not visible to ginmake code: e.g. #ifndef GINMAKE #define GXGRAM #endif uint16_t GXGRAM option_variable; // [Option X, …]
<checksum_name> Name of region checksum variable. Optional.
<checksum_type> Type of region checksum. Possible values: additive crc16 next_region [default] none

Defaults

Unless specified, segments are defined by default that are equivalent to the following:

1// [SEGMENT,ram,RAMBS,idata]
2// [SEGMENT,nvm,EEROM,near]
3// [SEGMENT,ram,ROMBS,bdata]

Tip

For unused pages in the page table, you can create an unused area:

// [SEGMENT,rom,NOT_USED,__not_used]

The page table file should define the physical addresses of the various segments using #define statements.

e.g.

1#define RAMBS 0x2000
2#define EEROM 0x3000
3#define ROMBS 0x8000
 1const uint16_t near wpagetbl[32] = {
 2RAMBS, // $00 Parameters start here (0x2000)
 3RAMBS + 0x100, // $01
 4RAMBS + 0x200, // $02
 5RAMBS + 0x300, // $03
 6RAMBS + 0x400, // $04
 7RAMBS + 0x500, // $05
 8RAMBS + 0x600, // $06
 9RAMBS + 0x700, // $07 Parameters end here (0x27FF)
10RAMBS + 0x800, // $08
11RAMBS + 0x900, // $09
12RAMBS + 0xA00, // $0A
13RAMBS + 0xB00, // $0B
14RAMBS + 0xC00, // $0C
15RAMBS + 0xD00, // $0D
16EEROM, // $0E Options start here (0x3000)
17EEROM + 0x100, // $0F
18EEROM + 0x200, // $10
19EEROM + 0x300, // $11
20EEROM + 0x400, // $12
21// etc..

ASM Segments

In ASM code, the page table is similar to that in C compilation. In ginmake versions prior to 2.07.00, it was not possible to define custom segments that were larger than a single page and additionally all EEROM based sections would be merged into a single Region in the GIN file.

The situation has now changed in 2.07.00 and [SEGMENT] definitions are handled.

There are defaults applied in the absence of any SEGMENT definitions:

If the EQU name starts with EEROM then interpreted as NVM. Checksums will be set to ‘InNextRegion’ until chkloc or crcloc is seen.

ROMBS will be a ROM section and must start at page 0x1F.

Anything else will be RAM by default unless a SEGMENT definition overrides that.

e.g.

1;[LSB_FIRST][SEGMENT,nvm,COPROPT2,COPROPT2,,none]
2COPROPT2 EQU $7800
3ifdef __GINMAKE__
4segment 'COPROPT2'
5endif
6// data in segment 'COPROPT2'

pagetbl.asm entries parse the labels and discard the value after the ‘+’. It is expected that entries are contiguous for a given segment name.