|
GEL
0.99
|
Macros | |
| #define | gel_cursor_at_end(c) ((c).cur_addr >= (c).base_addr + (c).size) |
| #define | gel_cursor_avail(c) ((c).base_addr + (c).size - (c).cur_addr) |
| #define | gel_read_data(c, b, s) { memcpy((b), (c).cur_addr, (s)); (c).cur_addr += (s); } |
| #define | gel_read_u8(c) ((c).cur_addr += 1 , *((u8_t*)((c).cur_addr - 1))) |
| #define | gel_read_s8(c) ((c).cur_addr += 1 , *((s8_t*)((c).cur_addr - 1))) |
| #define | gel_read_u16(c) ((c).cur_addr += 2, ENDIAN2((c).endianness, (*((u16_t*)((c).cur_addr - 2))))) |
| #define | gel_read_s16(c) ((c).cur_addr += 2, ENDIAN2((c).endianness, (*((s16_t*)((c).cur_addr - 2))))) |
| #define | gel_read_u32(c) ((c).cur_addr += 4, ENDIAN4((c).endianness, (*((u32_t*)((c).cur_addr - 4))))) |
| #define | gel_read_s32(c) ((c).cur_addr += 4, ENDIAN4((c).endianness, (*((s32_t*)((c).cur_addr - 4))))) |
| #define | gel_read_vaddr(c) ((c).cur_addr += 4, ENDIAN4((c).endianness, (*((vaddr_t*)((c).cur_addr - 4))))) |
| #define | gel_read_raddr(c) ((c).cur_addr += 4, ENDIAN4((c).endianness, (*((raddr_t*)((c).cur_addr - 4))))) |
| #define | gel_write_u8(c, v) {*((u8_t*)((c).cur_addr)) = (v) ; (c).cur_addr += 1; } while (0) |
| #define | gel_write_s8(c, v) {*((s8_t*)((c).cur_addr)) = (v) ; (c).cur_addr += 1; } while (0) |
| #define | gel_write_u16(c, v) {*((u16_t*)((c).cur_addr)) = ENDIAN2((c).endianness,(v)) ; (c).cur_addr += 2; } while (0) |
| #define | gel_write_s16(c, v) {*((s16_t*)((c).cur_addr)) = ENDIAN2((c).endianness,(v)) ; (c).cur_addr += 2; } while (0) |
| #define | gel_write_u32(c, v) {*((u32_t*)((c).cur_addr)) = ENDIAN4((c).endianness,(v)) ; (c).cur_addr += 4; } while (0) |
| #define | gel_write_s32(c, v) {*((s32_t*)((c).cur_addr)) = ENDIAN4((c).endianness,(v)) ; (c).cur_addr += 4; } while (0) |
| #define | gel_write_vaddr(c, v) {*((vaddr_t*)((c).cur_addr)) = ENDIAN4((c).endianness,(v)) ; (c).cur_addr += 4; } while (0) |
| #define | gel_write_raddr(c, v) {*((raddr_t*)((c).cur_addr)) = ENDIAN4((c).endianness,(v)) ; (c).cur_addr += 4; } while (0) |
| #define | gel_cursor_reset(c) { (c).cur_addr = (c).base_addr; } |
| #define | GEL_ALIGN(v, n) (((v) + (n) - 1) & ~((n) - 1)) |
| #define | GEL_ALIGNP(t, p, n) ((t *)GEL_ALIGN((intptr_t)(p), (n))) |
Typedefs | |
| typedef struct gel_cursor_s | gel_cursor_t |
Functions | |
| int | gel_move (gel_cursor_t *p, u32_t off) |
| int | gel_move_abs (gel_cursor_t *p, raddr_t addr) |
| int | gel_move_rel (gel_cursor_t *p, s32_t off) |
| raddr_t | gel_cursor_addr (gel_cursor_t *c) |
| int | gel_cursor_bounds (gel_cursor_t *p) |
| int | gel_write_block (gel_cursor_t *bc, char *blk, int blksize, raddr_t dest) |
| int | gel_read_block (gel_cursor_t *bc, char *blk, int blksize, raddr_t src) |
| void | gel_align_hi (gel_cursor_t *p) |
| void | gel_align_lo (gel_cursor_t *p) |
| int | gel_subcursor (gel_cursor_t *base, size_t size, gel_cursor_t *sub) |
This group contains definitions of items used to handle cursor to read or write in section and segments. The cursor perform two tasks:
Cursor may be obtained from:
| #define GEL_ALIGN | ( | v, | |
| n | |||
| ) | (((v) + (n) - 1) & ~((n) - 1)) |
Align an integer value to an upper bound multiple of v.
| v | Integer value to align. |
| n | Multiple to align to (must be a power of 2). |
| #define GEL_ALIGNP | ( | t, | |
| p, | |||
| n | |||
| ) | ((t *)GEL_ALIGN((intptr_t)(p), (n))) |
Align a real pointer value to an upper bound multiple of v.
| t | Pointed type. |
| p | Real pointer value to align. |
| n | Multiple to align to (must be a power of 2). |
| #define gel_cursor_at_end | ( | c | ) | ((c).cur_addr >= (c).base_addr + (c).size) |
Test if the end of the buffer is reached.
| c | Current cursor. |
| #define gel_cursor_avail | ( | c | ) | ((c).base_addr + (c).size - (c).cur_addr) |
Compute the number of available bytes in the current block.
| c | Used cursor. |
| #define gel_cursor_reset | ( | c | ) | { (c).cur_addr = (c).base_addr; } |
Reset the position of the cursor to the start.
| c | Cursor to reset. |
| #define gel_read_data | ( | c, | |
| b, | |||
| s | |||
| ) | { memcpy((b), (c).cur_addr, (s)); (c).cur_addr += (s); } |
Read a block of data.
| c | Cursor to read from. |
| b | Byte buffer to write to. |
| s | Number of bytes to read. |
| #define gel_read_raddr | ( | c | ) | ((c).cur_addr += 4, ENDIAN4((c).endianness, (*((raddr_t*)((c).cur_addr - 4))))) |
Read an actual address and increment the cursor.
| c | Used cursor. |
| #define gel_read_s16 | ( | c | ) | ((c).cur_addr += 2, ENDIAN2((c).endianness, (*((s16_t*)((c).cur_addr - 2))))) |
Read a signed half-word and increment the cursor.
| c | Used cursor. |
| #define gel_read_s32 | ( | c | ) | ((c).cur_addr += 4, ENDIAN4((c).endianness, (*((s32_t*)((c).cur_addr - 4))))) |
Read a signed word and increment the cursor.
| c | Used cursor. |
| #define gel_read_s8 | ( | c | ) | ((c).cur_addr += 1 , *((s8_t*)((c).cur_addr - 1))) |
Read a signed byte and increment the cursor.
| c | Used cursor. |
| #define gel_read_u16 | ( | c | ) | ((c).cur_addr += 2, ENDIAN2((c).endianness, (*((u16_t*)((c).cur_addr - 2))))) |
Read an unsigned half-word and increment the cursor.
| c | Used cursor. |
| #define gel_read_u32 | ( | c | ) | ((c).cur_addr += 4, ENDIAN4((c).endianness, (*((u32_t*)((c).cur_addr - 4))))) |
Read an unsigned word and increment the cursor.
| c | Used cursor. |
| #define gel_read_u8 | ( | c | ) | ((c).cur_addr += 1 , *((u8_t*)((c).cur_addr - 1))) |
Read an unsigned byte and increment the cursor.
| c | Used cursor. |
| #define gel_read_vaddr | ( | c | ) | ((c).cur_addr += 4, ENDIAN4((c).endianness, (*((vaddr_t*)((c).cur_addr - 4))))) |
Read a virtual address and increment the cursor.
| c | Used cursor. |
| #define gel_write_raddr | ( | c, | |
| v | |||
| ) | {*((raddr_t*)((c).cur_addr)) = ENDIAN4((c).endianness,(v)) ; (c).cur_addr += 4; } while (0) |
Write an actual address and increment the cursor.
| c | Current cursor. |
| v | Value to write. |
| #define gel_write_s16 | ( | c, | |
| v | |||
| ) | {*((s16_t*)((c).cur_addr)) = ENDIAN2((c).endianness,(v)) ; (c).cur_addr += 2; } while (0) |
Write a signed half-word and increment the cursor.
| c | Current cursor. |
| v | Value to write. |
| #define gel_write_s32 | ( | c, | |
| v | |||
| ) | {*((s32_t*)((c).cur_addr)) = ENDIAN4((c).endianness,(v)) ; (c).cur_addr += 4; } while (0) |
Write a signed byte word and increment the cursor.
| c | Current cursor. |
| v | Value to write. |
| #define gel_write_s8 | ( | c, | |
| v | |||
| ) | {*((s8_t*)((c).cur_addr)) = (v) ; (c).cur_addr += 1; } while (0) |
Write a signed byte and increment the cursor.
| c | Current cursor. |
| v | Value to write. |
| #define gel_write_u16 | ( | c, | |
| v | |||
| ) | {*((u16_t*)((c).cur_addr)) = ENDIAN2((c).endianness,(v)) ; (c).cur_addr += 2; } while (0) |
Write an unsigned half-word and increment the cursor.
| c | Current cursor. |
| v | Value to write. |
| #define gel_write_u32 | ( | c, | |
| v | |||
| ) | {*((u32_t*)((c).cur_addr)) = ENDIAN4((c).endianness,(v)) ; (c).cur_addr += 4; } while (0) |
Write an unsigned word and increment the cursor.
| c | Current cursor. |
| v | Value to write. |
| #define gel_write_u8 | ( | c, | |
| v | |||
| ) | {*((u8_t*)((c).cur_addr)) = (v) ; (c).cur_addr += 1; } while (0) |
Write an unsigned byte and increment the cursor.
| c | Current cursor. |
| v | Value to write. |
| #define gel_write_vaddr | ( | c, | |
| v | |||
| ) | {*((vaddr_t*)((c).cur_addr)) = ENDIAN4((c).endianness,(v)) ; (c).cur_addr += 4; } while (0) |
Write a virtual address and increment the cursor.
| c | Current cursor. |
| v | Value to write. |
Datastructure to represent a cursor on memory block, allowing to read or write in it (independently of the endianness of executable or host machine).
| void gel_align_hi | ( | gel_cursor_t * | p | ) |
Align the cursor on the higher bound.
| p | Cursor to move. |
| void gel_align_lo | ( | gel_cursor_t * | p | ) |
Align the cursor on the lower bound.
| p | Cursor to move. |
| raddr_t gel_cursor_addr | ( | gel_cursor_t * | c | ) |
Get the current actual address of the cursor.
| c | Cursor to get address of. |
| int gel_cursor_bounds | ( | gel_cursor_t * | p | ) |
Check if the current cursor is in the buffer bounds.
| p | Current cursor. |
| int gel_move | ( | gel_cursor_t * | p, |
| u32_t | off | ||
| ) |
Move the cursor the position given by the offset from the start of the buffer.
| p | Cursor to set. |
| off | Offset to move to. |
| int gel_move_abs | ( | gel_cursor_t * | p, |
| raddr_t | addr | ||
| ) |
Move the cursor to an actual addresse (that must be in the cursor buffer).
| p | Cursor to set. |
| addr | Actual address to set. |
| int gel_move_rel | ( | gel_cursor_t * | p, |
| s32_t | off | ||
| ) |
Move the cursor relatively to the current position.
| p | Cursot to set. |
| off | Offset to add to the current position (may be negative). |
| int gel_read_block | ( | gel_cursor_t * | bc, |
| char * | blk, | ||
| int | blksize, | ||
| raddr_t | src | ||
| ) |
Read a block from a cursor buffer at the given actual address with bound checking.
| bc | Current cursor. |
| blk | Base block to copy to. |
| blksize | Block size. |
| src | Actual address in the buffer of the block to copy. |
| int gel_subcursor | ( | gel_cursor_t * | base, |
| size_t | size, | ||
| gel_cursor_t * | sub | ||
| ) |
Build a cursor as sub-cursor on the buffer the base cursor.
| base | Base cursor. |
| size | Size of the sub-buffer. |
| sub | New sub-cursor. |
| int gel_write_block | ( | gel_cursor_t * | bc, |
| char * | blk, | ||
| int | blksize, | ||
| raddr_t | dest | ||
| ) |
Write a block in the cursor buffer with bound checking.
| bc | Current cursor. |
| blk | Base address of the block to copy. |
| blksize | Block size. |
| dest | Actual destination address. |