criscv/include/address_space.h
Minecon724 a64b878058
All checks were successful
/ deploy (push) Successful in 1m16s
comit
2024-10-24 11:38:13 +02:00

32 lines
No EOL
1 KiB
C

#ifndef ADDRESS_SPACE_H
#define ADDRESS_SPACE_H
#include <stdint.h>
#include <stdbool.h>
struct AddressSpace_s {
// A pointer to a ROM array. The array can vary in length.
uint8_t *rom;
// The size of ROM.
uint32_t romSize; // TODO look into making it const
// Is ROM read only
bool romLocked;
// A pointer to a RAM array. The array can vary in length.
uint8_t *ram;
// The size of RAM.
uint32_t ramSize;
// The CSRs, size is always 4096 (12 bits)
uint32_t *csr;
};
typedef struct AddressSpace_s AddressSpace;
AddressSpace *create_address_space(const uint32_t romSize, const uint32_t ramSize);
int read_address_space(const AddressSpace *addressSpace, const uint32_t address, const int n, void *dest);
int write_address_space(const AddressSpace *addressSpace, const uint32_t address, const int n, void *src);
int read_csr(const AddressSpace *addressSpace, const uint16_t address, void *dest);
int write_csr(const AddressSpace *addressSpace, const uint16_t address, void *src);
#endif