GBDK 2020 Docs
4.3.0
API Documentation for GBDK 2020
|
Go to the source code of this file.
Data Structures | |
union | __far_ptr |
Macros | |
#define | TO_FAR_PTR(ofs, seg) (((FAR_PTR)seg << 16) | (FAR_PTR)ofs) |
#define | FAR_SEG(ptr) (((union __far_ptr *)&ptr)->segofs.seg) |
#define | FAR_OFS(ptr) (((union __far_ptr *)&ptr)->segofs.ofs) |
#define | FAR_FUNC(ptr, typ) ((typ)(((union __far_ptr *)&ptr)->segfn.fn)) |
#define | FAR_CALL(ptr, typ, ...) (__call_banked_ptr=ptr,((typ)(&__call__banked))(__VA_ARGS__)) |
Typedefs | |
typedef uint32_t | FAR_PTR |
Functions | |
void | __call__banked (void) |
uint32_t | to_far_ptr (void *ofs, uint16_t seg) |
Variables | |
volatile FAR_PTR | __call_banked_ptr |
volatile void * | __call_banked_addr |
volatile uint8_t | __call_banked_bank |
Far pointers include a segment (bank) selector so they are able to point to addresses (functions or data) outside of the current bank (unlike normal pointers which are not bank-aware).
See the banks_farptr
example project included with gbdk.
Macro to obtain a far pointer at compile-time
ofs | Memory address within the given Segment (Bank) |
seg | Segment (Bank) number |
#define FAR_SEG | ( | ptr | ) | (((union __far_ptr *)&ptr)->segofs.seg) |
Macro to get the Segment (Bank) number of a far pointer
ptr | A far pointer (type FAR_PTR) |
#define FAR_OFS | ( | ptr | ) | (((union __far_ptr *)&ptr)->segofs.ofs) |
Macro to get the Offset (address) of a far pointer
ptr | A far pointer (type FAR_PTR) |
#define FAR_FUNC | ( | ptr, | |
typ | |||
) | ((typ)(((union __far_ptr *)&ptr)->segfn.fn)) |
#define FAR_CALL | ( | ptr, | |
typ, | |||
... | |||
) | (__call_banked_ptr=ptr,((typ)(&__call__banked))(__VA_ARGS__)) |
Macro to call a function at far pointer ptr of type typ
ptr | Far pointer of a function to call (type FAR_PTR) |
typ | Type to cast the function far pointer to. |
... | VA Args list of parameters for the function |
type should match the definition of the function being called. For example:
void __call__banked | ( | void | ) |
Obtain a far pointer at runtime
ofs | Memory address within the given Segment (Bank) |
seg | Segment (Bank) number |
|
extern |
|
extern |
|
extern |