Initial commit
This commit is contained in:
52
inc/libmem.h
Normal file
52
inc/libmem.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef __LIBMEM_H__
|
||||
#define __LIBMEM_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define GET_BIT(n, b) ((n >> b) & 1)
|
||||
|
||||
// Internal mem handlers
|
||||
typedef void* (*mem_h_read_func)(uint64_t ident, uint64_t addr, void* rawCells);
|
||||
typedef void (*mem_h_write_func)(uint64_t ident, uint64_t addr, void* rawCells, void* data);
|
||||
|
||||
typedef struct {
|
||||
mem_h_read_func func;
|
||||
uint64_t ident;
|
||||
} mem_h_read_handler;
|
||||
typedef struct {
|
||||
mem_h_write_func func;
|
||||
uint64_t ident;
|
||||
} mem_h_write_handler;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void* rawCells;
|
||||
void** cells;
|
||||
uint64_t smartAddrReadMask;
|
||||
uint64_t smartAddrWriteMask;
|
||||
mem_h_read_handler* smartAddrReadHandlers;
|
||||
mem_h_write_handler* smartAddrWriteHandlers;
|
||||
char** memsegNames;
|
||||
uint64_t* memsegShifts;
|
||||
uint64_t* memreadCellAddrs;
|
||||
uint64_t* memwriteCellAddrs;
|
||||
uint8_t memreadLen;
|
||||
uint8_t memwriteLen;
|
||||
} device_mem_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t start;
|
||||
uint64_t len;
|
||||
uint8_t wordLen;
|
||||
char* name;
|
||||
} memseg_spec_t;
|
||||
|
||||
|
||||
// External handlers
|
||||
typedef void* (*ext_h_read_func)(uint64_t addr, void* rawCells, void* devContext);
|
||||
typedef void (*ext_h_write_func)(uint64_t addr, void* rawCells, void* data, void* devContext);
|
||||
|
||||
#endif // ifndef __LIBMEM_H__
|
||||
Reference in New Issue
Block a user