libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
Memory/Bank Management

Macros

#define ws_iram   __wf_iram
#define ws_sram   __wf_sram
#define ws_rom   __wf_rom
#define ws_far   __far
#define ws_ptr_offset(x)
#define ws_ptr_segment(x)
#define ws_ptr_far(seg, ofs)
#define WS_IRAM_MEM   ((uint8_t ws_iram*) 0x00000000)
#define WS_SRAM_MEM   ((uint8_t ws_sram*) 0x10000000)
#define WS_ROM0_MEM   ((uint8_t __far*) 0x20000000)
#define WS_ROM1_MEM   ((uint8_t __far*) 0x30000000)
#define ws_bank_ram_save(new_bank)
 Switch to a new RAM bank, while preserving the value of the old one.
#define ws_bank_ram_set(new_bank)
 Switch to a new RAM bank.
#define ws_bank_ram_restore   ws_bank_ram_set
#define ws_bank_within_ram(var, ...)
 Switch to the RAM bank containing the specified variable for a code block.
#define ws_bank_with_ram(bank, ...)
 Switch to the specified RAM bank index for a code block.
#define ws_bank_rom0_save(new_bank)
 Switch to a new ROM bank in slot 0, while preserving the value of the old one.
#define ws_bank_rom0_set(new_bank)
 Switch to a new ROM bank in slot 0.
#define ws_bank_rom0_restore   ws_bank_rom0_set
#define ws_bank_within_rom0(var, ...)
 Switch to the ROM0 bank containing the specified variable for a code block.
#define ws_bank_with_rom0(bank, ...)
 Switch to the specified ROM0 bank index for a code block.
#define ws_bank_rom1_save(new_bank)
 Switch to a new ROM bank in slot 1, while preserving the value of the old one.
#define ws_bank_rom1_set(new_bank)
 Switch to a new ROM bank in slot 1.
#define ws_bank_rom1_restore   ws_bank_rom1_set
#define ws_bank_within_rom1(var, ...)
 Switch to the ROM1 bank containing the specified variable for a code block.
#define ws_bank_with_rom1(bank, ...)
 Switch to the specified ROM1 bank index for a code block.
#define ws_bank_roml_save(new_bank)
 Switch to a new ROM bank in the linear slot, while preserving the value of the old one.
#define ws_bank_roml_set(new_bank)
 Switch to a new ROM bank in the linear slot.
#define ws_bank_roml_restore   ws_bank_roml_set
#define ws_bank_within_roml(var, ...)
 Switch to the ROML bank containing the specified variable for a code block.
#define ws_bank_with_roml(bank, ...)
 Switch to the specified ROML bank index for a code block.

Typedefs

typedef uint8_t ws_bank_t
 Type indicating a bank index.

Functions

static uint32_t ws_ptr_to_linear (const void ws_far *src)
static const void ws_farws_ptr_from_linear (uint32_t src)

Detailed Description

Macro Definition Documentation

◆ ws_bank_ram_restore

#define ws_bank_ram_restore   ws_bank_ram_set

Definition at line 194 of file memory.h.

◆ ws_bank_ram_save

#define ws_bank_ram_save ( new_bank)
Value:
_ws_bank_save(_ws_bank_ram_port, (new_bank))

Switch to a new RAM bank, while preserving the value of the old one.

Parameters
new_bankNew RAM bank.
Returns
uint8_t The previous RAM bank.

Definition at line 186 of file memory.h.

◆ ws_bank_ram_set

#define ws_bank_ram_set ( new_bank)
Value:
_ws_bank_set(_ws_bank_ram_port, (new_bank))

Switch to a new RAM bank.

Parameters
new_bankNew RAM bank.

Definition at line 193 of file memory.h.

◆ ws_bank_rom0_restore

#define ws_bank_rom0_restore   ws_bank_rom0_set

Definition at line 241 of file memory.h.

◆ ws_bank_rom0_save

#define ws_bank_rom0_save ( new_bank)
Value:
_ws_bank_save(_ws_bank_rom0_port, (new_bank))

Switch to a new ROM bank in slot 0, while preserving the value of the old one.

Parameters
new_bankNew ROM bank.
Returns
uint8_t The previous ROM bank.

Definition at line 233 of file memory.h.

◆ ws_bank_rom0_set

#define ws_bank_rom0_set ( new_bank)
Value:
_ws_bank_set(_ws_bank_rom0_port, (new_bank))

Switch to a new ROM bank in slot 0.

Parameters
new_bankNew ROM bank.

Definition at line 240 of file memory.h.

◆ ws_bank_rom1_restore

#define ws_bank_rom1_restore   ws_bank_rom1_set

Definition at line 288 of file memory.h.

◆ ws_bank_rom1_save

#define ws_bank_rom1_save ( new_bank)
Value:
_ws_bank_save(_ws_bank_rom1_port, (new_bank))

Switch to a new ROM bank in slot 1, while preserving the value of the old one.

Parameters
new_bankNew ROM bank.
Returns
uint8_t The previous ROM bank.

Definition at line 280 of file memory.h.

◆ ws_bank_rom1_set

#define ws_bank_rom1_set ( new_bank)
Value:
_ws_bank_set(_ws_bank_rom1_port, (new_bank))

Switch to a new ROM bank in slot 1.

Parameters
new_bankNew ROM bank.

Definition at line 287 of file memory.h.

◆ ws_bank_roml_restore

#define ws_bank_roml_restore   ws_bank_roml_set

Definition at line 335 of file memory.h.

◆ ws_bank_roml_save

#define ws_bank_roml_save ( new_bank)
Value:
_ws_bank_save(_ws_bank_roml_port, (new_bank))

Switch to a new ROM bank in the linear slot, while preserving the value of the old one.

Parameters
new_bankNew ROM bank.
Returns
uint8_t The previous ROM bank.

Definition at line 327 of file memory.h.

◆ ws_bank_roml_set

#define ws_bank_roml_set ( new_bank)
Value:
_ws_bank_set(_ws_bank_roml_port, (new_bank))

Switch to a new ROM bank in the linear slot.

Parameters
new_bankNew ROM bank.

Definition at line 334 of file memory.h.

◆ ws_bank_with_ram

#define ws_bank_with_ram ( bank,
... )
Value:
ws_bank_with_(bank, ram, WF_MACRO_CONCAT(_wf_bank_, __COUNTER__), __VA_ARGS__)

Switch to the specified RAM bank index for a code block.

This is equivalent to:

ws_bank_t previous_bank = ws_bank_ram_save(bank);
// ...
ws_bank_ram_restore(previous_bank);
#define ws_bank_ram_restore
Definition memory.h:194
uint8_t ws_bank_t
Type indicating a bank index.
Definition memory.h:139
#define ws_bank_ram_save(new_bank)
Switch to a new RAM bank, while preserving the value of the old one.
Definition memory.h:186
Parameters
bankThe bank index.
...The code block to run with the specified value in view.

Definition at line 225 of file memory.h.

◆ ws_bank_with_rom0

#define ws_bank_with_rom0 ( bank,
... )
Value:
ws_bank_within_(bank, rom0, WF_MACRO_CONCAT(_wf_bank_, __COUNTER__), __VA_ARGS__)

Switch to the specified ROM0 bank index for a code block.

This is equivalent to:

ws_bank_t previous_bank = ws_bank_ram_save(bank);
// ...
ws_bank_ram_restore(previous_bank);
Parameters
bankThe bank index.
...The code block to run with the specified value in view.

Definition at line 272 of file memory.h.

◆ ws_bank_with_rom1

#define ws_bank_with_rom1 ( bank,
... )
Value:
ws_bank_with_(bank, rom1, WF_MACRO_CONCAT(_wf_bank_, __COUNTER__), __VA_ARGS__)

Switch to the specified ROM1 bank index for a code block.

This is equivalent to:

ws_bank_t previous_bank = ws_bank_ram_save(bank);
// ...
ws_bank_ram_restore(previous_bank);
Parameters
bankThe bank index.
...The code block to run with the specified value in view.

Definition at line 319 of file memory.h.

◆ ws_bank_with_roml

#define ws_bank_with_roml ( bank,
... )
Value:
ws_bank_with_(bank, roml, WF_MACRO_CONCAT(_wf_bank_, __COUNTER__), __VA_ARGS__)

Switch to the specified ROML bank index for a code block.

This is equivalent to:

ws_bank_t previous_bank = ws_bank_ram_save(bank);
// ...
ws_bank_ram_restore(previous_bank);
Parameters
bankThe bank index.
...The code block to run with the specified value in view.

Definition at line 366 of file memory.h.

◆ ws_bank_within_ram

#define ws_bank_within_ram ( var,
... )
Value:
ws_bank_within_(var, ram WF_MACRO_CONCAT(_wf_bank_, __COUNTER__), __VA_ARGS__)

Switch to the RAM bank containing the specified variable for a code block.

This is equivalent to:

extern const void __bank_var;
ws_bank_t previous_bank = ws_bank_ram_save(&__bank_var);
// ...
ws_bank_ram_restore(previous_bank);
Parameters
varThe variable name.
...The code block to run with the specified value in view.

Definition at line 210 of file memory.h.

◆ ws_bank_within_rom0

#define ws_bank_within_rom0 ( var,
... )
Value:
ws_bank_within_(var, rom0, WF_MACRO_CONCAT(_wf_bank_, __COUNTER__), __VA_ARGS__)

Switch to the ROM0 bank containing the specified variable for a code block.

This is equivalent to:

extern const void __bank_var;
ws_bank_t previous_bank = ws_bank_ram_save(&__bank_var);
// ...
ws_bank_ram_restore(previous_bank);
Parameters
varThe variable name.
...The code block to run with the specified value in view.

Definition at line 257 of file memory.h.

◆ ws_bank_within_rom1

#define ws_bank_within_rom1 ( var,
... )
Value:
ws_bank_within_(var, rom1, WF_MACRO_CONCAT(_wf_bank_, __COUNTER__), __VA_ARGS__)

Switch to the ROM1 bank containing the specified variable for a code block.

This is equivalent to:

extern const void __bank_var;
ws_bank_t previous_bank = ws_bank_ram_save(&__bank_var);
// ...
ws_bank_ram_restore(previous_bank);
Parameters
varThe variable name.
...The code block to run with the specified value in view.

Definition at line 304 of file memory.h.

◆ ws_bank_within_roml

#define ws_bank_within_roml ( var,
... )
Value:
ws_bank_within_(var, roml, WF_MACRO_CONCAT(_wf_bank_, __COUNTER__), __VA_ARGS__)

Switch to the ROML bank containing the specified variable for a code block.

This is equivalent to:

extern const void __bank_var;
ws_bank_t previous_bank = ws_bank_ram_save(&__bank_var);
// ...
ws_bank_ram_restore(previous_bank);
Parameters
varThe variable name.
...The code block to run with the specified value in view.

Definition at line 351 of file memory.h.

◆ ws_far

#define ws_far   __far

Address space for all far pointers.

Definition at line 67 of file memory.h.

◆ ws_iram

#define ws_iram   __wf_iram

Address space for pointers to internal RAM.

This is always a near pointer, either DS-indexed or SS-indexed.

Definition at line 46 of file memory.h.

◆ WS_IRAM_MEM

#define WS_IRAM_MEM   ((uint8_t ws_iram*) 0x00000000)

Pointer to internal RAM memory.

Definition at line 101 of file memory.h.

◆ ws_ptr_far

#define ws_ptr_far ( seg,
ofs )
Value:
MK_FP(seg, ofs)

Create a far pointer from a segment and offset value.

Definition at line 82 of file memory.h.

◆ ws_ptr_offset

#define ws_ptr_offset ( x)
Value:
((uint16_t) (x))

Extract the 16-bit offset of any (near and/or far) pointer.

Definition at line 72 of file memory.h.

◆ ws_ptr_segment

#define ws_ptr_segment ( x)
Value:
FP_SEG(x)

Extract the 16-bit segment of a far pointer.

Definition at line 77 of file memory.h.

◆ ws_rom

#define ws_rom   __wf_rom

Address space for pointers to read-only data.

As this can be a far or near pointer - some targets store read-only data in the data segment - this should not be used to mark pointers to cartridge ROM.

Definition at line 62 of file memory.h.

◆ WS_ROM0_MEM

#define WS_ROM0_MEM   ((uint8_t __far*) 0x20000000)

Pointer to the on-cartridge ROM0 bank.

Definition at line 109 of file memory.h.

◆ WS_ROM1_MEM

#define WS_ROM1_MEM   ((uint8_t __far*) 0x30000000)

Pointer to the on-cartridge ROM1 bank.

Definition at line 113 of file memory.h.

◆ ws_sram

#define ws_sram   __wf_sram

Address space for pointers to cartridge SRAM.

This can be a far or near pointer, depending on target.

Definition at line 53 of file memory.h.

◆ WS_SRAM_MEM

#define WS_SRAM_MEM   ((uint8_t ws_sram*) 0x10000000)

Pointer to the on-cartridge SRAM bank.

Definition at line 105 of file memory.h.

Typedef Documentation

◆ ws_bank_t

typedef uint8_t ws_bank_t

Type indicating a bank index.

Definition at line 139 of file memory.h.

Function Documentation

◆ ws_ptr_from_linear()

const void ws_far * ws_ptr_from_linear ( uint32_t src)
inlinestatic

Convert a 20-bit linear address location to a far pointer.

Definition at line 94 of file memory.h.

◆ ws_ptr_to_linear()

uint32_t ws_ptr_to_linear ( const void ws_far * src)
inlinestatic

Convert a far pointer to a 20-bit linear address location.

Definition at line 87 of file memory.h.