GBDK 2020 Docs  4.0.6
API Documentation for GBDK 2020
far_ptr.h
Go to the documentation of this file.
1 
13 #ifndef __FAR_PTR_H_INCLUDE
14 #define __FAR_PTR_H_INCLUDE
15 
16 #include <types.h>
17 #include <stdint.h>
18 
25 #define TO_FAR_PTR(ofs, seg) (((FAR_PTR)seg << 16) | (FAR_PTR)ofs)
26 
32 #define FAR_SEG(ptr) (((union __far_ptr *)&ptr)->segofs.seg)
33 
39 #define FAR_OFS(ptr) (((union __far_ptr *)&ptr)->segofs.ofs)
40 
41 #define FAR_FUNC(ptr, typ) ((typ)(((union __far_ptr *)&ptr)->segfn.fn))
42 
65 #define FAR_CALL(ptr, typ, ...) (__call_banked_ptr=ptr,((typ)(&__call__banked))(__VA_ARGS__))
66 
69 typedef uint32_t FAR_PTR;
70 
73 union __far_ptr {
75  struct {
76  void * ofs;
78  } segofs;
79  struct {
80  void (*fn)();
81  uint16_t seg;
82  } segfn;
83 };
84 
85 extern volatile FAR_PTR __call_banked_ptr;
86 extern volatile void * __call_banked_addr;
87 extern volatile uint8_t __call_banked_bank;
88 
90 
98 
99 #endif
to_far_ptr
uint32_t to_far_ptr(void *ofs, uint16_t seg) OLDCALL
uint8_t
unsigned char uint8_t
Definition: stdint.h:51
__call_banked_ptr
volatile FAR_PTR __call_banked_ptr
uint32_t
unsigned long int uint32_t
Definition: stdint.h:53
__far_ptr::ofs
void * ofs
Definition: far_ptr.h:76
__far_ptr::segfn
struct __far_ptr::@1 segfn
__call_banked_addr
volatile void * __call_banked_addr
uint16_t
unsigned short int uint16_t
Definition: stdint.h:52
stdint.h
OLDCALL
#define OLDCALL
Definition: types.h:19
__far_ptr::fn
void(* fn)()
Definition: far_ptr.h:80
__far_ptr::seg
uint16_t seg
Definition: far_ptr.h:77
__far_ptr
Definition: far_ptr.h:73
__call_banked_bank
volatile uint8_t __call_banked_bank
__far_ptr::ptr
FAR_PTR ptr
Definition: far_ptr.h:74
__far_ptr::segofs
struct __far_ptr::@0 segofs
__call__banked
void __call__banked()
FAR_PTR
uint32_t FAR_PTR
Definition: far_ptr.h:69